From 41fa4565062ede49913d5a39104cfd86eb3b305d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Sep 2011 06:56:50 +0000 Subject: replace macros with math lib functions --- source/blender/blenkernel/intern/anim.c | 8 +++--- source/blender/editors/space_view3d/drawobject.c | 32 ++++++++++++---------- source/blender/editors/space_view3d/view3d_view.c | 8 +++--- .../render/intern/raytrace/rayobject_octree.cpp | 2 +- .../blender/render/intern/source/convertblender.c | 4 +-- source/blender/render/intern/source/rendercore.c | 12 +++----- source/blender/render/intern/source/zbuf.c | 10 +++---- 7 files changed, 37 insertions(+), 39 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 9ca11db7fce..824bbb8f70d 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -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) { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 02f3bec3782..32a6a39a97a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -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; a31) 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(); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 44ae6837aa2..c7feaebcddc 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -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 */ diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp index e35fcbc2df7..5fa0b836f4f 100644 --- a/source/blender/render/intern/raytrace/rayobject_octree.cpp +++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp @@ -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; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c323760296b..934894f63b6 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -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); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 16bbe1ca5c2..59a505a3195 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -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); + madd_v3_v3v3fl(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; + 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; } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index b8fbd5c44f7..ac56304bdcb 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -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); -- cgit v1.2.3