p.UseConnectivity

p.UseConnectivity

#Overview

name: p.UseConnectivity

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.UseConnectivity is to control whether the connectivity graph is used when breaking up clusters in the Chaos physics system of Unreal Engine 5. This setting is part of the experimental Chaos physics module, which is a new physics engine introduced in Unreal Engine.

The Chaos physics module, specifically the rigid clustering system, relies on this setting variable. It’s used in the PBDRigidClustering.cpp file, which is part of the experimental Chaos namespace.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands. It’s initialized with a value of 1 (true).

The associated variable UseConnectivity interacts directly with p.UseConnectivity. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the behavior of cluster breaking in the Chaos physics system. When enabled (set to 1), the system uses a connectivity graph to determine how clusters break apart. This can lead to more realistic and localized breaking of objects.

Best practices when using this variable include:

  1. Consider the performance implications of enabling the connectivity graph, as it may increase computational overhead.
  2. Test your simulations with both enabled and disabled states to determine which provides the best balance of realism and performance for your specific use case.
  3. Be aware that changing this setting may significantly alter the behavior of breaking objects in your game or simulation.

Regarding the associated variable UseConnectivity:

The purpose of UseConnectivity is the same as p.UseConnectivity - it controls the use of the connectivity graph in cluster breaking calculations.

It’s used directly in the code to conditionally execute certain operations. For example, in the ReleaseClusterParticlesImpl function, it determines whether to update the connected graph of removed children.

The value of UseConnectivity is set by the console variable p.UseConnectivity, so changing one will affect the other.

Developers should be aware that this variable is used in performance-critical sections of the physics code, so its state can have a significant impact on simulation performance and behavior.

Best practices include using this variable in conjunction with profiling tools to optimize physics performance, and considering its impact when debugging unexpected physics behavior in clustered objects.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	int32 UseConnectivity = 1;
	FAutoConsoleVariableRef CVarUseConnectivity(TEXT("p.UseConnectivity"), UseConnectivity, TEXT("Whether to use connectivity graph when breaking up clusters"));

	bool bCheckForInterclusterEdgesOnRelease = true;
	FAutoConsoleVariableRef CVarCheckForInterclusterEdgesOnRelease(TEXT("p.Chaos.CheckForInterclusterEdgesOnRelease"), bCheckForInterclusterEdgesOnRelease, TEXT("Whether to check for intercluster edges when removing a child from its parent cluster so that we can add the particle back into a cluster union."));

	bool bOnlyUseInterclusterEdgesAttachedToMainParticles = true;
	FAutoConsoleVariableRef CVarOnlyUseInterclusterEdgesAttachedToMainParticles(TEXT("p.Chaos.OnlyUseInterclusterEdgesAttachedToMainParticles"), bOnlyUseInterclusterEdgesAttachedToMainParticles, TEXT("If true, an intercluster edge must be directly attached to a main particle for the particle to remain a part of the cluster union."));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FAutoConsoleVariableRef CVarClusterDistance(TEXT("p.ClusterDistanceThreshold"), ClusterDistanceThreshold, TEXT("How close a cluster child must be to a contact to break off"));

	int32 UseConnectivity = 1;
	FAutoConsoleVariableRef CVarUseConnectivity(TEXT("p.UseConnectivity"), UseConnectivity, TEXT("Whether to use connectivity graph when breaking up clusters"));

	bool bCheckForInterclusterEdgesOnRelease = true;
	FAutoConsoleVariableRef CVarCheckForInterclusterEdgesOnRelease(TEXT("p.Chaos.CheckForInterclusterEdgesOnRelease"), bCheckForInterclusterEdgesOnRelease, TEXT("Whether to check for intercluster edges when removing a child from its parent cluster so that we can add the particle back into a cluster union."));

	bool bOnlyUseInterclusterEdgesAttachedToMainParticles = true;
	FAutoConsoleVariableRef CVarOnlyUseInterclusterEdgesAttachedToMainParticles(TEXT("p.Chaos.OnlyUseInterclusterEdgesAttachedToMainParticles"), bOnlyUseInterclusterEdgesAttachedToMainParticles, TEXT("If true, an intercluster edge must be directly attached to a main particle for the particle to remain a part of the cluster union."));

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

Scope (from outer to inner):

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

Source code excerpt:

			}

			if (UseConnectivity)
			{
				// The cluster may have contained forests, so find the connected pieces and cluster them together.
				//first update the connected graph of the children we already removed
				for (FPBDRigidParticleHandle* Child : ActivatedChildren)
				{
					RemoveNodeConnections(Child);

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FRigidClustering::UpdateConnectivityGraphUsingPointImplicit

Source code excerpt:

		SCOPE_CYCLE_COUNTER(STAT_UpdateConnectivityGraphUsingPointImplicit);

		if (!UseConnectivity)
		{
			return;
		}

		const FReal Delta = FMath::Min(FMath::Max(CollisionThicknessPercent, FReal(0)), FReal(1));