test: harden jajce terrain navigation

This commit is contained in:
2026-07-08 15:47:01 +02:00
parent d2eca15ecd
commit cc0d6ef548
5 changed files with 71 additions and 3 deletions
+26
View File
@@ -26,6 +26,12 @@ func _run() -> void:
terrain.get_camera() == main_scene.get_node("CameraRig/Camera3D"),
"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"
)
_check(
(
not main_scene.has_node("World")
@@ -73,6 +79,9 @@ func _run() -> void:
not path.is_empty(),
"Navigation path should exist from %s to %s" % [origin, destination]
)
_check_path_tracks_terrain(
terrain, path, "Runtime navigation path should track Terrain3D height"
)
var village := SimVillage.new()
var worker := SimNPC.new(100, "BaselineWorker", SimulationIds.PROFESSION_SCHOLAR, 5.0, 5.0)
@@ -126,3 +135,20 @@ func _wait_for_navigation_map(navigation_map: RID) -> void:
func _check(condition: bool, message: String) -> void:
if not condition:
failures.append(message)
func _check_path_tracks_terrain(terrain: Terrain3D, path: PackedVector3Array, message: String) -> void:
if path.is_empty():
return
for point in path:
var terrain_height: float = terrain.data.get_height(point)
if is_nan(terrain_height):
failures.append("%s: missing terrain height at %s" % [message, point])
return
if absf(point.y - terrain_height) > 0.85:
failures.append(
"%s: path point %s is too far from terrain height %.2f"
% [message, point, terrain_height]
)
return