Basically, the meshes are visibly in collision according to the DebugDrawer, but no collisions seem to be generated (neither via the DebugDrawer or by iterating over the ContactManifolds as suggested on various posts and in CollisionInterfaceDemo). Specifically, a call to getNumManifolds() from the dispacther returns 0 (similar to post 7 in this topic: http://www.bulletphysics.org/Bullet/php ... 26&start=0), even though the broadphase (btDbvtBroadphase) algorithm reports there are 4 overlapping pairs with a call to getNumOverlappingPairs(). As I understand it, there should always be a btPersistentManifold for each overlapping pair. Is this not the case?
I feel like I'm probably missing something basic, but I can't figure out what it is...
Here's my pertinent "world building" code:
Code: Select all
//CD stuff
btDefaultCollisionConfiguration* colConfig = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(colConfig);
btBroadphaseInterface* broadphase = new btDbvtBroadphase();
btCollisionWorld* world = new btCollisionWorld(dispatcher, broadphase, colConfig);
//arrays for keeping mesh data, shapes, and collision objects
btAlignedObjectArray<btCollisionObject*> armCollObjs;
btAlignedObjectArray<btBvhTriangleMeshShape*> armTriMeshShapes;
btAlignedObjectArray<btTriangleMesh*> armTriMeshes;
//how above arrays are filled (bt is a pointer to a class I made to encapsulate Bullet related functions and variables)
//loop through mesh data imported from Panda3d, calling addTriangle() on armTriMeshes
bt->armTriMeshShapes.push_back(new btBvhTriangleMeshShape(bt->armTriMeshes[i], true));
bt->armCollObjs.push_back(new btCollisionObject());
bt->armCollObjs[i]->setCollisionShape(bt->armTriMeshShapes[i]);
bt->world->addCollisionObject(bt->armCollObjs[i]);
Now for the collision detection:
Code: Select all
bt->world->performDiscreteCollisionDetection();
btOverlappingPairCache* overlap = broadphase->getOverlappingPairCache(); //<------this returns 4, as expected
printf("num overlaps: %d\n", overlap->getNumOverlappingPairs());
int numManifolds = bt->world->getDispatcher()->getNumManifolds(); //<-------this returns 0!
printf("num manifolds: %d\n", numManifolds);
for (int i=0;i<numManifolds;i++) // borrowed directly from CollisionInterfaceDemo
{
btPersistentManifold* contactManifold = bt->world->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0()); //separate note: why are these here?
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
int numContacts = contactManifold->getNumContacts();
printf("num contacts: %d\n", numContacts);
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
printf("ptA: %f, %f, %f\n", ptA.x(),ptA.y(),ptA.z());
printf("ptB: %f, %f, %f\n", ptB.x(),ptB.y(),ptB.z());
}
//you can un-comment out this line, and then all points are removed
//contactManifold->clearManifold();
}
bt->world->debugDrawWorld();
Thanks for any help anyone can provide.
On a side note, does the feature request of positive distance for concave objects mentioned here (http://www.bulletphysics.org/Bullet/php ... 47&p=18791) have any ETA? It would eventually be very useful for collision avoidance!