mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 13:29:18 +02:00
low framerate cab movement fix
This commit is contained in:
14
Train.cpp
14
Train.cpp
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user