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
+4
View File
@@ -40,6 +40,10 @@ for (const subject of ['A', 'B']) {
`the world needs a marked window behind the far wall (TESTING 5.8): ${JSON.stringify(cov)}`)
assert.equal(cov.markedWindowsOccludedSeen, 0,
`a wall behind a sight blocker yields no marker: ${JSON.stringify(cov)}`)
// #26: a wall lying along a vision ray with a hidden token beyond it must be in the world;
// the checker's HIDDEN_TOKEN class is the assertion that it does not leak.
assert.ok(cov.onRayHidden >= 1,
`the world needs a token hidden behind a wall lying along a vision ray (#26): ${JSON.stringify(cov)}`)
}
const check = runChecker(transcript, subject)
fs.writeFileSync(path.join(results, `leak-${subject}.log`), check.output)