From bbf1dc99907bdbb071c6489c46bfd9cac3df2988 Mon Sep 17 00:00:00 2001 From: Olivier Date: Tue, 6 Oct 2026 20:09:46 +0200 Subject: [PATCH] fix(world): wind terrain triangles clockwise so the seabed is a front face Co-Authored-By: Claude Sonnet 5.5 --- game/world/sites/bathymetric_terrain_actor.gd | 4 ++-- tests/integration/run_site_terrain_integration.gd | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/game/world/sites/bathymetric_terrain_actor.gd b/game/world/sites/bathymetric_terrain_actor.gd index e4a9305..a7fca5d 100644 --- a/game/world/sites/bathymetric_terrain_actor.gd +++ b/game/world/sites/bathymetric_terrain_actor.gd @@ -92,8 +92,8 @@ func _build_tile(start_column: int, end_column: int, start_row: int, end_row: in var top_right := top_left + 1 var bottom_left := top_left + columns_in_tile var bottom_right := bottom_left + 1 - indices.append_array([top_left, bottom_left, top_right]) - indices.append_array([top_right, bottom_left, bottom_right]) + indices.append_array([top_left, top_right, bottom_left]) + indices.append_array([top_right, bottom_right, bottom_left]) var arrays: Array = [] arrays.resize(Mesh.ARRAY_MAX) arrays[Mesh.ARRAY_VERTEX] = vertices diff --git a/tests/integration/run_site_terrain_integration.gd b/tests/integration/run_site_terrain_integration.gd index ab87e89..3552133 100644 --- a/tests/integration/run_site_terrain_integration.gd +++ b/tests/integration/run_site_terrain_integration.gd @@ -15,7 +15,7 @@ const ReferenceBathymetryAcquisition = preload( ) const DIVE_SITE_SCENE = preload("res://game/world/sites/dive_site.tscn") -const TEST_COUNT := 23 +const TEST_COUNT := 24 var _failures: Array[String] = [] @@ -68,6 +68,16 @@ func _test_actor_matches_field() -> void: await physics_frame _expect(actor.tile_count() == 4, "80 cells per side split into 2 x 2 tiles of 64") + var first_tile := actor.get_node("Tiles").get_child(0) as MeshInstance3D + var arrays: Array = first_tile.mesh.surface_get_arrays(0) + var tile_vertices: PackedVector3Array = arrays[Mesh.ARRAY_VERTEX] + var tile_indices: PackedInt32Array = arrays[Mesh.ARRAY_INDEX] + var first_face := Plane( + tile_vertices[tile_indices[0]], + tile_vertices[tile_indices[1]], + tile_vertices[tile_indices[2]] + ) + _expect(first_face.normal.y > 0.0, "tile triangles are wound clockwise from above (front face up)") var space := actor.get_world_3d().direct_space_state var worst_error := 0.0 for cell: Vector2i in [