code wiki / (root) / nx_interp.nx

nx_interp.nx

buildroot/runtime/nx_interp.nx

6200 B147 linesdepth 0pulls 0 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_interp.nx nx_adverse_net_gate.nx nx_interp_ex_gate.nx nx_interp_gate.nx

imports: none

imported by: nx_adverse_net_gate.nxnx_interp_ex_gate.nxnx_interp_gate.nx

structs

none

consts

13const IP_STRIDE: i64 = 11 // time + 10 fields

functions

15func ip_init(hist: *i64) -> i64 { hist[0] = 0; return 0 }
called by 3: mainmainmain
16func ip_count(hist: *i64) -> i64 { return hist[0] }
called by 1: main
17func ip_time(hist: *i64, i: i64) -> i64 { return hist[1 + i*IP_STRIDE] }
18func ip_field(hist: *i64, i: i64, j: i64) -> i64 { return hist[1 + i*IP_STRIDE + 1 + j] }
20func ip_entset(hist: *i64, idx: i64, time: i64, f: *i64) -> i64
called by 1: ip_push
27func ip_entswap(hist: *i64, a: i64, b: i64) -> i64
called by 1: ip_push
35func ip_shiftdrop(hist: *i64, c: i64) -> i64
called by 1: ip_push
47func ip_push(hist: *i64, K: i64, time: i64, f: *i64) -> i64
63func ip_lerp_angle(va: i64, vb: i64, num: i64, span: i64) -> i64
called by 1: ip_sample
73func ip_sample(hist: *i64, rt: i64, out: *i64) -> i64
111func ip_sample_ex(hist: *i64, rt: i64, max_extrap_ms: i64, out: *i64) -> i64
called by 2: mainmain calls 3: ip_timeip_sampleip_field