contactPairTest problem with object inside another object

Post Reply
Enrico Cappelletto
Posts: 1
Joined: Mon Mar 11, 2019 3:20 pm

contactPairTest problem with object inside another object

Post by Enrico Cappelletto » Tue Mar 12, 2019 3:10 pm

Hey guys!
I am quite new to the Bullet library and I have a problem trying detect if an object in inside another one!

If two solids are partially overlapped the method finds correctly the collision, whereas if one of them is completely inside the other one the callback addSingleResult is never called.

What am I missing??
Any help would be appreciated.


BulletContactResultCallback resultCallback;
m_pCollisionWorld->contactPairTest(pSolidA->m_pBulletObject, pSolidB->m_pBulletObject, resultCallback);
struct BulletContactResultCallback : public btCollisionWorld::ContactResultCallback
bool bCollisionFound;
double aBBox[6];

bCollisionFound = false;
aBBox[0] = aBBox[1] = aBBox[2] = DBL_MAX;
aBBox[3] = aBBox[4] = aBBox[5] = -DBL_MAX;

virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper * colObj1Wrap, int partId1, int index1)
aBBox[0] = min(cp.getPositionWorldOnA().x(), aBBox[0]);
aBBox[1] = min(cp.getPositionWorldOnA().y(), aBBox[1]);
aBBox[2] = min(cp.getPositionWorldOnA().z(), aBBox[2]);
aBBox[3] = max(cp.getPositionWorldOnA().x(), aBBox[3]);
aBBox[4] = max(cp.getPositionWorldOnA().y(), aBBox[4]);
aBBox[5] = max(cp.getPositionWorldOnA().z(), aBBox[5]);

aBBox[0] = min(cp.getPositionWorldOnB().x(), aBBox[0]);
aBBox[1] = min(cp.getPositionWorldOnB().y(), aBBox[1]);
aBBox[2] = min(cp.getPositionWorldOnB().z(), aBBox[2]);
aBBox[3] = max(cp.getPositionWorldOnB().x(), aBBox[3]);
aBBox[4] = max(cp.getPositionWorldOnB().y(), aBBox[4]);
aBBox[5] = max(cp.getPositionWorldOnB().z(), aBBox[5]);

bCollisionFound = true;
return 1;

User avatar
Posts: 489
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: contactPairTest problem with object inside another object

Post by drleviathan » Tue Mar 19, 2019 4:14 pm

The ContactResultCallback::addSingleResult() is only called when an actual ManifoldContactPoint is added to the ContactManifold. Therefore it must be the case that no points are being added when one object is completely inside the other.

What btCollisionShape are you using for the outer btCollisionObject? If it is one of the btConcaveShapes then I wouldn't be surprised that no points are being added, however if it were a btConvexShape I would expect to get some points in the manifold.

Post Reply