Skip to content

Commit

Permalink
Set custom AABB for terrain baking to make bakings stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Jan 24, 2024
1 parent 0d509e0 commit ddfee71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/match/Navigation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func get_navigation_map_rid_by_domain(domain):
func setup(map):
assert(_static_obstacles.is_empty())
air.bake(map)
terrain.bake()
terrain.bake(map)
_setup_static_obstacles()


Expand Down
7 changes: 6 additions & 1 deletion source/match/TerrainNavigation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ func _process(_delta):
_rebake()


func bake():
func bake(map):
assert(
_navigation_region.navigation_mesh.get_polygon_count() == 0,
"bake() should be called exactly once - during runtime"
)
# setting custom AABB for baking so that height of dynamic AABB is always the same
# - without such setting, re-baking may yield different results depending on geometry height
_navigation_region.navigation_mesh.filter_baking_aabb = AABB(
Vector3.ZERO, Vector3(map.size.x, 5.0, map.size.y)
)
NavigationServer3D.parse_source_geometry_data(
_navigation_region.navigation_mesh, _map_geometry, get_tree().root
)
Expand Down

0 comments on commit ddfee71

Please sign in to comment.