I need some rigid bodies in my simulation to remain static until an event occurs. Disabling the simulation for those bodies with setActiovationState() won't do, because they would be reactivated when interacting with other bodies. So I thought of setting their mass to 0 until the event occurs, then I set their mass to some positive value.
This is not the actual code, but shows how I am doing:
Code: Select all
/* general code */
btVector3 inertia(0.0, 0.0, 0.0);
pShape->calculateLocalInertia(mass, inertia);
btRigidBody::btRigidBodyConstructionInfo info(mass, this, pShape, inertia);
info.m_friction = friction;
m_pRigidBody = new btRigidBody(info);
/* specific code */
m_pRigidBody->setMassProps(0.0f, btVector(0.0f, 0.0f, 0.0f));
/* .... */
/* on event occurrence */
m_pRigidBody->setMassProps(mass, inertia);
This way, the body starts up stationary, but when I call setMassProps() upon the event occurrence, the body starts floating up defying gravity, like a slow floating asteroid in space, while I expect it to fall in the direction of gravity.
Do you know what is wrong? What am I missing in the usage of setMassProps() ?