perf(sites): validate the site once and hand collision the field array

DiveSite.configure() builds the height field once (TerrainHeightField
validates the data) instead of running the definition validation and
then the field construction again; the composition root relies on the
error returned by configure(). The collision shape takes the field's
row-major elevations directly instead of copying 263k cells one by one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OlivierandClaude Opus 5.5 committed 2026-10-06 20:52:04 +02:00
1 parent be16d2ee07
commit 682e1f18e5
5 files changed
+14 -16

No files matched your search

+4 -2
View File
@@ -7,7 +7,7 @@ const SitePlacement = preload("res://game/domain/sites/site_placement.gd")
const SiteRoute = preload("res://game/domain/sites/site_route.gd")
const DiveSiteDefinition = preload("res://game/domain/sites/dive_site_definition.gd")
const TEST_COUNT := 38
const TEST_COUNT := 39
var _failures: Array[String] = []
@@ -83,10 +83,12 @@ func _test_terrain_data_validation() -> void:
func _test_height_field_sampling() -> void:
var field := TerrainHeightField.from_data(_make_terrain(3, 4))
var data := _make_terrain(3, 4)
var field := TerrainHeightField.from_data(data)
_expect(field != null, "valid data yields a field")
if field == null:
return
_expect(field.elevations_m() == data.elevations_m, "elevations are exposed in row-major data order")
_expect(field.bounds_m().is_equal_approx(Rect2(-10.0, 100.0, 4.0, 6.0)), "bounds cover (columns-1) by (rows-1) cells")
_expect(field.cell_world_position(2, 3).is_equal_approx(Vector3(-6.0, -26.0, 106.0)), "cell position follows origin and cell size")
_expect(is_equal_approx(field.elevation_at(-10.0, 100.0), -20.0), "elevation at a vertex is exact")