From 75b61ea1f4b5a8f07e17b94b7df7d43bcfa04701 Mon Sep 17 00:00:00 2001 From: Carlo Cabanilla Date: Thu, 2 Dec 2021 14:14:28 -0800 Subject: [PATCH] Let MultiMeshInstances affect NavigationMeshes --- modules/navigation/navigation_mesh_generator.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index 05e040b5184..7e731e6753f 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -36,6 +36,7 @@ #include "core/os/thread.h" #include "scene/3d/collision_shape_3d.h" #include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/multimesh_instance_3d.h" #include "scene/3d/physics_body_3d.h" #include "scene/resources/box_shape_3d.h" #include "scene/resources/capsule_shape_3d.h" @@ -148,6 +149,21 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor } } + if (Object::cast_to(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { + MultiMeshInstance3D *multimesh_instance = Object::cast_to(p_node); + Ref multimesh = multimesh_instance->get_multimesh(); + Ref 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_accumulated_transform * multimesh->get_instance_transform(i), p_verticies, p_indices); + } + } + } + #ifdef MODULE_CSG_ENABLED if (Object::cast_to(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { CSGShape3D *csg_shape = Object::cast_to(p_node);