Fixed wheel position in case of a rescue: if the suspension of

a wheel is stretched at the time a rescue or explosion is triggered,
the wheel will appear to be very far away from the kart (not connected
anymore).
This commit is contained in:
hiker
2016-07-28 09:47:56 +10:00
parent 6ca0eed28f
commit 83117fe649
3 changed files with 22 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
#include "graphics/slip_stream.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_model.hpp"
#include "karts/skidding.hpp"
#include "modes/world.hpp"
#include "physics/physics.hpp"
@@ -55,6 +56,12 @@ AbstractKartAnimation::AbstractKartAnimation(AbstractKart *kart,
// A time of 0 reset the squashing
kart->setSquash(0.0f, 0.0f);
}
// Reset the wheels (and any other animation played for that kart)
// This avoid the effect that some wheels might be way below the kart
// which is very obvious in the rescue animation.
m_kart->getKartModel()->resetVisualWheelPosition();
} // AbstractKartAnimation
// ----------------------------------------------------------------------------

View File

@@ -982,6 +982,20 @@ void KartModel::update(float dt, float distance, float steer, float speed,
m_animated_node->setCurrentFrame(frame);
} // update
//-----------------------------------------------------------------------------
/** Called when a kart is rescued to reset all visual wheels to their default
* position to avoid that some wheels look too far away from the kart (which
* is not that visible while a kart is driving).
*/
void KartModel::resetVisualWheelPosition()
{
for(unsigned int i=0; i<4; i++)
{
m_kart->getVehicle()->getWheelInfo(i).m_raycastInfo.m_suspensionLength =
m_default_physics_suspension[i];
} // for i < 4
} // resetVisualSuspension
//-----------------------------------------------------------------------------
void KartModel::attachHat()
{

View File

@@ -249,6 +249,7 @@ public:
float current_lean_angle,
int gt_replay_index = -1);
void finishedRace();
void resetVisualWheelPosition();
scene::ISceneNode*
attachModel(bool animatedModels, bool always_animated);
// ------------------------------------------------------------------------