p.Chaos.Solver.PersistentGraph
p.Chaos.Solver.PersistentGraph
#Overview
name: p.Chaos.Solver.PersistentGraph
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.PersistentGraph is to control whether the constraint graph in the Chaos physics solver retains its state between simulation ticks. This setting is crucial for the performance and behavior of the physics simulation in Unreal Engine 5.
This setting variable is primarily used in the Chaos physics solver, which is part of Unreal Engine’s experimental physics system. It’s specifically utilized in the collision handling and constraint solving components of the Chaos module.
The value of this variable is set through a console variable (CVar) system, allowing it to be modified at runtime. It’s initialized with a default value of true, meaning the constraint graph is persistent by default.
The associated variable bChaosSolverPersistentGraph directly interacts with p.Chaos.Solver.PersistentGraph. They share the same value and are used interchangeably in the code.
Developers must be aware that disabling this feature (setting it to false) can be very expensive in terms of performance. As noted in the comments, “It will be very expensive with this disabled…”
Best practices when using this variable include:
- Keeping it enabled (true) for better performance in most scenarios.
- Only disabling it if there’s a specific need that outweighs the performance cost.
- Profiling the application when changing this setting to understand its impact.
Regarding the associated variable bChaosSolverPersistentGraph:
- It’s used in various parts of the Chaos physics implementation, including the IslandManager and PBDCollisionConstraints.
- It directly affects how collision constraints are handled between simulation ticks.
- When set to false, it causes all awake collisions to be removed and recalculated each tick, which can be computationally expensive.
- It’s crucial for the efficiency of the constraint graph in the physics simulation.
Developers should be cautious when modifying this variable, as it can significantly impact both the performance and behavior of the physics simulation. Any changes should be thoroughly tested and profiled to ensure they don’t negatively affect the application’s performance or physics behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:126
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// Whether the constraint graph retains state between ticks. It will be very expensive with this disabled...
bool bChaosSolverPersistentGraph = true;
FAutoConsoleVariableRef CVarChaosSolverPersistentGraph(TEXT("p.Chaos.Solver.PersistentGraph"), bChaosSolverPersistentGraph, TEXT(""));
// Determines what happens when two one-way particles collide
// See EOneWayInteractionPairCollisionMode
int32 ChaosOneWayInteractionPairCollisionMode = (int32)EOneWayInteractionPairCollisionMode::SphereCollision;
FAutoConsoleVariableRef CVarChaosIgnoreOneWayPairCollisions(TEXT("p.Chaos.Solver.OneWayPairCollisionMode"), ChaosOneWayInteractionPairCollisionMode, TEXT("How to treat collisions between two one-way interaction particles. See EOneWayInteractionPairCollisionMode (0: Ignore collisions; 1: Collide as normal; 2: Collide as spheres)"));
#Associated Variable and Callsites
This variable is associated with another variable named bChaosSolverPersistentGraph
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandManager.cpp:39
Scope (from outer to inner):
file
namespace Chaos::CVars
Source code excerpt:
extern int32 ChaosSolverCollisionPositionShockPropagationIterations;
extern int32 ChaosSolverCollisionVelocityShockPropagationIterations;
extern bool bChaosSolverPersistentGraph;
extern FRealSingle SmoothedPositionLerpRate;
bool bChaosConstraintGraphValidate = (CHAOS_CONSTRAINTGRAPH_CHECK_ENABLED != 0);
FAutoConsoleVariableRef CVarChaosConstraintGraphValidate(TEXT("p.Chaos.ConstraintGraph.Validate"), bChaosConstraintGraphValidate, TEXT("Enable per-tick ConstraintGraph validation checks/assertions"));
/** Cvar to enable/disable the island sleeping */
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp:33
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
extern bool bChaos_PBDCollisionSolver_UseJacobiPairSolver2;
extern bool bChaosSolverPersistentGraph;
}
int32 CollisionParticlesBVHDepth = 4;
FAutoConsoleVariableRef CVarCollisionParticlesBVHDepth(TEXT("p.CollisionParticlesBVHDepth"), CollisionParticlesBVHDepth, TEXT("The maximum depth for collision particles bvh"));
int32 ConstraintBPBVHDepth = 2;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp:667
Scope (from outer to inner):
file
namespace Chaos
function void FPBDCollisionConstraints::AddConstraintsToGraph
Source code excerpt:
// @chaos(todo): if graph persistent is disabled we remove all collisions, but in a non-optimal way...
TempCollisions.Reset();
const bool bRemoveAllAwakeCollisions = !CVars::bChaosSolverPersistentGraph;
IslandManager.VisitAwakeConstraints(GetContainerId(),
[this, bRemoveAllAwakeCollisions](const Private::FPBDIslandConstraint* IslandConstraint)
{
FPBDCollisionConstraintHandle* CollisionHandle = IslandConstraint->GetConstraint()->AsUnsafe<FPBDCollisionConstraintHandle>();
if (bRemoveAllAwakeCollisions || !CollisionHandle->IsEnabled() || CollisionHandle->IsProbe() || ConstraintAllocator.IsConstraintExpired(CollisionHandle->GetContact()))
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:125
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// Whether the constraint graph retains state between ticks. It will be very expensive with this disabled...
bool bChaosSolverPersistentGraph = true;
FAutoConsoleVariableRef CVarChaosSolverPersistentGraph(TEXT("p.Chaos.Solver.PersistentGraph"), bChaosSolverPersistentGraph, TEXT(""));
// Determines what happens when two one-way particles collide
// See EOneWayInteractionPairCollisionMode
int32 ChaosOneWayInteractionPairCollisionMode = (int32)EOneWayInteractionPairCollisionMode::SphereCollision;
FAutoConsoleVariableRef CVarChaosIgnoreOneWayPairCollisions(TEXT("p.Chaos.Solver.OneWayPairCollisionMode"), ChaosOneWayInteractionPairCollisionMode, TEXT("How to treat collisions between two one-way interaction particles. See EOneWayInteractionPairCollisionMode (0: Ignore collisions; 1: Collide as normal; 2: Collide as spheres)"));