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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`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

opened this

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, height, boxes, reach, hull), airAccelerate(vel, dir, speed, dt, tuning), and accelerate unchanged. No parameter has a default, so nothing can substitute a tuning quietly. MoveTuning and Hull are named types; MOVE and HULL keep their values to the digit and stay exported from this file — moving them is the next issue. The duck rate of 5/s became MOVE.duckRate because 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 — pass MOVE and HULL explicitly and change in no other way. combat.ts, observe.ts and hud.ts turned out to import only the constants and call no function, so they needed nothing; I left them alone rather than refactoring combat.ts's inline hull height into a call. Nothing moved file, nothing entered src/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.ts keeps 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 against v²/2g and 2v/g (57.0 units and 48 ticks under CS, 450 units and 192 ticks under the second profile), plus the friction equilibrium accel × 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 in src/client/replay.test.ts are untouched and still pass, bit for bit — the game did not move. bun test is 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

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs