P.Chaos.Simulation.Enable
P.Chaos.Simulation.Enable
#Overview
name: P.Chaos.Simulation.Enable
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable / disable chaos simulation. If disabled, physics will not tick.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of P.Chaos.Simulation.Enable is to control the activation of the Chaos physics simulation in Unreal Engine 5. This setting variable is used to enable or disable the Chaos physics system, which is responsible for simulating physical interactions in the game world.
-
The Chaos physics subsystem within Unreal Engine 5 relies on this setting variable. It is part of the PhysicsCore module, as evident from the file path where it’s defined.
-
The value of this variable is set using a TAutoConsoleVariable, which allows it to be changed at runtime through console commands. It is initialized with a default value of 1 (enabled).
-
The associated variable CVar_ChaosSimulationEnable directly interacts with this setting. It is used to access the value of P.Chaos.Simulation.Enable within the C++ code.
-
Developers must be aware that when this variable is set to 0, the physics simulation will not tick. This means that no physical interactions or movements will be calculated, which can significantly impact gameplay and visual fidelity.
-
Best practices for using this variable include:
- Use it for debugging or performance testing purposes.
- Be cautious when disabling it in a shipping game, as it will likely break physics-based gameplay elements.
- Consider the implications on other systems that may depend on physics simulations when toggling this setting.
Regarding the associated variable CVar_ChaosSimulationEnable:
-
Its purpose is to provide a convenient way to access the P.Chaos.Simulation.Enable setting within the C++ code.
-
It is used within the FChaosScene class, specifically in the StartFrame and EndFrame functions, to determine whether the physics simulation should proceed.
-
The value is retrieved using the GetValueOnGameThread() method, which ensures thread-safe access to the console variable.
-
Developers should be aware that this variable is checked at the beginning of each physics frame, allowing for real-time toggling of the physics simulation.
-
Best practices include:
- Use this variable for conditional logic related to physics simulation.
- Be mindful of performance implications when frequently checking this value.
- Consider caching the value if it’s accessed multiple times within a single frame to reduce overhead.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp:48
Scope: file
Source code excerpt:
DECLARE_DWORD_ACCUMULATOR_STAT(TEXT("NumDirtyNonEmptyCellsInGrid"), STAT_ChaosCounter_NumDirtyNonEmptyCellsInGrid, STATGROUP_ChaosCounters);
TAutoConsoleVariable<int32> CVar_ChaosSimulationEnable(TEXT("P.Chaos.Simulation.Enable"),1,TEXT("Enable / disable chaos simulation. If disabled, physics will not tick."));
TAutoConsoleVariable<int32> CVar_ApplyProjectSettings(TEXT("p.Chaos.Simulation.ApplySolverProjectSettings"), 1, TEXT("Whether to apply the solver project settings on spawning a solver"));
FChaosScene::FChaosScene(
UObject* OwnerPtr
, Chaos::FReal InAsyncDt
#if CHAOS_DEBUG_NAME
#Associated Variable and Callsites
This variable is associated with another variable named CVar_ChaosSimulationEnable
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp:48
Scope: file
Source code excerpt:
DECLARE_DWORD_ACCUMULATOR_STAT(TEXT("NumDirtyNonEmptyCellsInGrid"), STAT_ChaosCounter_NumDirtyNonEmptyCellsInGrid, STATGROUP_ChaosCounters);
TAutoConsoleVariable<int32> CVar_ChaosSimulationEnable(TEXT("P.Chaos.Simulation.Enable"),1,TEXT("Enable / disable chaos simulation. If disabled, physics will not tick."));
TAutoConsoleVariable<int32> CVar_ApplyProjectSettings(TEXT("p.Chaos.Simulation.ApplySolverProjectSettings"), 1, TEXT("Whether to apply the solver project settings on spawning a solver"));
FChaosScene::FChaosScene(
UObject* OwnerPtr
, Chaos::FReal InAsyncDt
#if CHAOS_DEBUG_NAME
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp:370
Scope (from outer to inner):
file
function void FChaosScene::StartFrame
Source code excerpt:
SCOPE_CYCLE_COUNTER(STAT_Scene_StartFrame);
if(CVar_ChaosSimulationEnable.GetValueOnGameThread() == 0)
{
return;
}
const float UseDeltaTime = OnStartFrame(MDeltaTime);;
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp:493
Scope (from outer to inner):
file
function void FChaosScene::EndFrame
Source code excerpt:
SCOPE_CYCLE_COUNTER(STAT_Scene_EndFrame);
if(CVar_ChaosSimulationEnable.GetValueOnGameThread() == 0 || GetSolver() == nullptr)
{
return;
}
#if !UE_BUILD_SHIPPING
{