Single-sided collision response with btBvhTriangleMeshShapes

Post Reply
David20321
Posts: 17
Joined: Sat Mar 13, 2010 10:08 pm

Single-sided collision response with btBvhTriangleMeshShapes

Post by David20321 »

When a rigid body collides with a btBvhTriangleMesh shape, the collision response seems to ignore the orientation of the triangle face (i.e. clockwise or counter-clockwise), and instead, determine which direction to move based on whichever side is closer. This means that if a sphere of diameter 1 is penetrating a btBvhTriangleMesh with depth greater than 0.5, the collision response will push it all the way into the mesh and keep it trapped there. Similarly, if an articulated system like a ragdoll collides with the btBvhTriangleMesh, some of the parts could be pushed inwards while the others are pushed outwards, resulting in an unfixable situation in which the system is stuck halfway into the mesh -- for example, a character's legs might be stuck in the mesh, while the torso is outside.

To fix this, we can use the orientation of each triangle face to determine which direction is 'out' regardless of which one is closer. This way, even if a sphere of diameter 1 is penetrating a wall to a depth of 0.99, it would be correctly pushed out. Similarly, a ragdoll could never be stuck half-in and half-out -- the penetrating bodies would collide with the surface and be pushed out in the correct direction.

Is there any way to enable this kind of behavior? This was the default triangle mesh collision response in ODE, and seems like it must at least be an option in Bullet.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Single-sided collision response with btBvhTriangleMeshShapes

Post by Erwin Coumans »

We use double sided triangle meshes by default in Bullet. It would be possible to use single-sided meshes. You can adjust the contact normal in the contact callback, and use the triangle normal.

The internal edge utility can help towards this (see Bullet/Demos/InternalEdgeDemo). Currently it only adjusts the contact normal for contacts close to an edge, but you can adjust it so it corrects all contacts with the mesh.
Please ask if you need more details. I filed a feature request, so at some stage we will create a demo how to do this: http://code.google.com/p/bullet/issues/detail?id=367
Thanks,
Erwin
David20321
Posts: 17
Joined: Sat Mar 13, 2010 10:08 pm

Re: Single-sided collision response with btBvhTriangleMeshShapes

Post by David20321 »

Thanks for the advice! To the end of btAdjustInternalEdgeContacts() I added:

Code: Select all

cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis()*tri_normal;
And now it gives a single-sided collision response.
Post Reply