Propperly handle instand speed increases in the physics when rewinding.
This commit is contained in:
@@ -1168,6 +1168,9 @@ void Kart::eliminate()
|
||||
*/
|
||||
void Kart::update(float dt)
|
||||
{
|
||||
// Reset any instand speed increase in the bullet kart
|
||||
m_vehicle->resetInstantSpeed();
|
||||
|
||||
// update star effect (call will do nothing if stars are not activated)
|
||||
m_stars_effect->update(dt);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ BareNetworkString* KartRewinder::saveState() const
|
||||
buffer->add(body->getLinearVelocity());
|
||||
buffer->add(body->getAngularVelocity());
|
||||
buffer->addUInt8(m_has_started); // necessary for startup speed boost
|
||||
buffer->addFloat(m_vehicle->getZipperSpeed());
|
||||
buffer->addFloat(m_vehicle->getInstantSpeedIncrease());
|
||||
|
||||
// 2) Steering and other player controls
|
||||
// -------------------------------------
|
||||
@@ -116,6 +116,9 @@ void KartRewinder::rewindToState(BareNetworkString *buffer)
|
||||
// This function also reads the velocity, so it must be called
|
||||
// after the velocities are set
|
||||
body->proceedToTransform(t);
|
||||
// Update kart transform in case that there are access to its value
|
||||
// before Moveable::update() is called (which updates the transform)
|
||||
setTrans(t);
|
||||
m_has_started = buffer->getUInt8()!=0; // necessary for startup speed boost
|
||||
m_vehicle->instantSpeedIncreaseTo(buffer->getFloat());
|
||||
|
||||
|
||||
@@ -1062,6 +1062,11 @@ void btKart::setSliding(bool active)
|
||||
*/
|
||||
void btKart::instantSpeedIncreaseTo(float speed)
|
||||
{
|
||||
// Avoid that a speed 'increase' might cause a slowdown
|
||||
if (m_chassisBody->getLinearVelocity().length2() > speed*speed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_zipper_active = speed > 0;
|
||||
m_zipper_speed = speed;
|
||||
} // activateZipper
|
||||
|
||||
@@ -276,7 +276,9 @@ public:
|
||||
} // setTimedTorque
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current zipper speed. */
|
||||
float getZipperSpeed() const { return m_zipper_speed; }
|
||||
float getInstantSpeedIncrease() const { return m_zipper_speed; }
|
||||
// ------------------------------------------------------------------------
|
||||
void resetInstantSpeed() { m_zipper_speed = 0; }
|
||||
}; // class btKart
|
||||
|
||||
#endif //BT_KART_HPP
|
||||
|
||||
Reference in New Issue
Block a user