p.Chaos.Solver.ParticlePoolNumFrameUntilShrink
p.Chaos.Solver.ParticlePoolNumFrameUntilShrink
#Overview
name: p.Chaos.Solver.ParticlePoolNumFrameUntilShrink
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Num Frame until we can potentially shrink the pool
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.ParticlePoolNumFrameUntilShrink is to control the behavior of the particle pool in the Chaos physics solver, specifically determining the number of frames that must pass before the pool can potentially be shrunk.
This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics simulation module. It’s specifically related to the particle pool optimization in the PBDRigidsSolver (Position Based Dynamics Rigids Solver).
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through the console or configuration files. The default value is set to 30 frames.
The associated variable ChaosSolverParticlePoolNumFrameUntilShrink directly interacts with this console variable. They share the same value, with the console variable allowing for runtime modification.
Developers should be aware that this variable affects the memory management of the particle pool in the Chaos solver. A higher value will keep the pool size stable for longer, potentially using more memory but reducing allocation/deallocation overhead. A lower value allows the pool to shrink more frequently, potentially saving memory but possibly increasing overhead if the pool size fluctuates often.
Best practices when using this variable include:
- Monitor performance and memory usage to find the optimal value for your specific use case.
- Consider the nature of your physics simulation - if the number of particles is relatively stable, a higher value might be beneficial.
- Be cautious about setting this value too low, as frequent resizing of the pool could impact performance.
Regarding the associated variable ChaosSolverParticlePoolNumFrameUntilShrink:
This is an int32 variable that directly holds the value set by the console variable. It’s declared in the Chaos::CVars namespace and is also externally accessible as indicated by its declaration in the header file.
The purpose of this associated variable is to provide a quick access point for the solver to check how many frames should pass before considering shrinking the particle pool. It’s likely used in the main loop of the solver to determine when to evaluate and potentially resize the pool.
Developers should be aware that modifying this variable directly in code won’t persist changes across sessions or allow for runtime tuning like the console variable does. It’s best to use the console variable for adjustments and rely on this associated variable for internal logic in the solver.
#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:279
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
int32 ChaosSolverParticlePoolNumFrameUntilShrink = 30;
FAutoConsoleVariableRef CVarChaosSolverParticlePoolNumFrameUntilShrink(TEXT("p.Chaos.Solver.ParticlePoolNumFrameUntilShrink"), ChaosSolverParticlePoolNumFrameUntilShrink, TEXT("Num Frame until we can potentially shrink the pool"));
// Joint solver mode (linear vs non-linear)
bool bChaosSolverJointUseLinearSolver = true;
FAutoConsoleVariableRef CVarChaosSolverJointUseCachedSolver(TEXT("p.Chaos.Solver.Joint.UseLinearSolver"), bChaosSolverJointUseLinearSolver, TEXT("Use linear version of joint solver. (default is true"));
// Enable/Disable collisions
#Associated Variable and Callsites
This variable is associated with another variable named ChaosSolverParticlePoolNumFrameUntilShrink
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:278
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
FAutoConsoleVariableRef CVarChaosSolverUseParticlePool(TEXT("p.Chaos.Solver.UseParticlePool"), ChaosSolverUseParticlePool, TEXT("Whether or not to use dirty particle pool (Optim)"));
int32 ChaosSolverParticlePoolNumFrameUntilShrink = 30;
FAutoConsoleVariableRef CVarChaosSolverParticlePoolNumFrameUntilShrink(TEXT("p.Chaos.Solver.ParticlePoolNumFrameUntilShrink"), ChaosSolverParticlePoolNumFrameUntilShrink, TEXT("Num Frame until we can potentially shrink the pool"));
// Joint solver mode (linear vs non-linear)
bool bChaosSolverJointUseLinearSolver = true;
FAutoConsoleVariableRef CVarChaosSolverJointUseCachedSolver(TEXT("p.Chaos.Solver.Joint.UseLinearSolver"), bChaosSolverJointUseLinearSolver, TEXT("Use linear version of joint solver. (default is true"));
// Enable/Disable collisions
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/PBDRigidsSolver.h:38
Scope: file
Source code excerpt:
#define GEOMETRY_PREALLOC_COUNT 100
extern int32 ChaosSolverParticlePoolNumFrameUntilShrink;
namespace ChaosTest
{
template <typename TSolver>
void AdvanceSolverNoPushHelper(TSolver* Solver, Chaos::FReal Dt);
}