Fixed skidding rewind by adding all necessary variable to skidding
state and adding timed impulse to physics state of kart.
This commit is contained in:
parent
bfc832d5de
commit
7bbaebe594
@ -81,7 +81,7 @@ void KartRewinder::computeError()
|
||||
*/
|
||||
BareNetworkString* KartRewinder::saveState() const
|
||||
{
|
||||
const int MEMSIZE = 13*sizeof(float) + 9+3;
|
||||
const int MEMSIZE = 17*sizeof(float) + 9+3;
|
||||
|
||||
BareNetworkString *buffer = new BareNetworkString(MEMSIZE);
|
||||
const btRigidBody *body = getBody();
|
||||
@ -96,6 +96,8 @@ BareNetworkString* KartRewinder::saveState() const
|
||||
buffer->add(body->getAngularVelocity());
|
||||
buffer->addUInt8(m_has_started); // necessary for startup speed boost
|
||||
buffer->addFloat(m_vehicle->getMinSpeed());
|
||||
buffer->addFloat(m_vehicle->getTimedRotationTime());
|
||||
buffer->add(m_vehicle->getTimedRotation());
|
||||
|
||||
// 2) Steering and other player controls
|
||||
// -------------------------------------
|
||||
@ -134,16 +136,8 @@ void KartRewinder::rewindToState(BareNetworkString *buffer)
|
||||
t.setRotation(buffer->getQuat());
|
||||
btRigidBody *body = getBody();
|
||||
body->setLinearVelocity(buffer->getVec3());
|
||||
Log::info("KartRewinder", "t %f xyz %f %f %f v %f %f %f",
|
||||
World::getWorld()->getTime(),
|
||||
t.getOrigin().getX(),
|
||||
t.getOrigin().getY(),
|
||||
t.getOrigin().getZ(),
|
||||
body->getLinearVelocity().getX(),
|
||||
body->getLinearVelocity().getY(),
|
||||
body->getLinearVelocity().getZ());
|
||||
|
||||
body->setAngularVelocity(buffer->getVec3());
|
||||
|
||||
// This function also reads the velocity, so it must be called
|
||||
// after the velocities are set
|
||||
body->proceedToTransform(t);
|
||||
@ -152,6 +146,9 @@ void KartRewinder::rewindToState(BareNetworkString *buffer)
|
||||
setTrans(t);
|
||||
m_has_started = buffer->getUInt8()!=0; // necessary for startup speed boost
|
||||
m_vehicle->setMinSpeed(buffer->getFloat());
|
||||
float time_rot = buffer->getFloat();
|
||||
// Set timed rotation divides by time_rot
|
||||
m_vehicle->setTimedRotation(time_rot, time_rot*buffer->getVec3());
|
||||
|
||||
// 2) Steering and other controls
|
||||
// ------------------------------
|
||||
|
@ -98,10 +98,10 @@ void Skidding::saveState(BareNetworkString *buffer)
|
||||
{
|
||||
buffer->addUInt8(m_skid_state);
|
||||
buffer->addFloat(m_remaining_jump_time);
|
||||
if(m_skid_state == SKID_NONE)
|
||||
return;
|
||||
buffer->addFloat(m_skid_time);
|
||||
buffer->addFloat(m_skid_factor);
|
||||
if(m_skid_state == SKID_NONE)
|
||||
return;
|
||||
} // saveState
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -112,9 +112,7 @@ void Skidding::rewindTo(BareNetworkString *buffer)
|
||||
{
|
||||
m_skid_state = (SkidState)buffer->getUInt8();
|
||||
m_remaining_jump_time = buffer->getFloat();
|
||||
if (m_skid_state == SKID_NONE)
|
||||
return;
|
||||
m_skid_time = buffer->getFloat();
|
||||
m_skid_time = buffer->getFloat();
|
||||
m_skid_factor = buffer->getFloat();
|
||||
} // rewindTo
|
||||
|
||||
|
@ -274,10 +274,14 @@ public:
|
||||
* \param torque The rotation to apply. */
|
||||
void setTimedRotation(float t, const btVector3 &rot)
|
||||
{
|
||||
m_additional_rotation = rot/t;
|
||||
if(t>0) m_additional_rotation = rot/t;
|
||||
m_time_additional_rotation = t;
|
||||
} // setTimedTorque
|
||||
// ------------------------------------------------------------------------
|
||||
const btVector3& getTimedRotation() const { return m_additional_rotation; }
|
||||
// ------------------------------------------------------------------------
|
||||
float getTimedRotationTime() const { return m_time_additional_rotation; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the maximum speed for this kart. */
|
||||
void setMaxSpeed(float new_max_speed)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user