Browse Source

Fix memory corruption and assert failures in convex decomposition

This PR fixes how triangular faces are decomposed into vertices and indices. The pre-increment resulted in the indices table skipping entry 0 and potentially overrunning the end of the vertices vector.

(cherry picked from commit bf7cdc522987b5c8675ccaafdb4b2c5d2b19e726)
Malcolm Nixon 1 year ago
parent
commit
51816380b5
1 changed files with 1 additions and 1 deletions
  1. 1 1
      scene/resources/importer_mesh.cpp

+ 1 - 1
scene/resources/importer_mesh.cpp

@@ -969,7 +969,7 @@ Vector<Ref<Shape3D>> ImporterMesh::convex_decompose(const Ref<MeshConvexDecompos
 				if (found_vertex) {
 					index = found_vertex->value;
 				} else {
-					index = ++vertex_count;
+					index = vertex_count++;
 					vertex_map[vertex] = index;
 					vertex_w[index] = vertex;
 				}