nx_lerp_smooth.nx
buildroot/runtime/nx_lerp_smooth.nx
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
imports: none
imported by: nx_lerp_smooth_gate.nxnx_pets3d_wasm.nx
structs
| none |
consts
| 8 | const LS_CUR: i64 = 256 // alpha at which rendered == cur |
| 9 | const LS_MAX: i64 = 320 // alpha cap = 256 + 64 -> 25% bounded extrapolation past cur (no runaway on loss) |
| 10 | const LS_STEP: i64 = 52 // ~5 frames per ~80ms sync to glide prev->cur |
functions
| 13 | func ls_interp(p: i64, c: i64, a: i64) -> i64 { return p + (c - p) * a / LS_CUR } |
| 15 | func ls_advance(a: i64) -> i64 { let n: i64 = a + LS_STEP; if n > LS_MAX { return LS_MAX } return n } |