code wiki / _hdl_build / nx_collide2d.nx

nx_collide2d.nx

buildroot/runtime/_hdl_build/nx_collide2d.nx

5723 B128 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_collide2d.nx nx_collide2d_gate.nx

imports: nx_syscalls.nx

imported by: nx_collide2d_gate.nx

structs

none

consts

11const C2_Q: i64 = 256 // Q8 fixed-point denominator for step fractions + restitution
12const C2_MAXIT: i64 = 4 // contact resolutions per step (corner = 2 walls in one step)
13const C2_CKMOD: i64 = 1000000007 // rolling-checksum modulus (bounded, overflow-free)

functions

19func c2_sweep(px: i64, py: i64, vx: i64, vy: i64, r: i64, walls: *i64, nw: i64, nrm: *i64) -> i64
called by 1: c2_step
80func c2_step(st: *i64, walls: *i64, nw: i64, gy: i64, rest: i64, nrm: *i64) -> i64
called by 1: main calls 1: c2_sweep
122func c2_ck(ck0: i64, v: i64) -> i64
called by 1: main