perf: test only the in-sector 64-gon chord per vision ray (#64)

Each fan ray now tests the one circle-segment chord of its angular sector
instead of all 64. A sector-boundary ray tests both meeting chords, so the
rayHit set and the picked minimum are unchanged: the polygon is bit-identical
to the all-segments fan. tests/tgeometry.nim keeps the old fan as an oracle
and asserts exact float equality over the prototype corpus, the seed scene
(all switch shapes), the 5k sparse/dense scenegen layouts, the #26
collinear/radial cases and random walls. tools/mutation.sh gains a2 (a ray
tests the next sector's chord), which fails 5 of those tests.

Bench on this host, before -> after (3-run median):
  1 poly, prototype 0.028 -> 0.008 ms (3.5x)
  1 poly, 5k sparse 0.062 -> 0.033 ms (1.9x)
  1 poly, 5k dense  1.085 -> 0.708 ms (1.5x)

Refs #64.
This commit is contained in:
2026-11-20 23:28:04 +01:00
parent 1dff520f31
commit d192381d13
4 changed files with 172 additions and 26 deletions
+14 -19
View File
@@ -1,22 +1,17 @@
/home/davide/Projects/GDR/FFF_vtt-chore/server/worldmap.nim(18, 44) Warning: imported and not used: 'faults' [UnusedImport]
/home/davide/Projects/GDR/FFF_vtt-chore/server/vision.nim(31, 43) Warning: imported and not used: 'faults' [UnusedImport]
== prototype scene (60 walls, 8 tokens, radius 400, cell 32) ==
1 poly (jittered start positions): n=2000 avg=0.030ms worst=0.546ms
6 polys (one 6-token party): n=500 avg=0.180ms worst=2.611ms
1 poly + cellsTouched (scanline): n=2000 avg=0.039ms worst=0.553ms
6 polys + cellsTouched (scanline): n=300 avg=0.214ms worst=0.908ms
1 poly + cellsTouchedOld (prototype reference): n=500 avg=0.537ms worst=1.708ms
TARGET polygon+cells, prototype scene (prototype baseline 0.451): 0.039 ms vs <= 0.451 ms: PASS
1 poly (jittered start positions): n=2000 avg=0.008ms worst=0.042ms
6 polys (one 6-token party): n=500 avg=0.049ms worst=0.062ms
1 poly + cellsTouched (scanline): n=2000 avg=0.015ms worst=0.036ms
6 polys + cellsTouched (scanline): n=300 avg=0.088ms worst=0.118ms
1 poly + cellsTouchedOld (prototype reference): n=500 avg=0.517ms worst=1.031ms
TARGET polygon+cells, prototype scene (prototype baseline 0.451): 0.015 ms vs <= 0.451 ms: PASS
== 5k sparse: genScene(world=16384., n=5000, seed=1), avg walls in vision bbox 15.6 ==
1 poly, 5k sparse: n=2000 avg=0.064ms worst=0.524ms
1 poly + cellsTouched, 5k sparse: n=2000 avg=0.074ms worst=0.158ms
1 move check (pathClear, cap-length step), 5k sparse: n=20000 avg=0.008ms worst=0.578ms
TARGET polygon, 5k-wall scene: 0.064 ms vs <= 1.0 ms: PASS
1 poly, 5k sparse: n=2000 avg=0.031ms worst=0.059ms
1 poly + cellsTouched, 5k sparse: n=2000 avg=0.042ms worst=0.364ms
1 move check (pathClear, cap-length step), 5k sparse: n=20000 avg=0.008ms worst=0.162ms
TARGET polygon, 5k-wall scene: 0.031 ms vs <= 1.0 ms: PASS
== 5k dense: genScene(world=4096., n=5000, seed=1), avg walls in vision bbox 206.9 ==
1 poly, 5k dense: n=2000 avg=1.036ms worst=2.647ms
1 poly + cellsTouched, 5k dense: n=2000 avg=1.882ms worst=6.806ms
1 move check (pathClear, cap-length step), 5k dense: n=20000 avg=0.008ms worst=0.109ms
== egress (#28: 6 players x 40 encountered entries, 262144 explored cells) ==
GM egress pass (fresh diff base): n=200 avg=0.242ms worst=0.306ms
player egress pass (fresh diff base): n=200 avg=0.082ms worst=0.103ms
(sink 6038922)
1 poly, 5k dense: n=2000 avg=0.681ms worst=2.336ms
1 poly + cellsTouched, 5k dense: n=2000 avg=0.710ms worst=2.193ms
1 move check (pathClear, cap-length step), 5k dense: n=20000 avg=0.007ms worst=0.127ms
(sink 6023672)