p.Chaos.ClusterUnion.GenerateInterclusterEdges

p.Chaos.ClusterUnion.GenerateInterclusterEdges

#Overview

name: p.Chaos.ClusterUnion.GenerateInterclusterEdges

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.ClusterUnion.GenerateInterclusterEdges is to control the automatic generation of intercluster edges when adding particles to a cluster union in the Chaos physics system of Unreal Engine 5. This setting variable is specifically related to the physics simulation and clustering system within the Chaos framework.

This setting variable is primarily used in the Chaos module of Unreal Engine 5, which is part of the experimental physics system. Based on the callsites, it’s clear that this variable is utilized within the ClusterUnionManager.cpp file, which is responsible for managing cluster unions in the Chaos physics system.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through the console. Its default value is set to true.

The associated variable bChaosClusterUnionGenerateInterclusterEdges directly interacts with p.Chaos.ClusterUnion.GenerateInterclusterEdges. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the behavior of cluster unions in the Chaos physics system. When set to true, it automatically generates intercluster edges when adding particles to a cluster union and removes them when removing particles from the union. This can have implications for performance and simulation accuracy.

Best practices when using this variable include:

  1. Consider the performance impact of generating intercluster edges, especially in scenarios with many particles or complex cluster structures.
  2. Test the simulation behavior with both true and false settings to determine the optimal configuration for your specific use case.
  3. Be aware that changing this setting may require adjustments to other parts of your physics simulation setup.

Regarding the associated variable bChaosClusterUnionGenerateInterclusterEdges:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionManager.cpp:19

Scope (from outer to inner):

file
namespace    Chaos
namespace    anonymous

Source code excerpt:

		bool bChaosClusterUnionGenerateInterclusterEdges = true;
		FAutoConsoleVariableRef CVarChaosClusterUnionGenerateInterclusterEdges(
			TEXT("p.Chaos.ClusterUnion.GenerateInterclusterEdges"),
			bChaosClusterUnionGenerateInterclusterEdges,
			TEXT("Whether to generate intercluster edges automatically when adding to a cluster union (and remove them when removing from the cluster union).")
		);

		// @tmp: To be removed
		bool bChaosClusterUnionDoNotAddEmptyClusters = true;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionManager.cpp:17

Scope (from outer to inner):

file
namespace    Chaos
namespace    anonymous

Source code excerpt:

	namespace
	{
		bool bChaosClusterUnionGenerateInterclusterEdges = true;
		FAutoConsoleVariableRef CVarChaosClusterUnionGenerateInterclusterEdges(
			TEXT("p.Chaos.ClusterUnion.GenerateInterclusterEdges"),
			bChaosClusterUnionGenerateInterclusterEdges,
			TEXT("Whether to generate intercluster edges automatically when adding to a cluster union (and remove them when removing from the cluster union).")
		);

		// @tmp: To be removed
		bool bChaosClusterUnionDoNotAddEmptyClusters = true;
		FAutoConsoleVariableRef CVarChaosClusterUnionDoNotAddEmptyClusters(

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionManager.cpp:165

Scope (from outer to inner):

file
namespace    anonymous
function     void AddParticleToConnectionGraph
lambda-function

Source code excerpt:

								}

								if (bChaosClusterUnionGenerateInterclusterEdges && Particle && OtherParticle)
								{
									// Only generate intercluster edges for main particles. Auxiliary particles that are just bits and pieces of geometry collections
									// shouldn't also generate intercluster edges.
									if (!Properties || !Properties->bIsAuxiliaryParticle)
									{
										const TArray<FPBDRigidParticleHandle*>& ParticleChildren = Clustering.GetChildrenMap().FindRef(Particle->CastToClustered());

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionManager.cpp:205

Scope (from outer to inner):

file
namespace    Chaos
namespace    anonymous
function     void RemoveClusterUnionEdges

Source code excerpt:

			Clustering.RemoveNodeConnections(ParticleHandle);

			if (bChaosClusterUnionGenerateInterclusterEdges)
			{
				if (FPBDRigidClusteredParticleHandle* ClusterParticle = ParticleHandle->CastToClustered())
				{
					if (TArray<FPBDRigidParticleHandle*>* AllChildren = Clustering.GetChildrenMap().Find(ClusterParticle))
					{
						for (FPBDRigidParticleHandle* Child : *AllChildren)