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/editors/space_view3d/drawobject.c | 32 ++++++++++++----------- source/blender/editors/space_view3d/view3d_view.c | 8 +++--- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'source/blender/editors') 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 */ -- cgit v1.2.3