In the following code (from btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup)...
Code: Select all
if (colObj0->getIslandTag() >= 0)
{
if (colObj0->getCompanionId() >= 0)
{
//body has already been converted
solverBodyIdA = colObj0->getCompanionId();
} else
{
solverBodyIdA = m_tmpSolverBodyPool.size();
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
initSolverBody(&solverBody,colObj0);
colObj0->setCompanionId(solverBodyIdA);
}
} else
{
//create a static body
solverBodyIdA = m_tmpSolverBodyPool.size();
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
initSolverBody(&solverBody,colObj0);
}
However, all the solver bodies write back to the body that they represent, at the end of the constraint solver. So if there was any meaningful data in the solver bodies for these objects, the last one would 'win'. On the other hand, since these objects (static objects, at least) have zero mass and a zero inertia tensor, their velocities shouldn't have been changed during the constraint solver anyway. Maybe the situation is different for kinematic objects?
I'd like to make a change such that every body gets a single solver body, and everything works on these solver bodies including all the non-contact/friction constraints. This will save various writing to/from bodies and solver bodies. Based on the above it should also reduce the size of the solver body array most of the time, and improve performance in that way too.
I just need to understand whether this is some subtle reason for the behaviour of the above code
EDIT: Is the issue simply that because 'm_companionId' isn't cleared on a per-island basis, but the objects in question span multiple islands? (The issue if you're solving islands on different threads is more serious!).
Many thanks,
Rob