Make sure all karts has the same position before go phase
This commit is contained in:
parent
2fa233179c
commit
f48491c279
@ -143,16 +143,6 @@ void AbstractKart::setKartAnimation(AbstractKartAnimation *ka)
|
|||||||
m_kart_animation = ka;
|
m_kart_animation = ka;
|
||||||
} // setKartAnimation
|
} // setKartAnimation
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
/** Moves the current physical transform into this kart's position.
|
|
||||||
*/
|
|
||||||
void AbstractKart::kartIsInRestNow()
|
|
||||||
{
|
|
||||||
// Update the kart transforms with the newly computed position
|
|
||||||
// after all karts are reset
|
|
||||||
setTrans(getBody()->getWorldTransform());
|
|
||||||
} // kartIsInRest
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Returns the time at which the kart was at a given distance.
|
/** Returns the time at which the kart was at a given distance.
|
||||||
* Returns -1.0f if none */
|
* Returns -1.0f if none */
|
||||||
@ -160,3 +150,27 @@ float AbstractKart::getTimeForDistance(float distance)
|
|||||||
{
|
{
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
} // getTimeForDistance
|
} // getTimeForDistance
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Moves the current physical transform into this kart's position.
|
||||||
|
*/
|
||||||
|
void AbstractKart::kartIsInRestNow()
|
||||||
|
{
|
||||||
|
// Update the kart transforms with the newly computed position
|
||||||
|
// after all karts are reset
|
||||||
|
m_starting_transform = getBody()->getWorldTransform();
|
||||||
|
setTrans(m_starting_transform);
|
||||||
|
} // kartIsInRest
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Called before go phase to make sure all karts start at the same
|
||||||
|
* position in case there is a slope. */
|
||||||
|
void AbstractKart::makeKartRest()
|
||||||
|
{
|
||||||
|
btRigidBody *body = getBody();
|
||||||
|
body->clearForces();
|
||||||
|
body->setLinearVelocity(Vec3(0.0f));
|
||||||
|
body->setAngularVelocity(Vec3(0.0f));
|
||||||
|
body->proceedToTransform(m_starting_transform);
|
||||||
|
setTrans(m_starting_transform);
|
||||||
|
} // makeKartRest
|
||||||
|
@ -74,7 +74,7 @@ private:
|
|||||||
/** Index of kart in world. */
|
/** Index of kart in world. */
|
||||||
unsigned int m_world_kart_id;
|
unsigned int m_world_kart_id;
|
||||||
|
|
||||||
|
btTransform m_starting_transform;
|
||||||
protected:
|
protected:
|
||||||
/** The kart properties. */
|
/** The kart properties. */
|
||||||
std::unique_ptr<KartProperties> m_kart_properties;
|
std::unique_ptr<KartProperties> m_kart_properties;
|
||||||
@ -509,6 +509,9 @@ public:
|
|||||||
virtual void playSound(SFXBuffer* buffer) = 0;
|
virtual void playSound(SFXBuffer* buffer) = 0;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
virtual bool isVisible() = 0;
|
virtual bool isVisible() = 0;
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual void makeKartRest();
|
||||||
|
|
||||||
}; // AbstractKart
|
}; // AbstractKart
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ public:
|
|||||||
float getTimeForEggs(int egg_number);
|
float getTimeForEggs(int egg_number);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
virtual void kartIsInRestNow() OVERRIDE {};
|
virtual void kartIsInRestNow() OVERRIDE {}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
virtual void makeKartRest() OVERRIDE {}
|
||||||
}; // GhostKart
|
}; // GhostKart
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1064,6 +1064,8 @@ void World::update(int ticks)
|
|||||||
// Update all karts that are not eliminated
|
// Update all karts that are not eliminated
|
||||||
if(!m_karts[i]->isEliminated() || (sta && sta->isMoving()))
|
if(!m_karts[i]->isEliminated() || (sta && sta->isMoving()))
|
||||||
m_karts[i]->update(ticks);
|
m_karts[i]->update(ticks);
|
||||||
|
if (isStartPhase())
|
||||||
|
m_karts[i]->makeKartRest();
|
||||||
}
|
}
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(ticks);
|
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(ticks);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user