From d700df6afb157ffb57ac6f972dba6d07b226b2ee Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 15 Jul 2024 16:23:49 -0500 Subject: [PATCH] Add PhysX option for enabling enhanced determinism --- Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp | 2 ++ Source/Engine/Physics/PhysicsSettings.h | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp b/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp index 80d264857..60da71ad3 100644 --- a/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp +++ b/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp @@ -1256,6 +1256,8 @@ void* PhysicsBackend::CreateScene(const PhysicsSettings& settings) sceneDesc.simulationEventCallback = &scenePhysX->EventsCallback; sceneDesc.filterShader = FilterShader; sceneDesc.bounceThresholdVelocity = settings.BounceThresholdVelocity; + if (settings.EnableEnhancedDeterminism) + sceneDesc.flags |= PxSceneFlag::eENABLE_ENHANCED_DETERMINISM; switch (settings.SolverType) { case PhysicsSolverType::ProjectedGaussSeidelIterativeSolver: diff --git a/Source/Engine/Physics/PhysicsSettings.h b/Source/Engine/Physics/PhysicsSettings.h index fca1ea2d4..728a18367 100644 --- a/Source/Engine/Physics/PhysicsSettings.h +++ b/Source/Engine/Physics/PhysicsSettings.h @@ -94,10 +94,16 @@ public: API_FIELD(Attributes="EditorOrder(71), EditorDisplay(\"Simulation\")") PhysicsBroadPhaseType BroadPhaseType = PhysicsBroadPhaseType::ParallelAutomaticBoxPruning; + /// + /// Enables enhanced determinism in the simulation. This has a performance impact. + /// + API_FIELD(Attributes="EditorOrder(71), EditorDisplay(\"Simulation\")") + bool EnableEnhancedDeterminism = false; + /// /// The solver type to use in the simulation. /// - API_FIELD(Attributes="EditorOrder(72), EditorDisplay(\"Simulation\")") + API_FIELD(Attributes="EditorOrder(73), EditorDisplay(\"Simulation\")") PhysicsSolverType SolverType = PhysicsSolverType::ProjectedGaussSeidelIterativeSolver; ///