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 <noreply@anthropic.com>
This commit is contained in:
@@ -182,6 +182,12 @@ func settle() -> void:
|
|||||||
terrain.build_all_now()
|
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:
|
func _focus() -> void:
|
||||||
if terrain != null:
|
if terrain != null:
|
||||||
terrain.focus = camera.position
|
terrain.focus = camera.position
|
||||||
|
if weather != null and sim != null:
|
||||||
|
weather.apply(weather.weather, camera.transform.origin)
|
||||||
|
|||||||
@@ -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_true(view.is_under(Vector3(1.0, 4.0, 1.0)))
|
||||||
assert_false(view.is_under(Vector3(1.0, 6.0, 1.0)))
|
assert_false(view.is_under(Vector3(1.0, 6.0, 1.0)))
|
||||||
view.free()
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user