H11: Hide pines between the shoulder camera and the player

PropView.clear_view() hides every pine whose drawn shape crosses the line
from the camera to the followed player's chest or head, or holds the
camera, and shows it again once the line is clear. Candidates come from the
trunks in the ground's solid index around the line. MatchView.follow()
applies it; look_from() (framing, overview) shows everything again.

Test: a player against the most crowded pine on seed 2, at 16 yaws, hides
exactly the blocking pines and brings them all back afterwards. Captures
canopy and canopy_before (tools/capture.sh canopy ...).

Closes #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 21:25:26 -05:00
co-authored by Claude Opus 5.5
parent dff83fbe11
commit b9f5493c03
8 changed files with 173 additions and 1 deletions
+52
View File
@@ -80,3 +80,55 @@ func test_the_camera_follows_a_player_and_frames_one() -> void:
view.overview()
assert_true(view.camera.position.y > 200.0)
view.free()
## H11: a pine's canopy never hides the followed player from the shoulder camera.
func test_pines_between_the_shoulder_camera_and_the_player_are_hidden() -> void:
var loop: ServerLoop = _match()
var sim: Simulation = loop.sim
var view: MatchView = MatchView.new()
view.setup(sim, 1)
while not sim.drop.finished:
loop.run_tick()
# The pine with the most pines around it, and a player standing against its trunk.
var best: int = -1
var crowd: int = -1
for prop: int in sim.props.count():
if sim.props.kind_name(prop) != "pine" or prop % 7 != 0:
continue
var around: int = sim.props.near(sim.props.boxes[prop].get_center(), 6.0).size()
if around > crowd:
crowd = around
best = prop
assert_true(best >= 0)
var trunk: AABB = sim.props.boxes[best]
var player: SimEntity = sim.entities.find(1)
player.drop_state = Drop.NONE
player.position = Vector3(trunk.end.x + Tuning.PLAYER_RADIUS + 0.05, sim.ground.terrain_height(trunk.end.x + 0.4, trunk.get_center().z), trunk.get_center().z)
view.sync()
var hid_any: bool = false
var hidden_at_some_yaw: Dictionary = {}
for step: int in 16:
var yaw: float = TAU * step / 16.0
assert_true(view.follow(1, 0.0, yaw))
var eye: Vector3 = view.camera.transform.origin
var height: float = Movement.body_height(player)
var chest: Vector3 = player.position + Vector3(0.0, height * 0.6, 0.0)
var head: Vector3 = player.position + Vector3(0.0, height, 0.0)
for prop: int in sim.props.near(player.position, 20.0):
if sim.props.kind_name(prop) != "pine":
continue
var shape: AABB = view.props.canopy_bounds(prop)
var blocks: bool = shape.has_point(eye) or shape.intersects_segment(eye, chest) or shape.intersects_segment(eye, head)
assert_eq(view.props.is_drawn(prop), not blocks, "yaw %d: pine %d %s" % [step, prop, "blocks the view" if blocks else "is hidden for nothing"])
if blocks:
hidden_at_some_yaw[prop] = true
hid_any = hid_any or not view.props.screened().is_empty()
assert_true(hid_any, "standing against a pine, some yaw looks through a canopy")
# Looking from anywhere else brings them all back. (Headless Godot keeps no MultiMesh
# instance transforms, so the restored transform itself is checked by capture.)
view.overview()
assert_eq(view.props.screened().size(), 0)
for prop: int in hidden_at_some_yaw:
assert_true(view.props.is_drawn(prop))
view.free()