Use only y-axis for timed rotation
This commit is contained in:
parent
7b4a4e3727
commit
b91e018a18
@ -155,7 +155,7 @@ BareNetworkString* KartRewinder::saveState(std::vector<std::string>* ru)
|
||||
buffer->add(body->getLinearVelocity());
|
||||
buffer->add(body->getAngularVelocity());
|
||||
buffer->addUInt16(m_vehicle->getTimedRotationTicks());
|
||||
buffer->add(m_vehicle->getTimedRotation());
|
||||
buffer->addFloat(m_vehicle->getTimedRotation());
|
||||
|
||||
// For collision rewind
|
||||
buffer->addUInt16(m_bounce_back_ticks);
|
||||
@ -262,10 +262,10 @@ void KartRewinder::restoreState(BareNetworkString *buffer, int count)
|
||||
}
|
||||
|
||||
uint16_t time_rot = buffer->getUInt16();
|
||||
float timed_rotation_y = buffer->getFloat();
|
||||
// Set timed rotation divides by time_rot
|
||||
m_vehicle->setTimedRotation(time_rot,
|
||||
stk_config->ticks2Time(time_rot)
|
||||
* buffer->getVec3());
|
||||
stk_config->ticks2Time(time_rot) * timed_rotation_y);
|
||||
|
||||
// Collision rewind
|
||||
m_bounce_back_ticks = buffer->getUInt16();
|
||||
|
@ -87,7 +87,7 @@ void Skidding::reset()
|
||||
btVector3 rot(0, 0, 0);
|
||||
// Only access the vehicle if the kart is not a ghost
|
||||
if (!m_kart->isGhostKart())
|
||||
m_kart->getVehicle()->setTimedRotation(0, rot);
|
||||
m_kart->getVehicle()->setTimedRotation(0, 0);
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -535,9 +535,9 @@ void Skidding::update(int ticks, bool is_on_ground,
|
||||
float t = std::min(skid_time_float, kp->getSkidVisualTime());
|
||||
t = std::min(t, kp->getSkidRevertVisualTime());
|
||||
|
||||
btVector3 rot(0, m_visual_rotation * kp->getSkidPostSkidRotateFactor(), 0);
|
||||
m_kart->getVehicle()->setTimedRotation(
|
||||
(uint16_t)stk_config->time2Ticks(t), rot);
|
||||
(uint16_t)stk_config->time2Ticks(t),
|
||||
m_visual_rotation * kp->getSkidPostSkidRotateFactor());
|
||||
// skid_time is used to count backwards for the GFX
|
||||
m_skid_time = stk_config->time2Ticks(t);
|
||||
if(bonus_time>0)
|
||||
|
@ -121,7 +121,7 @@ void btKart::reset()
|
||||
m_num_wheels_on_ground = 0;
|
||||
m_additional_impulse = btVector3(0,0,0);
|
||||
m_ticks_additional_impulse = 0;
|
||||
m_additional_rotation = btVector3(0,0,0);
|
||||
m_additional_rotation = 0;
|
||||
m_ticks_additional_rotation = 0;
|
||||
m_max_speed = -1.0f;
|
||||
m_min_speed = 0.0f;
|
||||
@ -522,9 +522,9 @@ void btKart::updateVehicle( btScalar step )
|
||||
btTransform &t = m_chassisBody->getWorldTransform();
|
||||
// We have fixed timestep
|
||||
float dt = stk_config->ticks2Time(1);
|
||||
btQuaternion add_rot(m_additional_rotation.getY()*dt,
|
||||
m_additional_rotation.getX()*dt,
|
||||
m_additional_rotation.getZ()*dt);
|
||||
btQuaternion add_rot(m_additional_rotation * dt,
|
||||
0.0f,
|
||||
0.0f);
|
||||
t.setRotation(t.getRotation()*add_rot);
|
||||
m_chassisBody->setWorldTransform(t);
|
||||
// Also apply the rotation to the interpolated world transform.
|
||||
|
@ -83,8 +83,8 @@ private:
|
||||
/** The time the additional impulse should be applied. */
|
||||
uint16_t m_ticks_additional_impulse;
|
||||
|
||||
/** Additional rotation that is applied over a certain amount of time. */
|
||||
btVector3 m_additional_rotation;
|
||||
/** Additional rotation in y-axis that is applied over a certain amount of time. */
|
||||
float m_additional_rotation;
|
||||
|
||||
/** Duration over which the additional rotation is applied. */
|
||||
uint16_t m_ticks_additional_rotation;
|
||||
@ -236,21 +236,26 @@ public:
|
||||
{ return m_ticks_additional_impulse; }
|
||||
// ------------------------------------------------------------------------
|
||||
const btVector3& getAdditionalImpulse() const
|
||||
{ return m_additional_impulse; }
|
||||
{ return m_additional_impulse; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets a rotation that is applied over a certain amount of time (to avoid
|
||||
* a too rapid changes in the kart).
|
||||
* \param t Ticks for the rotation to be applied.
|
||||
* \param torque The rotation to apply. */
|
||||
void setTimedRotation(uint16_t t, const btVector3 &rot)
|
||||
* \param rot_in_y_axis The rotation in y-axis to apply. */
|
||||
void setTimedRotation(uint16_t t, float rot_in_y_axis)
|
||||
{
|
||||
if(t>0) m_additional_rotation = rot / (stk_config->ticks2Time(t));
|
||||
if (t > 0)
|
||||
{
|
||||
m_additional_rotation =
|
||||
rot_in_y_axis / (stk_config->ticks2Time(t));
|
||||
}
|
||||
m_ticks_additional_rotation = t;
|
||||
} // setTimedTorque
|
||||
// ------------------------------------------------------------------------
|
||||
const btVector3& getTimedRotation() const { return m_additional_rotation; }
|
||||
float getTimedRotation() const { return m_additional_rotation; }
|
||||
// ------------------------------------------------------------------------
|
||||
uint16_t getTimedRotationTicks() const { return m_ticks_additional_rotation; }
|
||||
uint16_t getTimedRotationTicks() const
|
||||
{ return m_ticks_additional_rotation; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the maximum speed for this kart. */
|
||||
void setMaxSpeed(float new_max_speed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user