322 lines
27 KiB
Markdown
322 lines
27 KiB
Markdown
# Sight with thick and low walls
|
||
|
||
Research for ticket [#39](https://git.fossellini.top/SirStone/FFF_vtt/issues/39), map [#38](https://git.fossellini.top/SirStone/FFF_vtt/issues/38).
|
||
Scope: how 2D top-down sight systems handle **wall thickness** and **wall height (see-over)**, and what each option costs
|
||
against our sight budget (polygon < 1 ms, 5k-wall scene, per-move recompute). Facts and trade-offs only:
|
||
the decisions belong to the owner on the later cards (#41 height model, #44 low walls, #45 thick walls).
|
||
|
||
Everything marked **[MEASURED, #39]** was measured for this ticket on scratch copies of our own code under
|
||
`/tmp/opencode/thickbench/` (method in §5); nothing in the repo was modified to measure. Pre-existing numbers marked
|
||
`results/bench.log` are the committed bench. **[DERIVED]** is elementary geometry worked out here. **[INFERRED]** is a
|
||
conclusion from cited facts that nobody measured.
|
||
|
||
## TL;DR
|
||
|
||
1. **Thickness in the ray fan is a 4–10× polygon cost, not a 4× one.** A rectangular wall (4 segments) turns 6 rays per
|
||
wall into 24 and 1 segment into 4: measured **0.257 ms** on the 5k sparse scene (15.6 walls in the vision box, still
|
||
inside the 1 ms target) and **12.8 ms** on the 5k dense one (206.9 walls in the box, 9.9× over). Cheaper variants
|
||
exist: 2 offset faces = 3.8 ms dense (3.0×), 1 near face = same cost as today's thin wall [MEASURED, #39].
|
||
2. **Thickness barely changes the explored set on a realistic map, and a lot on a pathological one:** cells that flip
|
||
from visible to hidden against a 10 px wall are 4.6 % of the polygon on the prototype scene, 10 % on 5k sparse,
|
||
53 % on 5k dense [MEASURED, #39]. Thick polygons are always a *subset* of thin ones (0 cells gained, measured).
|
||
3. **Height cannot be expressed by one 2D polygon.** The region behind a low wall that is hidden is a *band* whose depth
|
||
depends on the viewer's distance to the wall (`d_floor = s · h_eye / (h_eye − h_wall)`), so the shadow boundary is a
|
||
curve, and a ray fan can only shorten rays, never restart them [DERIVED]. Every engine surveyed therefore does height
|
||
as a per-token or per-ray *predicate*, not as occlusion geometry.
|
||
4. **The cheapest see-over that is expressible in our raycaster is a distance threshold per ray** (one float compare per
|
||
candidate hit): measured **within noise of today** (0.088 vs 0.084 ms sparse; 1.18 vs 1.28 ms dense) and it is exactly
|
||
Foundry's "Proximity / Reverse Proximity" restriction. Per-target 3D LOS on top of the polygon costs **0.55–0.60 ms per
|
||
40 targets** at 5k walls without a wall index (0.10 ms with the candidate walls precomputed) [MEASURED, #39].
|
||
5. **Nothing about the explored format, the wire polygon shape or the tile gate changes**: explored chunks stay 64×64 =
|
||
512 B, the wire stays a full integer-px polygon (Q16), the gate stays one cell = one tile. What changes is the vertex
|
||
count (2.5–3.7× [MEASURED, #39]) and the independent leak-checker oracle, which is currently zero-width.
|
||
|
||
## 1. Our baseline, exactly
|
||
|
||
- One wall record, one predicate: `Wall{a, b, door, open}` and `blocks = not (door and open)` (`server/geometry.nim:18-26`).
|
||
Anything that blocks is a **zero-width segment**; there is no width or height field anywhere in the model
|
||
(`DESIGN` §8 "Wall/Door": `blocks = not (door and open)`, later kinds are extra `kind`/`flags` values and "v1 geometry
|
||
treats any non-open blocker identically").
|
||
- The polygon (`server/geometry.nim:41-69`): rays at ±`RayEps` = 1e-4 rad around every wall endpoint (3 rays per
|
||
endpoint), plus an inscribed 64-gon of the vision radius; each ray takes the **nearest** hit among all segments + the
|
||
64-gon; bbox cull against the radius box (`:52-56`). Cost is `O(rays × segments)`, and both numbers grow with the wall
|
||
count in the box (`DESIGN` §5.3, §5.4).
|
||
- Cells: `cellsTouched` is a scanline over the polygon (`server/geometry.nim:100-141`); `vision.refresh` unions the
|
||
result into the player's explored set and hands the delta to egress (`server/vision.nim:58-74`). Explored is stored as
|
||
64×64-cell chunks of 512 B (`server/explored.nim:26-30`), and the tile gate unlocks a 32 px tile iff its cell is
|
||
explored (`DESIGN` §3.3, Q4).
|
||
- Wire: the full polygon, integer px, only on change (`DESIGN` Q16, `server/vision.nim:20-21`); client fog draws the
|
||
polygon into a mask and the explored bitmap separately (`DESIGN` §7.3).
|
||
- Movements: `dist(c, W) < r` for stuck/overlap and the capsule test in `pathClear` (`server/moverules.nim:137-149`,
|
||
`:157-159`); both are distance-to-*segment* computations.
|
||
- Baseline numbers (`results/bench.log`, prototype scene 60 walls / radius 400 / cell 32): 1 polygon 0.037 ms, polygon +
|
||
cells 0.048 ms, 6 polygons + cells 0.267 ms, server recompute per move 1.18 ms avg / 4.55 ms worst; 5k sparse polygon
|
||
0.083 ms, 5k dense polygon 1.282 ms (dense = stress reference, ~207 walls in the vision box).
|
||
- Interim rule in force from #26: a zero-width wall hides exactly what is behind it on the line (`GLOSSARY.md` `Wall`;
|
||
map #38 Notes).
|
||
|
||
## 2. Thick walls
|
||
|
||
### 2.1 What thickness does to a sight polygon
|
||
|
||
A wall with thickness `t` is a body, so three things change [DERIVED, confirmed by the spot checks in §5]:
|
||
|
||
- the **wall body itself is hidden** (previously a zero-area line, now a strip of width `t`);
|
||
- the **shadow boundary moves out by `t/2`** on the far side, and the shadow of the two ends widens by `t/2` each, so the
|
||
shadow is a slightly wider wedge; at a distance `s` behind the wall the lateral error of the thin model is about
|
||
`(t/2)(1 + s/d_wall)` — 10 px of a 10 px wall at 400 px range behind a wall 400 px away;
|
||
- **joints stop leaking**: two rectangles meeting at an angle overlap, where two zero-width segments leave a sliver at the
|
||
shared vertex (the same class of artefact our boundary `RayEps` ambiguity already covers, `DESIGN` §5.4);
|
||
- a **door opening becomes a slot of depth `t`**, and the door as an object has a leaf rectangle rather than a line.
|
||
|
||
Because a thick wall's polygon is the union of its body and a widened shadow, the thick polygon is a **subset** of the
|
||
thin one. Sampling 50–200 origins per scene, cells gained by thickness were **0** in every scene; cells lost
|
||
[MEASURED, #39]:
|
||
|
||
| scene | explored cells per polygon (thin) | thin-only | thick-only | share lost |
|
||
|---|---|---|---|---|
|
||
| prototype (60 walls, 4096 px, rooms ≈ 500 px) | 390 | 18 | 0 | 4.6 % |
|
||
| 5k sparse (16.4k px, 15.6 walls/box) | 216 | 21 | 0 | 9.7 % |
|
||
| 5k dense (4.1k px, 206.9 walls/box, rooms ≈ 82 px) | 59 | 31 | 0 | 53 % |
|
||
|
||
Read: thickness costs explored area in proportion to `t / room size`. In the dense stress layout the "rooms" are 2.5
|
||
cells wide, so a 10 px wall eats half of what a token can see; on the prototype-scale map it is one cell border here and
|
||
there — inside the one-cell residual leak of Q4/§3.3.
|
||
|
||
### 2.2 Four representations, and the measured price
|
||
|
||
A thick wall is a polygon obstacle; there is no way to keep one segment and be exact. The four implementations differ only
|
||
in how many extra segments and vertices they add to the same ray fan:
|
||
|
||
| variant | segments per wall | endpoints (rays) per wall | prototype 60 walls | 5k sparse (15.6/box) | 5k dense (206.9/box) |
|
||
|---|---|---|---|---|---|
|
||
| thin, today | 1 | 2 (6 rays) | 0.038 ms | 0.084 ms | 1.284 ms |
|
||
| 1 near face, offset `t/2` toward the viewer | 1 | 2 (6 rays) | 0.034 ms | 0.174 ms\* | 1.328 ms\* |
|
||
| 2 offset faces (no caps) | 2 | 4 (12 rays) | 0.052 ms | 0.136 ms | 3.760 ms |
|
||
| 4-edge quad (exact) | 4 | 8 (24 rays) | 0.079 ms | 0.257 ms | 12.779 ms |
|
||
|
||
[MEASURED, #39], same harness and machine class as `results/bench.log` (thin numbers reproduce: 0.038 vs 0.037 committed,
|
||
1.284 vs 1.282). \*The near-face row includes building 5000 offset segments *inside* the timed call: that expansion alone
|
||
costs ~0.09 ms per 5000 walls; hoisted (as for the other rows) it is the same work as thin. The quad/face rows exclude
|
||
their one-time expansion (`DESIGN`-style: once per wall edit, not per query).
|
||
|
||
Why not 4×: rays and segments both grow, so the raw work is ~16× per wall; measured 9.9× dense, 3.1× sparse, because the
|
||
fixed 64-gon and the sort dominate at low wall counts.
|
||
|
||
Side effects of each variant:
|
||
|
||
- **Near face only** hides everything behind the near face, i.e. the wall body plus its shadow, which is what a *solid*
|
||
wall should do; what it gets wrong is the far half: an object *inside* the far half of the wall band is treated as
|
||
visible-ish, and the shadow boundary sits at `t/2` in front of where the exact model puts it. Cost: zero.
|
||
- **2 faces** is the same approximation with a more honest boundary (the near face blocks, then the far face is
|
||
unreachable); it buys nothing over the near face in the polygon (`⊂`), for 1.6–3.0× the cost.
|
||
- **4-edge quad** is exact for a rectangular wall (modulo the `±RayEps` ambiguity at its 8 vertices).
|
||
|
||
### 2.3 Against the budget
|
||
|
||
The M2 target is "polygon < 1 ms on the 5k-wall scene" (`DESIGN` §5.3, `results/bench.log`), and the per-move server
|
||
recompute budget in play is ~1.2 ms avg / 4.55 ms worst (`DESIGN` §5.3).
|
||
|
||
- **5k sparse (realistic density for a 16k px map): quads pass** at 0.257 ms; 2 faces 0.136 ms; near face ≈ thin.
|
||
- **5k dense (stress): all exact variants miss.** Quads 12.8 ms (12.8× the target), 2 faces 3.8 ms, near face 1.33 ms.
|
||
- **A 6-token party in one recompute** (dense): 6 thick polygons = 75.6 ms vs 7.7 ms thin [MEASURED, #39]. That is the
|
||
number that matters if a real map ever reaches ~200 walls in an 800×800 vision box.
|
||
- Wire: thickness adds vertices to the polygon that is sent on every change — 2.5× (sparse) to 3.7× (dense) more
|
||
vertices than today (158→398, 1303→4866 average) [MEASURED, #39]. Q16 measured 3.4–3.7 KB per mover delivery for the
|
||
thin polygon; the thick one would be ~2.5–3.7× that [INFERRED].
|
||
- `cellsTouched` on a thick polygon: 0.281 vs 0.257 ms sparse, 12.82 vs 12.78 ms dense — i.e. ~+3 %, because the
|
||
scanline cost is dominated by rows spanned, not by vertices [MEASURED, #39].
|
||
- Move checks: `pathClear` over 4 edges per wall = 0.030 ms vs 0.010 ms dense (3.0×), 0.034 vs 0.010 sparse
|
||
[MEASURED, #39] — irrelevant next to the 0.7 ms move-ack cost (`DESIGN` #21 decision).
|
||
|
||
**The asymptotics are the real limit.** A spatial index (`DESIGN` §5.5 "Wall index", H3) does not help: the bbox cull
|
||
already restricts the work to walls in the vision box, and thickness multiplies the work *per wall in the box*. Only a
|
||
different algorithm changes that: a rotational sweep is `O(n log n)` (Asano 1985; CGAL `Visibility_2`, measured 50×
|
||
faster than the naive fan in Red Blob's reading), and Bungiu et al. 2014 give a linear-time-per-query method after
|
||
preprocessing. Both are a rewrite of `visibilityPolygon`, not a wall-model change.
|
||
|
||
### 2.4 Precedent for representing thickness
|
||
|
||
- **Polygon obstacles are the standard formulation.** Red Blob's visibility article covers segments and has a companion
|
||
page for polygon obstacles; a thick wall is simply a convex polygon in that model.
|
||
- **The interchange format agrees.** Universal VTT (Dungeondraft / Dungeon Alchemist / Arkenforge / DungeonFog export;
|
||
imported by Foundry via a module, and natively by Roll20 and Fantasy Grounds) separates two lists: `line_of_sight`
|
||
(arrays of points — thin walls) and `objects_line_of_sight` (arrays of points per object — thick obstacles), plus
|
||
`portals` (doors/windows with `bounds` and `closed`). Thickness lives in the polygon list, not in the wall list.
|
||
- **Roll20's barrier layer is polygon drawing**: rectangles and shapes on the Dynamic Lighting layer block light, and a
|
||
"thick wall" is drawn as a shape rather than a line.
|
||
|
||
## 3. Low walls: what "see over" can mean in a 2D top-down view
|
||
|
||
### 3.1 Two different questions
|
||
|
||
A low wall splits into two questions that our pipeline answers in two different places:
|
||
|
||
1. **What does the fog/explored set cover?** — driven by the visibility polygon (§1). Binary per point.
|
||
2. **Is a token hidden behind it?** — driven by `insideAny(poly)` today (`server/vision.nim:95-101`), i.e. also binary.
|
||
|
||
A height model that only changes (2) leaves the explored set conservative (the ground behind a low wall stays fogged
|
||
until something else reveals it); one that changes (1) rewrites the polygon and therefore the explored set and the tile
|
||
gate.
|
||
|
||
### 3.2 What the engines actually do
|
||
|
||
- **Foundry VTT** (KB "Walls", updated 2026-10-24, v14.369): each wall has four independent restrictions (movement,
|
||
light, sight/senses, sound) with levels **None / Normal / Limited / Proximity / Reverse Proximity**:
|
||
- *Limited* ("Terrain Wall" preset): "the first Wall with a Limited restriction in the way does not interfere at all,
|
||
but the second Limited wall is fully blocking" — you see the bush or the building, not through it.
|
||
- *Proximity*: "blocking, but only for tokens that are far enough away"; *Reverse Proximity*: "only for tokens that are
|
||
close enough", applied at a configured distance from the wall in grid units, with optional **attenuation** that lets
|
||
"a small but increasing radius of … vision … pass through the wall".
|
||
- Presets: Solid, Terrain, Invisible (blocks movement only), Ethereal (blocks sight/sound only), Door, Secret Door,
|
||
**Window** ("only block sight and sound beyond a certain distance. The closer a token moves, the more it can see").
|
||
- **No wall height in core**: the maintainer, answering the eight-year request for a height property, wrote "As part of
|
||
working on Scene Levels we have intentionally chosen *not* to make this change. Walls are treated as infinite height,
|
||
but only apply within the Level that they belong to" (foundryvtt/foundryvtt#1829, 2026-02-20).
|
||
- **The "Wall Height" module** (schultzcole/FVTT-Wall-Height, GPL, archived) is the reference implementation of height
|
||
*without* touching the fog polygon: each wall gets `wallHeightTop` / `wallHeightBottom` flags (default `+∞`/`−∞`), and
|
||
the module wraps the collision predicate `WallsLayer.testWall(ray, wall)` to return "no hit" unless the observer
|
||
token's `elevation` lies inside `[bottom, top)`. So see-over is a **binary per wall, per observer** decision inside the
|
||
raycast — the polygon is unchanged, and a low wall is fully transparent or fully blocking for a given token.
|
||
- **Fantasy Grounds Unity**: the LOS layer has occluder *types* Wall, Terrain, Door, Secret; terrain behaves as a region:
|
||
"If players are outside of a terrain section, they will be able to see the entire contents of the first terrain that
|
||
their vision reveals. They will not be able to see past it. If players are inside of a terrain section, they will be
|
||
able to see out of it in every direction" (Map Line of Sight Style Guide, 2022). Same idiom as Foundry's *Limited*.
|
||
- **Roll20**: barriers on the Dynamic Lighting layer block vision and light; **Transparent** barriers block movement but
|
||
not vision ("players can see over the bushes but can not walk through the thicker areas"); **One Way** barriers pass
|
||
vision "from one side of the barrier but not the other", and the documented use is elevation ("anyone on the balcony
|
||
above the stairwell can see everything happening below them but anyone below is unable to see onto the balcony")
|
||
(Help Center, updated 2026-07-16).
|
||
|
||
Pattern: **no surveyed engine puts height into the sight polygon.** They all model "see over" as a predicate — a
|
||
per-restriction distance threshold, a region flag, or a per-token elevation gate — and keep the occluder geometry 2D.
|
||
|
||
### 3.3 Why height cannot go into one polygon [DERIVED]
|
||
|
||
Eye at height `h_e`, wall top at `h_w < h_e`, wall at horizontal distance `s`, target on the floor at distance `d > s`.
|
||
The sight line's height where it crosses the wall is `h_e · (1 − s/d)`. The target is hidden iff
|
||
|
||
```
|
||
h_e · (1 − s/d) < h_w ⇔ d < s · h_e / (h_e − h_w) =: d_floor
|
||
```
|
||
|
||
So a low wall hides a **band** immediately behind it, of depth `d_floor − s = s · h_w / (h_e − h_w)`, and the floor
|
||
beyond `d_floor` is visible again. Two consequences:
|
||
|
||
- The boundary between hidden and visible behind a low wall is a **curve** whose position depends on the *viewer's*
|
||
distance to that wall, not only on the wall's geometry.
|
||
- A visibility polygon is "the nearest hit along each ray". A ray can be shortened, never resumed: geometry added behind
|
||
a wall only hides more. Therefore a single 2D polygon cannot represent "hidden for 100 px, then visible again" — the
|
||
representation has to become a predicate (per point, per cell, or per ray) or a binary collapse.
|
||
|
||
Worked numbers for a human eye at 1.6 m (5 ft ≈ 1.6 m; the unit choice is #41's, not this ticket's): a 0.9 m wall at 5 m
|
||
hides floor out to `5 · 1.6 / (1.6 − 0.9) = 11.4 m` (band 6.4 m); the same wall at 20 m hides out to 45.7 m. Near the wall
|
||
you see almost nothing over it; far from it you see well over it. (Foundry's *Reverse Proximity* documents this same
|
||
asymmetry: "When a token is immediately next to the Wall, the restriction is fully blocking. As the token moves away, the
|
||
restriction is gradually eased".)
|
||
|
||
### 3.4 Four implementable families, with measured cost
|
||
|
||
| family | semantics | fog/explored | cost against today (sparse / dense) |
|
||
|---|---|---|---|
|
||
| **A. flag**: low walls do not block sight | see-over always, at any distance | polygon loses the low wall entirely; explored grows | 0 (predicate already exists) |
|
||
| **B. per-ray distance threshold** ("horizon circle") | a low wall blocks only hits farther than `R_h = R·(1 − h_w/h_e)` from the eye; one radius per wall height | polygon correct in the *far* field, no near-field band; explored grows near the wall | **0.088 / 1.18 ms** vs 0.084 / 1.28 — free [MEASURED, #39] |
|
||
| **C. per-target 3D LOS** on top of the 2D polygon | exact `d < d_floor` test per token (the Wall Height model, with a real comparison instead of an elevation band) | polygon unchanged (conservative) | **0.55–0.60 ms per 40 targets** at 5k walls unindexed; **0.10 ms** with candidate walls precomputed; today's `insideAny` for 40 targets is 0.004 / 0.025 ms [MEASURED, #39] |
|
||
| **D. two polygons**: strict (low walls block) + permissive (they do not) | fog = strict, token visibility = permissive, GM sees where they differ | no new geometry, 2× polygon cost (or 1× if the permissive one is only recomputed on wall edits) | +1 polygon per token = +0.084 / +1.28 ms [MEASURED, #39] |
|
||
|
||
Notes on B: the threshold is exactly Foundry's Proximity/Reverse-Proximity machinery expressed in our geometry, and it is
|
||
the only variant that keeps the *polygon* (and therefore the fog and the tile gate) responsive to height at near-zero
|
||
cost. It is also the least faithful: it cannot show the near-field band, and all low walls of one height produce shadows
|
||
starting at one circle. Attenuation (Foundry's partial pass-through) has no analogue in a nearest-hit ray fan without
|
||
turning each low wall into a graded occluder — out of scope of anything measured here.
|
||
|
||
Notes on C: without a spatial index the 40-target pass costs 0.45 ms just scanning 5000 wall bboxes; that is the number to
|
||
compare with the 1.2 ms per-move budget, not the 0.10 ms candidate number. `pathClear` (0.010 ms) is the closest existing
|
||
piece of code and is the natural place for such a predicate.
|
||
|
||
## 4. What this means for our pipeline (concrete, per file)
|
||
|
||
| place | what thickness/height touches | fact |
|
||
|---|---|---|
|
||
| `server/geometry.nim:18-20` `Wall` | + `thickness`, + `height`/kind bits | the record is copied into `geometryWalls` (`server/worldmap.nim:20-24`) and into every test fixture |
|
||
| `visibilityPolygon` | 1→4 segments per thick wall; low-wall predicate per hit | §2.2 table; not an interface change if thickness is expanded before the call |
|
||
| `cellsTouched`, `server/vision.nim` | unchanged code | cells follow the polygon; thick polygons are subsets (§2.1) |
|
||
| `server/explored.nim` | **no change** | chunks stay 64×64 cells = 512 B, bit layout pinned (#21) |
|
||
| wire `vision` (Q16) | full polygon, integer px | only the vertex count changes: 2.5–3.7× [MEASURED, #39] |
|
||
| tile gate (`DESIGN` §3.3) | no mechanism change | a tile is unlocked iff its cell is explored; thickness/height changes *which* cells, and the 32 px residual (Q4) already covers sub-cell wall widths |
|
||
| `server/moverules.nim:137-149,157-159` | `dist(c, W)` must become distance-to-rectangle; `pathClear` 3.0× | 0.010 → 0.030 ms dense [MEASURED, #39]; door push is perpendicular-to-segment and needs the leaf geometry |
|
||
| `tools/leakcheck.nim:192-197` `clearLine` | zero-width by construction | an independent oracle for thickness needs the same 4 edges (or a rectangle distance test) and a tolerance statement; the GEOMETRY check (`:644-660`) samples 64 angles × 3 radii and would need re-baselining |
|
||
| `tools/bench.nim` | 5k scenes already exist | a thick/low variant is a new arm in the same harness; numbers in §2.2/§3.4 are what to expect |
|
||
| `DESIGN` §5.3 table | needs a re-baseline | this doc supplies the delta (thin 1.28 → quad 12.8 ms dense; 0.084 → 0.257 sparse) |
|
||
|
||
Thresholds worth stating before #44/#45 decide anything: the decision between "thickness in the polygon" and "thickness
|
||
only in movement + the wall body" turns on whether real maps look like the sparse layout (16 walls per 800 px box → quads
|
||
cost 0.26 ms, affordable) or approach the dense one (207 → 12.8 ms, not).
|
||
|
||
## 5. Measurement method
|
||
|
||
- Scratch tree `/tmp/opencode/thickbench/`: `geometry.nim` copied verbatim from `server/geometry.nim`; `testutil.nim`,
|
||
`scenegen.nim`, `moverules.nim`, `tests/fixtures/scene.json` copied verbatim (imports flattened); `thickgeom.nim` is
|
||
`visibilityPolygon` re-expressed over an explicit segment list (with an optional per-segment top height) and the three
|
||
wall expansions (`expandQuads`, `expandFaces`, `expandNearFace`); `bench2.nim` mirrors `tools/bench.nim` (50 warm-up
|
||
iterations, O(1) accumulators, avg + worst, `-d:release`).
|
||
- The re-expressed fan reproduces the shipped one exactly: on 200 origins of the prototype scene (jittered starts,
|
||
`geometry.visibilityPolygon` vs `polyFromSegs` over the same segments) both polygons have the same length and every
|
||
vertex agrees to < 1e-6 px — 200/200 identical, 0 different. It times slightly faster (0.033 vs 0.038 ms), a codegen
|
||
difference between the two module layouts, not an algorithmic one.
|
||
- Correctness spot checks in the harness (a vertical wall at x=100, eye at (0,100), radius 400): the thin polygon hides
|
||
(102,100) and (350,100); the 10 px quad hides its own body (98,100) and still hides (350,100) — i.e. thickness only
|
||
shifts the boundary; with a wall top at half the eye height, (350,100) is visible over a wall at x=50 and hidden behind
|
||
one at x=300, and the per-target predicate agrees (`false` / `true`).
|
||
- Caveats: single machine, power-save class, same class as `results/bench.log` (thin numbers match); the 5k dense layout
|
||
is a stress reference, not a real map (`DESIGN` §5.3); client fog rendering, network bytes and a wall spatial index are
|
||
**not** measured here.
|
||
|
||
## 6. Sources
|
||
|
||
- Our code and design: `server/geometry.nim`, `server/vision.nim`, `server/explored.nim`, `server/moverules.nim`,
|
||
`server/worldmap.nim`, `tools/bench.nim`, `tools/leakcheck.nim`, `tests/fixtures/scene.json`, `results/bench.log`;
|
||
`docs/DESIGN.md` §3.3, §5.1, §5.3, §5.4, §5.5, §6.1, §7.3, §8, §10.2, §10.3, Q4, Q16, H3; `GLOSSARY.md` `Wall`.
|
||
- Foundry VTT, *Walls* (Knowledge Base, updated 2026-10-24, v14.369) — restriction types, restriction levels
|
||
(None/Normal/Limited/Proximity/Reverse Proximity), attenuation, presets (Terrain, Invisible, Ethereal, Door, Secret
|
||
Door, Window) — <https://foundryvtt.com/article/walls/>
|
||
- Foundry VTT issue #1829, "Support a height property for Wall objects…" (opened 2019, closed not planned 2026-02-20,
|
||
including the maintainer's statement that walls are infinite height and bounded by their Scene Level) —
|
||
<https://github.com/foundryvtt/foundryvtt/issues/1829>
|
||
- `schultzcole/FVTT-Wall-Height` (GPL-3.0, archived): `scripts/utils.js`, `scripts/patches.js` (wraps
|
||
`WallsLayer.testWall` with a `wallHeightTop`/`wallHeightBottom` vs token `elevation` test) —
|
||
<https://github.com/schultzcole/FVTT-Wall-Height>
|
||
- Fantasy Grounds Unity, *Map Line of Sight Style Guide* (2022): Wall/Terrain/Door/Secret occluders; terrain "see the
|
||
first terrain, not past it" —
|
||
<https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996640584/Map+Line+of+Sight+Style+Guide>
|
||
- Roll20 Help Center, *Creating Light, Windows, and Barriers* (updated 2026-07-16): barrier layer, Transparent and
|
||
One-Way barriers with the balcony (elevation) example, doors/windows — <https://help.roll20.net/hc/en-us/articles/360051768974-Creating-Light-Windows-and-Barriers>
|
||
- Red Blob Games, *2D Visibility* (2012, rev. 2020): the ray-to-each-endpoint algorithm, the rotational sweep, and the
|
||
performance note that CGAL's linear-time algorithm is ~50× faster than the sweep; plus the subtractive/shadow-quad
|
||
alternative — <https://www.redblobgames.com/articles/visibility/>
|
||
- Red Blob Games, *Thin wall field of view* (2021, unpublished notes): FOV when walls are line segments on cell edges
|
||
rather than cells, and the symmetry problems that follow — <https://www.redblobgames.com/x/2128-thin-wall-fov/>
|
||
- Universal VTT format (`line_of_sight` polylines, `objects_line_of_sight` polygons, `portals`) as documented by Arkenforge
|
||
— <https://arkenforge.com/universal-vtt-files/>; Roll20's import support —
|
||
<https://help.roll20.net/hc/en-us/articles/41643201127831-Universal-Virtual-Tabletop-UVTT-Support>
|
||
- F. Bungiu, M. Hemmer, J. Hershberger, K. Huang, A. Kröller, *Efficient Computation of Visibility Polygons*,
|
||
arXiv:1403.3905 (2014) — <https://arxiv.org/abs/1403.3905>
|
||
- T. Asano, *An efficient algorithm for finding the visibility polygon for a polygonal region with holes*, IEICE
|
||
Transactions 68(9), 1985 (cited via Red Blob's reference list; the paper itself is not online).
|
||
|
||
## 7. What this research does not decide (inputs for #41, #44, #45)
|
||
|
||
- **Height model**: what `h_e`, `h_w` and the target height are, in what units, and whether height is a per-wall number,
|
||
a per-kind default (low wall / window), or a per-token elevation (#41). §3.3 needs all three to produce a number.
|
||
- **Which of families A–D feeds the fog** (#44). They differ in cost (A zero, B zero, C +0.1…0.6 ms, D +1 polygon) *and*
|
||
in what players remember: only A/B/D change the explored set, so only they change what a tile unlocks.
|
||
- **Thickness in the polygon or only in movement** (#45). Quads pass the 1 ms target at 15.6 walls/box and miss it by 12×
|
||
at 207; the near face costs nothing but puts the shadow boundary at `t/2` and needs a "solid vs see-through band"
|
||
answer anyway (it is where a low wall's thickness and height meet).
|
||
- **Door geometry**: a thick door is a leaf in a deep opening; #46's locked/secret semantics and the existing push rule
|
||
(`DESIGN` §5.5) both assume a zero-width segment today.
|
||
- **One-way walls** (#47): Roll20's documented one-way use is elevation (balcony), so one-way and low walls may be the
|
||
same mechanism seen from different sides — worth deciding together.
|
||
- **Oracle and gate work**: the leak checker's zero-width `clearLine` and 64×3 sample grid, the tile-gate oracle, and the
|
||
bench baseline all need a decided model before they can be extended (no ticket on the map covers this yet).
|