p.Chaos.Collision.EnableMeshManifoldOptimizedLoop

p.Chaos.Collision.EnableMeshManifoldOptimizedLoop

#Overview

name: p.Chaos.Collision.EnableMeshManifoldOptimizedLoop

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Collision.EnableMeshManifoldOptimizedLoop is to enable an optimized loop for mesh manifold collision detection in Unreal Engine’s Chaos physics system. This setting is specifically related to the collision detection system within the Chaos physics engine.

This setting variable is primarily used in the Chaos physics subsystem, which is part of Unreal Engine’s experimental features. It’s referenced in the collision-related source files within the Chaos module.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through the console or configuration files. By default, it’s set to true.

The associated variable bChaos_Collision_EnableMeshManifoldOptimizedLoop directly interacts with this setting. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects the performance and potentially the accuracy of mesh collision detection. Enabling the optimized loop may improve performance but could potentially impact collision accuracy in some edge cases.

Best practices when using this variable include:

  1. Testing thoroughly when enabling or disabling this optimization to ensure it doesn’t negatively impact your specific use case.
  2. Monitoring performance metrics to verify the optimization is beneficial for your project.
  3. Being cautious when modifying this setting in shipping builds, as it could affect gameplay consistency.

Regarding the associated variable bChaos_Collision_EnableMeshManifoldOptimizedLoop:

This boolean variable is used directly in the code to control the execution of the optimized mesh manifold collision detection loop. It’s set to true by default, mirroring the console variable.

The variable is used in conditional statements to determine whether to use the optimized loop or fall back to a potentially more accurate but slower method. It’s particularly relevant in functions dealing with convex-heightfield and planar-convex-heightfield collision detection.

Developers should treat this variable with the same considerations as the console variable, understanding that it directly impacts the collision detection process in the Chaos physics system. Any changes to this variable should be thoroughly tested to ensure desired performance and accuracy in collision detection.

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

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

#Associated Variable and Callsites

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

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

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	extern FRealSingle Chaos_Collision_TriMeshPhiToleranceScale;
	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;
	

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructQuadraticConvexHeightFieldOneShotManifold

Source code excerpt:

			const FReal DistanceTolerance = Chaos_Collision_TriMeshDistanceTolerance;

			if (bChaos_Collision_EnableMeshManifoldOptimizedLoop)
			{
				// New version uses a two-pass loop over triangles to avoid visiting triangles whose vertices are all colliding as a result of checking adjacent triangles
				Private::FMeshContactGeneratorSettings ContactGeneratorSettings;
				ContactGeneratorSettings.FaceNormalDotThreshold = 0.9999;	// ~0.8deg Normals must be accurate or rolling will not work correctly
				ContactGeneratorSettings.bUseTwoPassLoop = false;			// two-pass loop is not helpful for capsules and spheres
				Private::FMeshContactGenerator ContactGenerator(ContactGeneratorSettings);

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructPlanarConvexHeightFieldOneShotManifold

Source code excerpt:

			const FReal DistanceTolerance = Chaos_Collision_TriMeshDistanceTolerance;

			if (bChaos_Collision_EnableMeshManifoldOptimizedLoop)
			{
				// New version uses a two-pass loop over triangles to avoid visiting triangles whose vertices are all colliding as a result of checking adjacent triangles
				Private::FMeshContactGeneratorSettings ContactGeneratorSettings;
				Private::FMeshContactGenerator ContactGenerator(ContactGeneratorSettings);
				const FVec3 RelativeMovement = FVec3(Constraint.GetRelativeMovement());