Hi,
I want to check collision/penetration depth between 5 (convex & concave) triangle meshes that move a bit now and then, and have tried various ways to do this.
(It's mechanical system that needs collision protection, so I figured that using enlarged 3d-models and a physics engine/collision detection library would be a good thing. I only need discrete checks, not continous detection.)
What I do is to change the WorldTransform of these objects, step the simulation, then check for collision pairs from the CollisionDispatcher's manifold.
In my code I create either btGImpactMeshShape or btBvhTriangleMeshShape for each mesh, and they look ok in when viewed via the DebugDrawer, but I'm not getting any collisions. If I use btSphereShape:s, I get collisions.
Related, I just found http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=4359 which says that TriangleMeshes don't support dynamic objects.
Am I using the wrong approach, or is it something subtle that needs doing?
Using Bullet to test collision between triangle meshes
-
- Posts: 6
- Joined: Fri Jan 15, 2010 8:57 am
- Location: Gothenburg, Sweden
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Using Bullet to test collision between triangle meshes
There is no 'TriangleMesh' in Bullet, so we need to be more precise and use the class names.
If you want to detect collisions between concave triangle meshes, it is best to either approximate them using convex decomposition, for example creating several btConvexHullShape and store them into a btCompoundShape. See Bullet/Demos/ConvexDecompositionDemo. Alternatively, you can use a btGImpactMeshShape, but not as child of a btCompoundShape.
For static, non-moving triangle meshes you can use btBvhTriangleMeshShape, but there is no collision between static (non-moving) btBvhTriangleMeshShapes. Collisions are detected between a btBvhTriangleMeshShape and a btGImpactMeshShape..
If you want to detect collisions between concave triangle meshes, it is best to either approximate them using convex decomposition, for example creating several btConvexHullShape and store them into a btCompoundShape. See Bullet/Demos/ConvexDecompositionDemo. Alternatively, you can use a btGImpactMeshShape, but not as child of a btCompoundShape.
For static, non-moving triangle meshes you can use btBvhTriangleMeshShape, but there is no collision between static (non-moving) btBvhTriangleMeshShapes. Collisions are detected between a btBvhTriangleMeshShape and a btGImpactMeshShape..
-
- Posts: 6
- Joined: Fri Jan 15, 2010 8:57 am
- Location: Gothenburg, Sweden
Re: Using Bullet to test collision between triangle meshes
Thanks for replying!
By "TriangleMesh" I was referring to any type of triangle-soup-supporting btCollisionShape (i.e. btBvhTriangleMeshShape and btGImpactMeshShape)-
Do I understand you right that there are no collisions between btBvhTriangleMeshShape:s and btBvhTriangleMeshShape:s, nor between btGImpactMeshShape:s and btGImpactMeshShape:s, but only between objects of different types, i.e. btGImpactMeshShape:s and btBvhTriangleMeshShape:s, where the bvh-shape is static?
If I can get this to work, I'll try to add a tutorial to the wiki, since it seems a basic yet non-trivial issue.(at least for new users, like myself).
By "TriangleMesh" I was referring to any type of triangle-soup-supporting btCollisionShape (i.e. btBvhTriangleMeshShape and btGImpactMeshShape)-
Do I understand you right that there are no collisions between btBvhTriangleMeshShape:s and btBvhTriangleMeshShape:s, nor between btGImpactMeshShape:s and btGImpactMeshShape:s, but only between objects of different types, i.e. btGImpactMeshShape:s and btBvhTriangleMeshShape:s, where the bvh-shape is static?
If I can get this to work, I'll try to add a tutorial to the wiki, since it seems a basic yet non-trivial issue.(at least for new users, like myself).
-
- Posts: 6
- Joined: Fri Jan 15, 2010 8:57 am
- Location: Gothenburg, Sweden
Re: Using Bullet to test collision between triangle meshes
I solved it by using btBoxShape for the boxy stuff. I won't need btGImpactMeshShape as much as I thought.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Using Bullet to test collision between triangle meshes
This is not correct. Generally there are collision detection routines between all collision types, even if the types are the same, except for a few (static) exceptions such as btStaticPlaneShape and btBvhTriangleMeshShape. There is collision detection between btGImpactMeshShape and btGImpactMeshShape.marcusl wrote: Do I understand you right that there are no collisions between btBvhTriangleMeshShape:s and btBvhTriangleMeshShape:s, nor between btGImpactMeshShape:s and btGImpactMeshShape:s, but only between objects of different types, i.e. btGImpactMeshShape:s and btBvhTriangleMeshShape:s, where the bvh-shape is static?
Thanks,
Erwin
-
- Posts: 6
- Joined: Fri Jan 15, 2010 8:57 am
- Location: Gothenburg, Sweden
Re: Using Bullet to test collision between triangle meshes
Ok. Thanks! I just wanted to make things absolutely clear. 

-
- Posts: 6
- Joined: Fri Jan 15, 2010 8:57 am
- Location: Gothenburg, Sweden
Re: Using Bullet to test collision between triangle meshes
I solved this a few weeks ago (as we needed to fix mesh-mesh collisions). I had forgotten to register the GImpactCollisionAlgorithm:
This is necessary or it won't work.
Code: Select all
btGImpactCollisionAlgorithm::registerAlgorithm(&m_collision_dispatcher);