Update m_hardPointWS after a rewind to make sure the current

terrain is computed based on the new (rewound) kart position.
This commit is contained in:
hiker
2018-06-04 08:50:37 +10:00
parent 91f472e1c7
commit b15de8c3dc
3 changed files with 21 additions and 0 deletions

6
src/karts/kart_rewinder.cpp Executable file → Normal file
View File

@@ -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
// ------------------------------

View File

@@ -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
// ----------------------------------------------------------------------------
/**
*/

View File

@@ -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);