p.Chaos.Collision.EnableManifoldGJKReplace

p.Chaos.Collision.EnableManifoldGJKReplace

#Overview

name: p.Chaos.Collision.EnableManifoldGJKReplace

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.EnableManifoldGJKReplace is to control the behavior of the collision detection system in the Chaos physics engine of Unreal Engine 5. Specifically, it enables or disables the replacement of existing manifold contacts with new GJK (Gilbert-Johnson-Keerthi) generated contacts.

This setting variable is primarily used in the Chaos physics module, which is part of Unreal Engine’s experimental features. It’s utilized in the collision detection and resolution subsystem.

The value of this variable is set through the Unreal Engine console variable system. It’s initialized as a boolean with a default value of false in the CollisionOneShotManifolds.cpp file.

This variable interacts closely with another variable called bChaos_Collision_EnableManifoldGJKReplace. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the accuracy and performance of collision detection in the Chaos physics system. Enabling this feature may lead to more precise collision manifolds but could potentially impact performance.

Best practices when using this variable include:

  1. Testing thoroughly with both enabled and disabled states to understand its impact on your specific use case.
  2. Considering performance implications, especially in scenarios with many complex collisions.
  3. Using it in conjunction with other Chaos physics settings for optimal results.

Regarding the associated variable bChaos_Collision_EnableManifoldGJKReplace:

This variable serves the same purpose as p.Chaos.Collision.EnableManifoldGJKReplace. It’s used internally within the Chaos physics code to control the manifold GJK replacement feature.

It’s defined in the Chaos namespace and is used in multiple files within the Chaos physics module, including CollisionOneShotManifolds.cpp and PBDCollisionConstraint.cpp.

The value of this variable is set by the console variable system, mirroring p.Chaos.Collision.EnableManifoldGJKReplace.

Developers should treat this variable as an internal implementation detail of the Chaos physics system. Direct manipulation of this variable is not recommended; instead, use the console variable p.Chaos.Collision.EnableManifoldGJKReplace to control this feature.

Best practices for this associated variable are the same as for p.Chaos.Collision.EnableManifoldGJKReplace, as they effectively control the same feature.

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	bool bChaos_Collision_EnableManifoldGJKReplace = false;
	bool bChaos_Collision_EnableManifoldGJKInject = false;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableManifoldReplace(TEXT("p.Chaos.Collision.EnableManifoldGJKReplace"), bChaos_Collision_EnableManifoldGJKReplace, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Collision_EnableManifoldInject(TEXT("p.Chaos.Collision.EnableManifoldGJKInject"), bChaos_Collision_EnableManifoldGJKInject, TEXT(""));

	bool bChaos_Manifold_EnableGjkWarmStart = true;
	FAutoConsoleVariableRef CVarChaos_Manifold_EnableGjkWarmStart(TEXT("p.Chaos.Collision.Manifold.EnableGjkWarmStart"), bChaos_Manifold_EnableGjkWarmStart, TEXT(""));

	// See GJKContactPointMargin for comments on why these matter

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	extern bool bChaos_Collision_EnableManifoldGJKInject;
	extern bool bChaos_Collision_EnableManifoldGJKReplace;

	FRealSingle Chaos_Manifold_MatchPositionTolerance = 0.3f;		// Fraction of object size position tolerance
	FRealSingle Chaos_Manifold_MatchNormalTolerance = 0.02f;		// Dot product tolerance
	FAutoConsoleVariableRef CVarChaos_Manifold_MatchPositionTolerance(TEXT("p.Chaos.Collision.Manifold.MatchPositionTolerance"), Chaos_Manifold_MatchPositionTolerance, TEXT("A tolerance as a fraction of object size used to determine if two contact points are the same"));
	FAutoConsoleVariableRef CVarChaos_Manifold_MatchNormalTolerance(TEXT("p.Chaos.Collision.Manifold.MatchNormalTolerance"), Chaos_Manifold_MatchNormalTolerance, TEXT("A tolerance on the normal dot product used to determine if two contact points are the same"));

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	TEXT("If enabled, if one shot manifold hits edge/edge case, we will force a cull distance of zero. That means edge/edge contacts will be thrown out if separated at all. Only applies to Convex/Convex oneshot impl."));

	bool bChaos_Collision_EnableManifoldGJKReplace = false;
	bool bChaos_Collision_EnableManifoldGJKInject = false;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableManifoldReplace(TEXT("p.Chaos.Collision.EnableManifoldGJKReplace"), bChaos_Collision_EnableManifoldGJKReplace, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Collision_EnableManifoldInject(TEXT("p.Chaos.Collision.EnableManifoldGJKInject"), bChaos_Collision_EnableManifoldGJKInject, TEXT(""));

	bool bChaos_Manifold_EnableGjkWarmStart = true;
	FAutoConsoleVariableRef CVarChaos_Manifold_EnableGjkWarmStart(TEXT("p.Chaos.Collision.Manifold.EnableGjkWarmStart"), bChaos_Manifold_EnableGjkWarmStart, TEXT(""));

	// See GJKContactPointMargin for comments on why these matter

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructConvexConvexOneShotManifold

Source code excerpt:

			}

			const bool bCanUpdateManifold = bChaos_Collision_EnableManifoldGJKReplace;
			if (bCanUpdateManifold && Constraint.TryAddManifoldContact(GJKContactPoint))
			{
				PHYSICS_CSV_CUSTOM_EXPENSIVE(PhysicsCounters, NumManifoldsMaintained, 1, ECsvCustomStatOp::Accumulate);
				return;
			}