Deactivate a rigid body in Bullet

Started by
8 comments, last by GuyWithBeard 11 years, 3 months ago

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.

Advertisement

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).

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.

Ashaman is right. I don't want to touch the collision flags. Anyway, if you get the chance to look up the "right way" and post it here I'd be grateful. :)

Also, I am not looking for code. Just the general idea of how to do it...
Right, I tried this out and it seems to work:

mRigidBody->forceActivationState(WANTS_DEACTIVATION);

Is this what you were doing?

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?

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.

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.

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!

This topic is closed to new replies.

Advertisement