rigid body exploded out when I use btGImpactMeshShape

absifreei
Posts: 6
Joined: Sat Oct 23, 2010 7:58 am

rigid body exploded out when I use btGImpactMeshShape

Post by absifreei »

hello world: :)
At first I must say I am new to bullet, and I am testing on bullet solver for houdini in DOP at the moment, and my problem is:
1) when I build rigid body using btGImpactMeshShape, and all rigid bodies have no gaps between each other, when simulation start, the bodies will explode out, below is my code:

Code: Select all

// concave collision shape
btGImpactMeshShape *impactShape = new btGImpactMeshShape(indexVertexArray); 
impactShape->updateBound();
fallShape = impactShape;
btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>
(state->m_dynamicsWorld ->getDispatcher());
btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
2) then I tried build rigid body using btConvexTriangleMeshShape, everything is ok, but if there are some concave shapes like broken woods, they will explode out again, so how can I solve this problem . :roll:
anyone could help me?
User avatar
dotsquid
Posts: 22
Joined: Fri Jan 14, 2011 7:10 pm
Location: Ukraine

Re: rigid body exploded out when I use btGImpactMeshShape

Post by dotsquid »

Hi!
I have a quite similar problem. I create a torus with btGImpactMeshShape and drop it on a static (mass == 0) cube.
When the torus touches the cube, it bounces with too high force. And that happens again and again and again for every collision. It never stops.

I've tried to set margin = 0.05f. But that did no help at all. As well as commenting / uncommenting #define BULLET_TRIANGLE_COLLISION 1 in btGImpactCollisionAlgorithm.h

Any ideas?
absifreei
Posts: 6
Joined: Sat Oct 23, 2010 7:58 am

Re: rigid body exploded out when I use btGImpactMeshShape

Post by absifreei »

dotsquid wrote:Hi!
I have a quite similar problem. I create a torus with btGImpactMeshShape and drop it on a static (mass == 0) cube.
When the torus touches the cube, it bounces with too high force. And that happens again and again and again for every collision. It never stops.

I've tried to set margin = 0.05f. But that did no help at all. As well as commenting / uncommenting #define BULLET_TRIANGLE_COLLISION 1 in btGImpactCollisionAlgorithm.h

Any ideas?
Did you test it in bullet or other 3d program, I did same simple test in houdini, everything was ok, so I have no idea what's wrong with your code, sorry!
Maybe you can paste your codepiece here so we can find what is going on.
User avatar
dotsquid
Posts: 22
Joined: Fri Jan 14, 2011 7:10 pm
Location: Ukraine

Re: rigid body exploded out when I use btGImpactMeshShape

Post by dotsquid »

Here is some piece of code which creates a btGImpactMeshShape

Code: Select all

btTriangleIndexVertexArray * indexVertexArrays = new btTriangleIndexVertexArray(numIndices / 3, indices, sizeof(int) * 3, numVertices, (btScalar*)vertices, sizeof(float) * 3);
btCollisionShape * shape = new btGImpactMeshShape(indexVertexArrays);
shape->setUserPointer((void*)indexVertexArrays);
_collisionShapes.push_back(shape);
((btGImpactMeshShape *)shape)->updateBound();
btCollisionDispatcher * dispatcher = static_cast<btCollisionDispatcher *>(_world->getDispatcher());
btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher);
btTransform transform;
transform.setIdentity();
btVector3 localInertia(0.0f, 0.0f, 0.0f);
if(mass != 0.0f && shape != NULL)
  shape->calculateLocalInertia(mass, localInertia);
btDefaultMotionState * motionState = new btDefaultMotionState(transform);
btRigidBody::btRigidBodyConstructionInfo bodyInfo(mass, motionState, shape, localInertia);
btRigidBody * body = new btRigidBody(bodyInfo);
_world->addRigidBody(body);