From 4c3a31077b4ebeb1fcabfde9feeeaa4fec57aaee Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Thu, 23 Dec 2010 02:01:54 +0000 Subject: [PATCH] Applied rolling-influence fix. For backwards compatibility, you can un-comment the #define ROLLING_INFLUENCE_FIX in btRaycastVehicle.cpp Thanks to Vlad Turchenko for the report and fix, see Issue 468 --- src/BulletDynamics/Vehicle/btRaycastVehicle.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp b/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp index c7419cc4d..af9163b5d 100644 --- a/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp +++ b/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp @@ -22,6 +22,9 @@ #include "LinearMath/btIDebugDraw.h" #include "BulletDynamics/ConstraintSolver/btContactConstraint.h" +#define ROLLING_INFLUENCE_FIX + + btRigidBody& btActionInterface::getFixedBody() { static btRigidBody s_fixed(0, 0,0); @@ -694,7 +697,12 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) btVector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel]; +#if defined ROLLING_INFLUENCE_FIX // fix. It only worked if car's up was along Y - VT. + btVector3 vChassisWorldUp = getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(1); + rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * wheelInfo.m_rollInfluence); +#else rel_pos[m_indexUpAxis] *= wheelInfo.m_rollInfluence; +#endif m_chassisBody->applyImpulse(sideImp,rel_pos); //apply friction impulse on the ground