perf(sites): build terrain tiles from bulk field blocks
Building the 64 tiles of the Banc du Vigilant cost about 1.9 s through per-vertex cell_world_position/normal_at_cell calls, leaving the 3 s load budget with too little headroom (2.1-2.9 s measured, one 4.8 s outlier). TerrainHeightField now returns positions and normals of a cell block in one call, with normal_at_cell sharing the same formula; the tile build drops to about 0.5 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bce5c20dec
commit
ce3b75989e
3 files changed
+80
-16
No files matched your search
@@ -78,14 +78,12 @@ func _build_tile(start_column: int, end_column: int, start_row: int, end_row: in
|
||||
0.0,
|
||||
(corner_min.z + corner_max.z) * 0.5
|
||||
)
|
||||
var vertices := PackedVector3Array()
|
||||
var normals := PackedVector3Array()
|
||||
var vertices := _field.cell_block_positions(start_column, end_column, start_row, end_row)
|
||||
for index in vertices.size():
|
||||
vertices[index] -= centre
|
||||
var normals := _field.cell_block_normals(start_column, end_column, start_row, end_row)
|
||||
var indices := PackedInt32Array()
|
||||
var columns_in_tile := end_column - start_column + 1
|
||||
for row in range(start_row, end_row + 1):
|
||||
for column in range(start_column, end_column + 1):
|
||||
vertices.append(_field.cell_world_position(column, row) - centre)
|
||||
normals.append(_field.normal_at_cell(column, row))
|
||||
for row in range(end_row - start_row):
|
||||
for column in range(end_column - start_column):
|
||||
var top_left := row * columns_in_tile + column
|
||||
|
||||
Reference in new issue
Block a user