[Bf-blender-cvs] [a6457f2] master: Cleanup: comment out isect_ray_tri_threshold_v3

Campbell Barton noreply at git.blender.org
Thu Aug 20 04:56:18 CEST 2015


Commit: a6457f283ed7d5aaa87c61a3fbd7e93af0d26519
Author: Campbell Barton
Date:   Thu Aug 20 12:36:21 2015 +1000
Branches: master
https://developer.blender.org/rBa6457f283ed7d5aaa87c61a3fbd7e93af0d26519

Cleanup: comment out isect_ray_tri_threshold_v3

Also define epsilon var for ray-cast functions.

===================================================================

M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/intern/math_geom.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 5124da4..ec1bb3c 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -163,9 +163,10 @@ bool isect_line_line_strict_v3(const float v1[3], const float v2[3],
                                const float v3[3], const float v4[3],
                                float vi[3], float *r_lambda);
 
-bool isect_ray_plane_v3(const float p1[3], const float d[3],
-                        const float v0[3], const float v1[3], const float v2[3],
-                        float *r_lambda, const int clip);
+bool isect_ray_plane_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, const bool clip);
 
 bool isect_point_planes_v3(float (*planes)[4], int totplane, const float p[3]);
 bool isect_line_plane_v3(float out[3], const float l1[3], const float l2[3],
@@ -176,17 +177,26 @@ bool isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
                           const float plane_b_co[3], const float plane_b_no[3]) ATTR_WARN_UNUSED_RESULT;
 
 /* line/ray triangle */
-bool isect_line_tri_v3(const float p1[3], const float p2[3],
-                       const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2]);
-bool isect_line_tri_epsilon_v3(const float p1[3], const float p2[3],
-                       const float v0[3], const float v1[3], const float v2[3],
-                       float *r_lambda, float r_uv[2], const float epsilon);
-bool isect_ray_tri_v3(const float p1[3], const float d[3],
-                      const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2]);
-bool isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
-                                const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float threshold);
-bool isect_ray_tri_epsilon_v3(const float p1[3], const float d[3],
-                              const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon);
+bool isect_line_tri_v3(
+        const float p1[3], const float p2[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2]);
+bool isect_line_tri_epsilon_v3(
+        const float p1[3], const float p2[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2], const float epsilon);
+bool isect_ray_tri_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2]);
+bool isect_ray_tri_threshold_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2], const float threshold);
+bool isect_ray_tri_epsilon_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2], const float epsilon);
 bool isect_tri_tri_epsilon_v3(
         const float t_a0[3], const float t_a1[3], const float t_a2[3],
         const float t_b0[3], const float t_b1[3], const float t_b2[3],
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 197a50d..94924e0 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1155,9 +1155,10 @@ int isect_point_quad_v2(const float pt[2], const float v1[2], const float v2[2],
  * test if the line starting at p1 ending at p2 intersects the triangle v0..v2
  * return non zero if it does
  */
-bool isect_line_tri_v3(const float p1[3], const float p2[3],
-                       const float v0[3], const float v1[3], const float v2[3],
-                       float *r_lambda, float r_uv[2])
+bool isect_line_tri_v3(
+        const float p1[3], const float p2[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2])
 {
 
 	float p[3], s[3], d[3], e1[3], e2[3], q[3];
@@ -1194,9 +1195,10 @@ bool isect_line_tri_v3(const float p1[3], const float p2[3],
 }
 
 /* like isect_line_tri_v3, but allows epsilon tolerance around triangle */
-bool isect_line_tri_epsilon_v3(const float p1[3], const float p2[3],
-                       const float v0[3], const float v1[3], const float v2[3],
-                       float *r_lambda, float r_uv[2], const float epsilon)
+bool isect_line_tri_epsilon_v3(
+        const float p1[3], const float p2[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2], const float epsilon)
 {
 
 	float p[3], s[3], d[3], e1[3], e2[3], q[3];
@@ -1236,10 +1238,14 @@ bool isect_line_tri_epsilon_v3(const float p1[3], const float p2[3],
  * test if the ray starting at p1 going in d direction intersects the triangle v0..v2
  * return non zero if it does
  */
-bool isect_ray_tri_v3(const float p1[3], const float d[3],
-                      const float v0[3], const float v1[3], const float v2[3],
-                      float *r_lambda, float r_uv[2])
+bool isect_ray_tri_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2])
 {
+	/* note: these values were 0.000001 in 2.4x but for projection snapping on
+	 * a human head (1BU == 1m), subsurf level 2, this gave many errors - campbell */
+	const float epsilon = 0.00000001f;
 	float p[3], s[3], e1[3], e2[3], q[3];
 	float a, f, u, v;
 
@@ -1248,9 +1254,7 @@ bool isect_ray_tri_v3(const float p1[3], const float d[3],
 
 	cross_v3_v3v3(p, d, e2);
 	a = dot_v3v3(e1, p);
-	/* note: these values were 0.000001 in 2.4x but for projection snapping on
-	 * a human head (1BU == 1m), subsurf level 2, this gave many errors - campbell */
-	if ((a > -0.00000001f) && (a < 0.00000001f)) return false;
+	if ((a > -epsilon) && (a < epsilon)) return false;
 	f = 1.0f / a;
 
 	sub_v3_v3v3(s, p1, v0);
@@ -1278,10 +1282,12 @@ bool isect_ray_tri_v3(const float p1[3], const float d[3],
  * if clip is nonzero, will only return true if lambda is >= 0.0
  * (i.e. intersection point is along positive d)
  */
-bool isect_ray_plane_v3(const float p1[3], const float d[3],
-                        const float v0[3], const float v1[3], const float v2[3],
-                        float *r_lambda, const int clip)
+bool isect_ray_plane_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, const bool clip)
 {
+	const float epsilon = 0.00000001f;
 	float p[3], s[3], e1[3], e2[3], q[3];
 	float a, f;
 	/* float  u, v; */ /*UNUSED*/
@@ -1293,7 +1299,7 @@ bool isect_ray_plane_v3(const float p1[3], const float d[3],
 	a = dot_v3v3(e1, p);
 	/* note: these values were 0.000001 in 2.4x but for projection snapping on
 	 * a human head (1BU == 1m), subsurf level 2, this gave many errors - campbell */
-	if ((a > -0.00000001f) && (a < 0.00000001f)) return false;
+	if ((a > -epsilon) && (a < epsilon)) return false;
 	f = 1.0f / a;
 
 	sub_v3_v3v3(s, p1, v0);
@@ -1310,9 +1316,10 @@ bool isect_ray_plane_v3(const float p1[3], const float d[3],
 	return true;
 }
 
-bool isect_ray_tri_epsilon_v3(const float p1[3], const float d[3],
-                              const float v0[3], const float v1[3], const float v2[3],
-                              float *r_lambda, float uv[2], const float epsilon)
+bool isect_ray_tri_epsilon_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float uv[2], const float epsilon)
 {
 	float p[3], s[3], e1[3], e2[3], q[3];
 	float a, f, u, v;
@@ -1322,7 +1329,7 @@ bool isect_ray_tri_epsilon_v3(const float p1[3], const float d[3],
 
 	cross_v3_v3v3(p, d, e2);
 	a = dot_v3v3(e1, p);
-	if (a == 0.0f) return 0;
+	if (a == 0.0f) return false;
 	f = 1.0f / a;
 
 	sub_v3_v3v3(s, p1, v0);
@@ -1346,10 +1353,17 @@ bool isect_ray_tri_epsilon_v3(const float p1[3], const float d[3],
 	return true;
 }
 
-bool isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
-                                const float v0[3], const float v1[3], const float v2[3],
-                                float *r_lambda, float r_uv[2], const float threshold)
+#if 0  /* UNUSED */
+/**
+ * A version of #isect_ray_tri_v3 which takes a threshold argument
+ * so rays slightly outside the triangle to be considered as intersecting.
+ */
+bool isect_ray_tri_threshold_v3(
+        const float p1[3], const float d[3],
+        const float v0[3], const float v1[3], const float v2[3],
+        float *r_lambda, float r_uv[2], const float threshold)
 {
+	const float epsilon = 0.00000001f;
 	float p[3], s[3], e1[3], e2[3], q[3];
 	float a, f, u, v;
 	float du, dv;
@@ -1359,7 +1373,7 @@ bool isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
 
 	cross_v3_v3v3(p, d, e2);
 	a = dot_v3v3(e1, p);
-	if ((a > -0.000001f) && (a < 0.000001f)) return false;
+	if ((a > -epsilon) && (a < epsilon)) return false;
 	f = 1.0f / a;
 
 	sub_v3_v3v3(s, p1, v0);
@@ -1400,6 +1414,7 @@ bool isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
 
 	return true;
 }
+#endif
 
 /**
  * Check if a point is behind all planes.
@@ -1782,6 +1797,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
 bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3],
                              const float v0[3], const float v1[3], const float v2[3], float *r_lambda)
 {
+	const float epsilon = 0.000001f;
 	float p[3], e1[3], e2[3];
 	float u, v, f;
 	int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3;
@@ -1803,15 +1819,15 @@ bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3
 	sub_v3_v3v3(p, v0, p1);
 
 	f = (e2[a1] * e1[a2] - e2[a2] * e1[a1]);
-	if ((f > -0.000001f) && (f < 0.000001f)) return false;
+	if ((f > -epsilon) && (f < epsilon)) return false;
 
 	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list