btConvexTriangleMeshShape Problem

GLPhysx
Posts: 14
Joined: Sat Nov 28, 2009 11:28 pm

btConvexTriangleMeshShape Problem

Post by GLPhysx »

I am trying to use btConvexTriangleMeshShape with a shape like a "+", It work and interact with the world but when I create a sphere and want that sphere to fall in one of corner of this "+" that's when I realize that the btConvexTriangleMeshShape boundaries seems to have been "optimized" for something that appears to be like a cube and does not behave properly, the sphere seems to float on top of the "+" but never drop into a corner.

I can see when I debug draw that all the shape and all triangles are entered properly. And if I change the type of the btConvexTriangleMeshShape for btBvhTriangleMeshShape (and put the mass to 0.0f) now the sphere is able to get stuck in the "+" corner but of course my "+" is not influenced by gravity and stay static. And if I use btBvhTriangleMeshShape with a mass it does not collide with the ground that is also a btBvhTriangleMeshShape.

Basically I base myself on the Blender game engine, and in Blender this behavior is working properly. When I create my "+" shape (a Rigid Body, Triangle Mesh) in Blender and the sphere, and test it with the game engine the "+" fall down and hit the ground (a Static, Triangle Mesh) the sphere fall down and get stuck in one of the "+" corner (which is exactly what I want).

Blender must use btConvexTriangleMeshShape with rigid body no? I try to dig in the code but coudn't find anything relevant... it seems that they are using btBvhTriangleMeshShape, but btBvhTriangleMeshShape cannot collide with another btBvhTriangleMeshShape, so Im confused...

Am I missing something or? What is the method that Blender is using to handle rigid body triangle mesh?
GLPhysx
Posts: 14
Joined: Sat Nov 28, 2009 11:28 pm

Re: btConvexTriangleMeshShape Problem

Post by GLPhysx »

Ok my bad... I simply switch for btGImpactMeshShape and register:

btGImpactCollisionAlgorithm::registerAlgorithm( btCollisionDispatcher );
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: btConvexTriangleMeshShape Problem

Post by Flix »

GLPhysx wrote:
I am trying to use btConvexTriangleMeshShape with a shape like a "+"
[...]
I simply switch for btGImpactMeshShape
Well, of course, btBvhTriangleMeshShape is the best solution for (both convex and concave) static triangle meshes and if you need dynamic concave triangle meshes you must use "convex decomposition" , i.e. convex child shapes in a btCompoundShape or use GImpact (btGImpactMeshShape concave dynamic shapes as you've done or a similiar GImpact "decomposed" compound shape (I don't remember its name right now)).

For such a simple shape ( a '+' ), you could very easily create a btCompoundShape with two boxes instead of using a btGImpactMeshShape:

Code: Select all

[code]
btCompoundShape* cs = new btCoumpoundShape();
btBoxShape* bs = new btBoxShape(btVector3(2.0,0.4,0.4));
cs->addChildShape(btTransform(btQuaternion(btVector3(0,0,1),SIMD_HALF_PI),btVector3(0,0,0)),bs);
cs->addChildShape(btTransform(btQuaternion::getIdentity(),btVector3(0,0,0)),bs);
The reason is that convex decomposed shapes should more likely perform better than btGImpactMeshShape.

Hope it helps.