summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorsmix8 <52464204+smix8@users.noreply.github.com>2022-06-23 13:54:41 +0200
committersmix8 <52464204+smix8@users.noreply.github.com>2022-06-23 14:55:21 +0200
commit0c4d99f4fdcee4b1b6c289c83fb448262e60974b (patch)
tree7d03e4437a5ac64b1cb1ed95e8402f7523440152 /modules
parentc18d0f20357a11bd9cfa2f57b8b9b500763413bc (diff)
Implement NavigationMesh bake area
Adds two new properties to NavigationMesh resources to restrict the navmesh baking to an area enclosed by an AABB with volume.
Diffstat (limited to 'modules')
-rw-r--r--modules/navigation/navigation_mesh_generator.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp
index e430f5fd59..c620776dc6 100644
--- a/modules/navigation/navigation_mesh_generator.cpp
+++ b/modules/navigation/navigation_mesh_generator.cpp
@@ -482,6 +482,21 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
cfg.bmax[1] = bmax[1];
cfg.bmax[2] = bmax[2];
+ AABB baking_aabb = p_nav_mesh->get_filter_baking_aabb();
+
+ bool aabb_has_no_volume = baking_aabb.has_no_volume();
+
+ if (!aabb_has_no_volume) {
+ Vector3 baking_aabb_offset = p_nav_mesh->get_filter_baking_aabb_offset();
+
+ cfg.bmin[0] = baking_aabb.position[0] + baking_aabb_offset.x;
+ cfg.bmin[1] = baking_aabb.position[1] + baking_aabb_offset.y;
+ cfg.bmin[2] = baking_aabb.position[2] + baking_aabb_offset.z;
+ cfg.bmax[0] = cfg.bmin[0] + baking_aabb.size[0];
+ cfg.bmax[1] = cfg.bmin[1] + baking_aabb.size[1];
+ cfg.bmax[2] = cfg.bmin[2] + baking_aabb.size[2];
+ }
+
#ifdef TOOLS_ENABLED
if (ep) {
ep->step(TTR("Calculating grid size..."), 2);