Public: anyone can read this; the crew can change it.
forked from trevato/cs · proposes · 4 behind
Physics takes its tuning as arguments, in place: no constant read from module scope, and the digest does not move #131
Check · Review · Land · Live done — Landed and live in production.
`src/client/physics.ts` keeps its name and its place and no longer reads Counter-Strike's numbers out of its own module scope: every function now takes what it is tuned by as a required argument, in one order — subject, situation, tuning, hull — `move(body, wish, dt, boxes, tuning, hull)`, `eyeHeight(body, hull)`, `hullHeight(body, hull)`, `stuck(pos, height, boxes, hull)`, `groundUnder(pos, heigh…
shipped production is serving it deploy ae07c2d
Sign in to join this conversation.
new above
offline
src/client/physics.tskeeps its name and its place and no longer reads Counter-Strike's numbers out of its own module scope: every function now takes what it is tuned by as a required argument, in one order — subject, situation, tuning, hull —move(body, wish, dt, boxes, tuning, hull),eyeHeight(body, hull),hullHeight(body, hull),stuck(pos, height, boxes, hull),groundUnder(pos, height, boxes, reach, hull),airAccelerate(vel, dir, speed, dt, tuning), andaccelerateunchanged. No parameter has a default, so nothing can substitute a tuning quietly.MoveTuningandHullare named types;MOVEandHULLkeep their values to the digit and stay exported from this file — moving them is the next issue. The duck rate of 5/s becameMOVE.duckRatebecause Counter-Strike chose it, and the two-unit floor contact stayed a solver constant,CONTACT, documented as the slack a discrete step needs rather than dressed up as tuning — the same two decisions pull #7 made.The call sites that actually call the solver —
world.ts,scene.ts,physics.test.ts— passMOVEandHULLexplicitly and change in no other way.combat.ts,observe.tsandhud.tsturned out to import only the constants and call no function, so they needed nothing; I left them alone rather than refactoringcombat.ts's inline hull height into a call. Nothing moved file, nothing enteredsrc/engine/, the door did not change, and the rebuilt bundle is committed because its hash did change (static/app.436c7e87eb.js, 72,128 B raw / 33,544 B gzip, under the 75,400 / 34,900 ceilings).Worth looking at:
physics.test.tskeeps all eleven original assertions and adds seven that run the same functions under a second profile — half gravity, a 600 u/s jump, a 96×96×144 hull, a 36-unit step, 500 u/s, a 2.5/s crouch, a 60 u/s air cap — with the apex and hang time hand-checked againstv²/2gand2v/g(57.0 units and 48 ticks under CS, 450 units and 192 ticks under the second profile), plus the friction equilibriumaccel × wishSpeed / friction ≈ 134.6 u/s. I swept all fourteen tuned values by re-baking each one into module scope: every one of them fails a test, so a later extraction cannot quietly re-capture a constant. The golden digests insrc/client/replay.test.tsare untouched and still pass, bit for bit — the game did not move.bun testis 603 pass / 0 fail, and the preview should feel identical: run, walk, crouch, strafe-jump, step onto a crate.🤖 Generated with Claude Code
Closes #122