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:
+3
-2
@@ -2,7 +2,7 @@
|
||||
# usage: devbox run mutation (or tools/mutation.sh inside devbox shell)
|
||||
# Mutation check on a TEMP COPY of server/ + tests/ + tools/ (the tree is never touched). One mutation per run, ALL
|
||||
# tests/t*.nim are run. Control must pass; every mutation must fail >=1 expected test; a sed that changes nothing is an error.
|
||||
# a: no +-RayEps rays | b: upper segment end exclusive | c: lower segment end exclusive (rayHit only)
|
||||
# a: no +-RayEps rays | a2: a ray tests the next sector's chord (#64) | b: upper segment end exclusive | c: lower segment end exclusive (rayHit only)
|
||||
# d1/d2: drop arm 1/2 of the shared-vertex fixture
|
||||
# e: cellsTouched without the fill spans | f: escape rule without the crossing check | g: GM moves checked against walls
|
||||
# h: capsule reduced to centre path + destination circle (prototype H10) | i: no step cap | j: blocked trigger needs centre-on-wall
|
||||
@@ -115,6 +115,7 @@ run() {
|
||||
}
|
||||
run control "unmutated copy (must pass)" server/geometry.nim "" ""
|
||||
run a "remove the +-RayEps rays" server/geometry.nim '/angles.add ang [-+] RayEps/d' "$NEW"
|
||||
run a2 "a ray tests the next sector's chord" server/geometry.nim 's/^ best = min(best, rayHit(o, d, segs\[sector\]\[0\], segs\[sector\]\[1\]))$/ best = min(best, rayHit(o, d, segs[(sector + 1) mod circleSegs][0], segs[(sector + 1) mod circleSegs][1]))/' "bit-identical"
|
||||
run b "upper segment end exclusive" server/geometry.nim 's/u <= 1 + Eps/u < 1 - Eps/' "$NEW"
|
||||
run c "lower segment end exclusive" server/geometry.nim 's/u >= -Eps/u > Eps/' "$NEW"
|
||||
run d1 "shared-vertex fixture without arm 1" tests/tgeometry.nim 's/@\[arm1, arm2\] *# SHARED-VERTEX/@[arm2]/' "$D"
|
||||
@@ -219,7 +220,7 @@ run f3 "the opaque depth cap is not enforced" server/props.nim 's/if depth > Max
|
||||
wait
|
||||
|
||||
rc=0; : > "$LOG"
|
||||
for id in control a b c d1 d2 d3 e e1 e2 e3 e4 e5 f1 f2 f3 f g h i j k l m n o p q r s t u v w x y z z2 \
|
||||
for id in control a a2 b c d1 d2 d3 e e1 e2 e3 e4 e5 f1 f2 f3 f g h i j k l m n o p q r s t u v w x y z z2 \
|
||||
s1 s2 s3 s4 s5 s6 s7 aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au \
|
||||
av aw ax ay az b1 b2 b3 b4 c1 c2 c3 c4; do
|
||||
[ -f "$T/$id/res" ] && cat "$T/$id/res" >> "$LOG"
|
||||
|
||||
Reference in New Issue
Block a user