Skip to content

Commit

Permalink
Throw on errors caused by overlarge meshes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kythyria committed Jun 14, 2021
1 parent 1c33ee9 commit 0444c66
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PD2ModelParser/Importers/GltfImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ public void AppendVertices(IEnumerable<Vertex> vertices)

public static MeshData FromGltfMesh(GLTF.Mesh mesh)
{

var vcount = mesh.Primitives.Select(prim => prim.VertexAccessors["POSITION"].Count).Sum();
if (vcount >= ushort.MaxValue)
{
throw new Exception($"Too many vertices ({vcount}) in mesh {mesh.Name}. Limit is 65535");
}

var attribsUsed = mesh.Primitives.First().VertexAccessors.Select(i => i.Key).OrderBy(i => i);
var ok = mesh.Primitives.Select(i => i.VertexAccessors.Keys.OrderBy(j => j)).Aggregate(true, (acc, curr) => acc && curr.SequenceEqual(attribsUsed));
if (!ok)
Expand Down

0 comments on commit 0444c66

Please sign in to comment.