Sign in to follow this  

Deactivate a rigid body in Bullet

This topic is 1833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya,

 

I realize that this is a question best asked on the Bullet forums, but here goes anyway...

 

What is the correct way to deactivate an RB that is active? Ie. "put to sleep". There is an activate() method but no deactivate(). There is something called forceActivationState(), so I guess I could just pass ISLAND_SLEEPING to that, but it seems awfully hacky. Is there a cleaner way? Also, since it refers to islands, will it affect other nearby objects if I do it that way?

 

Some other engines have methods for putting objects to sleep regardless of their current state.

Share this post


Link to post
Share on other sites

I guess, you can use btRigidBody::setFlags method and set proper flags to configure behavior for your rigid body. Here is a list of all flags(line 117). 

Share this post


Link to post
Share on other sites

I have implemented this behaviour with bullet, but I can't look it up at the moment.

 

[quote name='GuyWithBeard' timestamp='1357731652' post='5019419']
Also, since it refers to islands, will it affect other nearby objects if I do it that way?
[/quote]

ISLAND_SLEEPING is set, when a group of nearby objects is deactivated, I believe that this is not the correct way, but I will look it up later.

 

 

[quote name='DgekGD' timestamp='1357732134' post='5019422']
I guess, you can use btRigidBody::setFlags method and set proper flags to configure behavior for your rigid body. Here is a list of all flags(line 117).
[/quote]

The flags at 117 affects the collision behavior of the object. In this case you want to keep the behaviour and just disable the active physical control by the physics engine until an other object triggers it again or you manually activate it again.

Share this post


Link to post
Share on other sites

Out of interest - why are you wanting to set this yourself rather than letting Bullet set it for you when it thinks the object is actually deactivated?

Share this post


Link to post
Share on other sites

I am doing networked physics. As long as the RB on the server is active it sends updated transforms to the client every x milliseconds. When it gets deactivated it sends a deactivated-message to the client and stops sending transforms. At this point the client RB needs to be moved to the last known server RB position, and get deactivated, so that the RBs are in sync across the network. If I don't do this there is a slight chance that the RB on the client is not deactivated when the server RB is, and it keeps moving around when it should stay in place.

Share this post


Link to post
Share on other sites

Ok, makes sense. just had a quick check through as I'd forgotten how this stuff worked exactly, but you should just be able to call :

 

setActivationState  rather then forceActivationState as the former will honour the disable deactivation /simulation states while the latter won't.

 

it sounds like you're running stepSimulation on the client as well ? (to allow local collision query calls) so the RB would be brought back to life anyway if it was required.

Share this post


Link to post
Share on other sites
Yes, I am simulating on both the client and the server since the server does not send updates across the network on every tick. Using setActivationState might be a good idea. I'll check that out, thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this