Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit mesh complexity in LOD generation to prevent crashing #80467

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scene/resources/importer_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
aaronfranke marked this conversation as resolved.
Show resolved Hide resolved
// 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);

Expand Down