btSequentialImpulseConstraintSolver, SOLVER_CACHE_FRIENDLY

User avatar
mirat
Posts: 16
Joined: Thu May 29, 2008 10:47 am

btSequentialImpulseConstraintSolver, SOLVER_CACHE_FRIENDLY

Post by mirat »

Hello!

btSequentialImpulseConstraintSolver with switched SOLVER_CACHE_FRIENDLY on doesn't use my own solver functions set by the setContactSolverFunc(). Is this a bug or a feature? :)

I use bullet 2.68.
User avatar
mirat
Posts: 16
Joined: Thu May 29, 2008 10:47 am

Re: btSequentialImpulseConstraintSolver, SOLVER_CACHE_FRIENDLY

Post by mirat »

btSequentialImpulseConstraintSolver has internal tables m_contactDispatch and m_frictionDispatch, which filled by pointers to resolveSingleCollision and resolveSingleFriction functions by default.

I'm trying to make btSequentialImpulseConstraintSolver use my own solver functions because I want to handle contacts and need to know what impulse objects took in contact/friction.

Replacing entries in m_contactDispatch and m_frictionDispatch tables by the pointers to my functions works fine, solveGroup() calls my functions to handle contacts:

line 1373 of btSequentialImpulseConstraintSolver.cpp:

Code: Select all

				{

					btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData;
					btScalar impulse = cpd->m_contactSolverFunc(   // <-- here it looks up in the table
						*body0,*body1,
						cp,
						info);

					if (maxImpulse < impulse)
						maxImpulse  = impulse;

				}
But when solver in SOLVER_CACHE_FRIENDLY mode, solveGroup function calls to solveGroupCacheFriendly which calls to hard coded resolveSingleCollisionCombinedCacheFriendly function (not table entry).

lines 923 and 937 of btSequentialImpulseConstraintSolver.cpp:

Code: Select all

btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** /*bodies */,int /*numBodies*/,btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* /*debugDrawer*/,btStackAlloc* /*stackAlloc*/)
{
....
				for (j=0;j<numPoolConstraints;j++)
				{
					
					const btSolverConstraint& solveManifold = m_tmpSolverConstraintPool[m_orderTmpConstraintPool[j]];
					resolveSingleCollisionCombinedCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
						m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal); // <-- here
				}

...

				 for (j=0;j<numFrictionPoolConstraints;j++)
				{
					const btSolverConstraint& solveManifold = m_tmpSolverFrictionConstraintPool[m_orderFrictionConstraintPool[j]];
					btScalar totalImpulse = m_tmpSolverConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse+
								m_tmpSolverConstraintPool[solveManifold.m_frictionIndex].m_appliedPushImpulse;			

						resolveSingleFrictionCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
							m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal,
							totalImpulse); // <-- and here
				}
...
Will it be fixed or changing the solver functions is not the best way of contacts handling ? I need only some callback to process contacts in standard way with grabbing information about affected impulse.