Why is "solverConstraint.m_jacDiagABInv" updated again?

lgchemer
Posts: 5
Joined: Fri Jan 20, 2012 11:28 pm
Location: Urbana, IL

Why is "solverConstraint.m_jacDiagABInv" updated again?

Post by lgchemer »

Hello. I am a newbie to Bullet physics, and please forgive my ignorance if this question looks silly.
In btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(...), solverConstraint.m_jacDiagABInv looks initialized first:
(This is the effective mass for calculating impulse, isn't it?
i.e., 1/ [J][M]^-1[J]^T, where [J] is Jacobian matrix.)

Code: Select all

btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(...) 
{
...
...

	btVector3 iMJlA = solverConstraint.m_contactNormal*rbA.getInvMass();
	btVector3 iMJaA = rbA.getInvInertiaTensorWorld()*solverConstraint.m_relpos1CrossNormal;
	btVector3 iMJlB = solverConstraint.m_contactNormal*rbB.getInvMass();//sign of normal?
	btVector3 iMJaB = rbB.getInvInertiaTensorWorld()*solverConstraint.m_relpos2CrossNormal;

	btScalar sum = iMJlA.dot(solverConstraint.m_contactNormal);
	sum += iMJaA.dot(solverConstraint.m_relpos1CrossNormal);
	sum += iMJlB.dot(solverConstraint.m_contactNormal);
	sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal);

	solverConstraint.m_jacDiagABInv = btScalar(1.)/sum;
...
...
	convertContact(manifold,infoGlobal);
}
However, I see it is updated again in setupContactConstraint(...) in convertContact(manifold,infoGlobal):

Code: Select all

void	btSequentialImpulseConstraintSolver::convertContact(...)
{
...
...
	setupContactConstraint(...);
...
...
}

Code: Select all

void btSequentialImpulseConstraintSolver::setupContactConstraint(...)
{
...
...
	if (rb0)
	{
		vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1);
		denom0 = rb0->getInvMass() + cp.m_normalWorldOnB.dot(vec);
	}
	if (rb1)
	{
		vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2);
		denom1 = rb1->getInvMass() + cp.m_normalWorldOnB.dot(vec);
	}

	btScalar denom = relaxation/(denom0+denom1);
	solverConstraint.m_jacDiagABInv = denom;
...
...
}
I am not sure why the effective mass (m_jacDiagABInv) is updated again.
What is the difference between these two?
Is there any one can shed some lights on me?

Thanks!!
User avatar
jarno
Posts: 57
Joined: Tue Mar 16, 2010 1:42 am

Re: Why is "solverConstraint.m_jacDiagABInv" updated again?

Post by jarno »

It's not updated again. They are two different sets of constraints.

There are three sets of constraints involved:
  • The contact constraints
  • The friction constraints
  • All other constraints (e.g. hinge, 6dof, point2point, etc.)
The ones set up in solveGroupCacheFriendlySetup() are the constraints from the 3rd category, while convertContact() sets up the contact constraints and friction constraints.

---JvdL---
lgchemer
Posts: 5
Joined: Fri Jan 20, 2012 11:28 pm
Location: Urbana, IL

Re: Why is "solverConstraint.m_jacDiagABInv" updated again?

Post by lgchemer »

Thanks much!
Now it makes sense.