p.gc.CreateGTParticlesForChildren
p.gc.CreateGTParticlesForChildren
#Overview
name: p.gc.CreateGTParticlesForChildren
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true create all children particles at initilaization time, otherwise wait until destruction occurs.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.gc.CreateGTParticlesForChildren is to control the creation of child particles in the Geometry Collection system of Unreal Engine 5’s Chaos physics engine.
This setting variable is primarily used in the Chaos physics subsystem, specifically within the Geometry Collection module. It affects the initialization and management of physics particles for child objects in a geometry collection.
The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. It’s initialized to true by default.
The associated variable bCreateGTParticleForChildren directly interacts with p.gc.CreateGTParticlesForChildren. They share the same value and purpose.
Developers must be aware that:
- This variable affects the initialization behavior of child particles in geometry collections.
- When set to true, all child particles are created at initialization time.
- When set to false, child particle creation is deferred until destruction occurs.
Best practices when using this variable include:
- Consider performance implications when deciding whether to create all particles upfront or defer creation.
- Be consistent in its usage across related systems to avoid unexpected behavior.
- Test both true and false scenarios to ensure your game performs well in both cases.
Regarding the associated variable bCreateGTParticleForChildren:
- It serves the same purpose as p.gc.CreateGTParticlesForChildren.
- It’s used in conjunction with another variable bBuildGeometryForChildrenOnGT to determine particle creation and geometry building behavior.
- When either bCreateGTParticleForChildren or bBuildGeometryForChildrenOnGT is true, the system creates particles for all children at initialization time.
- If both are false, particle creation for non-root objects is deferred until later in the lifecycle.
Developers should be aware that these settings can impact memory usage and initialization time, so they should be tuned based on the specific needs of their project.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:550
Scope: file
Source code excerpt:
bool bCreateGTParticleForChildren = true;
FAutoConsoleVariableRef CVarCreateGTParticleForChildren(TEXT("p.gc.CreateGTParticlesForChildren"), bCreateGTParticleForChildren, TEXT("If true create all children particles at initilaization time, otherwise wait until destruction occurs."));
bool bRemoveImplicitsInDynamicCollections = false;
FAutoConsoleVariableRef CVarbRemoveImplicitsInDynamicCollections(TEXT("p.gc.RemoveImplicitsInDynamicCollections"),
bRemoveImplicitsInDynamicCollections, TEXT("This cvar has an impact only if geometry are not added for children. It removes implicits from the Dynamic Collections, and recreate then from the rest collection. \
Using this cvar could have an impact if geometry are updated from the dynamic collection on the GT, then those changes won't be ported to the PT."));
#Associated Variable and Callsites
This variable is associated with another variable named bCreateGTParticleForChildren
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:549
Scope: file
Source code excerpt:
FAutoConsoleVariableRef CVarbBuildGeometryForChildrenOnGT(TEXT("p.gc.BuildGeometryForChildrenOnGT"), bBuildGeometryForChildrenOnGT, TEXT("If true build all children geometry on Game Thread at initilaization time, otherwise wait until destruction occurs."));
bool bCreateGTParticleForChildren = true;
FAutoConsoleVariableRef CVarCreateGTParticleForChildren(TEXT("p.gc.CreateGTParticlesForChildren"), bCreateGTParticleForChildren, TEXT("If true create all children particles at initilaization time, otherwise wait until destruction occurs."));
bool bRemoveImplicitsInDynamicCollections = false;
FAutoConsoleVariableRef CVarbRemoveImplicitsInDynamicCollections(TEXT("p.gc.RemoveImplicitsInDynamicCollections"),
bRemoveImplicitsInDynamicCollections, TEXT("This cvar has an impact only if geometry are not added for children. It removes implicits from the Dynamic Collections, and recreate then from the rest collection. \
Using this cvar could have an impact if geometry are updated from the dynamic collection on the GT, then those changes won't be ported to the PT."));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:709
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::Initialize
Source code excerpt:
}
// If GT particle have been created, we can use directly the UniqueIdx from the GTParticle, then free up some space.
if (bBuildGeometryForChildrenOnGT || bCreateGTParticleForChildren)
{
UniqueIdxs.Empty();
}
}
void FGeometryCollectionPhysicsProxy::CreateGTParticles(TManagedArray<Chaos::FImplicitObjectPtr>& Implicits, Chaos::FPBDRigidsEvolutionBase* Evolution, bool bInitializationTime)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:724
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::CreateGTParticles
Source code excerpt:
TArray<int32> ChildrenToCheckForParentFix;
if (!bInitializationTime && !bCreateGTParticleForChildren && !bBuildGeometryForChildrenOnGT)
{
GTParticlesToTransformGroupIndex.Reserve(NumEffectiveParticles);
}
for (int32 ParticleIndex = 0; ParticleIndex < NumEffectiveParticles; ++ParticleIndex)
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:741
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::CreateGTParticles
Source code excerpt:
if ((bInitializationTime && TransformIndex == Parameters.InitialRootIndex) || // When initializing always create particle for the root
((bInitializationTime && (bCreateGTParticleForChildren || bBuildGeometryForChildrenOnGT)) || // When initializing create all particles if one of the flag is true
(!bInitializationTime && TransformIndex != Parameters.InitialRootIndex && !bCreateGTParticleForChildren && !bBuildGeometryForChildrenOnGT))) // When not initializing create other particles if flag was set to not create
{
GTParticles[ParticleIndex] = FParticle::CreateParticle();
P = GTParticles[ParticleIndex].Get();
GTParticlesToTransformGroupIndex.Add(P, TransformIndex);
GTParticles[ParticleIndex]->SetUniqueIdx(UniqueIdxs[ParticleIndex]);
#if CHAOS_DEBUG_NAME