Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-03-29 15:23:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-29 15:24:12 +0400
commitfb0959f88dc57a73eacd36600607cd10584da387 (patch)
tree0e2a500050613bcd53005b81956e4b12c10f424e /source/blender/blenlib
parent6bba006bf2bb7ef4b8758a215def13885fc2f9f7 (diff)
Code cleanup: replace dot with len_squared and is_zero checks
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h14
-rw-r--r--source/blender/blenlib/intern/BLI_kdtree.c2
-rw-r--r--source/blender/blenlib/intern/math_geom.c22
3 files changed, 19 insertions, 19 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 14357c06f78..29ebf9f4688 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -71,9 +71,9 @@ MINLINE float plane_point_side_v3(const float plane[4], const float co[3]);
float volume_tetrahedron_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
-int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
-int is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
-int is_poly_convex_v2(const float verts[][2], unsigned int nr);
+bool is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
+bool is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
+bool is_poly_convex_v2(const float verts[][2], unsigned int nr);
/********************************* Distance **********************************/
@@ -122,7 +122,7 @@ int isect_line_line_v2_int(const int a1[2], const int a2[2], const int b1[2], co
int isect_line_sphere_v3(const float l1[3], const float l2[3], const float sp[3], const float r, float r_p1[3], float r_p2[3]);
int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2], const float r, float r_p1[2], float r_p2[2]);
int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2]);
-int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
+bool isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
int isect_line_line_v3(const float v1[3], const float v2[3],
const float v3[3], const float v4[3],
@@ -162,9 +162,9 @@ bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsign
int isect_point_quad_v2(const float p[2], const float a[2], const float b[2], const float c[2], const float d[2]);
-int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2]);
-int isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2]);
-int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b);
+int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2]);
+bool isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2]);
+int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b);
bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3]);
/* axis-aligned bounding box */
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c
index 1a4d8bc7f78..ed6e6e3ab92 100644
--- a/source/blender/blenlib/intern/BLI_kdtree.c
+++ b/source/blender/blenlib/intern/BLI_kdtree.c
@@ -170,7 +170,7 @@ static float squared_distance(const float v2[3], const float v1[3], const float
d[1] = v2[1] - v1[1];
d[2] = v2[2] - v1[2];
- dist = dot_v3v3(d, d);
+ dist = len_squared_v3(d);
/* can someone explain why this is done?*/
if (n2 && (dot_v3v3(d, n2) < 0.0f)) {
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 3daa74180ea..e41ec8bc9ac 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -601,7 +601,7 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[
return -1;
}
-int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
+bool isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
{
#define CCW(A, B, C) ((C[1] - A[1]) * (B[0] - A[0]) > (B[1]-A[1]) * (C[0]-A[0]))
@@ -638,7 +638,7 @@ int isect_line_sphere_v3(const float l1[3], const float l2[3],
l2[2] - l1[2]
};
- const float a = dot_v3v3(ldir, ldir);
+ const float a = len_squared_v3(ldir);
const float b = 2.0f *
(ldir[0] * (l1[0] - sp[0]) +
@@ -646,8 +646,8 @@ int isect_line_sphere_v3(const float l1[3], const float l2[3],
ldir[2] * (l1[2] - sp[2]));
const float c =
- dot_v3v3(sp, sp) +
- dot_v3v3(l1, l1) -
+ len_squared_v3(sp) +
+ len_squared_v3(l1) -
(2.0f * dot_v3v3(sp, l1)) -
(r * r);
@@ -854,7 +854,7 @@ bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsign
/* point in tri */
/* only single direction */
-int isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
+bool isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
{
if (line_point_side_v2(v1, v2, pt) >= 0.0f) {
if (line_point_side_v2(v2, v3, pt) >= 0.0f) {
@@ -1145,7 +1145,7 @@ bool isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
mul_v3_fl(e1, du);
mul_v3_fl(e2, dv);
- if (dot_v3v3(e1, e1) + dot_v3v3(e2, e2) > threshold * threshold) {
+ if (len_squared_v3(e1) + len_squared_v3(e2) > threshold * threshold) {
return 0;
}
@@ -2140,7 +2140,7 @@ static float tri_signed_area(const float v1[3], const float v2[3], const float v
}
/* return 1 when degenerate */
-static int barycentric_weights(const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3])
+static bool barycentric_weights(const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3])
{
float wtot;
int i, j;
@@ -2182,7 +2182,7 @@ void interp_weights_face_v3(float w[4], const float v1[3], const float v2[3], co
else {
/* otherwise compute barycentric interpolation weights */
float n1[3], n2[3], n[3];
- int degenerate;
+ bool degenerate;
sub_v3_v3v3(n1, v1, v3);
if (v4) {
@@ -3791,7 +3791,7 @@ float form_factor_hemi_poly(float p[3], float n[3], float v1[3], float v2[3], fl
}
/* evaluate if entire quad is a proper convex quad */
-int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
+bool is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
{
float nor[3], nor_a[3], nor_b[3], vec[4][2];
float mat[3][3];
@@ -3841,13 +3841,13 @@ int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], c
return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0);
}
-int is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
+bool is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
{
/* linetests, the 2 diagonals have to instersect to be convex */
return (isect_line_line_v2(v1, v3, v2, v4) > 0);
}
-int is_poly_convex_v2(const float verts[][2], unsigned int nr)
+bool is_poly_convex_v2(const float verts[][2], unsigned int nr)
{
unsigned int sign_flag = 0;
unsigned int a;