code wiki / _hdl_build / nx_collide2d.nx
nx_collide2d.nx
buildroot/runtime/_hdl_build/nx_collide2d.nx
about
nx_collide2d.nx -- certified composable part: CONTINUOUS (swept) 2D collision with slide response
and impulse integration. The gamebench board's own bar for a physics-collision HAVE names exactly
three absences (nx_gamebench.nx bit-5 comment): swept/continuous collision, slide-along-surface
response, velocity/impulse integration -- this part is those three, gated and mutation-proven.
LIB, no main (ecosystem convention, cf. nx_gamesave/nx_swgpu). Integer-only: positions/velocities in
plain i64 world units, time-of-impact as a Q8 fraction of one step. Deterministic by construction.
Restitution is a Q8 PARAMETER (rule 11: coefficients are data, never buried constants); rest=0 gives
pure slide (normal component killed, tangent PRESERVED), rest=C2_Q gives a perfect bounce.
license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_collide2d_gate.nx
structs
| none |
consts
| 11 | const C2_Q: i64 = 256 // Q8 fixed-point denominator for step fractions + restitution |
| 12 | const C2_MAXIT: i64 = 4 // contact resolutions per step (corner = 2 walls in one step) |
| 13 | const C2_CKMOD: i64 = 1000000007 // rolling-checksum modulus (bounded, overflow-free) |
functions
| 19 | func c2_sweep(px: i64, py: i64, vx: i64, vy: i64, r: i64, walls: *i64, nw: i64, nrm: *i64) -> i64 called by 1: c2_step |
| 80 | func c2_step(st: *i64, walls: *i64, nw: i64, gy: i64, rest: i64, nrm: *i64) -> i64 |
| 122 | func c2_ck(ck0: i64, v: i64) -> i64 called by 1: main |