1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-04 17:04:49 +00:00

[3.x] Consider gridmap collisions in navigation bake

This commit is contained in:
rafallus
2022-01-14 09:36:59 -06:00
parent f9d0975b72
commit 75fcb31cee
4 changed files with 118 additions and 11 deletions

View File

@@ -35,6 +35,7 @@
#include "scene/3d/light.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/physics_material.h"
#include "scene/resources/primitive_meshes.h"
#include "scene/resources/surface_tool.h"
#include "scene/scene_string_names.h"
#include "servers/navigation_server.h"
@@ -193,6 +194,24 @@ Ref<PhysicsMaterial> GridMap::get_physics_material() const {
return physics_material;
}
Array GridMap::get_collision_shapes() const {
Array shapes;
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
Octant *g = E->get();
RID body = g->static_body;
Transform body_xform = PhysicsServer::get_singleton()->body_get_state(body, PhysicsServer::BODY_STATE_TRANSFORM);
int nshapes = PhysicsServer::get_singleton()->body_get_shape_count(body);
for (int i = 0; i < nshapes; i++) {
RID shape = PhysicsServer::get_singleton()->body_get_shape(body, i);
Transform xform = PhysicsServer::get_singleton()->body_get_shape_transform(body, i);
shapes.push_back(body_xform * xform);
shapes.push_back(shape);
}
}
return shapes;
}
void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) {
if (!mesh_library.is_null()) {
mesh_library->unregister_owner(this);
@@ -939,7 +958,7 @@ Array GridMap::get_used_cells() const {
return a;
}
Array GridMap::get_meshes() {
Array GridMap::get_meshes() const {
if (mesh_library.is_null()) {
return Array();
}