From 42548371707e05dec7b562a5994bf94aff9564c2 Mon Sep 17 00:00:00 2001 From: Lunkhound Date: Sat, 12 May 2018 19:54:39 -0700 Subject: [PATCH] solvers: remove erroneous 'break' statement that can occur with incorrectly flagged objects; also added asserts to warn when incorrectly flagged objects are detected --- .../btSequentialImpulseConstraintSolver.cpp | 2 ++ .../btSequentialImpulseConstraintSolverMt.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp index 24db9567e..9ef7e89d8 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp @@ -780,6 +780,8 @@ int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& } else { + // Incorrectly set collision object flags can degrade performance in various ways. + btAssert( body.isStaticOrKinematicObject() ); // all fixed bodies (inf mass) get mapped to a single solver id if ( m_fixedBodyId < 0 ) { diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp index 6fe068aac..4306c37e4 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp @@ -422,9 +422,10 @@ void btSequentialImpulseConstraintSolverMt::internalCollectContactManifoldCached btSolverBody* solverBodyA = &m_tmpSolverBodyPool[ solverBodyIdA ]; btSolverBody* solverBodyB = &m_tmpSolverBodyPool[ solverBodyIdB ]; - ///avoid collision response between two static objects - if ( solverBodyA->m_invMass.fuzzyZero() && solverBodyB->m_invMass.fuzzyZero() ) - break; + // A contact manifold between 2 static object should not exist! + // check the collision flags of your objects if this assert fires. + // Incorrectly set collision object flags can degrade performance in various ways. + btAssert( !m_tmpSolverBodyPool[ solverBodyIdA ].m_invMass.isZero() || !m_tmpSolverBodyPool[ solverBodyIdB ].m_invMass.isZero() ); int iContact = 0; for ( int j = 0; j < manifold->getNumContacts(); j++ )