five-on-it / packages/net-client/src/smoothing
packages/net-client/src/smoothing
A visual offset that hides reconciliation corrections: when the predicted car is snapped to a corrected pose, the difference is added here and rendered on top of the true pose, decaying to zero over about 150 ms.
Not every correction of the player's own car is hidden. The offset moves what it is drawn on at up to SMOOTHING_DECAY_PER_SECOND times its size a second, so a correction eased away is a motion of the drawn car, and one larger than what a frame could hide at the car's pace shows as a dash (or, on a car that has just stopped at a wall, as the car moving on after its stop): given the car's pace, such a correction is taken at once (snapsAt), a jump to the true pose, as the remotes' blend takes a jump of metres and as racing games do. The bound is the one the remotes' blend goes by: a third again the car's pace, a quarter of a metre a second at the least (BLEND_PACE_SHARE, BLEND_PACE_FLOOR). Measured at the wall (tests/netcode/impact.ts): a correction at a crash was 34 to 76 cm, eased over 150 ms on a car that had stopped; now the crash is predicted to the bit and nothing is left to hide, and what a wrong prediction leaves (a blast the server alone deals) is taken at once past the bound. The near cars and pieces are eased whatever the size (no pace given): one of them jumped between two frames was a dash of its own on screen (E2E-641), where an eased one stays within the bound its blend goes by plus what the decay adds.