Fix a crash in ImporterMesh::create_shadow_mesh for non-triangle surfaces

optimize_vertex_cache_func assumes the input is a triangle mesh; when an
imported mesh contains points/lines/triangle strips, this code should be
disabled.
This commit is contained in:
Arseny Kapoulkine 2024-09-11 13:15:01 -07:00
parent 14a7e0abb3
commit 7d7b43bca2
1 changed files with 2 additions and 2 deletions

View File

@ -849,7 +849,7 @@ void ImporterMesh::create_shadow_mesh() {
index_wptr[j] = vertex_remap[index];
}
if (SurfaceTool::optimize_vertex_cache_func) {
if (SurfaceTool::optimize_vertex_cache_func && surfaces[i].primitive == Mesh::PRIMITIVE_TRIANGLES) {
SurfaceTool::optimize_vertex_cache_func((unsigned int *)index_wptr, (const unsigned int *)index_wptr, index_count, new_vertices.size());
}
@ -871,7 +871,7 @@ void ImporterMesh::create_shadow_mesh() {
index_wptr[k] = vertex_remap[index];
}
if (SurfaceTool::optimize_vertex_cache_func) {
if (SurfaceTool::optimize_vertex_cache_func && surfaces[i].primitive == Mesh::PRIMITIVE_TRIANGLES) {
SurfaceTool::optimize_vertex_cache_func((unsigned int *)index_wptr, (const unsigned int *)index_wptr, index_count, new_vertices.size());
}