diff --git a/src/karts/kart_rewinder.cpp b/src/karts/kart_rewinder.cpp old mode 100755 new mode 100644 index 635728f17..5db1d3c0d --- a/src/karts/kart_rewinder.cpp +++ b/src/karts/kart_rewinder.cpp @@ -150,6 +150,12 @@ void KartRewinder::restoreState(BareNetworkString *buffer, int count) float time_rot = buffer->getFloat(); // Set timed rotation divides by time_rot m_vehicle->setTimedRotation(time_rot, time_rot*buffer->getVec3()); + // For the raycast to determine the current material under the kart + // the m_hardPointWS of the wheels is used. So after a rewind we + // must restore the m_hardPointWS to the new values, otherwise they + // would still point at the kart position at the previous rewind + // (i.e. different terrain --> different slowdown). + m_vehicle->updateAllWheelTransformsWS(); // 2) Steering and other controls // ------------------------------ diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 3b985f498..26bfab4df 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -212,6 +212,20 @@ void btKart::updateWheelTransformsWS(btWheelInfo& wheel, wheel.m_wheelAxleCS; } // updateWheelTransformsWS +// ---------------------------------------------------------------------------- +/** Updates all wheel transform informations. This is used just after a rewind + * to update all m_hardPointWS (which is used by stk to determine the terrain + * under the kart). + */ +void btKart::updateAllWheelTransformsWS() +{ + for (unsigned int i = 0; i < m_wheelInfo.size(); i++) + { + btWheelInfo &wheel = m_wheelInfo[i]; + updateWheelTransformsWS(wheel, false, 1.0f); + } +} // updateAllWheelTransformsWS + // ---------------------------------------------------------------------------- /** */ diff --git a/src/physics/btKart.hpp b/src/physics/btKart.hpp index c04d11d27..68eeb36ca 100644 --- a/src/physics/btKart.hpp +++ b/src/physics/btKart.hpp @@ -166,6 +166,7 @@ public: void updateWheelTransformsWS(btWheelInfo& wheel, bool interpolatedTransform=true, float fraction = 1.0f); + void updateAllWheelTransformsWS(); void setAllBrakes(btScalar brake); void updateSuspension(btScalar deltaTime); virtual void updateFriction(btScalar timeStep);