void FPhysSubstepTask::StepSimulation(PhysXCompletionTask * Task) { check(SubTime > 0.f); check(DeltaSeconds > 0.f); FullSimulationTask = Task; Alpha = 0.f; StepScale = SubTime / DeltaSeconds; TotalSubTime = 0.f; CurrentSubStep = 0; SubstepSimulationStart(); }
void FPhysSubstepTask::SubstepSimulationEnd(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) { CompletionEvent = NULL; if (CurrentSubStep < NumSubsteps) { uint32 OutErrorCode = 0; ApexScene->fetchResults(true, &OutErrorCode); if (OutErrorCode != 0) { UE_LOG(LogPhysics, Log, TEXT("PHYSX FETCHRESULTS ERROR: %d"), OutErrorCode); } SubstepSimulationStart(); } else { //final step we call fetch on in game thread FullSimulationTask->removeReference(); } }
void FPhysSubstepTask::SubstepSimulationEnd(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) { #if WITH_PHYSX CompletionEvent = NULL; if (CurrentSubStep < NumSubsteps) { uint32 OutErrorCode = 0; { SCOPE_CYCLE_COUNTER(STAT_TotalPhysicsTime); SCOPE_CYCLE_COUNTER(STAT_SubstepSimulationEnd); #if WITH_APEX PAScene->fetchResults(true, &OutErrorCode); #else PAScene->lockWrite(); PAScene->fetchResults(true, &OutErrorCode); PAScene->unlockWrite(); #endif } if (OutErrorCode != 0) { UE_LOG(LogPhysics, Log, TEXT("PHYSX FETCHRESULTS ERROR: %d"), OutErrorCode); } SubstepSimulationStart(); } else { SCOPE_CYCLE_COUNTER(STAT_TotalPhysicsTime); SCOPE_CYCLE_COUNTER(STAT_SubstepSimulationEnd); //final step we call fetch on in game thread FullSimulationTask->removeReference(); } #endif }