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

Avoid crash when generating LODs on meshes with non-finite vertices. #82285

Merged
merged 1 commit into from
Sep 25, 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
4 changes: 4 additions & 0 deletions scene/resources/importer_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
const Vector3 &v2 = vertices_ptr[new_indices_ptr[j + 2]];
Vector3 face_normal = vec3_cross(v0 - v2, v0 - v1);
float face_area = face_normal.length(); // Actually twice the face area, since it's the same error_factor on all faces, we don't care
if (!Math::is_finite(face_area) || face_area == 0) {
WARN_PRINT_ONCE("Ignoring face with non-finite normal in LOD generation.");
continue;
}

Vector3 dir = face_normal / face_area;
int ray_count = CLAMP(5.0 * face_area * error_factor, 16, 64);
Expand Down
Loading