Noob question: Static to Dynamic

Post Reply
Rademanc
Posts: 11
Joined: Mon Nov 02, 2009 11:55 am

Noob question: Static to Dynamic

Post by Rademanc »

I have a stack of (rigidbodies)boxes in my world. They are static, i.e 0 mass. I want them to become dynamic when I click on them.
How can I do this?
Rademanc
Posts: 11
Joined: Mon Nov 02, 2009 11:55 am

Re: Noob question: Static to Dynamic

Post by Rademanc »

I solved it with the following code, but I don't know if it will hurt performance if you have to remove and add objects like this...

m_dynamicsWorld->removeRigidBody(body);
btCollisionShape* colShape = new btBoxShape(btVector3(0.1,0.1,0.1));
btVector3 localInertia(0,0,0);
colShape->calculateLocalInertia(10,localInertia);

pickedBody = body;
// pickedBody->setCollisionFlags(pickedBody->getCollisionFlags() & ~btCollisionObject::CF);
pickedBody->setActivationState(DISABLE_DEACTIVATION);
pickedBody->setMassProps(10,localInertia);
pickedBody->updateInertiaTensor();
m_dynamicsWorld->addRigidBody(pickedBody);
Post Reply