From ed04c213745362fcab99cdda89343aca7cbb65e5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Feb 2012 14:05:00 +0000 Subject: code cleanup: use float vector size in function definitions, and const's where the values are unchanged. --- source/blender/blenlib/BLI_math_geom.h | 4 ++-- source/blender/blenlib/intern/BLI_kdtree.c | 7 ++++-- source/blender/blenlib/intern/math_geom.c | 31 +++++++++++++++------------ source/blender/blenlib/intern/math_rotation.c | 4 ++-- source/blender/blenlib/intern/scanfill.c | 2 +- 5 files changed, 27 insertions(+), 21 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 61e34b7cb75..b46f79fb2e6 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -214,8 +214,8 @@ void box_minmax_bounds_m4(float min[3], float max[3], /********************************** Mapping **********************************/ -void map_to_tube(float *u, float *v, const float x, const float y, const float z); -void map_to_sphere(float *u, float *v, const float x, const float y, const float z); +void map_to_tube(float *r_u, float *r_v, const float x, const float y, const float z); +void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z); /********************************** Normals **********************************/ diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 47c44629d65..6db21ec14a6 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -132,7 +132,7 @@ void BLI_kdtree_balance(KDTree *tree) tree->root= kdtree_balance(tree->nodes, tree->totnode, 0); } -static float squared_distance(float *v2, float *v1, float *UNUSED(n1), float *n2) +static float squared_distance(const float v2[3], const float v1[3], float *UNUSED(n1), float *n2) { float d[3], dist; @@ -143,8 +143,11 @@ static float squared_distance(float *v2, float *v1, float *UNUSED(n1), float *n2 dist = dot_v3v3(d, d); //if(n1 && n2 && (dot_v3v3(n1, n2) < 0.0f)) - if(n2 && (dot_v3v3(d, n2) < 0.0f)) + + /* can someone explain why this is done?*/ + if(n2 && (dot_v3v3(d, n2) < 0.0f)) { dist *= 10.0f; + } return dist; } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index f418b87f37e..f903072afb9 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2311,31 +2311,34 @@ void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], floa /********************************** Mapping **********************************/ -void map_to_tube(float *u, float *v, const float x, const float y, const float z) +void map_to_tube(float *r_u, float *r_v, const float x, const float y, const float z) { float len; - *v = (z + 1.0f) / 2.0f; + *r_v = (z + 1.0f) / 2.0f; - len= (float)sqrt(x*x+y*y); - if(len > 0.0f) - *u = (float)((1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0); - else - *v = *u = 0.0f; /* to avoid un-initialized variables */ + len = sqrtf(x * x + y * y); + if(len > 0.0f) { + *r_u = (float)((1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0); + } + else { + *r_v = *r_u = 0.0f; /* to avoid un-initialized variables */ + } } -void map_to_sphere(float *u, float *v, const float x, const float y, const float z) +void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z) { float len; - len= (float)sqrt(x*x+y*y+z*z); + len = sqrtf(x * x + y * y + z * z); if(len > 0.0f) { - if(x==0.0f && y==0.0f) *u= 0.0f; /* othwise domain error */ - else *u = (1.0f - atan2f(x,y) / (float)M_PI) / 2.0f; + if(x==0.0f && y==0.0f) *r_u= 0.0f; /* othwise domain error */ + else *r_u = (1.0f - atan2f(x,y) / (float)M_PI) / 2.0f; - *v = 1.0f - (float)saacos(z/len)/(float)M_PI; - } else { - *v = *u = 0.0f; /* to avoid un-initialized variables */ + *r_v = 1.0f - (float)saacos(z/len)/(float)M_PI; + } + else { + *r_v = *r_u = 0.0f; /* to avoid un-initialized variables */ } } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 6337e30a54b..38bc4794135 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -80,7 +80,7 @@ void mul_qt_qtqt(float *q, const float *q1, const float *q2) } /* Assumes a unit quaternion */ -void mul_qt_v3(const float *q, float *v) +void mul_qt_v3(const float q[4], float v[3]) { float t0, t1, t2; @@ -98,7 +98,7 @@ void mul_qt_v3(const float *q, float *v) v[1]=t2; } -void conjugate_qt(float *q) +void conjugate_qt(float q[4]) { q[1] = -q[1]; q[2] = -q[2]; diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 1e25d74cfb6..b828ae052f8 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -303,7 +303,7 @@ static void mergepolysSimp(PolyFill *pf1, PolyFill *pf2) /* add pf2 to pf1 */ pf1->f= (pf1->f | pf2->f); } -static short testedgeside(float *v1, float *v2, float *v3) +static short testedgeside(const float v1[3], const float v2[3], const float v3[3]) /* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ { float inp; -- cgit v1.2.3