Skip to content

Commit

Permalink
Merge pull request #31454 from lliberadzki/gridmap-navmesh-baking
Browse files Browse the repository at this point in the history
Support baking gridmap navmesh.
  • Loading branch information
akien-mga authored Aug 28, 2019
2 parents 46ad603 + 82acd43 commit 4aed4b4
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion modules/recast/navigation_mesh_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 4aed4b4

Please sign in to comment.