Some optimizations for btMultiBodyJointMotor (skip constraint generation if maxImpulse/maxForce = 0) and

skip constraint row generation if joint limit is not violated.
This commit is contained in:
Erwin Coumans 2017-05-08 09:06:39 -07:00
parent 6767b986d0
commit a69442d119
2 changed files with 11 additions and 2 deletions

View File

@ -110,7 +110,13 @@ void btMultiBodyJointLimitConstraint::createConstraintRows(btMultiBodyConstraint
for (int row=0;row<getNumRows();row++) for (int row=0;row<getNumRows();row++)
{ {
btScalar penetration = getPosition(row);
//todo: consider adding some safety threshold here
if (penetration>0)
{
continue;
}
btScalar direction = row? -1 : 1; btScalar direction = row? -1 : 1;
btMultiBodySolverConstraint& constraintRow = constraintRows.expandNonInitializing(); btMultiBodySolverConstraint& constraintRow = constraintRows.expandNonInitializing();
@ -158,7 +164,7 @@ void btMultiBodyJointLimitConstraint::createConstraintRows(btMultiBodyConstraint
} }
{ {
btScalar penetration = getPosition(row);
btScalar positionalError = 0.f; btScalar positionalError = 0.f;
btScalar velocityError = - rel_vel;// * damping; btScalar velocityError = - rel_vel;// * damping;
btScalar erp = infoGlobal.m_erp2; btScalar erp = infoGlobal.m_erp2;

View File

@ -117,6 +117,9 @@ void btMultiBodyJointMotor::createConstraintRows(btMultiBodyConstraintArray& con
if (m_numDofsFinalized != m_jacSizeBoth) if (m_numDofsFinalized != m_jacSizeBoth)
return; return;
if (m_maxAppliedImpulse==0.f)
return;
const btScalar posError = 0; const btScalar posError = 0;
const btVector3 dummy(0, 0, 0); const btVector3 dummy(0, 0, 0);