Remember previous positions
This commit is contained in:
parent
3425fb3c70
commit
c490db927b
@ -147,6 +147,12 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_boosted_ai = false;
|
||||
m_type = RaceManager::KT_AI;
|
||||
|
||||
for (int i=0;i<30;i++)
|
||||
{
|
||||
m_previous_xyz[i] = getXYZ();
|
||||
}
|
||||
time_previous_counter = 0.0f;
|
||||
|
||||
m_view_blocked_by_plunger = 0;
|
||||
m_has_caught_nolok_bubblegum = false;
|
||||
|
||||
@ -370,6 +376,12 @@ void Kart::reset()
|
||||
m_has_caught_nolok_bubblegum = false;
|
||||
m_is_jumping = false;
|
||||
|
||||
for (int i=0;i<30;i++)
|
||||
{
|
||||
m_previous_xyz[i] = getXYZ();
|
||||
}
|
||||
time_previous_counter = 0.0f;
|
||||
|
||||
// In case that the kart was in the air, in which case its
|
||||
// linear damping is 0
|
||||
if(m_body)
|
||||
@ -1278,9 +1290,22 @@ void Kart::update(float dt)
|
||||
{
|
||||
m_kart_animation->update(dt);
|
||||
}
|
||||
|
||||
time_previous_counter += dt;
|
||||
while (time_previous_counter > (1.0f/120.0f))
|
||||
{
|
||||
m_previous_xyz[0] = getXYZ();
|
||||
for (int i=29;i>0;i--)
|
||||
{
|
||||
m_previous_xyz[i] = m_previous_xyz[i-1];
|
||||
}
|
||||
time_previous_counter -= (1.0f/120.0f);
|
||||
}
|
||||
|
||||
// Update the position and other data taken from the physics (or
|
||||
// an animation which calls setXYZ(), which also updates the kart
|
||||
// physical position).
|
||||
|
||||
Moveable::update(dt);
|
||||
|
||||
Vec3 front(0, 0, getKartLength()*0.5f);
|
||||
@ -3050,6 +3075,14 @@ const Vec3& Kart::getNormal() const
|
||||
return m_terrain_info->getNormal();
|
||||
} // getNormal
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the position 0,25s before */
|
||||
const Vec3& Kart::getPreviousXYZ() const
|
||||
{
|
||||
return m_previous_xyz[29];
|
||||
} // getPreviousXYZ
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void Kart::playSound(SFXBuffer* buffer)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user