Fix possible NAN on some extreme tracks

This commit is contained in:
Benau 2019-12-12 09:16:10 +08:00
parent edfd638cc4
commit e40ab453a6

View File

@ -981,6 +981,8 @@ void btKart::adjustSpeed(btScalar min_speed, btScalar max_speed)
btVector3 upright_component = normal * normal.dot(velocity);
// Subtract the upright velocity component,
btVector3 v = velocity - upright_component;
if (!v.fuzzyZero())
{
const float velocity_ratio = min_speed / v.length();
// Scale the velocity in the plane, then add the upright component
// of the velocity back in.
@ -988,6 +990,7 @@ void btKart::adjustSpeed(btScalar min_speed, btScalar max_speed)
+ upright_component );
}
}
}
else if (speed >0 && max_speed >= 0 && speed > max_speed)
{
const float velocity_ratio = max_speed / speed;