Setting mass to a dynamic static rigidbody

Post Reply
rawtass
Posts: 8
Joined: Sun Dec 30, 2012 8:56 pm

Setting mass to a dynamic static rigidbody

Post by rawtass »

I create a rigidbody with a mass of zero and intertia of zero.
No flags or activationstates are set.

Later I try to update the mass of the rigidbody to make in non-static. To do this I use the following code:

Code: Select all

btVector3 inertia(0, 0, 0);
btScalar bt_mass(20.f);
bt_rigidbody->getCollisionShape()->calculateLocalInertia(bt_mass, inertia);
bt_rigidbody->setMassProps(mass, inertia);
Nothing happens, what am I missing?
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Setting mass to a dynamic static rigidbody

Post by Basroil »

rawtass wrote:I create a rigidbody with a mass of zero and intertia of zero.
No flags or activationstates are set.

Later I try to update the mass of the rigidbody to make in non-static. To do this I use the following code:

Nothing happens, what am I missing?
Well, in btDiscreteDynamicsWorld, a non-static body is added to m_nonStaticRigidBodies during the call to addRigidBody, and only bodies in m_nonStaticRigidBodies seem to be cycled through. Did you check to see if your body was in m_nonStaticRigidBodies?

I don't remember seeing anything that updates m_nonStaticRigidBodies after a body is added, so you might have to remove and then add the rigid body to get it, or make a function in your dynamics world code to add it to m_nonStaticRigidBodies (tread lightly though, not sure what will happen if you change the order of m_nonStaticRigidBodies)
rawtass
Posts: 8
Joined: Sun Dec 30, 2012 8:56 pm

Re: Setting mass to a dynamic static rigidbody

Post by rawtass »

Basroil wrote:
rawtass wrote:I create a rigidbody with a mass of zero and intertia of zero.
No flags or activationstates are set.

Later I try to update the mass of the rigidbody to make in non-static. To do this I use the following code:

Nothing happens, what am I missing?
Well, in btDiscreteDynamicsWorld, a non-static body is added to m_nonStaticRigidBodies during the call to addRigidBody, and only bodies in m_nonStaticRigidBodies seem to be cycled through. Did you check to see if your body was in m_nonStaticRigidBodies?

I don't remember seeing anything that updates m_nonStaticRigidBodies after a body is added, so you might have to remove and then add the rigid body to get it, or make a function in your dynamics world code to add it to m_nonStaticRigidBodies (tread lightly though, not sure what will happen if you change the order of m_nonStaticRigidBodies)
ok, thanks for your reply.

I tried:
- Removing the rigidbody world->removeRigidBody().
- Set the mass and intertia
- Adding the rigidbody: world->addRigidbody().

Yes, still m_nonStaticRigidBodies is empty, and no dynamic rigidbodies moving..
Post Reply