p.ComputeClusterCollisionStrains

p.ComputeClusterCollisionStrains

#Overview

name: p.ComputeClusterCollisionStrains

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.ComputeClusterCollisionStrains is to control whether collision constraints are used when processing clustering in the Chaos physics system of Unreal Engine 5. This setting variable is primarily used in the rigid body clustering functionality within the experimental Chaos physics engine.

This setting variable is relied upon by the Chaos physics module, specifically in the rigid clustering system. It’s used in the PBDRigidClustering.cpp file, which is part of the experimental Chaos physics engine in Unreal Engine 5.

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

The associated variable ComputeClusterCollisionStrains directly interacts with p.ComputeClusterCollisionStrains. 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 clustering system in the Chaos physics engine. When enabled, it adds additional computation for collision constraints during clustering, which may impact performance but potentially improve the accuracy of the simulation.

Best practices when using this variable include:

  1. Consider the performance implications of enabling this feature, especially in performance-critical scenarios.
  2. Test the behavior of your physics simulations with this setting both enabled and disabled to determine the best configuration for your specific use case.
  3. Be aware that changing this setting at runtime may cause sudden changes in physics behavior.

Regarding the associated variable ComputeClusterCollisionStrains: The purpose of ComputeClusterCollisionStrains is identical to p.ComputeClusterCollisionStrains. It’s an integer variable that acts as a boolean flag to determine whether to compute strain from collisions during the clustering process.

This variable is used directly in the AdvanceClustering function of the FRigidClustering class. When set to true (non-zero), it triggers the ComputeStrainFromCollision function, otherwise, it calls ResetCollisionImpulseArray.

Developers should be aware that this variable directly controls a significant aspect of the clustering algorithm’s behavior. Enabling it may lead to more accurate simulations but at the cost of additional computation.

Best practices for using ComputeClusterCollisionStrains include:

  1. Understand the performance-accuracy trade-off when enabling or disabling this feature.
  2. Consider exposing this setting in your game’s advanced physics options if fine-tuning of physics behavior is desired.
  3. Profile your application’s performance with this setting enabled and disabled to make informed decisions about its use.

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	int32 ComputeClusterCollisionStrains = 1;
	FAutoConsoleVariableRef CVarComputeClusterCollisionStrains(TEXT("p.ComputeClusterCollisionStrains"), ComputeClusterCollisionStrains, TEXT("Whether to use collision constraints when processing clustering."));

	int32 DeactivateClusterChildren = 0;
	FAutoConsoleVariableRef CVarDeactivateClusterChildren(TEXT("p.DeactivateClusterChildren"), DeactivateClusterChildren, TEXT("If children should be decativated when broken and put into another cluster."));

	int32 UseBoundingBoxForConnectionGraphFiltering = 0;
	FAutoConsoleVariableRef CVarUseBoundingBoxForConnectionGraphFiltering(TEXT("p.UseBoundingBoxForConnectionGraphFiltering"), UseBoundingBoxForConnectionGraphFiltering, TEXT("when on, use bounding box overlaps to filter connection during the connection graph generation [def: 0]"));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	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."));

	int32 ComputeClusterCollisionStrains = 1;
	FAutoConsoleVariableRef CVarComputeClusterCollisionStrains(TEXT("p.ComputeClusterCollisionStrains"), ComputeClusterCollisionStrains, TEXT("Whether to use collision constraints when processing clustering."));

	int32 DeactivateClusterChildren = 0;
	FAutoConsoleVariableRef CVarDeactivateClusterChildren(TEXT("p.DeactivateClusterChildren"), DeactivateClusterChildren, TEXT("If children should be decativated when broken and put into another cluster."));

	int32 UseBoundingBoxForConnectionGraphFiltering = 0;
	FAutoConsoleVariableRef CVarUseBoundingBoxForConnectionGraphFiltering(TEXT("p.UseBoundingBoxForConnectionGraphFiltering"), UseBoundingBoxForConnectionGraphFiltering, TEXT("when on, use bounding box overlaps to filter connection during the connection graph generation [def: 0]"));

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FRigidClustering::AdvanceClustering

Source code excerpt:

			//  Grab collision impulses for processing
			//
			if (ComputeClusterCollisionStrains)
			{
				ComputeStrainFromCollision(CollisionRule, Dt);
			}
			else
			{
				ResetCollisionImpulseArray();