p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh

p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh

#Overview

name: p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh

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.Collision.EnableMeshManifoldOptimizedLoopTriMesh is to enable or disable an optimized loop for mesh manifold collision detection, specifically for triangle meshes in the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used in the Chaos physics subsystem, which is part of Unreal Engine’s experimental features. It’s specifically related to collision detection and manifold generation for triangle meshes.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through the console. It’s initialized to true by default.

This variable interacts closely with another variable named bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh. They share the same value and are set up together in the code.

Developers should be aware that this is part of an experimental feature set. Changes to this variable could significantly impact the performance and accuracy of collision detection for triangle meshes in the Chaos physics system.

Best practices when using this variable include:

  1. Testing thoroughly when enabling or disabling this optimization, as it may affect collision behavior.
  2. Monitoring performance metrics to ensure the optimization is beneficial for your specific use case.
  3. Being cautious when modifying this in shipping builds, as it could potentially introduce unexpected behavior.

Regarding the associated variable bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh:

This variable serves the same purpose as p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh. It’s a boolean flag used internally in the C++ code to control the optimized loop for mesh manifold collision detection with triangle meshes.

It’s used in the ConstructPlanarConvexTriMeshOneShotManifold function to determine whether to use the optimized loop for triangle mesh collision detection.

The value of this variable is set in tandem with p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh using the FAutoConsoleVariableRef system.

Developers should treat this variable as internal to the Chaos system and generally interact with it through the console variable p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh rather than directly manipulating the C++ variable.

When working with this variable, developers should be aware of its impact on the collision detection process and ensure that any changes are thoroughly tested across various collision scenarios involving triangle meshes.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifolds.cpp:104

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	bool bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh = true;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableMeshManifoldOptimizedLoop(TEXT("p.Chaos.Collision.EnableMeshManifoldOptimizedLoop"), bChaos_Collision_EnableMeshManifoldOptimizedLoop, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh(TEXT("p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh"), bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh, TEXT(""));

	// MACD uses the non-MACD path when the shape is outside the triangle plane
	bool bChaos_Collision_EnableMACDFallback = false;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableMACDFallback(TEXT("p.Chaos.Collision.EnableMACDFallback"), bChaos_Collision_EnableMACDFallback, TEXT(""));

	// Whether to use the new index-less GJK. 

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifolds.cpp:102

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	// @todo(chaos): Temp while we test the new convex-mesh collision optimizations
	bool bChaos_Collision_EnableMeshManifoldOptimizedLoop = true;
	bool bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh = true;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableMeshManifoldOptimizedLoop(TEXT("p.Chaos.Collision.EnableMeshManifoldOptimizedLoop"), bChaos_Collision_EnableMeshManifoldOptimizedLoop, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh(TEXT("p.Chaos.Collision.EnableMeshManifoldOptimizedLoopTriMesh"), bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh, TEXT(""));

	// MACD uses the non-MACD path when the shape is outside the triangle plane
	bool bChaos_Collision_EnableMACDFallback = false;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableMACDFallback(TEXT("p.Chaos.Collision.EnableMACDFallback"), bChaos_Collision_EnableMACDFallback, TEXT(""));

	// Whether to use the new index-less GJK. 

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMeshShapes.cpp:35

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	extern int32 Chaos_Collision_MeshManifoldHashSize;
	extern bool bChaos_Collision_EnableMeshManifoldOptimizedLoop;
	extern bool bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh;
	extern bool bChaos_Collision_EnableMACDFallback;

	extern bool bChaos_Collision_UseCapsuleTriMesh2;
	extern bool bChaos_Collision_UseConvexTriMesh2;
	
	namespace CVars

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMeshShapes.cpp:486

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructPlanarConvexTriMeshOneShotManifold

Source code excerpt:

			const FReal DistanceTolerance = Chaos_Collision_TriMeshDistanceTolerance;

			if (bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh)
			{
				const FVec3 RelativeMovement = FVec3(Constraint.GetRelativeMovement());
				Private::FMeshContactGeneratorSettings ContactGeneratorSettings;

				// @todo(chaos): we don't need to enable normal fixup for MACD mode, except when 
				// fall back to non-MACD (which is a per-triangle decision) so for now it must be enabled.