示例#1
0
文件: bp_camera.c 项目: samanpa/bpray
static inline void init_ray_computer (const camera_t *camera)
{
 	if (!inited) {
		vector_t right, down;
		float mag;
		inited = 1;

		mag = MAG (camera->right);

		/* find the left top corner of the screen */
		ADD (left_top, camera->location, camera->direction);
		SUB (left_top, left_top, camera->right);
		ADD (left_top, left_top, camera->up);

		SMUL (right, 2, camera->right);
		SMUL (down, -2, camera->up);

		/* find the vector corresponding to a movement to the left & right */
		mag = 1.0 / (bp_scene_get_horizontal_resolution (curr_scene) - 1);
		SMUL (right_step, mag, right);
		
		mag = 1.0 / (bp_scene_get_vertical_resolution (curr_scene) - 1);
		SMUL (down_step, mag, down);
	}

}
示例#2
0
文件: bp_sphere.c 项目: samanpa/bpray
static void get_sphere_normal (const intersect_t *i, vector_t normal)
{
    float r_inv = 1 / get_sphere_radius (i->prim_id);
    SUB  (normal, i->pos, get_sphere_center (i->prim_id));

    /* normalize the normal vector */
    SMUL (normal, r_inv, normal);
}
示例#3
0
文件: bp_camera.c 项目: samanpa/bpray
void bp_camera_init (camera_t *camera)
{
	COPY3 (camera->location, origin);
	COPY3 (camera->direction, z);
	COPY3 (camera->up, y);
	COPY3 (camera->sky, y);
	SMUL (camera->right, 4.0/3.0, x);
}
示例#4
0
文件: bp_sphere.c 项目: samanpa/bpray
static void
get_2d_point (const intersect_t *i, double *u, double *v)
{
    vector_t orig_sphere;
    double r_inv;

    r_inv = 1/get_sphere_radius (i->prim_id);
    SUB (orig_sphere, i->pos, get_sphere_center (i->prim_id));
    SMUL (orig_sphere, r_inv, orig_sphere);

    *v = acos (orig_sphere [0]) / M_PI;
    *u = acos (orig_sphere [2] / sin (M_PI * *v))/ (2 * M_PI);
}
示例#5
0
void GGLAssembler::mul_factor(  component_t& d,
                                const integer_t& v,
                                const integer_t& f)
{
    int vs = v.size();
    int fs = f.size();
    int ms = vs+fs;

    // XXX: we could have special cases for 1 bit mul

    // all this code below to use the best multiply instruction
    // wrt the parameters size. We take advantage of the fact
    // that the 16-bits multiplies allow a 16-bit shift
    // The trick is that we just make sure that we have at least 8-bits
    // per component (which is enough for a 8 bits display).

    int xy;
    int vshift = 0;
    int fshift = 0;
    int smulw = 0;

    if (vs<16) {
        if (fs<16) {
            xy = xyBB;
        } else if (GGL_BETWEEN(fs, 24, 31)) {
            ms -= 16;
            xy = xyTB;
        } else {
            // eg: 15 * 18  ->  15 * 15
            fshift = fs - 15;
            ms -= fshift;
            xy = xyBB;
        }
    } else if (GGL_BETWEEN(vs, 24, 31)) {
        if (fs<16) {
            ms -= 16;
            xy = xyTB;
        } else if (GGL_BETWEEN(fs, 24, 31)) {
            ms -= 32;
            xy = xyTT;
        } else {
            // eg: 24 * 18  ->  8 * 18
            fshift = fs - 15;
            ms -= 16 + fshift;
            xy = xyTB;
        }
    } else {
        if (fs<16) {
            // eg: 18 * 15  ->  15 * 15
            vshift = vs - 15;
            ms -= vshift;
            xy = xyBB;
        } else if (GGL_BETWEEN(fs, 24, 31)) {
            // eg: 18 * 24  ->  15 * 8
            vshift = vs - 15;
            ms -= 16 + vshift;
            xy = xyBT;
        } else {
            // eg: 18 * 18  ->  (15 * 18)>>16
            fshift = fs - 15;
            ms -= 16 + fshift;
            xy = yB;    //XXX SMULWB
            smulw = 1;
        }
    }

    ALOGE_IF(ms>=32, "mul_factor overflow vs=%d, fs=%d", vs, fs);

    int vreg = v.reg;
    int freg = f.reg;
    if (vshift) {
        MOV(AL, 0, d.reg, reg_imm(vreg, LSR, vshift));
        vreg = d.reg;
    }
    if (fshift) {
        MOV(AL, 0, d.reg, reg_imm(vreg, LSR, fshift));
        freg = d.reg;
    }
    if (smulw)  SMULW(AL, xy, d.reg, vreg, freg);
    else        SMUL(AL, xy, d.reg, vreg, freg);


    d.h = ms;
    if (mDithering) {
        d.l = 0; 
    } else {
        d.l = fs; 
        d.flags |= CLEAR_LO;
    }
}