p.Chaos.Collision.EnableShapePairs

p.Chaos.Collision.EnableShapePairs

#Overview

name: p.Chaos.Collision.EnableShapePairs

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.Chaos.Collision.EnableShapePairs is to control whether the Chaos physics engine supports pre-flattened shape pair lists for collision detection optimization. This setting is part of the collision system within the Chaos physics module of Unreal Engine 5.

This setting variable is primarily used in the Chaos physics subsystem, specifically in the collision detection module. It’s referenced in the Experimental/Chaos runtime module, indicating it’s part of the newer Chaos physics engine rather than the older PhysX system.

The value of this variable is set through the Unreal Engine console variable system (CVars). It’s initialized to true by default but can be changed at runtime through console commands or configuration files.

The p.Chaos.Collision.EnableShapePairs variable interacts closely with another variable, p.Chaos.Collision.MaxShapePairs. Together, they control the behavior of the shape pair optimization in the collision system.

Developers must be aware that this variable affects the performance and behavior of collision detection in the Chaos physics system. Enabling this optimization (which is the default) can improve performance for common cases where particles have a small number of implicit objects each.

Best practices when using this variable include:

  1. Keep it enabled unless specific issues are encountered.
  2. If disabling it, test thoroughly to ensure no unexpected behavior in collision detection.
  3. Consider adjusting the MaxShapePairs value in conjunction with this setting for fine-tuning performance.

Regarding the associated variable bChaos_Collision_MidPhase_EnableShapePairs:

The purpose of bChaos_Collision_MidPhase_EnableShapePairs is to serve as the internal representation of the p.Chaos.Collision.EnableShapePairs console variable within the Chaos physics code.

This variable is used directly in the Chaos collision detection code to determine whether to use the optimized shape pair list or fall back to the generic midphase collision detection.

The value of this variable is set by the console variable system when p.Chaos.Collision.EnableShapePairs is modified.

It interacts closely with Chaos_Collision_MidPhase_MaxShapePairs to control the behavior of the shape pair optimization.

Developers should be aware that this is the actual variable checked in the collision detection code, so its value directly affects the behavior of the system.

Best practices include not modifying this variable directly in code, but instead using the p.Chaos.Collision.EnableShapePairs console variable to control its value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ParticlePairMidPhase.cpp:59

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		bool bChaos_Collision_MidPhase_EnableShapePairs = true;
		int32 Chaos_Collision_MidPhase_MaxShapePairs = 100;
		FAutoConsoleVariableRef CVarChaos_Collision_EnableShapePairs(TEXT("p.Chaos.Collision.EnableShapePairs"), bChaos_Collision_MidPhase_EnableShapePairs, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_Collision_MaxShapePairs(TEXT("p.Chaos.Collision.MaxShapePairs"), Chaos_Collision_MidPhase_MaxShapePairs, TEXT(""));

		extern int32 ChaosOneWayInteractionPairCollisionMode;

		extern bool bChaosForceMACD;
	}

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ParticlePairMidPhase.cpp:57

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// Whether we support the pre-flattened shape pair list which optimizes the common midphase case of collision between particles 
		// with only a small number implicit objects each. If so, how many shape pairs do we allow before switching to the generic version?
		bool bChaos_Collision_MidPhase_EnableShapePairs = true;
		int32 Chaos_Collision_MidPhase_MaxShapePairs = 100;
		FAutoConsoleVariableRef CVarChaos_Collision_EnableShapePairs(TEXT("p.Chaos.Collision.EnableShapePairs"), bChaos_Collision_MidPhase_EnableShapePairs, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_Collision_MaxShapePairs(TEXT("p.Chaos.Collision.MaxShapePairs"), Chaos_Collision_MidPhase_MaxShapePairs, TEXT(""));

		extern int32 ChaosOneWayInteractionPairCollisionMode;

		extern bool bChaosForceMACD;
	}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ParticlePairMidPhase.cpp:753

Scope (from outer to inner):

file
namespace    Chaos
function     EParticlePairMidPhaseType FParticlePairMidPhase::CalculateMidPhaseType

Source code excerpt:


		// We can force use of the Generic midphase (mainly for testing)
		if (!CVars::bChaos_Collision_MidPhase_EnableShapePairs)
		{
			return EParticlePairMidPhaseType::Generic;
		}

		// How many implicits does each particle have?
		const int32 NumImplicits0 = GetNumLeafImplicits(InParticle0->GetGeometry());