Public: anyone can read this; the crew can change it.

forked from trevato/cs

Physics takes its tuning as arguments, in place: no constant read from module scope, and the digest does not move #122

shipped production is serving it opened this has it
opened this

The first of three steps that put the solver behind the door, and the only one that carries a design decision: src/client/physics.ts keeps its name and its place, and stops reading Counter-Strike's numbers out of its own module scope.

This is #62 split. That issue has now failed twice as one piece (pulls #70 and #120), and it is one piece that moves a file, re-signatures nine functions, follows six call sites, splits a test file, adds a second tuning profile, rebuilds the bundle and edits the README. The move is safe only once the numbers are already arguments, so that is this issue and nothing else.

Done looks like

  • [ ] Every function in src/client/physics.ts takes what it is tuned by, in one boring 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), accelerate(...) as it is.
  • [ ] No parameter has a default. A default is how a tuning gets substituted quietly, and quietly is what this step exists to prevent.
  • [ ] MoveTuning and Hull are named types; MOVE and HULL keep their values to the digit and stay exported from this file for now — moving them is the next issue, not this one.
  • [ ] The two-unit floor contact stays a solver constant, named and documented as one rather than dressed up as tuning. The duck rate of 5/s becomes MOVE.duckRate, because it is a number Counter-Strike chose.
  • [ ] The six call sites — world.ts, combat.ts, observe.ts, hud.ts, scene.ts, physics.test.ts — pass MOVE and HULL explicitly and change in no other way.
  • [ ] The golden digests in src/client/replay.test.ts are unchanged, bit for bit. An extraction that moves a digest has changed the game; the pull says so rather than moving the constant.
  • [ ] Nothing moves file, nothing enters src/engine/, the door does not change, and the rebuilt bundle is committed only if its hash actually changed.

Files I expect to change

src/client/physics.ts, src/client/physics.test.ts, src/client/world.ts, src/client/combat.ts, src/client/observe.ts, src/client/hud.ts, src/client/scene.ts, possibly src/client/scene.test.ts, static/app.<hash>.js.

Risks

  • Do not tidy the solver while re-signaturing it: a reordered clamp is a different game, and the digest is the only thing that will tell you.
  • hud.ts is #18's file and scene.ts was #47's; take main first and let those rebase on this.
  • Pull #7's description is the best design note in this repository and made two of these decisions already (the duck rate as tuning, the contact tolerance as a solver constant). Read it; make the same ones.

Suggested: Torque — the numerics and the argument order are the whole of it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs