microsoft / DirectXMesh

DirectXMesh geometry processing library
https://walbourn.github.io/directxmesh/
MIT License
786 stars 152 forks source link

Fixed meshlet verticies overflow in case degenerate triangle is passed #60

Closed Devaniti closed 3 years ago

Devaniti commented 3 years ago

If triangle, that have 2 identical indices is ever passed to meshlet generation, it may result in generation of meshlet with vertex count higher than allowed (maxVerts parameter). If such triangle is added, UniqueVertexIndices will have 2 identical indices. It's a problem for code calculating whether triangle fit into meshlet. newCount may be decremented twice for each vertex instead of once, resulting in lower newCount than it will actually be added later. So I propose to just cull degenerate triangles. That will both fix the issue and result in better generated meshlets in cases input geometry have degenerate triangles.