Multiple collision shapes per body

fletschge
Posts: 6
Joined: Wed Aug 19, 2009 8:29 pm

Multiple collision shapes per body

Post by fletschge »

Hi guys,

I'm having a hard time figuring out how to attach multiple collision shapes to a single body. What I'd like to have is a concave shape (btBvhTriangleMeshShape) and a convex shape (btConvexHullShape) of the same original mesh at the same position. The concave shape is intended to collide with the 'player', a capsule-shaped body representing a camera. The convex shape is intended for a just approximate collision with other collision shapes (as btBvhTriangleMeshShape doesn't support collision and I prefer not using Gimpact for performance reasons).

What would be the easiest way to implement such a concept?

Thanks for your advices!
S.Lundmark
Posts: 50
Joined: Thu Jul 09, 2009 1:46 pm

Re: Multiple collision shapes per body

Post by S.Lundmark »

Hmm, why isn't btBvhTriangleMeshShape working for collision for you?

I would suggest using the btCompoundShape to be able to have both shapes for one object, although btBvhTriangleMeshShape should work for collision.

Cheers
/Simon
fletschge
Posts: 6
Joined: Wed Aug 19, 2009 8:29 pm

Re: Multiple collision shapes per body

Post by fletschge »

S.Lundmark wrote:Hmm, why isn't btBvhTriangleMeshShape working for collision for you?
Well collision works with a concave and a convex shape but not with two concave shapes (btBvhTriangleMeshShape), see here:
http://www.bulletphysics.com/Bullet/php ... 08&start=0


My problem is that I have multiple instances of that object, so I really need to collide two btBvhTriangleMeshShapes (or two btConvexHullShape).
S.Lundmark wrote: I would suggest using the btCompoundShape to be able to have both shapes for one object, although btBvhTriangleMeshShape should work for collision.
Sounds like a nice idea, but how do you make the player's capsule not collide with the convex shape? The convex shape is usually bigger than the concave, so it will most likely collide with the convex shape first.
fletschge
Posts: 6
Joined: Wed Aug 19, 2009 8:29 pm

Re: Multiple collision shapes per body

Post by fletschge »

After hours trying to setup collision shapes I found out that when using multiple collision shapes at the exact same position cause incredible performance issues when collisions occur.

That's why I decided to stick to Gimpact now.

However, I'm facing another problem: Is it possible that there is no collision between Gimpact and non-Gimpact shapes?
I.E.: Two Gimpact Shapes (btGImpactMeshShape) collide and behave good, but when colliding a btSphereShape or a btBoxShape for instance, no collision occurs. But: When I create a mesh of a sphere or box and load it into the scene via Gimpact like the other shapes, it collides. However this is not what I want, as I need a shape to be transparent/invisible...
S.Lundmark
Posts: 50
Joined: Thu Jul 09, 2009 1:46 pm

Re: Multiple collision shapes per body

Post by S.Lundmark »

I suggest that you use collision filtering to solve your problems, which is the "m_collisionFlags" set in the btCollisionObject. Look at the ConvexDecompositionDemo, I think you can deny contacts through such a callback. I'm not sure that this is what you want, otherwise I'd suggest implementing a collisionfiltering system into the solver that checks if two objects collide by simply comparing their set collision filters. That way you can use a certain amount of bits to provide filters (if two objects are within the same filter-level, they collide - otherwise they don't), and the rest of the bits to have an id that you can use for object-objects filtering.

I hope that this helps!

Best regards,
Simon.