From 2cc6d565cbc9da005e1c13828c6b3a3d46cd32cb Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 3 Aug 2005 18:22:30 +0000 Subject: moved some hardcoded constants into tweaking tresholds exposed those tresholds to python (more 'expert' settings) --- extern/bullet/Bullet/Bullet3_vc8.vcproj | 21 +++++++++------------ .../NarrowPhaseCollision/PersistentManifold.cpp | 3 ++- .../NarrowPhaseCollision/PersistentManifold.h | 3 +++ .../CollisionDispatch/ToiContactDispatcher.cpp | 13 +++++++++---- .../CollisionDispatch/ToiContactDispatcher.h | 20 ++++++++++++++++++++ .../ConstraintSolver/ContactSolverInfo.h | 3 ++- .../ConstraintSolver/OdeConstraintSolver.cpp | 12 ++++++------ .../ConstraintSolver/OdeConstraintSolver.h | 17 +++++++++++++++++ .../BulletDynamics/ConstraintSolver/SorLcp.cpp | 6 +++--- 9 files changed, 71 insertions(+), 27 deletions(-) (limited to 'extern') diff --git a/extern/bullet/Bullet/Bullet3_vc8.vcproj b/extern/bullet/Bullet/Bullet3_vc8.vcproj index b9046f451e5..c2f3e70180f 100644 --- a/extern/bullet/Bullet/Bullet3_vc8.vcproj +++ b/extern/bullet/Bullet/Bullet3_vc8.vcproj @@ -4,6 +4,7 @@ Version="8.00" Name="Bullet3ContinuousCollision" ProjectGUID="{FFD3C64A-30E2-4BC7-BC8F-51818C320400}" + SignManifests="true" > + + + + @@ -428,14 +437,6 @@ RelativePath=".\CollisionShapes\TriangleCallback.h" > - - - - @@ -508,10 +509,6 @@ RelativePath="..\LinearMath\GEN_random.h" > - - diff --git a/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.cpp b/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.cpp index 29b13f67b8f..16cd219903d 100644 --- a/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.cpp +++ b/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.cpp @@ -14,6 +14,7 @@ #include "SimdTransform.h" #include +float gContactBreakingTreshold = 0.02f; PersistentManifold::PersistentManifold() :m_body0(0), @@ -113,7 +114,7 @@ void PersistentManifold::AddManifoldPoint(const ManifoldPoint& newPoint) float PersistentManifold::GetManifoldMargin() const { - return 0.02f; + return gContactBreakingTreshold; } void PersistentManifold::RefreshContactPoints(const SimdTransform& trA,const SimdTransform& trB) diff --git a/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.h b/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.h index 96f91d5900e..ca02aa9c9a4 100644 --- a/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.h +++ b/extern/bullet/Bullet/NarrowPhaseCollision/PersistentManifold.h @@ -19,6 +19,9 @@ struct CollisionResult; +///contact breaking and merging treshold +extern float gContactBreakingTreshold; + #define MANIFOLD_CACHE_SIZE 4 ///PersistentManifold maintains contact points, and reduces them to 4 diff --git a/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.cpp b/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.cpp index a67da9bc889..da72d3e0cad 100644 --- a/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.cpp +++ b/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.cpp @@ -38,7 +38,10 @@ ToiContactDispatcher::ToiContactDispatcher (ConstraintSolver* solver): m_useIslands(true), m_unionFind(MAX_RIGIDBODIES), m_solver(solver), - m_count(0) + m_count(0), + m_sor(1.3f), + m_tau(0.4f), + m_damping(0.9f) { int i; @@ -158,13 +161,15 @@ void ToiContactDispatcher::SolveConstraints(float timeStep, int numIterations,in ///This island solving can all be scheduled in parallel ContactSolverInfo info; - info.m_damping = 0.9f; info.m_friction = 0.9f; info.m_numIterations = numIterations; info.m_timeStep = timeStep; - info.m_tau = 0.4f; + info.m_restitution = 0.0f;//m_restitution; - + + info.m_sor = m_sor; + info.m_tau = m_tau; + info.m_damping = m_damping; m_solver->SolveGroup( &islandmanifold[0], islandmanifold.size(),info,debugDrawer ); diff --git a/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.h b/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.h index 97897a69dc4..b1793f70979 100644 --- a/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.h +++ b/extern/bullet/BulletDynamics/CollisionDispatch/ToiContactDispatcher.h @@ -44,6 +44,10 @@ class ToiContactDispatcher : public Dispatcher UnionFind m_unionFind; ConstraintSolver* m_solver; + float m_sor; + float m_tau; + float m_damping; + CollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; public: @@ -97,6 +101,22 @@ public: virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;} + void SetSor(float sor) + { + m_sor = sor; + } + + void SetTau(float tau) + { + m_tau = tau; + } + + void SetDamping( float damping) + { + m_damping = damping; + } + + }; #endif //TOI_CONTACT_DISPATCHER_H diff --git a/extern/bullet/BulletDynamics/ConstraintSolver/ContactSolverInfo.h b/extern/bullet/BulletDynamics/ConstraintSolver/ContactSolverInfo.h index 83460771279..e262b1a599b 100644 --- a/extern/bullet/BulletDynamics/ConstraintSolver/ContactSolverInfo.h +++ b/extern/bullet/BulletDynamics/ConstraintSolver/ContactSolverInfo.h @@ -23,6 +23,7 @@ struct ContactSolverInfo m_restitution = 0.f; m_maxErrorReduction = 20.f; m_numIterations = 10; + m_sor = 1.3f; } float m_tau; @@ -32,7 +33,7 @@ struct ContactSolverInfo float m_restitution; int m_numIterations; float m_maxErrorReduction; - + float m_sor; }; diff --git a/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.cpp b/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.cpp index 37b3668bbf7..4050e75f90f 100644 --- a/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.cpp +++ b/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.cpp @@ -43,11 +43,13 @@ class BU_Joint; //see below +OdeConstraintSolver::OdeConstraintSolver(): +m_cfm(1e-5f), +m_erp(0.2f) +{ +} -int ConvertBody(RigidBody* body,RigidBody** bodies,int& numBodies); -void ConvertConstraint(PersistentManifold* manifold,BU_Joint** joints,int& numJoints, - RigidBody** bodies,int bodyId0,int bodyId1); @@ -59,8 +61,6 @@ float OdeConstraintSolver::SolveGroup(PersistentManifold** manifoldPtr, int numM m_CurBody = 0; m_CurJoint = 0; - float cfm = 1e-5f; - float erp = 0.2f; RigidBody* bodies [128]; @@ -82,7 +82,7 @@ float OdeConstraintSolver::SolveGroup(PersistentManifold** manifoldPtr, int numM } } - SolveInternal1(cfm,erp,bodies,numBodies,joints,numJoints,infoGlobal); + SolveInternal1(m_cfm,m_erp,bodies,numBodies,joints,numJoints,infoGlobal); return 0.f; diff --git a/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.h b/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.h index 354a444caa8..101f24867c5 100644 --- a/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.h +++ b/extern/bullet/BulletDynamics/ConstraintSolver/OdeConstraintSolver.h @@ -25,6 +25,9 @@ private: int m_CurBody; int m_CurJoint; + float m_cfm; + float m_erp; + int ConvertBody(RigidBody* body,RigidBody** bodies,int& numBodies); void ConvertConstraint(PersistentManifold* manifold,BU_Joint** joints,int& numJoints, @@ -32,10 +35,24 @@ private: public: + OdeConstraintSolver(); + virtual ~OdeConstraintSolver() {} virtual float SolveGroup(PersistentManifold** manifold,int numManifolds,const ContactSolverInfo& info,IDebugDraw* debugDrawer = 0); + ///setConstraintForceMixing, the cfm adds some positive value to the main diagonal + ///This can improve convergence (make matrix positive semidefinite), but it can make the simulation look more 'springy' + void setConstraintForceMixing(float cfm) { + m_cfm = cfm; + } + + ///setErrorReductionParamter sets the maximum amount of error reduction + ///which limits energy addition during penetration depth recovery + void setErrorReductionParamter(float erp) + { + m_erp = erp; + } }; diff --git a/extern/bullet/BulletDynamics/ConstraintSolver/SorLcp.cpp b/extern/bullet/BulletDynamics/ConstraintSolver/SorLcp.cpp index 700419f48b5..678536cd905 100644 --- a/extern/bullet/BulletDynamics/ConstraintSolver/SorLcp.cpp +++ b/extern/bullet/BulletDynamics/ConstraintSolver/SorLcp.cpp @@ -590,8 +590,8 @@ void SolveInternal1 (float global_cfm, const ContactSolverInfo& solverInfo) { - int numIter = 30; - float sOr = 1.3f; + int numIter = solverInfo.m_numIterations; + float sOr = solverInfo.m_sor; int i,j; @@ -756,7 +756,7 @@ void SolveInternal1 (float global_cfm, // scale CFM for (i=0; i