test(sites): geometric contract and integration checks for the terrain showcase
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7e60315b1
commit
caa74b3ee1
2 files changed
+151
-2
No files matched your search
@@ -16,8 +16,9 @@ const ReferenceBathymetryAcquisition = preload(
|
||||
const DIVE_SITE_SCENE = preload("res://game/world/sites/dive_site.tscn")
|
||||
|
||||
const ZONE1_SITE_PATH := "res://content/sites/zone1_vigilant.tres"
|
||||
const SHOWCASE_SITE_PATH := "res://content/sites/terrain_showcase.tres"
|
||||
const GROOVE_PROBE_OFFSET_M := 25.0
|
||||
const TEST_COUNT := 31
|
||||
const TEST_COUNT := 36
|
||||
|
||||
var _failures: Array[String] = []
|
||||
|
||||
@@ -30,6 +31,7 @@ func _run() -> void:
|
||||
await _test_actor_matches_field()
|
||||
await _test_dive_site_scene()
|
||||
await _test_zone1_site()
|
||||
await _test_showcase_site()
|
||||
|
||||
var exit_code := 0
|
||||
if _failures.is_empty():
|
||||
@@ -218,6 +220,45 @@ func _test_zone1_site() -> void:
|
||||
site.queue_free()
|
||||
|
||||
|
||||
func _test_showcase_site() -> void:
|
||||
await process_frame
|
||||
var definition := load(SHOWCASE_SITE_PATH) as DiveSiteDefinition
|
||||
_expect(definition != null, "showcase site definition loads")
|
||||
if definition == null:
|
||||
return
|
||||
var started_usec := Time.get_ticks_usec()
|
||||
var site := DIVE_SITE_SCENE.instantiate() as DiveSite
|
||||
root.add_child(site)
|
||||
_expect(site.configure(definition).is_empty(), "dive site scene accepts the Jardin des Formes")
|
||||
var configure_ms := float(Time.get_ticks_usec() - started_usec) / 1000.0
|
||||
_expect(configure_ms < 3000.0, "showcase configures under the 3 s load budget (%.0f ms)" % configure_ms)
|
||||
await physics_frame
|
||||
await physics_frame
|
||||
var space := site.get_world_3d().direct_space_state
|
||||
var terrain := site.terrain()
|
||||
var canyon_floor := _terrain_height(space, terrain, -130.0, -135.0, [])
|
||||
var mesa_top := _terrain_height(space, terrain, -80.0, -90.0, [])
|
||||
_expect(mesa_top - canyon_floor >= 18.0, "collision rays find the canyon under the mesa (%.1f m vs %.1f m)" % [canyon_floor, mesa_top])
|
||||
|
||||
# Sensor above the canyon looking along its first leg (the acquisition probes along
|
||||
# local +Z): rock walls and sand floor.
|
||||
var sensor := Transform3D(Basis.IDENTITY, Vector3(-130.0, -15.0, -135.0))
|
||||
sensor.basis = Basis.looking_at(-Vector3(40.0, 0.0, -30.0).normalized(), Vector3.UP)
|
||||
var acquisition := ReferenceBathymetryAcquisition.new(site.get_world_3d())
|
||||
var request := SonarCaptureRequest.new(
|
||||
&"scan", &"session", sensor, 5.0, 95.0, deg_to_rad(76.0), deg_to_rad(64.0), 49, 31
|
||||
)
|
||||
var result = acquisition.capture(request)
|
||||
var materials: Dictionary = {}
|
||||
for sample in result.samples:
|
||||
materials[sample.material] = true
|
||||
_expect(
|
||||
result.accepted and materials.has(SonarMaterial.Value.ROCK) and materials.has(SonarMaterial.Value.SAND),
|
||||
"a scan along the canyon reads rock walls and a sand floor"
|
||||
)
|
||||
site.queue_free()
|
||||
|
||||
|
||||
## Seabed height under (x, z), or NAN (every comparison fails) when the ray misses the terrain actor.
|
||||
func _terrain_height(
|
||||
space: PhysicsDirectSpaceState3D,
|
||||
|
||||
Reference in new issue
Block a user