Hopefully fixed all sliding introduced by recent changes to friction

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6506 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-11-12 00:02:15 +00:00
parent 30cb112c46
commit c10f695bd5
3 changed files with 20 additions and 1 deletions

View File

@ -1392,6 +1392,8 @@ void Kart::updatePhysics(float dt)
// Below angles of 0.25 rad, you have full traction; above 0.5 rad angles you have absolutely none; inbetween
// there is a linear change in friction
float friction = 1.0f;
bool enableSkidding = false;
if (isOnGround())
{
const btMatrix3x3 &m = m_vehicle->getChassisWorldTransform().getBasis();
@ -1403,6 +1405,7 @@ void Kart::updatePhysics(float dt)
if (distanceFromUp < 0.85f)
{
friction = 0.0f;
enableSkidding = true;
}
else if (distanceFromUp > 0.9f)
{
@ -1411,6 +1414,7 @@ void Kart::updatePhysics(float dt)
else
{
friction = (distanceFromUp - 0.85f) / 0.5f;
enableSkidding = true;
}
}
@ -1420,6 +1424,9 @@ void Kart::updatePhysics(float dt)
wheel.m_frictionSlip = friction*m_kart_properties->getFrictionSlip();
}
m_vehicle->enableSliding(enableSkidding);
/*
// debug prints
static float f = 0.0f;

View File

@ -742,7 +742,7 @@ void btKart::updateFriction(btScalar timeStep)
{
for (int wheel = 0;wheel < getNumWheels(); wheel++)
{
if (m_sideImpulse[wheel] != btScalar(0.))
if (m_sideImpulse[wheel] != btScalar(0.) && m_allow_sliding)
{
if (m_wheelInfo[wheel].m_skidInfo< btScalar(1.))
{

View File

@ -28,7 +28,14 @@ class btKart : public btRaycastVehicle
int m_num_wheels_on_ground;
bool m_zipper_active;
btScalar m_zipper_velocity;
/** Sliding (skidding) will only be permited when this is true. Also check
* the friction parameter in the wheels since friction directly affects skidding
*/
bool m_allow_sliding;
public:
btKart(const btVehicleTuning& tuning,btRigidBody* chassis,
btVehicleRaycaster* raycaster, float track_connect_accel );
virtual ~btKart() ;
@ -46,6 +53,11 @@ public:
void deactivateZipper() { m_zipper_active = false; }
void updateSuspension(btScalar deltaTime);
virtual void updateFriction(btScalar timeStep);
/** Sliding (skidding) will only be permited when this is set to true. Also check
* the friction parameter in the wheels since friction directly affects skidding
*/
void enableSliding(bool enabled) { m_allow_sliding = enabled; }
};
#endif //BT_KART_H