mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 08:35:01 +01:00
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>
This commit is contained in:
@@ -918,6 +918,11 @@ public:
|
||||
glm::dvec3 velocity{}; // current shaking vector
|
||||
glm::dvec3 offset{}; // overall shake-driven offset from base position
|
||||
} ShakeState;
|
||||
shake_state ShakeStateBefore; // the state before the last step of update_shake
|
||||
// the shake between the last two steps of update_shake: 0 the state before the last step, 1 the state after it.
|
||||
// the steps are fixed and the frames aren't, so the camera takes the state at its own moment between the two
|
||||
shake_state shake_between( double const Fraction ) const;
|
||||
std::pair<double, double> shake_angles( shake_state const &State ) const;
|
||||
|
||||
glm::dvec3 modelShake;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user