Bugfix: when m_skid_time was close to 0 (say 1e-8)

the visual rotation could become huge, resulting
in incorrect and constant visual rotation of the kart.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11755 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-10-24 09:14:29 +00:00
parent 7341c5c61f
commit 67487883f8

View File

@ -103,7 +103,14 @@ void Skidding::updateSteering(float steer, float dt)
m_real_steering = steer;
if(m_skid_time<m_skid_visual_time && m_skid_time>0)
{
m_visual_rotation -= m_visual_rotation*dt/m_skid_time;
float f = m_visual_rotation - m_visual_rotation*dt/m_skid_time;
// Floating point errors when m_skid_time is very close to 0
// can result in visual rotation set to a large number
if( (f<0 && m_visual_rotation>0 ) ||
(f>0 && m_visual_rotation<0) )
m_visual_rotation = 0;
else
m_visual_rotation = f;
}
break;
case SKID_ACCUMULATE_RIGHT: