Low-level test for a box and trimesh collision

venzon
Posts: 12
Joined: Mon Nov 26, 2007 2:42 am

Low-level test for a box and trimesh collision

Post by venzon »

I'd like to use some of bullet's lower level collision detection functions to collide a box shape (btBoxShape) with a trimesh shape (btBvhTriangleMeshShape). In the demo called "CollisionDemo", a box-to-box collision is done, but the functions/classes used seem specific to convex-convex collision. What should I use to do the convex-concave (box-trimesh) collision test?

Alternately, by looking in the btCollisionWorld::performDiscreteCollisionDetection implementation, I thought I might be able to create my own btOverlappingPairCache that just has the box and trimesh I'm interested in, and then do something like:

Code: Select all

my_bt_collision_world->getDispatcher()->dispatchAllCollisionPairs(my_pair_cache,getDispatchInfo());
This would allow me to use my already existing handler logic for looking at the collision manifolds.

Do either of these ideas sound like the Right Way to do this?
venzon
Posts: 12
Joined: Mon Nov 26, 2007 2:42 am

Re: Low-level test for a box and trimesh collision

Post by venzon »

I ended up going the latter route and it works fine. The only wrinkle is that I had to manually remove (release) all of the manifolds once I was done with them.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Low-level test for a box and trimesh collision

Post by Erwin Coumans »

What should I use to do the convex-concave (box-trimesh) collision test?
You need to use the btConvexConcaveCollisionAlgorithm::processCollision.

One low level way of doing this (given collision objects for boxshape and trimesh shape):
Use the dispatcher to find/create the collision algorithm (btConvexConcaveCollisionAlgorithm) and call algorithm->processCollision. See void btCollisionDispatcher::defaultNearCallback for details.

Thanks,
Erwin