Skip to content

Commit 0a6851a

Browse files
committed
- bugfix
1 parent 2abd773 commit 0a6851a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Utils/IndexedFaceMesh.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ namespace Utilities
187187

188188
m_normals[i] = v1.cross(v2);
189189
m_normals[i].normalize();
190+
// fix normals of degenerate triangles that can become zero vectors
191+
if (m_normals[i].squaredNorm() < 1e-6f)
192+
m_normals[i] = Vector3r::UnitX();
190193
}
191194
}
192195
}

Utils/VolumeIntegration.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ void VolumeIntegration::face_integrals(unsigned int f)
140140

141141
w = m_weights[f];
142142
n = m_face_normals[f];
143-
k1 = 1 / n[C]; k2 = k1 * k1; k3 = k2 * k1; k4 = k3 * k1;
143+
k1 = (n[C] == 0) ? 0 : 1 / n[C];
144+
k2 = k1 * k1; k3 = k2 * k1; k4 = k3 * k1;
144145

145146
Fa = k1 * Pa;
146147
Fb = k1 * Pb;

0 commit comments

Comments
 (0)