code wiki / (root) / nx_phys3d.nx

nx_phys3d.nx

buildroot/runtime/nx_phys3d.nx

12766 B294 linesdepth 2pulls 2 transitivereach 4 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_phys3d.nx -- the UNIFIED sovereign 3D rigid-body physics core (the 07-01 census's named gap; operator 2026-07-03: "real 3d s class exceed physics"). ONE engine for games + sim + CAD-motion: semi-implicit Euler, sphere/AABB contacts, sequential impulse solver (restitution + Coulomb friction + positional correction), sleeping. ALL INTEGER (deterministic law: fixed-point pos=1/256 m, vel=1/65536 m-per-tick; 60Hz implied) -- byte-identical replays by construction, no float, no libm. Base-relative so the same code runs native AND in-wasm (mineworld pattern). Broadphase is O(n^2) pairs at this rung (BVH = ladder R4); shapes = sphere + axis-aligned box (GJK convex = R5; rotation/orientation = R6 with joints -- stated, not hidden). license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_phys3d.nx nx_phys3d_gate.nx nx_wasm_physlab.nx

imports: nx_syscalls.nx

imported by: nx_phys3d_gate.nxnx_wasm_physlab.nx

structs

none

consts

15const PH_MAXB: i64 = 64
16const PH_G: i64 = 178 // ~9.8 m/s^2 at 60Hz in vel-units (0.00272 m/tick * 65536)
17const PH_SLOP: i64 = 4 // penetration allowance (fx256)
18const PH_POSPCT: i64 = 128 // positional correction percent (fx256 of penetration beyond slop)
19const PH_RESTV: i64 = 400 // |vn| below this -> restitution treated as 0 (rest, standard trick)
20const PH_SLEEPV: i64 = 80 // per-axis |v| threshold for stillness
21const PH_SLEEPN: i64 = 30 // still frames before sleep
22const PH_ITERS: i64 = 6 // solver iterations per tick

functions

24func ph_hdr(base: i64) -> *i64 { return base as *i64 } // [0]=nbodies [1]=tick [2..7]=spare
25func ph_body(base: i64, id: i64) -> *i64 { return (base + 64 + id * 128) as *i64 }
30func ph_acc(base: i64) -> *i64 { return (base + 64 + PH_MAXB * 128) as *i64 }
31func ph_warm(base: i64) -> *i64 { return (base + 64 + PH_MAXB * 128 + PH_MAXB * PH_MAXB * 8) as *i64 }
36func ph_tgt(base: i64) -> *i64 { return (base + 64 + PH_MAXB * 128 + PH_MAXB * PH_MAXB * 16) as *i64 }
37func ph_bytes() -> i64 { return 64 + PH_MAXB * 128 + PH_MAXB * PH_MAXB * 24 }
called by 1: main
39func ph_init(base: i64) -> i64
51func ph_add(base: i64, shape: i64, x: i64, y: i64, z: i64, hx: i64, hy: i64, hz: i64, invm: i64, rest: i64, fric: i64) -> i64
70func ph_set_vel(base: i64, id: i64, vx: i64, vy: i64, vz: i64) -> i64
called by 1: main calls 1: ph_body
78func ph_iabs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
79func ph_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
called by 2: ph_contactph_pair
81func ph_isqrt(v: i64) -> i64
called by 2: ph_contactph_pair
94func ph_contact(base: i64, ia: i64, ib: i64, nx: i64, ny: i64, nz: i64, pen: i64, docorr: i64) -> i64
184func ph_pair(base: i64, ia: i64, ib: i64, docorr: i64) -> i64
232func ph_imax(a: i64, b: i64) -> i64 { if a > b { return a } return b }
called by 2: ph_contactph_pair
234func ph_step(base: i64) -> i64