light: GLM_InterpolateNormal: make more robust against degenerate tris

This commit is contained in:
Eric Wasylishen 2018-01-28 02:29:24 -07:00
parent 6b14e166b8
commit b3cd6ccc1a
1 changed files with 2 additions and 2 deletions

View File

@ -720,7 +720,7 @@ std::pair<bool, qvec3f> GLM_InterpolateNormal(const std::vector<qvec3f> &points,
const qvec3f &n2 = normals.at(i); const qvec3f &n2 = normals.at(i);
const auto edgeplanes = GLM_MakeInwardFacingEdgePlanes({p0, p1, p2}); const auto edgeplanes = GLM_MakeInwardFacingEdgePlanes({p0, p1, p2});
if (edgeplanes.empty()) if (edgeplanes.size() != 3)
continue; continue;
if (GLM_EdgePlanes_PointInside(edgeplanes, point)) { if (GLM_EdgePlanes_PointInside(edgeplanes, point)) {
@ -728,7 +728,7 @@ std::pair<bool, qvec3f> GLM_InterpolateNormal(const std::vector<qvec3f> &points,
const qvec3f bary = Barycentric_FromPoint(point, make_tuple(p0, p1, p2)); 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; continue;
const qvec3f interpolatedNormal = Barycentric_ToPoint(bary, make_tuple(n0, n1, n2)); const qvec3f interpolatedNormal = Barycentric_ToPoint(bary, make_tuple(n0, n1, n2));