diff options
author | Lyuma <xn.lyuma@gmail.com> | 2023-09-24 23:05:26 -0700 |
---|---|---|
committer | Lyuma <xn.lyuma@gmail.com> | 2023-09-24 23:05:26 -0700 |
commit | acf76027bd2926ed2a9538f992ad6a7c9888d518 (patch) | |
tree | e9f92f65eef3a625db40a327ec8791a9d2f9bc45 | |
parent | 59139df16e7a10c3b9176f697d23b557af46601e (diff) | |
download | redot-engine-acf76027bd2926ed2a9538f992ad6a7c9888d518.tar.gz |
Avoid crash when generating LODs on meshes with non-finite vertices.
-rw-r--r-- | scene/resources/importer_mesh.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index a65a75d878..a3d6b803cf 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -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); |