diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2013-12-26 15:41:52 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2013-12-26 15:45:57 +0400 |
commit | 05eebf49d3c3af47bf157207b82cf559ac1fe274 (patch) | |
tree | d1f82266237e929e6cc19aac3dd001a32ee7d052 /extern/bullet2/src/BulletDynamics/MLCPSolvers | |
parent | 709041ed0b7e1848068c9d53543ed114229a9f5b (diff) |
Bullet: Update to svn r2719
Fixes part of T37905, fixed constraint didn't work correctly.
Diffstat (limited to 'extern/bullet2/src/BulletDynamics/MLCPSolvers')
3 files changed, 33 insertions, 11 deletions
diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp index 8888d3961f5..0635b958bed 100644 --- a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp +++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp @@ -19,9 +19,11 @@ subject to the following restrictions: #include "LinearMath/btQuickprof.h" #include "btSolveProjectedGaussSeidel.h" + btMLCPSolver::btMLCPSolver( btMLCPSolverInterface* solver) :m_solver(solver), -m_fallback(0) +m_fallback(0), +m_cfm(0.000001)//0.0000001 { } @@ -160,13 +162,17 @@ void btMLCPSolver::createMLCPFast(const btContactSolverInfo& infoGlobal) BT_PROFILE("init b (rhs)"); m_b.resize(numConstraintRows); m_bSplit.resize(numConstraintRows); - //m_b.setZero(); + m_b.setZero(); + m_bSplit.setZero(); for (int i=0;i<numConstraintRows ;i++) { - if (m_allConstraintArray[i].m_jacDiagABInv) + btScalar jacDiag = m_allConstraintArray[i].m_jacDiagABInv; + if (!btFuzzyZero(jacDiag)) { - m_b[i]=m_allConstraintArray[i].m_rhs/m_allConstraintArray[i].m_jacDiagABInv; - m_bSplit[i] = m_allConstraintArray[i].m_rhsPenetration/m_allConstraintArray[i].m_jacDiagABInv; + btScalar rhs = m_allConstraintArray[i].m_rhs; + btScalar rhsPenetration = m_allConstraintArray[i].m_rhsPenetration; + m_b[i]=rhs/jacDiag; + m_bSplit[i] = rhsPenetration/jacDiag; } } @@ -425,14 +431,12 @@ void btMLCPSolver::createMLCPFast(const btContactSolverInfo& infoGlobal) } } - ///todo: use proper cfm values from the constraints (getInfo2) if (1) { // add cfm to the diagonal of m_A for ( int i=0; i<m_A.rows(); ++i) { - float cfm = 0.00001f; - m_A.setElem(i,i,m_A(i,i)+ cfm / infoGlobal.m_timeStep); + m_A.setElem(i,i,m_A(i,i)+ m_cfm / infoGlobal.m_timeStep); } } @@ -473,6 +477,9 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal) if (infoGlobal.m_splitImpulse) m_bSplit.resize(numConstraintRows); + m_bSplit.setZero(); + m_b.setZero(); + for (int i=0;i<numConstraintRows ;i++) { if (m_allConstraintArray[i].m_jacDiagABInv) @@ -554,12 +561,10 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal) if (1) { - ///todo: use proper cfm values from the constraints (getInfo2) // add cfm to the diagonal of m_A for ( int i=0; i<m_A.rows(); ++i) { - float cfm = 0.0001f; - m_A.setElem(i,i,m_A(i,i)+ cfm / infoGlobal.m_timeStep); + m_A.setElem(i,i,m_A(i,i)+ m_cfm / infoGlobal.m_timeStep); } } @@ -618,6 +623,7 @@ btScalar btMLCPSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bod } else { + // printf("m_fallback = %d\n",m_fallback); m_fallback++; btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer); } diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h index a5dae2d28f6..31e8eb88ba5 100644 --- a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h +++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h @@ -42,6 +42,7 @@ protected: btConstraintArray m_allConstraintArray; btMLCPSolverInterface* m_solver; int m_fallback; + btScalar m_cfm; virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); @@ -70,6 +71,15 @@ public: m_fallback = num; } + btScalar getCfm() const + { + return m_cfm; + } + void setCfm(btScalar cfm) + { + m_cfm = cfm; + } + virtual btConstraintSolverType getSolverType() const { return BT_MLCP_SOLVER; diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h index 44fbfeadddc..d2ad54d21a8 100644 --- a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h +++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h @@ -20,11 +20,17 @@ subject to the following restrictions: #include "btMLCPSolverInterface.h" +///This solver is mainly for debug/learning purposes: it is functionally equivalent to the btSequentialImpulseConstraintSolver solver, but much slower (it builds the full LCP matrix) class btSolveProjectedGaussSeidel : public btMLCPSolverInterface { public: virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray<int>& limitDependency, int numIterations, bool useSparsity = true) { + if (!A.rows()) + return true; + //the A matrix is sparse, so compute the non-zero elements + A.rowComputeNonZeroElements(); + //A is a m-n matrix, m rows, n columns btAssert(A.rows() == b.rows()); |