feat: bake jajce terrain navigation
This commit is contained in:
@@ -11,7 +11,8 @@ func _run() -> void:
|
||||
var main_scene: Node = load("res://main.tscn").instantiate()
|
||||
root.add_child(main_scene)
|
||||
await process_frame
|
||||
await physics_frame
|
||||
for _frame in 10:
|
||||
await physics_frame
|
||||
|
||||
var simulation_manager: Node = main_scene.get_node("SimulationManager")
|
||||
simulation_manager.set_process(false)
|
||||
@@ -27,10 +28,9 @@ func _run() -> void:
|
||||
"Runtime Terrain3D should bind to the gameplay camera"
|
||||
)
|
||||
_check(terrain.collision_mode != 0, "Runtime Terrain3D collision should be enabled")
|
||||
var greybox_ground := main_scene.get_node("JajceWorld/NavigationRegion3D/GreyboxGround") as StaticBody3D
|
||||
_check(
|
||||
greybox_ground.collision_layer == 0 and greybox_ground.collision_mask == 0,
|
||||
"Runtime GreyboxGround should not provide physics collision"
|
||||
not main_scene.has_node("JajceWorld/NavigationRegion3D/GreyboxGround"),
|
||||
"Runtime should not keep the temporary greybox navigation ground"
|
||||
)
|
||||
_check(
|
||||
(
|
||||
@@ -49,6 +49,11 @@ func _run() -> void:
|
||||
)
|
||||
|
||||
var navigation_map: RID = main_scene.get_world_3d().navigation_map
|
||||
var navigation_region := main_scene.get_node("JajceWorld/NavigationRegion3D") as NavigationRegion3D
|
||||
_check(
|
||||
navigation_region.navigation_mesh.resource_path == "res://world/jajce/JajceNavigationMesh.tres",
|
||||
"Runtime navigation should use the Terrain3D-derived baked mesh resource"
|
||||
)
|
||||
await _wait_for_navigation_map(navigation_map)
|
||||
NavigationServer3D.map_force_update(navigation_map)
|
||||
|
||||
@@ -82,6 +87,9 @@ func _run() -> void:
|
||||
_check_path_tracks_terrain(
|
||||
terrain, path, "Runtime navigation path should track Terrain3D height"
|
||||
)
|
||||
_check_path_reaches_destination(
|
||||
path, destination, "Runtime navigation path should reach its requested target"
|
||||
)
|
||||
|
||||
var village := SimVillage.new()
|
||||
var worker := SimNPC.new(100, "BaselineWorker", SimulationIds.PROFESSION_SCHOLAR, 5.0, 5.0)
|
||||
@@ -152,3 +160,17 @@ func _check_path_tracks_terrain(terrain: Terrain3D, path: PackedVector3Array, me
|
||||
% [message, point, terrain_height]
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
func _check_path_reaches_destination(path: PackedVector3Array, destination: Vector3, message: String) -> void:
|
||||
if path.is_empty():
|
||||
return
|
||||
|
||||
var final_point := path[path.size() - 1]
|
||||
var final_xz := Vector2(final_point.x, final_point.z)
|
||||
var destination_xz := Vector2(destination.x, destination.z)
|
||||
if final_xz.distance_to(destination_xz) > 1.5:
|
||||
failures.append(
|
||||
"%s: final path point %s is too far from %s"
|
||||
% [message, final_point, destination]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user