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.
18 lines
1.1 KiB
Plaintext
18 lines
1.1 KiB
Plaintext
== prototype scene (60 walls, 8 tokens, radius 400, cell 32) ==
|
|
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.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=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)
|