From 4bc2171b01f05d2442fb84855c0dc7513e9d8770 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:08:54 -0500 Subject: [PATCH] H15: Re-check the underwater murk whenever the camera moves MatchView.setup() syncs with the camera at the origin, which is under the sea once it has risen, and nothing re-checked the murk when the camera was then placed. Captures of the late match (match_tide, match_final, match_results) came out as flat teal, and in the game every camera cut showed one frame of the wrong murk, since ClientSession syncs before moving the camera. _focus(), which every camera placement calls, now applies the weather again for the camera's new position. Test: a view under a risen sea, moved with no sync, follows the camera in and out of the murk. Closes #84 Co-Authored-By: Claude Opus 5.5 --- src/client/match_view.gd | 6 ++++++ test/client/test_weather.gd | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/client/match_view.gd b/src/client/match_view.gd index 7a169c6..78a87df 100644 --- a/src/client/match_view.gd +++ b/src/client/match_view.gd @@ -182,6 +182,12 @@ func settle() -> void: terrain.build_all_now() +## Called whenever the camera moves. The weather's murk is decided by where the camera +## is, so it is checked again here: a view placed after its last sync() (a capture, or +## the frame a spectator's camera cuts to the island) would otherwise keep the murk of +## wherever the camera was before, the origin under the sea at first (H6). func _focus() -> void: if terrain != null: terrain.focus = camera.position + if weather != null and sim != null: + weather.apply(weather.weather, camera.transform.origin) diff --git a/test/client/test_weather.gd b/test/client/test_weather.gd index ed32ab3..3000679 100644 --- a/test/client/test_weather.gd +++ b/test/client/test_weather.gd @@ -111,3 +111,19 @@ func test_the_sea_takes_its_colours_from_the_palette_and_a_heightmap() -> void: assert_true(view.is_under(Vector3(1.0, 4.0, 1.0))) assert_false(view.is_under(Vector3(1.0, 6.0, 1.0))) view.free() + + +func test_moving_the_camera_rechecks_the_murk_without_a_sync() -> void: + # H6: setup() syncs with the camera at the origin, under a risen sea. A camera + # placed afterwards, with no sync of its own, must not keep that murk. + var sim: Simulation = Simulation.new(3, SimGround.flat(-20.0)) + sim.set_sea_level(30.0) + var view: MatchView = MatchView.new() + view.setup(sim, 0) + assert_true(view.weather.underwater, "the camera starts at the origin, under the sea") + view.overview() + assert_false(view.weather.underwater, "the overview is high over the sea") + assert_ne(view.weather.environment.fog_light_color, Palette.SEA_MURK) + view.look_from(Vector3(500.0, 10.0, 500.0), Vector3(510.0, 10.0, 500.0)) + assert_true(view.weather.underwater, "and back under it") + view.free()