Added lost improvement: make sure that both wheels
of an axis are touching the ground if at least one wheel touches it (if only one wheel touches the ground, the kart will get a strong angular impulse and turn rapidly). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/physics@10251 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -326,6 +326,30 @@ void btKart::updateVehicle( btScalar step )
|
||||
if(m_wheelInfo[i].m_raycastInfo.m_isInContact)
|
||||
m_num_wheels_on_ground++;
|
||||
}
|
||||
// Work around: make sure that either both wheels on one axis
|
||||
// are on ground, or none of them. This avoids the problem of
|
||||
// the kart suddenly getting additional angular velocity because
|
||||
// e.g. only one rear wheel is on the ground.
|
||||
for(i=0; i<m_wheelInfo.size(); i+=2)
|
||||
{
|
||||
if( m_wheelInfo[i ].m_raycastInfo.m_isInContact !=
|
||||
m_wheelInfo[i+1].m_raycastInfo.m_isInContact)
|
||||
{
|
||||
int wheel_air_index = i;
|
||||
int wheel_ground_index = i+1;
|
||||
|
||||
if (m_wheelInfo[i].m_raycastInfo.m_isInContact)
|
||||
{
|
||||
wheel_air_index = i+1;
|
||||
wheel_ground_index = i;
|
||||
}
|
||||
|
||||
btWheelInfo& wheel_air = m_wheelInfo[wheel_air_index];
|
||||
btWheelInfo& wheel_ground = m_wheelInfo[wheel_ground_index];
|
||||
|
||||
wheel_air.m_raycastInfo = wheel_ground.m_raycastInfo;
|
||||
}
|
||||
} // for i=0; i<m_wheelInfo.size(); i+=2
|
||||
|
||||
updateSuspension(step);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user