replace macros with math lib functions

This commit is contained in:
Campbell Barton 2011-09-16 06:56:50 +00:00
parent 0abe1911d5
commit 41fa456506
7 changed files with 38 additions and 40 deletions

@ -1143,11 +1143,11 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
w= (mv4)? 0.25f: 1.0f/3.0f;
if(orco) {
VECADDFAC(dob->orco, dob->orco, orco[mv1], w);
VECADDFAC(dob->orco, dob->orco, orco[mv2], w);
VECADDFAC(dob->orco, dob->orco, orco[mv3], w);
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv1], w);
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv2], w);
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv3], w);
if(mv4)
VECADDFAC(dob->orco, dob->orco, orco[mv4], w);
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv4], w);
}
if(mtface) {

@ -5022,7 +5022,7 @@ static void curve_draw_speed(Scene *scene, Object *ob)
#endif // XXX old animation system stuff
static void draw_textcurs(float textcurs[][2])
static void draw_textcurs(float textcurs[4][2])
{
cpack(0);
@ -5039,12 +5039,14 @@ static void draw_textcurs(float textcurs[][2])
static void drawspiral(const float cent[3], float rad, float tmat[][4], int start)
{
float vec[3], vx[3], vy[3];
int a, tot=32;
char inverse=0;
const int tot=32;
const float tot_inv= (1.0f / 32.0f);
int a;
char inverse= FALSE;
if (start < 0) {
inverse = 1;
start *= -1;
inverse = TRUE;
start= -start;
}
mul_v3_v3fl(vx, tmat[0], rad);
@ -5058,26 +5060,26 @@ static void drawspiral(const float cent[3], float rad, float tmat[][4], int star
start=-a + 1;
glBegin(GL_LINES);
glVertex3fv(vec);
vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)a/(float)tot) + *(cosval+a+start) * (vy[0] * (float)a/(float)tot);
vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)a/(float)tot) + *(cosval+a+start) * (vy[1] * (float)a/(float)tot);
vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)a/(float)tot) + *(cosval+a+start) * (vy[2] * (float)a/(float)tot);
vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)a * tot_inv) + *(cosval+a+start) * (vy[0] * (float)a * tot_inv);
vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)a * tot_inv) + *(cosval+a+start) * (vy[1] * (float)a * tot_inv);
vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)a * tot_inv) + *(cosval+a+start) * (vy[2] * (float)a * tot_inv);
glVertex3fv(vec);
glEnd();
}
}
else {
a=0;
vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[0] * (float)(-a+31)/(float)tot);
vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[1] * (float)(-a+31)/(float)tot);
vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[2] * (float)(-a+31)/(float)tot);
vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[0] * (float)(-a+31) * tot_inv);
vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[1] * (float)(-a+31) * tot_inv);
vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[2] * (float)(-a+31) * tot_inv);
for(a=0; a<tot; a++) {
if (a+start>31)
start=-a + 1;
glBegin(GL_LINES);
glVertex3fv(vec);
vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[0] * (float)(-a+31)/(float)tot);
vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[1] * (float)(-a+31)/(float)tot);
vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[2] * (float)(-a+31)/(float)tot);
vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[0] * (float)(-a+31) * tot_inv);
vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[1] * (float)(-a+31) * tot_inv);
vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[2] * (float)(-a+31) * tot_inv);
glVertex3fv(vec);
glEnd();
}

@ -525,8 +525,8 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2]
ED_view3d_win_to_vector(ar, mval, vec);
copy_v3_v3(ray_start, rv3d->viewinv[3]);
VECADDFAC(ray_start, rv3d->viewinv[3], vec, v3d->near);
VECADDFAC(ray_end, rv3d->viewinv[3], vec, v3d->far);
madd_v3_v3v3fl(ray_start, rv3d->viewinv[3], vec, v3d->near);
madd_v3_v3v3fl(ray_end, rv3d->viewinv[3], vec, v3d->far);
}
else {
float vec[4];
@ -537,8 +537,8 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2]
mul_m4_v4(rv3d->persinv, vec);
VECADDFAC(ray_start, vec, rv3d->viewinv[2], 1000.0f);
VECADDFAC(ray_end, vec, rv3d->viewinv[2], -1000.0f);
madd_v3_v3v3fl(ray_start, vec, rv3d->viewinv[2], 1000.0f);
madd_v3_v3v3fl(ray_end, vec, rv3d->viewinv[2], -1000.0f);
}
/* clipping */

@ -264,7 +264,7 @@ static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3]
return 0;
}
static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short z, float rtf[][3])
static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short z, float rtf[4][3])
{
Branch *br;
Node *no;

@ -1488,8 +1488,8 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re
if(part->draw & PART_DRAW_VEL_LENGTH)
mul_v3_fl(vel, len_v3(state->vel));
VECADDFAC(loc0, loc, vel, -part->draw_line[0]);
VECADDFAC(loc1, loc, vel, part->draw_line[1]);
madd_v3_v3v3fl(loc0, loc, vel, -part->draw_line[0]);
madd_v3_v3v3fl(loc1, loc, vel, part->draw_line[1]);
particle_curve(re, obr, dm, ma, sd, loc0, loc1, seed, pa_co);

@ -2234,21 +2234,17 @@ static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, f
maxdist= R.r.bake_maxdist;
else
maxdist= RE_RAYTRACE_MAXDIST + R.r.bake_biasdist;
/* 'dir' is always normalized */
VECADDFAC(isect->start, start, dir, -R.r.bake_biasdist);
isect->dir[0] = dir[0]*sign;
isect->dir[1] = dir[1]*sign;
isect->dir[2] = dir[2]*sign;
/* 'dir' is always normalized */
madd_v3_v3v3fl(isect->start, start, dir, -R.r.bake_biasdist);
mul_v3_v3fl(isect->dir, dir, sign);
isect->dist = maxdist;
hit = RE_rayobject_raycast(raytree, isect);
if(hit) {
hitco[0] = isect->start[0] + isect->dist*isect->dir[0];
hitco[1] = isect->start[1] + isect->dist*isect->dir[1];
hitco[2] = isect->start[2] + isect->dist*isect->dir[2];
madd_v3_v3v3fl(hitco, isect->start, isect->dir, isect->dist);
*dist= isect->dist;
}

@ -843,7 +843,7 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), flo
}
static int clipline(float *v1, float *v2) /* return 0: do not draw */
static int clipline(float v1[4], float v2[4]) /* return 0: do not draw */
{
float dz,dw, u1=0.0, u2=1.0;
float dx, dy, v13;
@ -893,7 +893,7 @@ static int clipline(float *v1, float *v2) /* return 0: do not draw */
return 0;
}
void hoco_to_zco(ZSpan *zspan, float *zco, float *hoco)
void hoco_to_zco(ZSpan *zspan, float zco[3], const float hoco[4])
{
float div;
@ -998,7 +998,7 @@ void zbufclipwire(ZSpan *zspan, int obi, int zvlnr, int ec, float *ho1, float *h
}
void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, float *ho1, float *ho2)
void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const float ho2[4])
{
float f1[4], f2[4];
int c1, c2;
@ -1008,8 +1008,8 @@ void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, float *ho1, float *ho2)
if(c1 | c2) { /* not in the middle */
if(!(c1 & c2)) { /* not out completely */
QUATCOPY(f1, ho1);
QUATCOPY(f2, ho2);
copy_v4_v4(f1, ho1);
copy_v4_v4(f2, ho2);
if(clipline(f1, f2)) {
hoco_to_zco(zspan, f1, f1);