diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub index 02d0a31a699..8d4e3cf819e 100644 --- a/modules/bullet/SCsub +++ b/modules/bullet/SCsub @@ -208,6 +208,8 @@ if env['builtin_bullet']: # if env['target'] == "debug" or env['target'] == "release_debug": # env_bullet.Append(CPPDEFINES=['BT_DEBUG']) + env_bullet.Append(CPPDEFINES=["BT_USE_OLD_DAMPING_METHOD"]) + env_thirdparty = env_bullet.Clone() env_thirdparty.disable_warnings() env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources) diff --git a/thirdparty/bullet/0001-old-damping-def.patch b/thirdparty/bullet/0001-old-damping-def.patch new file mode 100644 index 00000000000..4c4c4c35ed2 --- /dev/null +++ b/thirdparty/bullet/0001-old-damping-def.patch @@ -0,0 +1,34 @@ +diff --git a/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp b/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp +index 9e8705b001..f1b50b39c8 100644 +--- a/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp ++++ b/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp +@@ -136,8 +136,13 @@ void btRigidBody::setGravity(const btVector3& acceleration) + + void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping) + { +- m_linearDamping = btClamped(lin_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); +- m_angularDamping = btClamped(ang_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); ++#ifdef BT_USE_OLD_DAMPING_METHOD ++ m_linearDamping = btMax(lin_damping, btScalar(0.0)); ++ m_angularDamping = btMax(ang_damping, btScalar(0.0)); ++#else ++ m_linearDamping = btClamped(lin_damping, btScalar(0.0), btScalar(1.0)); ++ m_angularDamping = btClamped(ang_damping, btScalar(0.0), btScalar(1.0)); ++#endif + } + + ///applyDamping damps the velocity, using the given m_linearDamping and m_angularDamping +@@ -146,10 +151,9 @@ void btRigidBody::applyDamping(btScalar timeStep) + //On new damping: see discussion/issue report here: http://code.google.com/p/bullet/issues/detail?id=74 + //todo: do some performance comparisons (but other parts of the engine are probably bottleneck anyway + +-//#define USE_OLD_DAMPING_METHOD 1 +-#ifdef USE_OLD_DAMPING_METHOD +- m_linearVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_linearDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); +- m_angularVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_angularDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); ++#ifdef BT_USE_OLD_DAMPING_METHOD ++ m_linearVelocity *= btMax((btScalar(1.0) - timeStep * m_linearDamping), btScalar(0.0)); ++ m_angularVelocity *= btMax((btScalar(1.0) - timeStep * m_angularDamping), btScalar(0.0)); + #else + m_linearVelocity *= btPow(btScalar(1) - m_linearDamping, timeStep); + m_angularVelocity *= btPow(btScalar(1) - m_angularDamping, timeStep); diff --git a/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp b/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp index 9e8705b001a..f1b50b39c82 100644 --- a/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp +++ b/thirdparty/bullet/BulletDynamics/Dynamics/btRigidBody.cpp @@ -136,8 +136,13 @@ void btRigidBody::setGravity(const btVector3& acceleration) void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping) { - m_linearDamping = btClamped(lin_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); - m_angularDamping = btClamped(ang_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); +#ifdef BT_USE_OLD_DAMPING_METHOD + m_linearDamping = btMax(lin_damping, btScalar(0.0)); + m_angularDamping = btMax(ang_damping, btScalar(0.0)); +#else + m_linearDamping = btClamped(lin_damping, btScalar(0.0), btScalar(1.0)); + m_angularDamping = btClamped(ang_damping, btScalar(0.0), btScalar(1.0)); +#endif } ///applyDamping damps the velocity, using the given m_linearDamping and m_angularDamping @@ -146,10 +151,9 @@ void btRigidBody::applyDamping(btScalar timeStep) //On new damping: see discussion/issue report here: http://code.google.com/p/bullet/issues/detail?id=74 //todo: do some performance comparisons (but other parts of the engine are probably bottleneck anyway -//#define USE_OLD_DAMPING_METHOD 1 -#ifdef USE_OLD_DAMPING_METHOD - m_linearVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_linearDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); - m_angularVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_angularDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); +#ifdef BT_USE_OLD_DAMPING_METHOD + m_linearVelocity *= btMax((btScalar(1.0) - timeStep * m_linearDamping), btScalar(0.0)); + m_angularVelocity *= btMax((btScalar(1.0) - timeStep * m_angularDamping), btScalar(0.0)); #else m_linearVelocity *= btPow(btScalar(1) - m_linearDamping, timeStep); m_angularVelocity *= btPow(btScalar(1) - m_angularDamping, timeStep);