p.Chaos.Solver.CollisionModifiersBeforeCCD
p.Chaos.Solver.CollisionModifiersBeforeCCD
#Overview
name: p.Chaos.Solver.CollisionModifiersBeforeCCD
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
True: run the collision modifiers before CCD rewind is applied; False(default): run modifiers after CCD rewind. See comments in code.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.CollisionModifiersBeforeCCD is to control the timing of collision modifier execution in the Chaos physics engine of Unreal Engine 5. It determines whether collision modifiers are run before or after the Continuous Collision Detection (CCD) rewind is applied.
This setting variable is primarily used in the Chaos physics subsystem, specifically in the PBDRigidsEvolutionGBF (Position Based Dynamics Rigids Evolution) module. It’s part of the experimental Chaos namespace, indicating that it’s a feature of the newer Chaos physics engine.
The value of this variable is set through the Unreal Engine console variable system. It’s initialized as a boolean with a default value of false, meaning by default, collision modifiers are run after CCD rewind.
The associated variable bChaosCollisionModiferBeforeCCD directly interacts with this console variable. They share the same value, and bChaosCollisionModiferBeforeCCD is used in the actual code logic to determine the execution order.
Developers must be aware that:
- This is part of the experimental Chaos physics system.
- Changing this variable affects the order of physics operations, which can have significant impacts on simulation results.
- The default behavior (false) runs modifiers after CCD rewind, which is the newer, preferred method.
Best practices when using this variable include:
- Generally, stick with the default value (false) unless there’s a specific need to change it.
- If changing this value, thoroughly test the physics behavior in your game to ensure it doesn’t introduce unexpected issues.
- Use this in conjunction with other Chaos physics settings for fine-tuning physics behavior.
Regarding the associated variable bChaosCollisionModiferBeforeCCD:
- Its purpose is to directly control the logic in the AdvanceOneTimeStepImpl function of the FPBDRigidsEvolutionGBF class.
- It’s used in conditional statements to determine when to apply collision modifiers.
- The value is set by the console variable p.Chaos.Solver.CollisionModifiersBeforeCCD.
- Developers should be aware that this variable directly affects the physics simulation loop.
- Best practice is to treat this as a read-only variable in most cases, allowing it to be controlled via the console variable system for easier debugging and tweaking.
#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:122
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// The new way to disable CCD contacts (pre-rewind) is to do it in a MidPhase- or CCD-Modifier callbacks. See FCCDModifier.
bool bChaosCollisionModiferBeforeCCD = false;
FAutoConsoleVariableRef CVarChaosCollisionModiferBeforeCCD(TEXT("p.Chaos.Solver.CollisionModifiersBeforeCCD"), bChaosCollisionModiferBeforeCCD, TEXT("True: run the collision modifiers before CCD rewind is applied; False(default): run modifiers after CCD rewind. See comments in code."));
// 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
#Associated Variable and Callsites
This variable is associated with another variable named bChaosCollisionModiferBeforeCCD
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:121
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// This cvar allows use to run the modifiers before CCD rewind which is how it used to be, just in case.
// The new way to disable CCD contacts (pre-rewind) is to do it in a MidPhase- or CCD-Modifier callbacks. See FCCDModifier.
bool bChaosCollisionModiferBeforeCCD = false;
FAutoConsoleVariableRef CVarChaosCollisionModiferBeforeCCD(TEXT("p.Chaos.Solver.CollisionModifiersBeforeCCD"), bChaosCollisionModiferBeforeCCD, TEXT("True: run the collision modifiers before CCD rewind is applied; False(default): run modifiers after CCD rewind. See comments in code."));
// 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
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:545
Scope (from outer to inner):
file
namespace Chaos
function void FPBDRigidsEvolutionGBF::AdvanceOneTimeStepImpl
Source code excerpt:
}
if(CollisionModifiers && CVars::bChaosCollisionModiferBeforeCCD)
{
SCOPE_CYCLE_COUNTER(STAT_Evolution_CollisionModifierCallback);
CollisionConstraints.ApplyCollisionModifier(*CollisionModifiers, Dt);
}
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:562
Scope (from outer to inner):
file
namespace Chaos
function void FPBDRigidsEvolutionGBF::AdvanceOneTimeStepImpl
Source code excerpt:
}
if (CollisionModifiers && !CVars::bChaosCollisionModiferBeforeCCD)
{
SCOPE_CYCLE_COUNTER(STAT_Evolution_CollisionModifierCallback);
CollisionConstraints.ApplyCollisionModifier(*CollisionModifiers, Dt);
}
{