16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 16:59:17 +02:00

low framerate cab movement fix

This commit is contained in:
tmj-fstate
2017-03-02 19:17:22 +01:00
parent 22a5cc8dbc
commit 0e3b414f8f
4 changed files with 11 additions and 149 deletions

View File

@@ -2616,9 +2616,17 @@ void TTrain::UpdateMechPosition(double dt)
pMechPosition += DynamicObject->GetPosition();
// framerate-independent speed reduction that doesn't break at high framerates...
vMechMovement -= vMechMovement * 50.0 * dt;
if( vMechMovement.LengthSquared() < 0.01 ) {
vMechMovement = Math3D::vector3();
Math3D::vector3 movementslowdown = vMechMovement * 35 * dt;
if( movementslowdown.LengthSquared() >= vMechMovement.LengthSquared() ) {
// if the reduction vector exceeds speed movement we're running at low fps,
// fallback on the old behaviour
vMechMovement *= 0.5;
}
else {
vMechMovement -= movementslowdown;
if( vMechMovement.LengthSquared() < 0.01 ) {
vMechMovement = Math3D::vector3();
}
}
};