I see that when a capsule collide with a scaled cylinder, the distance1 in btPersistentManifold is erroneous.
In btGjkPairDetector::getClosestPointsNonVirtual, before call output.addContactPoint, the data is computed correctly, but in btManifoldResult::addContactPoint, the localA and localB are wrong computed because is used btTransform::invXform function that uses transpose matrix, not real inverse matrix (in no scale matrix, transpose==inverse). Then, when btManifoldResult::refreshContactPoints is called later, m_positionWorldOnA, m_positionWorldOnB and distance1 are updated, the result is wrong by the error in m_localPointA or m_localPointB computed.
I think the solution would be something like:
Code: Select all
btMatrix3x3 inv;
// Do this because btTransform::inverse uses transpose instead of real inverse too
inv= m_rootTransA.getBasis().inverse();
btTransform transInvA(inv, inv * -m_rootTransA.getOrigin());
inv= m_rootTransB.getBasis().inverse();
btTransform transInvB(inv, inv * -m_rootTransB.getOrigin());
if (isSwapped)
{
localA = transInvB(pointA);
localB = transInvA(pointInWorld);
// localA = m_rootTransB.invXform(pointA );
// localB = m_rootTransA.invXform(pointInWorld);
} else
{
localA = transInvA(pointA);
localB = transInvB(pointInWorld);
// localA = m_rootTransA.invXform(pointA );
// localB = m_rootTransB.invXform(pointInWorld);
}