nx_interp.nx
buildroot/runtime/nx_interp.nx
about
nx_interp.nx -- sovereign snapshot INTERPOLATION buffer: the core trick that makes a peer on a
jittery/lossy link look smooth (render each remote peer slightly IN THE PAST and interpolate between
buffered snapshots -- the Valve/Source "interp" lag-comp model). Absorbs jitter (variable arrival),
hides loss (bracketing samples still exist), and tolerates reordering (sorted insert). 100% nx, no
syscalls -> wasm-friendly. The host only delivers raw bytes; ALL timing/interp logic is here.
Per-peer history: a time-sorted ring of up to K snapshots. Layout (flat *i64):
hist[0] = count
entry i at base = 1 + i*IP_STRIDE: [time_ms, f0..f9] (f = x,y,z,yaw,pitch,species,caught,action,anim,flags)
Spatial fields (0..4) are LERPed between brackets (yaw=3 shortest-arc); enum fields (5..9) are
step-held to the earlier bracket (no nonsense half-states). license_tier: ORIGINAL
dependencies 0 imports · 3 importers
imports: none
imported by: nx_adverse_net_gate.nxnx_interp_ex_gate.nxnx_interp_gate.nx
structs
| none |
consts
| 13 | const IP_STRIDE: i64 = 11 // time + 10 fields |
functions
| 15 | func ip_init(hist: *i64) -> i64 { hist[0] = 0; return 0 } |
| 16 | func ip_count(hist: *i64) -> i64 { return hist[0] } called by 1: main |
| 17 | func ip_time(hist: *i64, i: i64) -> i64 { return hist[1 + i*IP_STRIDE] } |
| 18 | func ip_field(hist: *i64, i: i64, j: i64) -> i64 { return hist[1 + i*IP_STRIDE + 1 + j] } |
| 20 | func ip_entset(hist: *i64, idx: i64, time: i64, f: *i64) -> i64 called by 1: ip_push |
| 27 | func ip_entswap(hist: *i64, a: i64, b: i64) -> i64 called by 1: ip_push |
| 35 | func ip_shiftdrop(hist: *i64, c: i64) -> i64 called by 1: ip_push |
| 47 | func ip_push(hist: *i64, K: i64, time: i64, f: *i64) -> i64 |
| 63 | func ip_lerp_angle(va: i64, vb: i64, num: i64, span: i64) -> i64 called by 1: ip_sample |
| 73 | func ip_sample(hist: *i64, rt: i64, out: *i64) -> i64 |
| 111 | func ip_sample_ex(hist: *i64, rt: i64, max_extrap_ms: i64, out: *i64) -> i64 |