I have a robot (btTriangleMeshShape for each component) and a chain of boxes used as a cable, which is anchored on two components of the robot. I want to rotate a robot component and when this happens, I want to twist/ roll the cable on that component. The problem is - when i rotate a robot component, collision does not work anymore with that component.

I cannot use btHullShape because of the lack of accuracy, neither btGimpact because of the complexity of computations (which gives a really unsatisfying performance). I couldn't improve enough any of these two shapes, so that is why I use btTriangleMeshShape and rotate it by code.

Also, I have replaced the btTriangleMeshShape of the rotating component with a simple static box and rotate the box. Using the box shape, collision is working with that box.

So the problem of collision not working is only when trying to rotate a (static) btTriangleMeshShape.

Here is the code I use to rotate the static body, although I don't think it's necessary (it works for box shape, not for triangle mesh shape):

   btTransform tr = m_dynamicsWorld->getCollisionObjectArray()[7]->getWorldTransform();
   static float angle = 0.f;
   angle += 0.1f;
   tr.setRotation(btQuaternion(btVector3(1, 0, 0), -angle));


I have to mention that I've searched the web before and couldn't find any solution and also I'm a newbie on Bullet Physics and any graphic libraries.

Any help would by really apreciated,


btTriangleMeshShape cannot be used as a dynamic objects as stated in the API documentation.

The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving objects.

So your alternative is to represent the mesh using Collision Primitives or a collection of them.

Single Primative

Using a singluar primitve is the easiest but loses accuraccy on complex models. For example:

Image showing the collision box of Suzanne

You would rotate the collision box and then apply the rotation from bullet to your robot mesh.

Multiple Primitives / Compound Collisions

The alternative is to use multiple collision primatives, choosing a base primative to rotate the mesh and to have all other primatives connected to. For example:

Compound Collision Primitives

  • \$\begingroup\$ thank you Soapy for your answer, but as i've already specified, i'm trying to use btTriangleMeshShape for both accuracy and performance. If I use CollisionPrimitives I lose accuracy. That's not ok in my case. If it would be ok, then I think btHullShape would be more indicated, I've already tried it:) \$\endgroup\$
    – tame
    May 6 '15 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.