p.Chaos.Solver.Collision.Enabled
p.Chaos.Solver.Collision.Enabled
#Overview
name: p.Chaos.Solver.Collision.Enabled
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable/Disable collisions in the main scene.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.Collision.Enabled is to control whether collisions are enabled or disabled in the main scene of the Chaos physics solver in Unreal Engine 5.
This setting variable is primarily used by the Chaos physics system, which is an experimental physics solver in Unreal Engine 5. It is part of the Runtime/Experimental/Chaos module.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands. It is initialized to true by default, enabling collisions in the main scene.
The associated variable bChaosSolverCollisionEnabled directly interacts with p.Chaos.Solver.Collision.Enabled. They share the same value, and bChaosSolverCollisionEnabled is used within the code to actually control the collision behavior.
Developers must be aware that this variable affects the entire main scene’s collision detection. Disabling it will turn off all collisions, which can have significant impacts on gameplay and physics simulations. It should be used carefully and only when necessary, such as for debugging or specific performance optimizations.
Best practices when using this variable include:
- Only disable collisions temporarily for debugging purposes.
- If disabling collisions, ensure to re-enable them when finished to avoid unexpected behavior.
- Consider the performance implications of enabling/disabling collisions on a scene-wide basis.
- Use this variable in conjunction with other Chaos solver settings for fine-tuned physics control.
Regarding the associated variable bChaosSolverCollisionEnabled:
The purpose of bChaosSolverCollisionEnabled is to serve as the in-code representation of the p.Chaos.Solver.Collision.Enabled setting.
This variable is used directly within the Chaos physics solver code, specifically in the FPBDRigidsSolver class, which is part of the Chaos physics system.
The value of bChaosSolverCollisionEnabled is set by the FAutoConsoleVariableRef linked to p.Chaos.Solver.Collision.Enabled. Any changes to the console variable will be reflected in this boolean variable.
bChaosSolverCollisionEnabled interacts directly with the Chaos solver’s collision system. It is used in the PrepareAdvanceBy function to set whether collisions are enabled for the evolution’s collision constraints.
Developers should be aware that this variable directly controls the collision state in the solver. Changes to this variable will immediately affect the physics simulation.
Best practices for using bChaosSolverCollisionEnabled include:
- Avoid modifying this variable directly in code; instead, use the console variable to ensure consistency.
- When reading this variable’s state, be aware that it may change at runtime due to console commands.
- Consider adding checks or notifications in critical code paths that depend on collision states to handle cases where collisions might be unexpectedly disabled.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:287
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// Enable/Disable collisions
bool bChaosSolverCollisionEnabled = true;
FAutoConsoleVariableRef CVarChaosSolverCollisionDisable(TEXT("p.Chaos.Solver.Collision.Enabled"), bChaosSolverCollisionEnabled, TEXT("Enable/Disable collisions in the main scene."));
// Shrink particle arrays every frame to recove rmemory when a scene changes significantly
bool bChaosSolverShrinkArrays = false;
float ChaosArrayCollectionMaxSlackFraction = 0.5f;
int32 ChaosArrayCollectionMinSlack = 100;
FAutoConsoleVariableRef CVarChaosSolverShrinkArrays(TEXT("p.Chaos.Solver.ShrinkArrays"), bChaosSolverShrinkArrays, TEXT("Enable/Disable particle array shrinking in the main scene"));
#Associated Variable and Callsites
This variable is associated with another variable named bChaosSolverCollisionEnabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:286
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// Enable/Disable collisions
bool bChaosSolverCollisionEnabled = true;
FAutoConsoleVariableRef CVarChaosSolverCollisionDisable(TEXT("p.Chaos.Solver.Collision.Enabled"), bChaosSolverCollisionEnabled, TEXT("Enable/Disable collisions in the main scene."));
// Shrink particle arrays every frame to recove rmemory when a scene changes significantly
bool bChaosSolverShrinkArrays = false;
float ChaosArrayCollectionMaxSlackFraction = 0.5f;
int32 ChaosArrayCollectionMinSlack = 100;
FAutoConsoleVariableRef CVarChaosSolverShrinkArrays(TEXT("p.Chaos.Solver.ShrinkArrays"), bChaosSolverShrinkArrays, TEXT("Enable/Disable particle array shrinking in the main scene"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:1281
Scope (from outer to inner):
file
namespace Chaos
function void FPBDRigidsSolver::PrepareAdvanceBy
Source code excerpt:
void FPBDRigidsSolver::PrepareAdvanceBy(const FReal DeltaTime)
{
MEvolution->GetCollisionConstraints().SetCollisionsEnabled(bChaosSolverCollisionEnabled);
FCollisionDetectorSettings CollisionDetectorSettings = MEvolution->GetCollisionConstraints().GetDetectorSettings();
CollisionDetectorSettings.bAllowManifoldReuse = (ChaosSolverCollisionAllowManifoldUpdate != 0);
CollisionDetectorSettings.bDeferNarrowPhase = (ChaosSolverCollisionDeferNarrowPhase != 0);
CollisionDetectorSettings.bAllowManifolds = (ChaosSolverCollisionUseManifolds != 0);
CollisionDetectorSettings.bAllowCCD = bChaosUseCCD;