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-08-16 09:13:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-08-16 09:13:11 +0400
commitc47a01da11b42df849ba0881c577d020c8eb0b44 (patch)
treeafb3c3cd7fb749f761fa49fefc05b10f39c980ca /source/blender/blenlib
parent88ee650263cb8f0670a9d3837f43325009b55115 (diff)
Math Lib: add isect_line_line_epsilon_v3
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h11
-rw-r--r--source/blender/blenlib/intern/math_geom.c15
2 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index d3158ef7926..81ca2908619 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -130,9 +130,14 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[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]);
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],
- float i1[3], float i2[3]);
+int isect_line_line_epsilon_v3(
+ const float v1[3], const float v2[3],
+ const float v3[3], const float v4[3], float i1[3], float i2[3],
+ const float epsilon);
+int isect_line_line_v3(
+ const float v1[3], const float v2[3],
+ const float v3[3], const float v4[3],
+ float i1[3], float i2[3]);
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);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 6ca98e52909..96a531bc4ea 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1562,7 +1562,10 @@ bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3
* 1 - lines are coplanar, i1 is set to intersection
* 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively
*/
-int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float i1[3], float i2[3])
+int isect_line_line_epsilon_v3(
+ const float v1[3], const float v2[3],
+ const float v3[3], const float v4[3], float i1[3], float i2[3],
+ const float epsilon)
{
float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3];
float d, div;
@@ -1588,7 +1591,7 @@ int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3],
return 0;
}
/* test if the two lines are coplanar */
- else if (d > -0.000001f && d < 0.000001f) {
+ else if (UNLIKELY(fabsf(d) <= epsilon)) {
cross_v3_v3v3(cb, c, b);
mul_v3_fl(a, dot_v3v3(cb, ab) / div);
@@ -1628,6 +1631,14 @@ int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3],
}
}
+int isect_line_line_v3(
+ const float v1[3], const float v2[3],
+ const float v3[3], const float v4[3], float i1[3], float i2[3])
+{
+ const float epsilon = 0.000001f;
+ return isect_line_line_epsilon_v3(v1, v2, v3, v4, i1, i2, epsilon);
+}
+
/** Intersection point strictly between the two lines
* \return false when no intersection is found
*/