| 1960 | } |
| 1961 | |
| 1962 | void PhysicsBackend::EndSimulateScene(void* scene) |
| 1963 | { |
| 1964 | PROFILE_MEM(Physics); |
| 1965 | auto scenePhysX = (ScenePhysX*)scene; |
| 1966 | |
| 1967 | { |
| 1968 | PROFILE_CPU_NAMED("Physics.Fetch"); |
| 1969 | |
| 1970 | // Gather results (with waiting for the end) |
| 1971 | scenePhysX->Stepper.wait(scenePhysX->Scene); |
| 1972 | } |
| 1973 | |
| 1974 | { |
| 1975 | PROFILE_CPU_NAMED("Physics.FlushActiveTransforms"); |
| 1976 | |
| 1977 | // Gather change info |
| 1978 | PxU32 activeActorsCount; |
| 1979 | PxActor** activeActors = scenePhysX->Scene->getActiveActors(activeActorsCount); |
| 1980 | |
| 1981 | // Update changed transformations |
| 1982 | #if PLATFORM_THREADS_LIMIT > 1 |
| 1983 | if (activeActorsCount > 50 && JobSystem::GetThreadsCount() > 1) |
| 1984 | { |
| 1985 | // Run in async via job system |
| 1986 | CachedActiveActors = activeActors; |
| 1987 | CachedActiveActorsCount = activeActorsCount; |
| 1988 | CachedActiveActorIndex = -1; |
| 1989 | JobSystem::Execute(FlushActiveTransforms, JobSystem::GetThreadsCount()); |
| 1990 | } |
| 1991 | else |
| 1992 | #endif |
| 1993 | { |
| 1994 | for (uint32 i = 0; i < activeActorsCount; i++) |
| 1995 | { |
| 1996 | const auto pxActor = (PxRigidActor*)*activeActors++; |
| 1997 | auto actor = static_cast<IPhysicsActor*>(pxActor->userData); |
| 1998 | if (actor) |
| 1999 | actor->OnActiveTransformChanged(); |
| 2000 | } |
| 2001 | } |
| 2002 | } |
| 2003 | |
| 2004 | #if WITH_CLOTH |
| 2005 | scenePhysX->UpdateCloths(scenePhysX->LastDeltaTime); |
| 2006 | #endif |
| 2007 | |
| 2008 | { |
| 2009 | PROFILE_CPU_NAMED("Physics.SendEvents"); |
| 2010 | scenePhysX->EventsCallback.SendTriggerEvents(); |
| 2011 | scenePhysX->EventsCallback.SendCollisionEvents(); |
| 2012 | scenePhysX->EventsCallback.SendJointEvents(); |
| 2013 | scenePhysX->EventsCallback.Clear(); |
| 2014 | } |
| 2015 | |
| 2016 | // Clear delta after simulation ended |
| 2017 | scenePhysX->LastDeltaTime = 0.0f; |
| 2018 | } |
| 2019 |
nothing calls this directly
no test coverage detected