p.gc.RemoveImplicitsInDynamicCollections
p.gc.RemoveImplicitsInDynamicCollections
#Overview
name: p.gc.RemoveImplicitsInDynamicCollections
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
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. \t\t\t\t\t\t\t\t\t\tUsing 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.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.gc.RemoveImplicitsInDynamicCollections is to control the removal of implicit objects from dynamic collections in the Chaos physics system of Unreal Engine 5, specifically for geometry collections.
This setting variable is primarily used in the Chaos physics module, which is part of Unreal Engine’s experimental physics system. It affects the behavior of the GeometryCollectionPhysicsProxy class.
The value of this variable is set through an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands or configuration files.
The associated boolean variable bRemoveImplicitsInDynamicCollections directly interacts with p.gc.RemoveImplicitsInDynamicCollections. They share the same value and are used interchangeably in the code.
Developers must be aware that:
- This variable only has an impact if geometries are not added for children.
- It removes implicits from dynamic collections and recreates them from the rest collection.
- Using this variable could have an impact if geometries are updated from the dynamic collection on the game thread, as those changes won’t be ported to the physics thread.
Best practices when using this variable:
- Use it cautiously, as it can affect memory usage and performance.
- Be aware of its impact on the synchronization between game thread and physics thread data.
- Test thoroughly when enabling this option to ensure it doesn’t introduce unexpected behavior in your geometry collections.
Regarding the associated variable bRemoveImplicitsInDynamicCollections:
- It serves the same purpose as p.gc.RemoveImplicitsInDynamicCollections.
- It’s used directly in the C++ code to control the behavior of implicit object removal and recreation.
- It’s referenced in several methods of the FGeometryCollectionPhysicsProxy class, including Initialize, CreateChildrenGeometry_External, InitializeBodiesPT, and CreateChildrenGeometry_Internal.
- When true, it triggers the removal of the ImplicitsAttribute from both GameThreadCollection and PhysicsThreadCollection, potentially freeing up memory.
- It also controls whether implicits are re-added and copied from the rest collection when creating children geometry.
Developers should use this variable with the same considerations and best practices as mentioned for p.gc.RemoveImplicitsInDynamicCollections.
#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:553
Scope: file
Source code excerpt:
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."));
void FGeometryCollectionPhysicsProxy::Initialize(Chaos::FPBDRigidsEvolutionBase *Evolution)
{
#Associated Variable and Callsites
This variable is associated with another variable named bRemoveImplicitsInDynamicCollections
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:552
Scope: file
Source code excerpt:
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."));
void FGeometryCollectionPhysicsProxy::Initialize(Chaos::FPBDRigidsEvolutionBase *Evolution)
{
check(IsInGameThread());
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:703
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::Initialize
Source code excerpt:
}
if (bHasBuiltGeometryOnGT || bRemoveImplicitsInDynamicCollections)
{
// The Implicits attributes from the Dynamic Collection are just used for initialization, after they can be removed and so free some memory.
GameThreadCollection.RemoveAttribute(FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
}
// If GT particle have been created, we can use directly the UniqueIdx from the GTParticle, then free up some space.
if (bBuildGeometryForChildrenOnGT || bCreateGTParticleForChildren)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:932
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::CreateChildrenGeometry_External
Source code excerpt:
if (Chaos::FPhysicsSolver* RBDSolver = GetSolver<Chaos::FPhysicsSolver>())
{
if (bRemoveImplicitsInDynamicCollections)
{
GameThreadCollection.AddAttribute<Chaos::FImplicitObjectPtr>(FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
GameThreadCollection.CopyAttribute(*Parameters.RestCollection, FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
}
TManagedArray<Chaos::FImplicitObjectPtr>& Implicits = GameThreadCollection.ModifyAttribute<Chaos::FImplicitObjectPtr>(FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1685
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::InitializeBodiesPT
Source code excerpt:
DirtyAllParticles(*RigidsSolver);
if (bHasBuiltGeometryOnPT || bRemoveImplicitsInDynamicCollections)
{
// The Implicits attributes from the Dynamic Collection are just used for geometry initialization, after they can be removed and so free some memory.
PhysicsThreadCollection.RemoveAttribute(FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
}
} // end if simulating...
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1702
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::CreateChildrenGeometry_Internal
Source code excerpt:
if (Parameters.Simulating && ensure(RestCollection))
{
if (bRemoveImplicitsInDynamicCollections)
{
PhysicsThreadCollection.AddAttribute<Chaos::FImplicitObjectPtr>(FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
PhysicsThreadCollection.CopyAttribute(*Parameters.RestCollection, FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
}
check(NumTransforms == PhysicsThreadCollection.NumElements(FTransformCollection::TransformGroup));