Page 1 of 1

Sleeping/Waking callbacks

Posted: Thu Nov 09, 2006 7:27 pm
by optime
Hi,

I am looking for a way to manually put btRigidBodies manually to sleep but have not found anything in the docs. Did I miss it?

Also I would like to set callbacks to be called when a btRigidBody wakes up and when it is beeing put to sleep by Bullet. I can leverage several optimizations in the graphics engine this way. Is such functionality already implemented?

Thanks!

Re: Sleeping/Waking callbacks

Posted: Thu Nov 09, 2006 7:32 pm
by Erwin Coumans
You can call

Code: Select all

body->setActivationState(ACTIVE_TAG)
to activate objects.

You can also prevent certain objects from ever falling asleep/get deactivated by calling:

Code: Select all

body->setActivationState(DISABLE_DEACTIVATION)
btMotionState::setWorldTransform gets only called by Bullet for active objects, so your derived version of btMotionState (for example BulletC4MotionState or btDefaultMotionState) can be used to detect active objects.

There is no put-to-sleep callback yet, I'll propose some implementation.
Thanks,
Erwin
optime wrote:Hi,

I am looking for a way to manually put btRigidBodies manually to sleep but have not found anything in the docs. Did I miss it?

Also I would like to set callbacks to be called when a btRigidBody wakes up and when it is beeing put to sleep by Bullet. I can leverage several optimizations in the graphics engine this way. Is such functionality already implemented?

Thanks!

Posted: Thu Nov 09, 2006 7:47 pm
by optime
Thanks for looking into this. PutToSleep is useful to me because there is a huge load on the simulation when loading a new world in game (stacked objects that are fine visually and need only to be active when they are subject to force other then gravity for example).

What about the onWake/onSleep callbacks?

Posted: Thu Nov 09, 2006 8:34 pm
by Erwin Coumans
optime wrote:Thanks for looking into this. PutToSleep is useful to me because there is a huge load on the simulation when loading a new world in game (stacked objects that are fine visually and need only to be active when they are subject to force other then gravity for example).

What about the onWake/onSleep callbacks?
the btMotionState 'setWorldTransform' is only called for awake objects, isn't that enough for a 'onWake' detection?

I can add virtual deactivation method in btMotionState that you can override to do things for objects that fall asleep (or even disable the sleeping for another frame).

Is that OK?
Thanks,
Erwin

Posted: Thu Nov 09, 2006 8:46 pm
by optime
Erwin Coumans wrote: the btMotionState 'setWorldTransform' is only called for onWake, isn't that enough for a 'onWake' detection?
It is sufficient. I would like to call functions that reset shadow caches and the like whenever an object is awaking, calling those more often is not that optimal. But you are right, I can track changes of object state in the app myself this way. Thanks once again.
Erwin Coumans wrote: I can add virtual deactivation method in btMotionState that you can override to do things for objects that fall asleep (or even disable the sleeping for another frame).
This would be very useful!