Fixed #697: after a kart explosion a kart would immediately be
rescued again (caused by floating point errors etc, which can cause a kart after an explosion to be under the track). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11859 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
37fa73991b
commit
381412322e
@ -63,7 +63,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart,
|
||||
: AbstractKartAnimation(kart, "ExplosionAnimation")
|
||||
{
|
||||
m_xyz = m_kart->getXYZ();
|
||||
|
||||
m_orig_y = m_xyz.getY();
|
||||
m_kart->playCustomSFX(SFXManager::CUSTOM_EXPLODE);
|
||||
m_timer = m_kart->getKartProperties()->getExplosionTime();
|
||||
|
||||
@ -130,6 +130,14 @@ void ExplosionAnimation::update(float dt)
|
||||
m_velocity -= dt*World::getWorld()->getTrack()->getGravity();
|
||||
|
||||
m_xyz.setY(m_xyz.getY() + dt*m_velocity);
|
||||
|
||||
// Make sure the kart does not end up under the track
|
||||
if(m_xyz.getY()<m_orig_y)
|
||||
{
|
||||
m_xyz.setY(m_orig_y);
|
||||
// This will trigger the end of the animations
|
||||
m_timer = -1;
|
||||
}
|
||||
m_kart->setXYZ(m_xyz);
|
||||
m_curr_rotation += dt*m_add_rotation;
|
||||
btQuaternion q(m_curr_rotation.getHeading(), m_curr_rotation.getPitch(),
|
||||
|
@ -40,6 +40,11 @@ protected:
|
||||
/** The coordinates where the kart was hit originally. */
|
||||
Vec3 m_xyz;
|
||||
|
||||
/** The original Y coordinate. The kart needs to be restored accurately
|
||||
* otherwise due to floating point errors, time step size variations,
|
||||
* a kart can be restarted under the track. */
|
||||
float m_orig_y;
|
||||
|
||||
/** The kart's current rotation. */
|
||||
Vec3 m_curr_rotation;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user