18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 13:15:02 +01:00
Files
maszyna/vehicle/DynObj.h
maj00r a1fbdf47c6 fix(camera): the cab shake taken at the frame's moment between its fixed steps, it no longer moves in steps (#403)
The shake of the cab camera (ShakeState) is stepped by update_shake at a fixed 1/50 s, while the camera read the
raw state every frame. At any frame rate other than 50 the shake moved in steps: some frames showed the same
state as the one before, others jumped one or two steps at once. Players with 144/165 Hz screens saw the cab
jump around the camera.

The vehicle now keeps the state from before the last step (ShakeStateBefore), and the camera takes the state
between the two at the share of the step the simulation time has reached (shake_between). The offset and the
velocity are blended, the angles worked out from the blended velocity. The shake itself is computed as before,
with the same fixed step and the same springs; only what the camera shows of it changes. It lags the vehicle
by a constant 1/50 s instead of 0 to 1/50 s.

Measured with the same build and the blending switched off by a temporary environment variable (not in this
commit), the EU07 on td.scn driven by the AI, frames over 30 km/h, two runs of each:
- 60 fps: frames with the shake standing still 25% -> 0%, the change in its speed frame to frame 4-5 times
  smaller for the offset, a third smaller for the angles
- ~144 fps: 65% -> 0%, 10-18 times smaller for the offset, 4 times for the angles
- no fps limit (~520 fps): 90% -> 0%

Co-authored-by: maj00r <maj00r@host>
2026-11-20 03:39:03 +01:00

49 KiB