Free and Un-Freeze rigid bodies on the fly !!

winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Free and Un-Freeze rigid bodies on the fly !!

Post by winspear »

Is there any good function to freeze and un-freeze rigid bodies on the fly?
In Nvidia Physx, you can set the body flag to be NX_BODY_FROZEN and it will just freeze.
I am looking for a similar feature in Bullet. What is it?

Thanks
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Free and Un-Freeze rigid bodies on the fly !!

Post by dphil »

I'm not sure if there's a "proper" way to do it, but I freeze objects by just setting their mass to 0. I assume they can be unfrozen by reverting their mass to a positive value.
winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Re: Free and Un-Freeze rigid bodies on the fly !!

Post by winspear »

Are you sure this works for you because I tried it, I was able to freeze it but was not able to un-freeze my object later during the simulation.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Free and Un-Freeze rigid bodies on the fly !!

Post by dphil »

Actually in my own simulation I never needed to unfreeze, so technically I don't know if that works. When you say you were "not able to un-freeze" your object, do you mean that it still wasn't affected by collision afterward? Or it didn't respond to gravity or manual forces? If it's just a case of not responding to gravity/forces, you probably just need to re-activate the body after you un-freeze it:

Code: Select all

rigidBody->activate(true);
If it's not being affected by collisions (ie it sits there like a rock while objects bounce off it), then yeah I guess setting mass to 0 might effect some other change that I'm unaware of that resetting the mass doesn't fix.
winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Re: Free and Un-Freeze rigid bodies on the fly !!

Post by winspear »

When I try to un-freeze it, it still acts as a static body i.e. applying force has no effect on the object.