fix: hit a wall lying along a sight ray so it casts its line's shadow (#26)

visibilityPolygon casts one ray per 64-gon vertex and ang, ang+-RayEps per wall
endpoint. A wall radial to the viewer is collinear with the ray that crosses it,
and rayHit rejected the collinear case; its own +-RayEps rays meet the wall's
line at the viewer (t = 0, rejected by t > Eps). So the wall got no ray, no
vertex and no shadow, and a token on the line beyond it stayed inside the
polygon: a player-view fog leak (DESIGN 3.1).

Fix: rayHit returns the nearest point of the overlap when the wall lies on the
ray's line (and Inf only for a parallel wall on another line). {.inline.} keeps
the fan's inner loop at its previous cost (CPU-time cross-check on 20k dense
polygons: 25.8s before, 32.5s without the pragma, 24.9s with it).

Proof: tgeometry visibility tests (horizontal k=0, vertical k=16, both wall
directions, a 32 px grid translation, 10 degrees, plus the non-radial and
0.5 px-off negative controls); the leak world gains a wall on the subject's own
column with a hidden token beyond it, and leakcheck's HIDDEN_TOKEN class now
asserts the token-level over-approximation (token centre + viewer->token
segment, 5.4 tolerance), which the GEOMETRY class structurally cannot see.
This commit is contained in:
2026-11-20 22:17:45 +01:00
parent a11782f00d
commit 414bb0326c
7 changed files with 169 additions and 6 deletions
+3 -1
View File
@@ -708,7 +708,9 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
These are the cases the algorithm handles. Proven by: TESTING §5.2 (port baseline, regression tests).
- Collinear rays skipped (neighbouring +-eps rays cover them).
- Collinear rays skipped (neighbouring +-eps rays cover them) — except a wall lying *along* the ray
(radial to the viewer): it is hit at the nearest point of the overlap, so it contributes a vertex
and the line beyond it is outside the polygon (#26).
- Token standing on an endpoint: that endpoint skipped, hits at t <= 1e-9 ignored.
- T-junction, shared vertex, free-standing wall, '<' apex, box corner, behind-viewer fan, long thin
corridor.
+6 -1
View File
@@ -361,7 +361,12 @@ from the prototype, what was missing, what the M3 build added, and the tools it
behind each, a one-way screen, a marked window the subject sees, the same window's switch cleared
and restored (retraction and re-earn), a marked solid wall and a marked window the subject never
sees. `tools/leak.test.mjs` asserts that coverage from the GM's wall frames and the subject's
marker frames, so a rewrite that drops an element fails on its own, not only inside a fault. All
marker frames, so a rewrite that drops an element fails on its own, not only inside a fault. The
world also holds a wall lying along one of the subject's vision rays with a token beyond it on the
same line: a zero-width wall hides exactly that line, and `HIDDEN_TOKEN` is the token-level
assertion for it (#26) — the class checks a token's own centre and the viewer -> token segment
against the walls, not sampled polygon points, because the `GEOMETRY` class only tests *missing*
vision and cannot see an over-approximation. All
pre-existing classes still fire under the rewrite, each as exactly its own class (all 21 entries
of the `FAULTS` table of `tools/fault.test.mjs`, 22 tests with the clean-build gate).
`tools/leakcheck.nim`