Help with btBvhTriangleMeshShape and convex shapes

nnattam
Posts: 2
Joined: Sun Nov 23, 2008 8:03 pm

Help with btBvhTriangleMeshShape and convex shapes

Post by nnattam »

Hello all! I just recently (as of yesterday) got into Bullet Physics to use with my hobbyist project (throwing out my old collision code) and right now I'm trying to just use the Collision Library with no dynamics.

Right now I have a concave shape and want to know contact information (enough to separate it) from a static triangle mesh. As of this point, I am able to handle contacts between concave shapes pretty easily (using a penetration depth solver) but not with the triangle mesh.

After creating the btBvhTriangleMeshShape and applying it to a btCollisionObject, I add it to the world. So this is what my chunk of code looks like when I'm searching for collision information between concave and convex (in this example there are only two objects in the world, a convex and concave):

Code: Select all

	
        pColWorld->performDiscreteCollisionDetection();

	// get the number of manifolds (contact sets) that occured
	const int numManifolds = Locals.pColWorld->getDispatcher()->getNumManifolds();
	for (int i(0); i < numManifolds; ++i)
	{
		// get the manifold
		btPersistentManifold *pManifold = pColWorld->getDispatcher()->getManifoldByIndexInternal(i);

		// get collision objects
		btCollisionObject *pColBodyA = static_cast<btCollisionObject*>(pManifold->getBody0());
		btCollisionObject *pColBodyB = static_cast<btCollisionObject*>(pManifold->getBody1());
	
		int numPoints = pManifold->getNumContacts();

		if (!pColBodyA->getUserPointer() || !pColBodyB->getUserPointer())
		{
			btCollisionAlgorithm *pAlgo = 
				Locals.pColWorld->getDispatcher()->findAlgorithm(pColBodyA, pColBodyB, pManifold);
			btManifoldResult result(pColBodyA, pColBodyB);
			pAlgo->processCollision(pColBodyA, pColBodyB, Locals.pColWorld->getDispatchInfo(),
				&result);
		}
So what I am trying to do is figure out enough information to separate the convex shape from the static shape. This code here will (once the convex shape touches the static concave) will cause the app to come to a crawl. I am pretty sure I'm approaching this the wrong way and I've tried to look at some tutorials but a lot of them involve using the dynamics world.

So looking for any help on how to approach this.
nnattam
Posts: 2
Joined: Sun Nov 23, 2008 8:03 pm

Re: Help with btBvhTriangleMeshShape and convex shapes

Post by nnattam »

Ha! I stumbled on the callbacks and got those working. Have some kinks to figure out but on the right track now. So please ignore this thread.