Fix possible NAN on some extreme tracks
This commit is contained in:
parent
edfd638cc4
commit
e40ab453a6
@ -981,11 +981,14 @@ void btKart::adjustSpeed(btScalar min_speed, btScalar max_speed)
|
|||||||
btVector3 upright_component = normal * normal.dot(velocity);
|
btVector3 upright_component = normal * normal.dot(velocity);
|
||||||
// Subtract the upright velocity component,
|
// Subtract the upright velocity component,
|
||||||
btVector3 v = velocity - upright_component;
|
btVector3 v = velocity - upright_component;
|
||||||
const float velocity_ratio = min_speed / v.length();
|
if (!v.fuzzyZero())
|
||||||
// Scale the velocity in the plane, then add the upright component
|
{
|
||||||
// of the velocity back in.
|
const float velocity_ratio = min_speed / v.length();
|
||||||
m_chassisBody->setLinearVelocity( v*velocity_ratio
|
// Scale the velocity in the plane, then add the upright component
|
||||||
+ upright_component );
|
// of the velocity back in.
|
||||||
|
m_chassisBody->setLinearVelocity( v*velocity_ratio
|
||||||
|
+ upright_component );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (speed >0 && max_speed >= 0 && speed > max_speed)
|
else if (speed >0 && max_speed >= 0 && speed > max_speed)
|
||||||
|
Loading…
Reference in New Issue
Block a user