Skip degenerate triangles targeted by shape keys

This commit is contained in:
ackwell 2024-01-30 21:39:12 +11:00 committed by Ottermandias
parent c1cdb28bb5
commit 1cee1c24ec

View file

@ -214,10 +214,18 @@ public class MeshExporter
var morphBuilder = meshBuilder.UseMorphTarget(shapeNames.Count);
shapeNames.Add(shape.ShapeName);
foreach (var shapeValue in shapeValues)
foreach (var (shapeValue, shapeValueIndex) in shapeValues.WithIndex())
{
var gltfIndex = gltfIndices[shapeValue.BaseIndicesIndex - indexBase];
if (gltfIndex == -1)
{
_notifier.Warning($"{name}: Shape {shape.ShapeName} mapping {shapeValueIndex} targets a degenerate triangle, ignoring.");
continue;
}
morphBuilder.SetVertex(
primitiveVertices[gltfIndices[shapeValue.BaseIndicesIndex - indexBase]].GetGeometry(),
primitiveVertices[gltfIndex].GetGeometry(),
vertices[shapeValue.ReplacingVertexIndex].GetGeometry()
);
}