Prototype: sight polygon with thickness and height #43

Closed
opened 2026-11-15 15:48:54 +01:00 by SirStone · 1 comment
Owner

Part of #38

Question

What does sight actually look like with thick and low walls in our polygon code? A throwaway rough implementation to react to (pictures/ASCII of polygons, explored cells, cost).

Input from #42 (DESIGN 5.8)

Filter the sight input before the geometry: a wall enters the polygon only with blocks_sight on, a one-way wall only for the blocked side, and an open door never. A terrain wall must produce no polygon change at all. Prototype the shapes of thickness (#45) and height (#44); no kind logic belongs in the geometry.

Part of #38 ## Question What does sight actually look like with thick and low walls in our polygon code? A throwaway rough implementation to react to (pictures/ASCII of polygons, explored cells, cost). ## Input from #42 (DESIGN 5.8) Filter the sight input before the geometry: a wall enters the polygon only with `blocks_sight` on, a one-way wall only for the blocked side, and an open door never. A `terrain` wall must produce no polygon change at all. Prototype the shapes of thickness (#45) and height (#44); no kind logic belongs in the geometry.
SirStone added the wayfinder:prototype label 2026-11-15 15:48:54 +01:00
SirStone added a new dependency 2026-11-15 15:48:58 +01:00
SirStone added a new dependency 2026-11-15 15:48:58 +01:00
SirStone added a new dependency 2026-11-15 15:48:58 +01:00
SirStone added a new dependency 2026-11-15 15:48:58 +01:00
SirStone self-assigned this 2026-11-15 18:36:07 +01:00
Author
Owner

Owner reactions (2026-11-15)

  • Low walls. A token is visible iff its top clears the wall on the line from the viewer's eye — a per-target predicate, not a wall-only flag. The floor stays fogged unless it is truly seen: the sight polygon stays strict, so a visible token can stand on a still-fogged tile. (The permissive polygon — fog over a band nobody can see — was rejected.) Showing players the % of body visible is not v1: that is cover, a rules-engine question → map Out of scope, no ticket.
  • Thick doorway. The tunnel/keyhole view through a thick opening is accepted as-is; no "opening as wide as the gap" special case.
  • Cost. ~10× on the 5k dense scene (≈13 ms vs 1.25 ms) is accepted for v1; the per-move budget is re-baselined and the polygon optimised later (fog line on the map updated).

Findings per scenario (pictures in index.html)

  1. Thin vs thick — the thick polygon is a strict subset; the shadow edge moves out by t/2; 228 → 227 explored cells, 0 gained. Cost scales with cell-vs-room ratio: a border cell on a normal map, half the view on the 5k dense layout.
  2. Corner — no crack and no sliver leak at a shared vertex even with zero width (the ±RayEps fan already covers it); the 10 lost cells come from the wall bodies, not the joint. "Thickness is needed to close joints" is not what this layout shows.
  3. Door in a thick wall — opening it reveals a keyhole whose shape depends on where the viewer stands, not the opening's width; on a 32 px grid that beam is 1–2 cells. A closed secret door is the identical rectangle, so indistinguishability from a solid wall is free.
  4. Low wall — the target's height matters as much as the wall's: a 1.67 m eye sees a 1.0 m token over a 1.0 m wall but not a 0.3 m crate; a 0.93 m eye still sees 1.8 m heads. The hidden band reaches d = s·h_eye/(h_eye − h_wall) behind the wall. No single polygon is statically right: strict = visible token on a fogged tile, permissive = fog over floor nobody sees.
  5. Terrain — blocks_sight:false costs exactly zero geometry (identical 64-vertex polygon, identical explored set), thickness and height included.
  6. One-way — the only scenario where two players' explored maps differ permanently, and the only one where the 5.8 filter must run per observer; that filter is not free per query.

Cost (avg ms per polygon, radius 400, cell 32, 2000 iters)

scene arm poly ms verts cells vs thin
prototype (60 walls) 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 (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 (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×

Hoisted quad is 0.26 ms on 5k sparse — inside the old 1 ms target; 12.7 ms on 5k dense, which the owner accepted. The 5.8 filter costs +0.15 ms per polygon at 5k walls (2.8× the sparse baseline ≈ 0.9 ms for a 6-token party). The 3-face silhouette is observer-dependent and can never be hoisted; the 4-face quad can.

Downstream suggestions (passed on, not fixed here — #44/#45/#47/#49 own them)

  • #45 — prefer the 4-face hoistable quad over the 3-face silhouette: exact, viewer-independent, cacheable per wall edit (0.26 vs 0.94 ms sparse; 12.7 vs 13.2 dense).
  • #49 — precompute the filtered sight-segment list once per wall edit (rebuild on wall.*/door.set) instead of filtering per query; only the one-way decision stays per observer (cheap per-wall test on the pre-built list, or two pre-built lists).
  • #47 — a one-way wall should still occlude its own body from the unblocked side; otherwise the fog over its footprint reads as a gap and leaks the direction.
  • #47 — 5.8's "left names the side whose view across the wall is blocked" reads both ways (blocked from the left, or the left side hidden from the right). This prototype implements the first (a west viewer of a left wall sees nothing across); it needs one clarifying sentence wherever it is fixed.

Artifact

Branch prototype/wall-sight (pushed, never merged, no PR):
https://git.fossellini.top/SirStone/FFF_vtt/src/branch/prototype/wall-sight/prototype-wall-sight/index.html

index.html (findings), cost.txt (raw bench), sightmodel.nim (5.8 filter + thickness expansion + height predicate, wrapping server/geometry.nim), pictures.nim (six SVG scenarios), bench_thick.nim. server/ untouched; nothing folded back.

## Owner reactions (2026-11-15) - **Low walls.** A token is visible iff its **top clears the wall on the line from the viewer's eye** — a per-target predicate, not a wall-only flag. The floor stays fogged unless it is truly seen: the sight polygon stays **strict**, so a visible token can stand on a still-fogged tile. (The permissive polygon — fog over a band nobody can see — was rejected.) Showing players the **% of body visible** is **not v1**: that is cover, a rules-engine question → map Out of scope, no ticket. - **Thick doorway.** The tunnel/keyhole view through a thick opening is accepted as-is; no "opening as wide as the gap" special case. - **Cost.** ~10× on the 5k dense scene (≈13 ms vs 1.25 ms) is accepted for v1; the per-move budget is re-baselined and the polygon optimised later (fog line on the map updated). ## Findings per scenario (pictures in `index.html`) 1. **Thin vs thick** — the thick polygon is a strict subset; the shadow edge moves out by t/2; 228 → 227 explored cells, 0 gained. Cost scales with cell-vs-room ratio: a border cell on a normal map, half the view on the 5k dense layout. 2. **Corner** — no crack and no sliver leak at a shared vertex even with zero width (the ±RayEps fan already covers it); the 10 lost cells come from the wall bodies, not the joint. "Thickness is needed to close joints" is *not* what this layout shows. 3. **Door in a thick wall** — opening it reveals a keyhole whose shape depends on where the viewer stands, not the opening's width; on a 32 px grid that beam is 1–2 cells. A closed secret door is the identical rectangle, so indistinguishability from a solid wall is free. 4. **Low wall** — the *target's* height matters as much as the wall's: a 1.67 m eye sees a 1.0 m token over a 1.0 m wall but not a 0.3 m crate; a 0.93 m eye still sees 1.8 m heads. The hidden band reaches `d = s·h_eye/(h_eye − h_wall)` behind the wall. No single polygon is statically right: strict = visible token on a fogged tile, permissive = fog over floor nobody sees. 5. **Terrain** — `blocks_sight:false` costs exactly zero geometry (identical 64-vertex polygon, identical explored set), thickness and height included. 6. **One-way** — the only scenario where two players' explored maps differ permanently, and the only one where the 5.8 filter must run per observer; that filter is not free per query. ## Cost (avg ms per polygon, radius 400, cell 32, 2000 iters) | scene | arm | poly ms | verts | cells | vs thin | |---|---|---|---|---|---| | prototype (60 walls) | 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 (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 (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× | Hoisted quad is 0.26 ms on 5k sparse — inside the old 1 ms target; 12.7 ms on 5k dense, which the owner accepted. The 5.8 filter costs +0.15 ms per polygon at 5k walls (2.8× the sparse baseline ≈ 0.9 ms for a 6-token party). The 3-face silhouette is observer-dependent and can never be hoisted; the 4-face quad can. ## Downstream suggestions (passed on, not fixed here — #44/#45/#47/#49 own them) - **#45** — prefer the 4-face hoistable quad over the 3-face silhouette: exact, viewer-independent, cacheable per wall edit (0.26 vs 0.94 ms sparse; 12.7 vs 13.2 dense). - **#49** — precompute the filtered sight-segment list once per wall edit (rebuild on `wall.*`/`door.set`) instead of filtering per query; only the one-way decision stays per observer (cheap per-wall test on the pre-built list, or two pre-built lists). - **#47** — a one-way wall should still occlude its own body from the unblocked side; otherwise the fog over its footprint reads as a gap and leaks the direction. - **#47** — 5.8's "left names the side whose view across the wall is blocked" reads both ways (blocked *from* the left, or the left side hidden *from* the right). This prototype implements the first (a west viewer of a `left` wall sees nothing across); it needs one clarifying sentence wherever it is fixed. ## Artifact Branch `prototype/wall-sight` (pushed, never merged, no PR): https://git.fossellini.top/SirStone/FFF_vtt/src/branch/prototype/wall-sight/prototype-wall-sight/index.html `index.html` (findings), `cost.txt` (raw bench), `sightmodel.nim` (5.8 filter + thickness expansion + height predicate, wrapping `server/geometry.nim`), `pictures.nim` (six SVG scenarios), `bench_thick.nim`. `server/` untouched; nothing folded back.
Sign in to join this conversation.