Merge pull request #55568 from clofresh/nav-multimesh

This commit is contained in:
Rémi Verschelde 2021-12-03 01:52:39 +01:00 committed by GitHub
commit cb3cce1134
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,7 @@
#include "core/os/thread.h" #include "core/os/thread.h"
#include "scene/3d/collision_shape_3d.h" #include "scene/3d/collision_shape_3d.h"
#include "scene/3d/mesh_instance_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/3d/physics_body_3d.h"
#include "scene/resources/box_shape_3d.h" #include "scene/resources/box_shape_3d.h"
#include "scene/resources/capsule_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<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_accumulated_transform * multimesh->get_instance_transform(i), p_verticies, p_indices);
}
}
}
#ifdef MODULE_CSG_ENABLED #ifdef MODULE_CSG_ENABLED
if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node); CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node);