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!
Sleeping/Waking callbacks
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Sleeping/Waking callbacks
You can call
to activate objects.
You can also prevent certain objects from ever falling asleep/get deactivated by calling:
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
Code: Select all
body->setActivationState(ACTIVE_TAG)
You can also prevent certain objects from ever falling asleep/get deactivated by calling:
Code: Select all
body->setActivationState(DISABLE_DEACTIVATION)
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!
-
- Posts: 7
- Joined: Mon Oct 30, 2006 7:44 pm
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?
What about the onWake/onSleep callbacks?
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
the btMotionState 'setWorldTransform' is only called for awake objects, isn't that enough for a 'onWake' detection?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?
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
-
- Posts: 7
- Joined: Mon Oct 30, 2006 7:44 pm
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: the btMotionState 'setWorldTransform' is only called for onWake, isn't that enough for a 'onWake' detection?
This would be very useful!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).