p.gc.BuildGeometryForChildrenOnPT

p.gc.BuildGeometryForChildrenOnPT

#Overview

name: p.gc.BuildGeometryForChildrenOnPT

This variable is created as a Console Variable (cvar).

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.gc.BuildGeometryForChildrenOnPT is to control the timing of geometry building for children in the Chaos physics system of Unreal Engine 5. Specifically, it determines whether to build all children geometry on the Physics Thread at initialization time or wait until destruction occurs.

This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics framework. It is referenced in the GeometryCollectionPhysicsProxy and PBDRigidClustering modules.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. It is initialized to true by default.

The associated variable bBuildGeometryForChildrenOnPT interacts directly with this setting. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the performance and behavior of the physics simulation, particularly for Geometry Collections. When set to true, it may increase initialization time but potentially improve runtime performance by having all geometry ready. When false, it may lead to faster initialization but could cause delays when destruction occurs.

Best practices when using this variable include:

  1. Consider the trade-off between initialization time and runtime performance for your specific use case.
  2. Test both true and false settings to determine which works best for your project.
  3. Be consistent in its usage across related systems to avoid unexpected behavior.

Regarding the associated variable bBuildGeometryForChildrenOnPT:

#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:544

Scope: file

Source code excerpt:


CHAOS_API bool bBuildGeometryForChildrenOnPT = true;
FAutoConsoleVariableRef CVarbBuildGeometryForChildrenOnPT(TEXT("p.gc.BuildGeometryForChildrenOnPT"), bBuildGeometryForChildrenOnPT, TEXT("If true build all children geometry on Physics Thread at initilaization time, otherwise wait until destruction occurs."));

bool bBuildGeometryForChildrenOnGT = true;
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."));

#Associated Variable and Callsites

This variable is associated with another variable named bBuildGeometryForChildrenOnPT. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:26

Scope: file

Source code excerpt:

#include "CoreMinimal.h"

extern CHAOS_API bool bBuildGeometryForChildrenOnPT;

namespace Chaos
{
	//
	//  Connectivity PVar
	//

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:1148

Scope (from outer to inner):

file
namespace    Chaos
function     TSet<FPBDRigidParticleHandle*> FRigidClustering::ReleaseClusterParticlesImpl

Source code excerpt:

			ShockDamagePropagationFactor = SimParams.ShockDamagePropagationFactor;
			
			if (bBuildGeometryForChildrenOnPT == false)
			{
				GenerateEdges(*ConcreteGCProxy, *ClusteredParticle, ClusterUnionManager);
			}
		}

		TArray<FPBDRigidParticleHandle*>& Children = MChildren[ClusteredParticle];

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:543

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarReportHighParticleFraction(TEXT("p.gc.ReportHighParticleFraction"), ReportHighParticleFraction, TEXT("Report any objects with particle fraction above this threshold"));

CHAOS_API bool bBuildGeometryForChildrenOnPT = true;
FAutoConsoleVariableRef CVarbBuildGeometryForChildrenOnPT(TEXT("p.gc.BuildGeometryForChildrenOnPT"), bBuildGeometryForChildrenOnPT, TEXT("If true build all children geometry on Physics Thread at initilaization time, otherwise wait until destruction occurs."));

bool bBuildGeometryForChildrenOnGT = true;
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."));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1220

Scope (from outer to inner):

file
function     void FGeometryCollectionPhysicsProxy::InitializeBodiesPT

Source code excerpt:

	bIsInitializedOnPhysicsThread = true;
	// Building geometry according to the cVar
	bHasBuiltGeometryOnPT = bBuildGeometryForChildrenOnPT;

	if (Parameters.Simulating && RestCollection)
	{
		const TManagedArray<int32>& BoneMap = RestCollection->BoneMap;
		const TManagedArray<int32>& SimulationType = RestCollection->SimulationType;
		const TManagedArray<FVector3f>& Vertex = RestCollection->Vertex;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1289

Scope (from outer to inner):

file
function     void FGeometryCollectionPhysicsProxy::InitializeBodiesPT
lambda-function

Source code excerpt:

					Parameters.Shared,
					Simplicials[TransformGroupIndex].Get(),
					(bBuildGeometryForChildrenOnPT || (TransformGroupIndex == Parameters.InitialRootIndex)) ? Implicits[TransformGroupIndex] : nullptr,
					SimFilter,
					QueryFilter,
					ScaledMass,
					ScaledInertia,
					Transforms[TransformGroupIndex],
					DynamicState[TransformGroupIndex],

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1959

Scope (from outer to inner):

file
function     Chaos::TPBDGeometryCollectionParticleHandle<Chaos::FReal, 3>* FGeometryCollectionPhysicsProxy::BuildNonClusters_Internal

Source code excerpt:

		Parameters.Shared,
		Simplicials[CollectionClusterIndex].Get(),
		(bBuildGeometryForChildrenOnPT || (CollectionClusterIndex == Parameters.InitialRootIndex)) ? Implicits[CollectionClusterIndex] : nullptr,
		SimFilter,
		QueryFilter,
		Mass,
		Inertia,
		ParticleTM,
		static_cast<uint8>(DynamicState[CollectionClusterIndex]),