Rigid Body mass change during simulation

jamie01
Posts: 3
Joined: Tue Jan 31, 2012 12:23 am

Rigid Body mass change during simulation

Post by jamie01 »

Is it possible to change the mass of a rigid body without removing it from the world first? Searches have indicated that it is, but I'm getting some really strange behaviour such as floating objects or just no movement at all.

I'm currently doing the following:

Code: Select all

btVector3 inertia;
rigidBody->getCollisionShape()->calculateLocalInertia( newmass, inertia );
rigidBody->setMassProps( newmass, inertia );
rigidBody->updateInertiaTensor();
The body in question is actually used in a btRaycastVehicle, though I don't suppose that should make any difference?

Thanks
jamie01
Posts: 3
Joined: Tue Jan 31, 2012 12:23 am

Re: Rigid Body mass change during simulation

Post by jamie01 »

Hmm, it would seem that even removing / re-adding the body before and after that block of code still doesn't help. The effects aren't particularly drastic but the vehicle is pretty much undrivable, even if I then set mass back to the original value :?
STTrife
Posts: 109
Joined: Tue May 01, 2012 10:42 am

Re: Rigid Body mass change during simulation

Post by STTrife »

It's probably important when you do this. Do you use the tick callback (pre or post)?