test: harden jajce terrain navigation
This commit is contained in:
@@ -26,6 +26,12 @@ func _run() -> void:
|
||||
terrain.data_directory == "res://terrain/jajce/data",
|
||||
"Terrain3D should use dedicated Jajce data"
|
||||
)
|
||||
_check(terrain.collision_mode != 0, "Terrain3D collision should be enabled for gameplay")
|
||||
var greybox_ground := world.get_node("NavigationRegion3D/GreyboxGround") as StaticBody3D
|
||||
_check(
|
||||
greybox_ground.collision_layer == 0 and greybox_ground.collision_mask == 0,
|
||||
"GreyboxGround should not provide runtime physics collision"
|
||||
)
|
||||
_check(
|
||||
configured_texture_count == 6,
|
||||
(
|
||||
@@ -215,6 +221,9 @@ func _run() -> void:
|
||||
not path.is_empty(),
|
||||
"Jajce navigation path should exist from %s to %s" % [origin, destination]
|
||||
)
|
||||
_check_path_tracks_terrain(
|
||||
terrain, path, "Jajce navigation path should track Terrain3D height"
|
||||
)
|
||||
|
||||
var adapter := ActiveWorldAdapter.new()
|
||||
adapter.pantry_storage = pantry
|
||||
@@ -304,3 +313,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
|
||||
|
||||
Reference in New Issue
Block a user