Throwaway prototype for issue #43 (wayfinder map #38). Pictures, explored cells and cost of what our
polygon code does when a wall has a width and a height. Branch prototype/wall-sight, never pushed,
server/ untouched.
server/geometry.nim (the same ray fan, the same cellsTouched) and adds only the model the
tickets are arguing about: the 5.8 switch filter, a thickness expansion and a per-target height predicate. Nothing
here is production code and nothing was folded back.visibilityPolygon output).Every picture is generated from scratch by pictures.nim. The filter is
5.8's and nothing else: a wall enters the fan only if blocks_sight, never when it is an open door,
a one-way wall only for the blocked side — no kind logic anywhere. Height never enters the polygon; it is a
per-target 3D test (eye + t·(target − eye) > wall height), which is what research #39 §3.3 said
has to happen because a nearest-hit fan can shorten a ray but never resume it.
Left: today's zero-width wall. Right: the same wall as a 3-face rectangle (near face + two end caps). The wall's own body becomes hidden floor, the shadow edge moves out by t/2 (7 px here — visible only if you compare the two panels), and the polygon is a strict subset: 228 explored cells thin, 227 thick, 0 gained, 1 lost.
Surprise: at 14 px on a 400 px room the pictures are almost identical. Thickness costs cells in proportion to cell size vs room size, so on a normal map it is a border cell here and there — the dense 5k layout is where it eats half the view.
Same L-shaped room, thin then thick. Thin: the polygon reaches the shared vertex exactly. Thick: the two bodies overlap at the joint, the inner corner loses its cells (242 → 232 explored, 0 gained, 10 lost), and the eye sees less into the corner because the near faces are 7 px closer.
Surprise: no crack at the joint in either panel. The expected zero-width sliver leak at a shared vertex did not appear at this scale — the ±RayEps fan already covers it — so "thickness is needed to close the joints" is not what this layout shows; the polygon change comes from the wall bodies alone.
The wall has a 90 px opening with a 14 px thick leaf. Closed (left): nothing passes. Open (right): the door is gone from the input, but the two jambs are 14 px deep, so the view through is a narrow diagonal beam — token A (right behind the opening) is visible, token C (left of it) is behind the wall, and token B is clipped by the far corner of the right jamb even though it is well past the opening.
Surprise: opening a thick door does not reveal the doorway's width, it reveals a keyhole whose shape depends on where the viewer stands. On a 32 px grid that beam is 1–2 cells wide, so a player standing two steps to the side unlocks almost nothing through a door they just opened.
Wall 12 px thick, 1.0 m high; the eye is 70 px in front of it. For the 1.8 m viewer (eye 1.67 m) the floor
behind the wall is hidden out to d = s·h_eye/(h_eye−h_wall) = 174 px from the eye — the salmon band —
and visible again beyond it. The dashed polygon is the same fan with the low wall ignored: exactly the extra floor
a "low walls never block" rule would reveal. For the 1.0 m viewer (eye 0.93 m, below the wall top) no floor behind
is ever visible: the whole far side is salmon, but a 1.8 m token's head still shows over the wall.
Surprise: the target's height matters as much as the wall's. In 4a a 1.0 m token 75 px behind the wall is visible while a 0.3 m crate 45 px behind it is not; in 4b (eye below the wall top) two tall tokens are visible and nothing else is. A wall-only flag ("low wall = see over") gets both of those wrong.
Surprise: the fog has to pick an error. Solid polygon = the floor behind a low wall is never explored from a distance, so a token you can see stands on a black tile. Dashed polygon = the fog reveals a band nobody can see. There is no polygon that does the right thing; that is #44's decision.
Left: no wall at all. Right: the same layout with a 14 px thick terrain wall
(blocks_sight:false, blocks_movement:true). The two polygons are vertex-identical (64/64, 318 explored
cells both), the explored sets are equal and nothing is drawn differently apart from the wall itself.
Confirmed rather than surprising: blocks_sight:false costs literally zero polygon work,
thickness and height included, because the wall never reaches the geometry. Any "cheap terrain" argument in #44/#45
can rely on that.
One 12 px thick wall, sight_dir:"left", a → b pointing down the page, so the left
(west) side is the blocked one. Left: a viewer west of it gets a polygon that stops at the wall, and both east
tokens stay in fog. Right: a viewer east of it has the wall absent from the geometry (one filter decision,
not a special case in the fan) and sees west through it, including the two west tokens.
Surprise: this is the only scenario where the explored maps of two players in the same room differ permanently, and it is the only place where the 5.8 filter must run per observer — i.e. per polygon, not per scene (see the cost table: that filter is not free).
Same harness as tools/bench.nim (2000 iterations, 50 warm-up, -d:release, avg ms per
one visibility polygon, radius 400, cell 32). "Today" = the blocking walls pre-expanded into the segment list the fan
already takes, which is what production does. Thick = 10 px, 3 faces (near + 2 caps, exact for a viewer on the near
side but observer-dependent) or 4 faces (a quad, exact and hoistable once per wall edit). Cells = explored cells per
polygon.
| scene | arm | poly ms | verts | cells | vs today |
|---|---|---|---|---|---|
| prototype (60 walls, 4096 px) | thin (today) | 0.031 | 88 | 412 | 1.00× |
| thin + 5.8 filter per query | 0.033 | 88 | 412 | 1.06× | |
| thick 3 faces, per query | 0.051 | 119 | 396 | 1.65× | |
| thick 4 faces, per query | 0.064 | 142 | 394 | 2.06× | |
| thick 4 faces, hoisted | 0.057 | 142 | 394 | 1.84× | |
| 5k sparse (16384 px, 15.8 walls in box) | thin (today) | 0.083 | 162 | 241 | 1.00× |
| thin + 5.8 filter per query | 0.237 | 162 | 241 | 2.84× | |
| thick 3 faces, per query | 0.699 | 314 | 219 | 8.37× | |
| thick 4 faces, per query | 0.943 | 410 | 217 | 11.30× | |
| thick 4 faces, hoisted | 0.263 | 410 | 217 | 3.15× | |
| 5k dense (4096 px, 206 walls in box) | thin (today) | 1.254 | 1332 | 54 | 1.00× |
| thin + 5.8 filter per query | 1.399 | 1332 | 54 | 1.12× | |
| thick 3 faces, per query | 7.851 | 3724 | 26 | 6.26× | |
| thick 4 faces, per query | 13.229 | 4976 | 21 | 10.55× | |
| thick 4 faces, hoisted | 12.721 | 4976 | 21 | 10.15× |
Read: on the realistic (sparse) density a hoisted quad costs 0.26 ms per polygon —
inside the 1 ms target, and it reproduces the 0.257 ms measured for #39. The dense stress layout is 10× over and stays
over for every exact variant. Two costs hide in the numbers: the 5.8 filter is +0.15 ms per polygon at 5k walls
(because it scans every wall in the scene: 2.8× the sparse baseline, ≈ 0.9 ms for a 6-token party — the whole
per-move budget), and the 3-face silhouette is observer-dependent so it can never be hoisted. Raw output:
cost.txt.
eye + t·(h_top − eye) > wall_h); a wall-only "see over" flag cannot express it. Treat "low barrier
hides everything behind it" as the special case h_top = 0.blocks = not (door and open)) and put see-over only in the per-target predicate (family C). It is the
only option with zero geometry cost, the explored set stays conservative and monotone (never un-explores), and the
dense numbers (1.25 ms today, 12.7 ms for thickness) say the fan has no budget left for a second height-aware
polygon. The price is visible in picture 4a: a token you can see can stand on a tile that is still fogged. If the
owner rejects that artefact, the fallback is family D — fog from a permissive polygon (the dashed one), tokens from
the strict one — at +1 fan per token, and picture 4a shows exactly the extra band it would reveal.wall.*/door.set), then runs the fan over
that list. Filtering per polygon costs 0.15 ms × 6 tokens at 5k walls, which is the whole per-move budget; hoisted
it is zero. The only thing that must stay per observer is the one-way decision, which is a cheap per-wall test on
the pre-built list, or two pre-built lists (one per direction).left wall sees nothing across).h_t
the see-over boundary of a low wall is that wall scaled about the eye by
(h_eye − h_t)/(h_eye − h_wall) (the straight salmon/parchment line in 4a is exactly that, with
h_t = 0). A fan could use those scaled segments to shorten rays, which fixes family B's single-radius
error cheaply, but it still cannot resume a ray, so the far side of a low wall would be lost. Use it only if a
height-aware fog polygon is ever wanted; per-target predicate stays the reference.pathClear / stuck numbers for thick rectangles (research #39 already has
them: 0.010 → 0.030 ms dense).cellsTouched, not the 32 px tile gate
itself.nim c -r prototype-wall-sight/pictures.nim # rewrites img/*.svg nim c -d:release -r prototype-wall-sight/bench_thick.nim # rewrites the table above (cost.txt)
Files: sightmodel.nim (filter, thickness expansion, height predicate),
pictures.nim (scenarios + SVG), bench_thick.nim (cost), cost.txt (raw run).