p.Chaos.ArrayCollection.MinSlack
p.Chaos.ArrayCollection.MinSlack
#Overview
name: p.Chaos.ArrayCollection.MinSlack
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Do not reduce the size of particle arrays if it would leave less slack than this
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.ArrayCollection.MinSlack is to control the minimum number of slack elements in particle arrays within the Chaos physics system of Unreal Engine 5. This setting is part of the memory management strategy for the Chaos solver, which is responsible for physics simulations.
-
The Chaos physics subsystem in Unreal Engine 5 relies on this setting variable. It’s specifically used in the PBDRigidsSolver, which is part of the Experimental Chaos module.
-
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 100 and can be modified at runtime using the console command “p.Chaos.ArrayCollection.MinSlack”.
-
This variable interacts with two other variables:
- p.Chaos.Solver.ShrinkArrays (bChaosSolverShrinkArrays)
- p.Chaos.ArrayCollection.MaxSlackFraction (ChaosArrayCollectionMaxSlackFraction)
-
Developers must be aware that this variable affects memory usage and performance of the Chaos physics system. It prevents the particle arrays from shrinking too much, which could lead to frequent reallocations.
-
Best practices when using this variable include:
- Setting it high enough to prevent frequent reallocations, but not so high that it wastes memory.
- Considering the typical number of particles in your scenes when adjusting this value.
- Using it in conjunction with p.Chaos.ArrayCollection.MaxSlackFraction for optimal memory management.
Regarding the associated variable ChaosArrayCollectionMinSlack:
-
The purpose of ChaosArrayCollectionMinSlack is the same as p.Chaos.ArrayCollection.MinSlack. It’s the internal representation of the console variable.
-
It’s used directly in the PBDRigidsSolver’s AdvanceOneTimeStepTask when shrinking particle arrays.
-
The value is set by the console variable system and can be modified at runtime.
-
It interacts with ChaosArrayCollectionMaxSlackFraction when shrinking arrays.
-
Developers should be aware that modifying p.Chaos.ArrayCollection.MinSlack will directly affect this variable.
-
Best practices include monitoring this variable’s value during performance profiling to ensure it’s set appropriately for your specific use case.
#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:295
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
FAutoConsoleVariableRef CVarChaosSolverShrinkArrays(TEXT("p.Chaos.Solver.ShrinkArrays"), bChaosSolverShrinkArrays, TEXT("Enable/Disable particle array shrinking in the main scene"));
FAutoConsoleVariableRef CVarChaosSolverArrayCollectionMaxSlackFraction(TEXT("p.Chaos.ArrayCollection.MaxSlackFraction"), ChaosArrayCollectionMaxSlackFraction, TEXT("Shrink particle arrays if the number of slack elements exceeds the number of elements by this fraction"));
FAutoConsoleVariableRef CVarChaosSolverArrayCollectionMinSlack(TEXT("p.Chaos.ArrayCollection.MinSlack"), ChaosArrayCollectionMinSlack, TEXT("Do not reduce the size of particle arrays if it would leave less slack than this"));
// Iteration count cvars
// These override the engine config if >= 0
int32 ChaosSolverCollisionPositionFrictionIterations = -1;
int32 ChaosSolverCollisionVelocityFrictionIterations = -1;
#Associated Variable and Callsites
This variable is associated with another variable named ChaosArrayCollectionMinSlack
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:292
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
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"));
FAutoConsoleVariableRef CVarChaosSolverArrayCollectionMaxSlackFraction(TEXT("p.Chaos.ArrayCollection.MaxSlackFraction"), ChaosArrayCollectionMaxSlackFraction, TEXT("Shrink particle arrays if the number of slack elements exceeds the number of elements by this fraction"));
FAutoConsoleVariableRef CVarChaosSolverArrayCollectionMinSlack(TEXT("p.Chaos.ArrayCollection.MinSlack"), ChaosArrayCollectionMinSlack, TEXT("Do not reduce the size of particle arrays if it would leave less slack than this"));
// Iteration count cvars
// These override the engine config if >= 0
int32 ChaosSolverCollisionPositionFrictionIterations = -1;
int32 ChaosSolverCollisionVelocityFrictionIterations = -1;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:610
Scope (from outer to inner):
file
namespace Chaos
class class AdvanceOneTimeStepTask : public FNonAbandonableTask
function void DoWork
Source code excerpt:
{
QUICK_SCOPE_CYCLE_COUNTER(ShrinkParticleArrays);
MSolver->GetParticles().ShrinkArrays(CVars::ChaosArrayCollectionMaxSlackFraction, CVars::ChaosArrayCollectionMinSlack);
}
if (FRewindData* RewindData = MSolver->GetRewindData())
{
SCOPE_CYCLE_COUNTER(STAT_RewindFinishFrame);
RewindData->FinishFrame();