feat(world): render steep tiles on a smooth bicubic surface, sampled in parallel

Tiles holding a slope over 35 degrees are meshed at two vertices per cell
on a clamped Catmull-Rom surface that passes through every grid node, so
cliffs and ledges lose the facets of the heightfield grid while the
collision stays on the grid. The domain field exposes the smooth
elevation and a separable, per-phase-weighted block sampler with linear
edge extrapolation and a one-cell margin for continuous normals; the actor
samples tiles on the worker thread pool and builds meshes afterwards.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
OlivierandClaude Fable 5.1 committed 2026-10-07 00:09:42 +02:00
1 parent d7e50f8879
commit 122f3f5800
11 files changed
+314 -19

No files matched your search

@@ -19,7 +19,7 @@ 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 := 41
const TEST_COUNT := 44
var _failures: Array[String] = []
@@ -109,12 +109,21 @@ func _test_actor_matches_field() -> void:
tile_vertices[tile_indices[2]]
)
_expect(first_face.normal.y > 0.0, "tile triangles are wound clockwise from above (front face up)")
# The first tile spans cells 0..64 on both axes, so vertex index = row * 65 + column.
# The first tile holds the steep bump, so it is rendered subdivided; the second tile
# (cells 64..80) is flat and stays on the grid.
var subdivision := actor.tile_subdivision(0)
_expect(subdivision == BathymetricTerrainActor.STEEP_TILE_SUBDIVISION, "the steep tile is subdivided (%d)" % subdivision)
_expect(actor.tile_subdivision(1) == 1, "the flat tile keeps one vertex per cell")
# The first tile spans cells 0..64 on both axes: vertex index = (row * n) * (64 n + 1) + column * n.
var points_per_row := 64 * subdivision + 1
var worst_vertex_error := 0.0
for cell: Vector2i in [Vector2i(0, 0), Vector2i(10, 50), Vector2i(64, 64)]:
var vertex := first_tile.global_transform * tile_vertices[cell.y * 65 + cell.x]
var vertex := first_tile.global_transform * tile_vertices[(cell.y * subdivision) * points_per_row + cell.x * subdivision]
worst_vertex_error = maxf(worst_vertex_error, vertex.distance_to(field.cell_world_position(cell.x, cell.y)))
_expect(worst_vertex_error < 0.01, "tile vertices sit on their field cells (worst %.4f m)" % worst_vertex_error)
_expect(worst_vertex_error < 0.01, "tile vertices on grid nodes sit on their field cells (worst %.4f m)" % worst_vertex_error)
var mid_vertex := first_tile.global_transform * tile_vertices[(50 * subdivision + 1) * points_per_row + 10 * subdivision + 1]
var mid_expected := field.smooth_elevation_at(mid_vertex.x, mid_vertex.z)
_expect(absf(mid_vertex.y - mid_expected) < 0.01, "subdivided vertices sit on the smooth surface (%.3f vs %.3f)" % [mid_vertex.y, mid_expected])
var space := actor.get_world_3d().direct_space_state
var worst_error := 0.0
for cell: Vector2i in [