summaryrefslogtreecommitdiffstats
path: root/scene/resources/importer_mesh.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-09-21 14:24:54 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-09-21 14:24:54 +0200
commit184e603c9923e6c770d43808afd0afc68e9cfe8b (patch)
tree4fb0db40d545891f0887727de9b2a3b7bd0e6667 /scene/resources/importer_mesh.cpp
parent4f314a64a5e44c1a7b607a3c1f41d2e07b2dac55 (diff)
parentf95f2d1149ad68cd4efb4d19e662e0eea0125b26 (diff)
downloadredot-engine-184e603c9923e6c770d43808afd0afc68e9cfe8b.tar.gz
Merge pull request #80467 from aaronfranke/mesh-lod-limit
Limit mesh complexity in LOD generation to prevent crashing
Diffstat (limited to 'scene/resources/importer_mesh.cpp')
-rw-r--r--scene/resources/importer_mesh.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp
index a65a75d878..8768cd7c2a 100644
--- a/scene/resources/importer_mesh.cpp
+++ b/scene/resources/importer_mesh.cpp
@@ -475,6 +475,14 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
if (new_index_count == 0 || (new_index_count >= (index_count * 0.75f))) {
break;
}
+ if (new_index_count > 5000000) {
+ // This limit theoretically shouldn't be needed, but it's here
+ // as an ad-hoc fix to prevent a crash with complex meshes.
+ // The crash still happens with limit of 6000000, but 5000000 works.
+ // In the future, identify what's causing that crash and fix it.
+ WARN_PRINT("Mesh LOD generation failed for mesh " + get_name() + " surface " + itos(i) + ", mesh is too complex. Some automatic LODs were not generated.");
+ break;
+ }
new_indices.resize(new_index_count);