summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-08-28 15:29:54 +0200
committerGitHub <noreply@github.com>2019-08-28 15:29:54 +0200
commit4aed4b44b633721b674e3325e760abbb94984fd7 (patch)
treed0041caaa6d3431142cc23c16dc563973eff0ae5
parent46ad60385b68a8af142108715a12a3363ffb3fea (diff)
parent82acd436b4f4587232fef3ba65873ef1785e8341 (diff)
Merge pull request #31454 from lliberadzki/gridmap-navmesh-baking
Support baking gridmap navmesh.
-rw-r--r--modules/recast/navigation_mesh_generator.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/modules/recast/navigation_mesh_generator.cpp b/modules/recast/navigation_mesh_generator.cpp
index 14467dc5c7..c5b60f2dca 100644
--- a/modules/recast/navigation_mesh_generator.cpp
+++ b/modules/recast/navigation_mesh_generator.cpp
@@ -49,6 +49,10 @@
#include "modules/csg/csg_shape.h"
#endif
+#ifdef MODULE_GRIDMAP_ENABLED
+#include "modules/gridmap/grid_map.h"
+#endif
+
EditorNavigationMeshGenerator *EditorNavigationMeshGenerator::singleton = NULL;
void EditorNavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) {
@@ -240,8 +244,21 @@ void EditorNavigationMeshGenerator::_parse_geometry(Transform p_accumulated_tran
}
}
- if (Object::cast_to<Spatial>(p_node)) {
+#ifdef MODULE_GRIDMAP_ENABLED
+ if (Object::cast_to<GridMap>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ GridMap *gridmap_instance = Object::cast_to<GridMap>(p_node);
+ Array meshes = gridmap_instance->get_meshes();
+ Transform xform = gridmap_instance->get_transform();
+ for (int i = 0; i < meshes.size(); i += 2) {
+ Ref<Mesh> mesh = meshes[i + 1];
+ if (mesh.is_valid()) {
+ _add_mesh(mesh, p_accumulated_transform * xform * meshes[i], p_verticies, p_indices);
+ }
+ }
+ }
+#endif
+ if (Object::cast_to<Spatial>(p_node)) {
Spatial *spatial = Object::cast_to<Spatial>(p_node);
p_accumulated_transform = p_accumulated_transform * spatial->get_transform();
}