Added zipper speed to state of kart.
This commit is contained in:
parent
876ba33876
commit
f8b48a0313
@ -26,6 +26,7 @@
|
||||
#include "modes/world.hpp"
|
||||
#include "network/rewind_manager.hpp"
|
||||
#include "network/network_string.hpp"
|
||||
#include "physics/btKart.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
#include <string.h>
|
||||
@ -73,6 +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());
|
||||
|
||||
// 2) Steering and other player controls
|
||||
// -------------------------------------
|
||||
@ -113,6 +115,7 @@ void KartRewinder::rewindToState(BareNetworkString *buffer)
|
||||
body->setLinearVelocity(buffer->getVec3());
|
||||
body->setAngularVelocity(buffer->getVec3());
|
||||
m_has_started = buffer->getUInt8()!=0; // necessary for startup speed boost
|
||||
m_vehicle->instantSpeedIncreaseTo(buffer->getFloat());
|
||||
|
||||
// 2) Steering and other controls
|
||||
// ------------------------------
|
||||
|
@ -117,7 +117,7 @@ void btKart::reset()
|
||||
}
|
||||
m_visual_wheels_touch_ground = false;
|
||||
m_zipper_active = false;
|
||||
m_zipper_velocity = btScalar(0);
|
||||
m_zipper_speed = btScalar(0);
|
||||
m_skid_angular_velocity = 0;
|
||||
m_is_skidding = false;
|
||||
m_allow_sliding = false;
|
||||
@ -810,7 +810,7 @@ void btKart::updateFriction(btScalar timeStep)
|
||||
(btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;
|
||||
if(!groundObject) continue;
|
||||
|
||||
if(m_zipper_active && m_zipper_velocity > 0)
|
||||
if(m_zipper_active && m_zipper_speed > 0)
|
||||
{
|
||||
if (wheel==2 || wheel==3)
|
||||
{
|
||||
@ -818,7 +818,7 @@ void btKart::updateFriction(btScalar timeStep)
|
||||
// reached. So compute the impulse to accelerate the
|
||||
// kart up to that speed:
|
||||
m_forwardImpulse[wheel] =
|
||||
0.5f*(m_zipper_velocity -
|
||||
0.5f*(m_zipper_speed -
|
||||
getRigidBody()->getLinearVelocity().length())
|
||||
/ m_chassisBody->getInvMass();
|
||||
}
|
||||
@ -882,8 +882,8 @@ void btKart::updateFriction(btScalar timeStep)
|
||||
} // for (int wheel=0; wheel<getNumWheels(); wheel++)
|
||||
|
||||
|
||||
m_zipper_active = false;
|
||||
m_zipper_velocity = 0;
|
||||
m_zipper_active = false;
|
||||
m_zipper_speed = 0;
|
||||
|
||||
// The kart just stopped skidding. Adjust the velocity so that
|
||||
// it points in the right direction.
|
||||
@ -1061,8 +1061,8 @@ void btKart::setSliding(bool active)
|
||||
*/
|
||||
void btKart::instantSpeedIncreaseTo(float speed)
|
||||
{
|
||||
m_zipper_active = true;
|
||||
m_zipper_velocity = speed;
|
||||
m_zipper_active = true;
|
||||
m_zipper_speed = speed;
|
||||
} // activateZipper
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -72,9 +72,9 @@ private:
|
||||
/** True if a zipper is active for that kart. */
|
||||
bool m_zipper_active;
|
||||
|
||||
/** The zipper velocity (i.e. the velocity the kart should reach in
|
||||
/** The zipper speed (i.e. the velocity the kart should reach in
|
||||
* the first frame that the zipper is active). */
|
||||
btScalar m_zipper_velocity;
|
||||
btScalar m_zipper_speed;
|
||||
|
||||
/** The angular velocity to be applied when the kart skids.
|
||||
* 0 means no skidding. */
|
||||
@ -274,6 +274,9 @@ public:
|
||||
m_additional_rotation = rot/t;
|
||||
m_time_additional_rotation = t;
|
||||
} // setTimedTorque
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current zipper speed. */
|
||||
float getZipperSpeed() const { return m_zipper_speed; }
|
||||
}; // class btKart
|
||||
|
||||
#endif //BT_KART_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user