/// Flush the scene's command queue for processing. virtual void FlushStream () { m_pScene->flushStream(); }
void plSimulationMgr::Advance(float delSecs) { if (fSuspended) return; plProfile_IncCount(StepLen, (int)(delSecs*1000)); #ifndef PLASMA_EXTERNAL_RELASE uint32_t stepTime = hsTimer::GetPrecTickCount(); #endif plProfile_BeginTiming(Step); plPXPhysicalControllerCore::UpdatePrestep(delSecs); plPXPhysicalControllerCore::UpdatePoststep( delSecs); for (SceneMap::iterator it = fScenes.begin(); it != fScenes.end(); it++) { NxScene* scene = it->second; bool do_advance = true; if (fSubworldOptimization) { plKey world = (plKey)it->first; if (world == GetKey()) world = nil; do_advance = plPXPhysicalControllerCore::AnyControllersInThisWorld(world); } if (do_advance) { scene->simulate(delSecs); scene->flushStream(); scene->fetchResults(NX_RIGID_BODY_FINISHED, true); } } plPXPhysicalControllerCore::UpdatePostSimStep(delSecs); plProfile_EndTiming(Step); #ifndef PLASMA_EXTERNAL_RELEASE if(plSimulationMgr::fDisplayAwakeActors)IDrawActiveActorList(); #endif if (fExtraProfile) { int contacts = 0, dynActors = 0, dynShapes = 0, awake = 0, stShapes=0, actors=0, scenes=0, controllers=0 ; for (SceneMap::iterator it = fScenes.begin(); it != fScenes.end(); it++) { bool do_advance = true; if (fSubworldOptimization) { plKey world = (plKey)it->first; if (world == GetKey()) world = nil; do_advance = plPXPhysicalControllerCore::AnyControllersInThisWorld(world); } if (do_advance) { NxScene* scene = it->second; NxSceneStats stats; scene->getStats(stats); contacts += stats.numContacts; dynActors += stats.numDynamicActors; dynShapes += stats.numDynamicShapes; awake += stats.numDynamicActorsInAwakeGroups; stShapes += stats.numStaticShapes; actors += stats.numActors; scenes += 1; controllers += plPXPhysicalControllerCore::NumControllers(); } } plProfile_IncCount(Awake, awake); plProfile_IncCount(Contacts, contacts); plProfile_IncCount(DynActors, dynActors); plProfile_IncCount(DynShapes, dynShapes); plProfile_IncCount(StaticShapes, stShapes); plProfile_IncCount(Actors, actors); plProfile_IncCount(Scenes, scenes); plProfile_IncCount(Controllers, controllers); } plProfile_IncCount(AnimatedPhysicals, plPXPhysical::fNumberAnimatedPhysicals); plProfile_IncCount(AnimatedActivators, plPXPhysical::fNumberAnimatedActivators); fSoundMgr->Update(); plProfile_BeginTiming(ProcessSyncs); IProcessSynchs(); plProfile_EndTiming(ProcessSyncs); plProfile_BeginTiming(UpdateContexts); ISendUpdates(); plProfile_EndTiming(UpdateContexts); }
void plSimulationMgr::Advance(float delSecs) { if (fSuspended) return; fAccumulator += delSecs; if (fAccumulator < kDefaultStepSize) { // Not enough time has passed to perform a substep. plPXPhysicalControllerCore::UpdateNonPhysical(fAccumulator / kDefaultStepSize); return; } else if (fAccumulator > kDefaultMaxDelta) { if (fExtraProfile) Log("Step clamped from %f to limit of %f", fAccumulator, kDefaultMaxDelta); fAccumulator = kDefaultMaxDelta; } ++fStepCount; // Perform as many whole substeps as possible saving the remainder in our accumulator. int numSubSteps = (int)(fAccumulator / kDefaultStepSize + 0.000001f); float delta = numSubSteps * kDefaultStepSize; fAccumulator -= delta; plProfile_IncCount(StepLen, (int)(delta*1000)); plProfile_BeginTiming(Step); plPXPhysicalControllerCore::Apply(delta); for (SceneMap::iterator it = fScenes.begin(); it != fScenes.end(); it++) { NxScene* scene = it->second; bool do_advance = true; if (fSubworldOptimization) { plKey world = (plKey)it->first; if (world == GetKey()) world = nil; do_advance = plPXPhysicalControllerCore::AnyControllersInThisWorld(world); } if (do_advance) { scene->simulate(delta); scene->flushStream(); scene->fetchResults(NX_RIGID_BODY_FINISHED, true); } } plPXPhysicalControllerCore::Update(numSubSteps, fAccumulator / kDefaultStepSize); plProfile_EndTiming(Step); #ifndef PLASMA_EXTERNAL_RELEASE if(plSimulationMgr::fDisplayAwakeActors)IDrawActiveActorList(); #endif if (fExtraProfile) { int contacts = 0, dynActors = 0, dynShapes = 0, awake = 0, stShapes=0, actors=0, scenes=0, controllers=0 ; for (SceneMap::iterator it = fScenes.begin(); it != fScenes.end(); it++) { bool do_advance = true; if (fSubworldOptimization) { plKey world = (plKey)it->first; if (world == GetKey()) world = nil; do_advance = plPXPhysicalControllerCore::AnyControllersInThisWorld(world); } if (do_advance) { NxScene* scene = it->second; NxSceneStats stats; scene->getStats(stats); contacts += stats.numContacts; dynActors += stats.numDynamicActors; dynShapes += stats.numDynamicShapes; awake += stats.numDynamicActorsInAwakeGroups; stShapes += stats.numStaticShapes; actors += stats.numActors; scenes += 1; controllers += plPXPhysicalControllerCore::NumControllers(); } } plProfile_IncCount(Awake, awake); plProfile_IncCount(Contacts, contacts); plProfile_IncCount(DynActors, dynActors); plProfile_IncCount(DynShapes, dynShapes); plProfile_IncCount(StaticShapes, stShapes); plProfile_IncCount(Actors, actors); plProfile_IncCount(Scenes, scenes); plProfile_IncCount(Controllers, controllers); } plProfile_IncCount(AnimatedPhysicals, plPXPhysical::fNumberAnimatedPhysicals); plProfile_IncCount(AnimatedActivators, plPXPhysical::fNumberAnimatedActivators); fSoundMgr->Update(); plProfile_BeginTiming(ProcessSyncs); IProcessSynchs(); plProfile_EndTiming(ProcessSyncs); plProfile_BeginTiming(UpdateContexts); ISendUpdates(); plProfile_EndTiming(UpdateContexts); }