From b3cd6ccc1a7ede6b498c97e0408023e2566738ed Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 28 Jan 2018 02:29:24 -0700 Subject: [PATCH] light: GLM_InterpolateNormal: make more robust against degenerate tris --- common/mathlib.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/mathlib.cc b/common/mathlib.cc index 3ad61187..7620e629 100644 --- a/common/mathlib.cc +++ b/common/mathlib.cc @@ -720,7 +720,7 @@ std::pair GLM_InterpolateNormal(const std::vector &points, const qvec3f &n2 = normals.at(i); const auto edgeplanes = GLM_MakeInwardFacingEdgePlanes({p0, p1, p2}); - if (edgeplanes.empty()) + if (edgeplanes.size() != 3) continue; if (GLM_EdgePlanes_PointInside(edgeplanes, point)) { @@ -728,7 +728,7 @@ std::pair GLM_InterpolateNormal(const std::vector &points, const qvec3f bary = Barycentric_FromPoint(point, make_tuple(p0, p1, p2)); - if (isnan(bary[0]) || isnan(bary[1]) || isnan(bary[2])) + if (!isfinite(bary[0]) || !isfinite(bary[1]) || !isfinite(bary[2])) continue; const qvec3f interpolatedNormal = Barycentric_ToPoint(bary, make_tuple(n0, n1, n2));