I imagine it can be used with a vehicle, for example, set somewhere underneath the visual representation (geometry), so that it never flips upside-down, or at least greatly reduces the chances of it happening.
Or if it's set somewhere above a chair, for example, it should easily tip over, right?
I set it to -10000 on the .y axis (in OpenGL +Y is up), thinking the thing will always stay upright, like a buoy (device floating on water), but nope. It just teleported it. What am I missing? It just seems to translate my entire entity downwards, or in whatever direction I set the center of mass. Capsule collider, very thin box collider, doesn't matter, even if I drop it from any height, it just rolls on the floor... Of if I set it to +/- 10000 on the X axis, I would expect the capsule to prefer rolling on that side only, but it just doesn't work.
I set it like this:
Code: Select all
rigidbody.rb->activate(); // Wake it up in case it's sleeping
btTransform transf = rigidbody.rb->getCenterOfMassTransform(); // Same thing as "getWorldTransform()"
const btVector3 pos = transf * rigidbody.centerOfMass; // Rotate this point so it's local to it and not in world-space somewhere near the center of the scene
transf.setOrigin(pos);
rigidbody.rb->setCenterOfMassTransform(transf);
"rigidbody.rb" is the "btRigidBody*" pointer.
"rigidbody.centerOfMass" is a btVector3 that I change the values to in the editor GUI (default is 0,0,0).