| 5283 | } |
| 5284 | |
| 5285 | void Sc::Scene::onBodySleep(BodySim* body) |
| 5286 | { |
| 5287 | if(mSimulationEventCallback) |
| 5288 | { |
| 5289 | if (body->readInternalFlag(BodySim::BF_WAKEUP_NOTIFY)) |
| 5290 | { |
| 5291 | PX_ASSERT(!body->readInternalFlag(BodySim::BF_SLEEP_NOTIFY)); |
| 5292 | |
| 5293 | // Body is in the list of woken bodies, hence, mark this list as dirty such that it gets cleaned up before |
| 5294 | // being sent to the user |
| 5295 | body->clearInternalFlag(BodySim::BF_WAKEUP_NOTIFY); |
| 5296 | mWokeBodyListValid = false; |
| 5297 | } |
| 5298 | |
| 5299 | body->raiseInternalFlag(BodySim::BF_SLEEP_NOTIFY); |
| 5300 | } |
| 5301 | |
| 5302 | // Avoid multiple insertion (the user can do multiple transitions between asleep and awake) |
| 5303 | // |
| 5304 | // even if no sleep events are requested, we still need to track the objects which were put to sleep because |
| 5305 | // for those we need to sync the buffered state (strictly speaking this only applies to sleep changes that are |
| 5306 | // triggered by the simulation and not the user but we do not distinguish here) |
| 5307 | if (!body->readInternalFlag(BodySim::BF_IS_IN_SLEEP_LIST)) |
| 5308 | { |
| 5309 | if(mSimulationEventCallback) |
| 5310 | { |
| 5311 | PX_ASSERT(!mSleepBodies.contains(&body->getBodyCore())); |
| 5312 | } |
| 5313 | mSleepBodies.insert(&body->getBodyCore()); |
| 5314 | body->raiseInternalFlag(BodySim::BF_IS_IN_SLEEP_LIST); |
| 5315 | } |
| 5316 | } |
| 5317 | |
| 5318 | void Sc::Scene::onBodyWakeUp(BodySim* body) |
| 5319 | { |
no test coverage detected