Skip to content

Commit 1cee1c2

Browse files
ackwellOttermandias
authored andcommitted
Skip degenerate triangles targeted by shape keys
1 parent c1cdb28 commit 1cee1c2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Penumbra/Import/Models/Export/MeshExporter.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,18 @@ uint attributeMask
214214
var morphBuilder = meshBuilder.UseMorphTarget(shapeNames.Count);
215215
shapeNames.Add(shape.ShapeName);
216216

217-
foreach (var shapeValue in shapeValues)
217+
foreach (var (shapeValue, shapeValueIndex) in shapeValues.WithIndex())
218218
{
219+
var gltfIndex = gltfIndices[shapeValue.BaseIndicesIndex - indexBase];
220+
221+
if (gltfIndex == -1)
222+
{
223+
_notifier.Warning($"{name}: Shape {shape.ShapeName} mapping {shapeValueIndex} targets a degenerate triangle, ignoring.");
224+
continue;
225+
}
226+
219227
morphBuilder.SetVertex(
220-
primitiveVertices[gltfIndices[shapeValue.BaseIndicesIndex - indexBase]].GetGeometry(),
228+
primitiveVertices[gltfIndex].GetGeometry(),
221229
vertices[shapeValue.ReplacingVertexIndex].GetGeometry()
222230
);
223231
}

0 commit comments

Comments
 (0)