summaryrefslogtreecommitdiff
path: root/modules/navigation
diff options
context:
space:
mode:
authortrollodel <33117082+trollodel@users.noreply.github.com>2022-05-01 13:30:58 +0200
committertrollodel <33117082+trollodel@users.noreply.github.com>2022-05-02 08:41:33 +0200
commit72c37c4bcd50e34b81c3dc5a2c5b8112014cc525 (patch)
tree829fdc99b33a630e8df5126ccc78dbc10bc9ef38 /modules/navigation
parent91f9a48ada60031d9d8253b37dc7b3ac3bb98e25 (diff)
Use CollisionObject3D API when baking the navmesh with static colliders, instead of collecting CollisionShape3D nodes
Diffstat (limited to 'modules/navigation')
-rw-r--r--modules/navigation/navigation_mesh_generator.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp
index 9e2daf3a99..2d6c78f704 100644
--- a/modules/navigation/navigation_mesh_generator.cpp
+++ b/modules/navigation/navigation_mesh_generator.cpp
@@ -34,7 +34,6 @@
#include "core/math/convex_hull.h"
#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"
@@ -202,14 +201,17 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(p_node);
if (static_body->get_collision_layer() & p_collision_mask) {
- for (int i = 0; i < p_node->get_child_count(); ++i) {
- Node *child = p_node->get_child(i);
- if (Object::cast_to<CollisionShape3D>(child)) {
- CollisionShape3D *col_shape = Object::cast_to<CollisionShape3D>(child);
-
- Transform3D transform = p_navmesh_transform * static_body->get_global_transform() * col_shape->get_transform();
+ List<uint32_t> shape_owners;
+ static_body->get_shape_owners(&shape_owners);
+ for (uint32_t shape_owner : shape_owners) {
+ const int shape_count = static_body->shape_owner_get_shape_count(shape_owner);
+ for (int i = 0; i < shape_count; i++) {
+ Ref<Shape3D> s = static_body->shape_owner_get_shape(shape_owner, i);
+ if (s.is_null()) {
+ continue;
+ }
- Ref<Shape3D> s = col_shape->get_shape();
+ const Transform3D transform = p_navmesh_transform * static_body->get_global_transform() * static_body->shape_owner_get_transform(shape_owner);
BoxShape3D *box = Object::cast_to<BoxShape3D>(*s);
if (box) {