code wiki / (root) / nx_lerp_smooth.nx

nx_lerp_smooth.nx

buildroot/runtime/nx_lerp_smooth.nx

1236 B15 linesdepth 0pulls 0 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_lerp_smooth.nx -- sovereign per-peer render-smoothing primitive. Interpolate prev->cur by an alpha that advances one step per frame, with BOUNDED extrapolation so a dropped network sync keeps the avatar gliding (no freeze / no teleport) instead of snapping. This is the nx_interp render-in-between mechanism reduced to two pure functions, shared identically by the wasm game (b_draw_peers / gi_net_smooth) AND its native gate (author-by-organ: same code both sides, gated by nx_cc->nxasm with no node). Q8 alpha: 0=prev, 256=cur. license_tier: ORIGINAL

dependencies 0 imports · 2 importers

nx_lerp_smooth.nx nx_lerp_smooth_gate.nx nx_pets3d_wasm.nx

imports: none

imported by: nx_lerp_smooth_gate.nxnx_pets3d_wasm.nx

structs

none

consts

8const LS_CUR: i64 = 256 // alpha at which rendered == cur
9const LS_MAX: i64 = 320 // alpha cap = 256 + 64 -> 25% bounded extrapolation past cur (no runaway on loss)
10const LS_STEP: i64 = 52 // ~5 frames per ~80ms sync to glide prev->cur

functions

13func ls_interp(p: i64, c: i64, a: i64) -> i64 { return p + (c - p) * a / LS_CUR }
called by 2: mainb_draw_peers
15func ls_advance(a: i64) -> i64 { let n: i64 = a + LS_STEP; if n > LS_MAX { return LS_MAX } return n }
called by 2: maingi_net_smooth