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>2015-09-04 15:25:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-09-04 15:29:12 +0300
commit39752eb912cd2eb606935dd41e4f2f3977190ea0 (patch)
tree161228ac9eafaac25d4cbd904113156f6eae79c4 /source/blender/blenlib/intern/math_geom.c
parent1d71ad2eaa5176ed6ab8ca5bfbeb5f8eb9fa3453 (diff)
Fix for isect_tri_tri_epsilon_v3 w/ small faces
tris with ~1e-05 edge lengths would fail
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index c644e04a9bb..548aed3a8ae 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1668,7 +1668,9 @@ bool isect_tri_tri_epsilon_v3(
plane_a[3] = -dot_v3v3(plane_a, t_a0);
plane_b[3] = -dot_v3v3(plane_b, t_b0);
- if (isect_plane_plane_v3(plane_a, plane_b, plane_co, plane_no)) {
+ if (isect_plane_plane_v3(plane_a, plane_b, plane_co, plane_no) &&
+ (normalize_v3(plane_no) > epsilon))
+ {
/**
* Implementation note: its simpler to project the triangles onto the intersection plane
* before intersecting their edges with the ray, defined by 'isect_plane_plane_v3'.
@@ -1681,10 +1683,6 @@ bool isect_tri_tri_epsilon_v3(
int t;
float co_proj[3];
- /* only for numeric stability
- * (and so we can call 'closest_to_plane3_normalized_v3' below) */
- normalize_v3(plane_no);
-
closest_to_plane3_normalized_v3(co_proj, plane_no, plane_co);
/* For both triangles, find the overlap with the line defined by the ray [co_proj, plane_no].
@@ -1698,7 +1696,10 @@ bool isect_tri_tri_epsilon_v3(
closest_to_plane3_normalized_v3(tri_proj[2], plane_no, tri_pair[t][2]);
for (j = 0, j_prev = 2; j < 3; j_prev = j++) {
- const float edge_fac = line_point_factor_v3_ex(co_proj, tri_proj[j_prev], tri_proj[j], epsilon, -1.0f);
+ /* note that its important to have a very small nonzero epsilon here
+ * otherwise this fails for very small faces.
+ * However if its too small, large adjacent faces will count as intersecting */
+ const float edge_fac = line_point_factor_v3_ex(co_proj, tri_proj[j_prev], tri_proj[j], 1e-10f, -1.0f);
/* ignore collinear lines, they are either an edge shared between 2 tri's
* (which runs along [co_proj, plane_no], but can be safely ignored).
*