diff options
author | Clay John <claynjohn@gmail.com> | 2022-05-30 15:44:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-30 15:44:28 -0700 |
commit | c89d2b8aacdd758bacd1b15dcdbbbcb2df1fba86 (patch) | |
tree | 848bfdd34b8e17959d6327f5191011b24e87c838 /modules | |
parent | 3df8296d8d6b77db8d6477a5df4d9a818a356310 (diff) | |
parent | caceceab0819dca9da4ca3c268bc07ded933e332 (diff) |
Merge pull request #61475 from smix8/navigation_fix_multimesh_bake_crash_4.x
Fix MultiMeshInstance crash in navmesh baking when MultiMesh Resource is empty
Diffstat (limited to 'modules')
-rw-r--r-- | modules/navigation/navigation_mesh_generator.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index 5cbaded6c1..1bc7cd7cdc 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -172,14 +172,16 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans if (Object::cast_to<MultiMeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { MultiMeshInstance3D *multimesh_instance = Object::cast_to<MultiMeshInstance3D>(p_node); Ref<MultiMesh> multimesh = multimesh_instance->get_multimesh(); - Ref<Mesh> mesh = multimesh->get_mesh(); - if (mesh.is_valid()) { - int n = multimesh->get_visible_instance_count(); - if (n == -1) { - n = multimesh->get_instance_count(); - } - for (int i = 0; i < n; i++) { - _add_mesh(mesh, p_navmesh_transform * multimesh_instance->get_global_transform() * multimesh->get_instance_transform(i), p_vertices, p_indices); + if (multimesh.is_valid()) { + Ref<Mesh> mesh = multimesh->get_mesh(); + if (mesh.is_valid()) { + int n = multimesh->get_visible_instance_count(); + if (n == -1) { + n = multimesh->get_instance_count(); + } + for (int i = 0; i < n; i++) { + _add_mesh(mesh, p_navmesh_transform * multimesh_instance->get_global_transform() * multimesh->get_instance_transform(i), p_vertices, p_indices); + } } } } |