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

@@ -116,12 +116,7 @@ func _build_collision() -> void:
var shape := HeightMapShape3D.new()
shape.map_width = _field.columns()
shape.map_depth = _field.rows()
var heights := PackedFloat32Array()
heights.resize(_field.columns() * _field.rows())
for row in _field.rows():
for column in _field.columns():
heights[row * _field.columns() + column] = _field.elevation_at_cell(column, row)
shape.map_data = heights
shape.map_data = _field.elevations_m()
_collision = CollisionShape3D.new()
_collision.name = "Collision"
_collision.shape = shape