Ashlar checks / tooling (push) Successful in 5s
- Shoulder view, auto shoulder switch, standing preview, deferred preview rotation, move 360, smooth view change and [Game] smooth movement are on by default. - Collision ease-out: the camera still snaps in on collision but eases back out (0.15 s half-life, 60 u/s minimum speed). - Aim mode: with a ranged weapon or a spell readied in third person the view stays over the shoulder, moves closer and narrows the FOV. Camera interface v2 adds getAimWeight and enable/disable functions. - Pure math in camera/ease.lua with unit tests; SCENARIO=camera with PASS/FAIL checks; docs in docs/ashlar/CAMERA.md. - ashlar-run.sh deletes stored Lua settings before each run so changed defaults are tested. Closes #29 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
3.8 KiB
Python
93 lines
3.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Summarizes the ASHLAR_CAMERA lines from a SCENARIO=camera run (see docs/ashlar/SCENARIOS.md)."""
|
|
import re
|
|
import sys
|
|
|
|
LINE = re.compile(
|
|
r"ASHLAR_CAMERA (frame|sample) (\w+) t=([\d.]+) mode=(\w+) dist=([-\d.]+) target=([-\d.]+) "
|
|
r"offsetX=([-\d.]+) offsetY=([-\d.]+) aim=([\d.]+) fov=([\d.]+) base=([\d.]+)"
|
|
)
|
|
|
|
|
|
def main(path):
|
|
phases = {}
|
|
with open(path, errors="replace") as f:
|
|
for line in f:
|
|
m = LINE.search(line)
|
|
if not m:
|
|
continue
|
|
kind, phase, t, mode, dist, target, ox, oy, aim, fov, base = m.groups()
|
|
phases.setdefault(phase, []).append(
|
|
dict(t=float(t), mode=mode, dist=float(dist), target=float(target), ox=float(ox), oy=float(oy),
|
|
aim=float(aim), fov=float(fov), base=float(base)))
|
|
|
|
results = []
|
|
|
|
def check(name, ok, detail):
|
|
results.append(ok)
|
|
print(f"{'PASS' if ok else 'FAIL'} {name}: {detail}")
|
|
|
|
shoulder = phases.get("shoulder", [])
|
|
if shoulder:
|
|
s = shoulder[-1]
|
|
check("shoulder view", s["mode"] in ("ThirdPerson", "Preview") and abs(s["ox"]) >= 20,
|
|
f"mode={s['mode']} offsetX={s['ox']:.1f} dist={s['dist']:.1f}")
|
|
else:
|
|
check("shoulder view", False, "no samples")
|
|
|
|
wall = phases.get("wall", [])
|
|
before = shoulder[-1]["dist"] if shoulder else 0
|
|
if wall:
|
|
low = min(w["dist"] for w in wall)
|
|
check("wall pulls the camera in", low < before - 40, f"{before:.1f} -> {low:.1f}")
|
|
else:
|
|
low = None
|
|
check("wall pulls the camera in", False, "no samples")
|
|
|
|
clear = phases.get("clear", [])
|
|
if clear and low is not None:
|
|
target = clear[-1]["target"]
|
|
dists = [c["dist"] for c in clear]
|
|
steps = [b - a for a, b in zip(dists, dists[1:])]
|
|
biggest = max(steps) if steps else 0
|
|
recovered = next((i for i, d in enumerate(dists) if abs(d - target) <= 2), None)
|
|
rising = [i for i, s in enumerate(steps) if s > 0.05]
|
|
# An ease-out: the camera returns over several frames, and the late steps are smaller than the early ones.
|
|
eased = recovered is not None and len(rising) >= 5 and biggest < 0.5 * (target - dists[0] if dists else 1)
|
|
if eased and len(rising) >= 6:
|
|
eased = steps[rising[-2]] <= steps[rising[0]] + 0.5
|
|
secs = clear[recovered]["t"] - clear[0]["t"] if recovered is not None else float("nan")
|
|
check("collision ease-out", eased,
|
|
f"{dists[0]:.1f} -> {target:.1f} in {recovered} frames ({secs:.2f} s), largest step {biggest:.1f}, "
|
|
f"first step {steps[rising[0]] if rising else 0:.1f}, last step {steps[rising[-1]] if rising else 0:.1f}")
|
|
else:
|
|
check("collision ease-out", False, "no samples")
|
|
|
|
aim = phases.get("aim", [])
|
|
if aim:
|
|
top = max(a["aim"] for a in aim)
|
|
last = aim[-1]
|
|
ratio = last["fov"] / last["base"] if last["base"] else 0
|
|
check("aim mode", top >= 0.99 and ratio < 0.95 and abs(last["ox"]) >= 20,
|
|
f"weight {top:.2f}, fov {ratio:.3f} of base, offsetX {last['ox']:.1f}, target dist {last['target']:.1f}")
|
|
else:
|
|
check("aim mode", False, "no samples")
|
|
|
|
unaim = phases.get("unaim", [])
|
|
if unaim:
|
|
last = unaim[-1]
|
|
check("aim released", last["aim"] == 0 and abs(last["fov"] - last["base"]) < 1e-4,
|
|
f"weight {last['aim']:.2f}, fov {last['fov']:.4f}, base {last['base']:.4f}")
|
|
else:
|
|
check("aim released", False, "no samples")
|
|
|
|
done = phases.get("done", [])
|
|
if done:
|
|
print(f"Final state: mode={done[-1]['mode']} offsetX={done[-1]['ox']:.1f} dist={done[-1]['dist']:.1f}")
|
|
print(f"Camera checks: {sum(results)}/{len(results)} passed")
|
|
return 0 if all(results) else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv[1]))
|