p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold

p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold

#Overview

name: p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold

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.Manifold.CapsuleAxisAlignedThreshold is to determine when to generate a multi-point manifold for capsule-capsule collisions in the Chaos physics system. This setting is used in the collision detection and response subsystem of Unreal Engine’s Chaos physics engine.

This setting variable is primarily used in the Chaos module, specifically in the collision handling system. It’s referenced in the CollisionOneShotManifolds.cpp and CollisionOneShotManifoldsMiscShapes.cpp files, which are part of the Chaos experimental runtime.

The value of this variable is set to 0.8f by default, which corresponds to about 30 degrees. It’s initialized in the C++ code and can be modified at runtime through the console variable system.

This variable interacts closely with other collision-related variables, such as Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction. Together, these variables control the behavior of capsule-capsule collision detection and response.

Developers must be aware that this variable affects the precision and performance of capsule-capsule collisions. A lower threshold will result in more multi-point manifolds being generated, which can increase accuracy but may also impact performance.

Best practices when using this variable include:

  1. Only modify it if you’re experiencing specific issues with capsule-capsule collisions.
  2. Test thoroughly after any modifications, as it can affect both collision accuracy and performance.
  3. Consider the trade-off between collision accuracy and performance when adjusting this value.

Regarding the associated variable Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold:

This is the actual variable that holds the value, while p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold is the console variable that allows runtime modification of this value.

The purpose of Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold is the same as p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold - it determines when to generate a multi-point manifold for capsule-capsule collisions.

This variable is used directly in the collision detection code, particularly in the ConstructCapsuleCapsuleOneShotManifold function. It’s compared against the dot product of the capsule axes to determine if they are sufficiently aligned to warrant a multi-point manifold.

The value of this variable is set initially in the C++ code and can be modified at runtime through the associated console variable.

Developers should be aware that this variable directly affects the collision detection logic and should be modified with caution. Any changes to this variable will immediately impact the behavior of capsule-capsule collisions in the Chaos physics system.

Best practices for this variable are the same as for the console variable - modify only when necessary, test thoroughly, and consider the performance implications of any changes.

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	// When two capsule axes are aligned more than this, generate a multi-point manifold
	FRealSingle Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold = 0.8f;	// About 30deg
	FAutoConsoleVariableRef CVarChaos_Manifold_CapsuleAxisAlignedThreshold(TEXT("p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold"), Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold, TEXT(""));

	// When two capsules penetrate by more than this fraction of the radius, generate a multi-point manifold
	FRealSingle Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction = 0.05f;
	FAutoConsoleVariableRef CVarChaos_Manifold_CapsuleDeepPenetrationFraction(TEXT("p.Chaos.Collision.Manifold.CapsuleDeepPenetrationFraction"), Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction, TEXT(""));

	// When two capsule lie on top of each other in an X, the extra manifold points are this fraction of the radius from the primary contact point

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	// When two capsule axes are aligned more than this, generate a multi-point manifold
	FRealSingle Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold = 0.8f;	// About 30deg
	FAutoConsoleVariableRef CVarChaos_Manifold_CapsuleAxisAlignedThreshold(TEXT("p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold"), Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold, TEXT(""));

	// When two capsules penetrate by more than this fraction of the radius, generate a multi-point manifold
	FRealSingle Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction = 0.05f;
	FAutoConsoleVariableRef CVarChaos_Manifold_CapsuleDeepPenetrationFraction(TEXT("p.Chaos.Collision.Manifold.CapsuleDeepPenetrationFraction"), Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction, TEXT(""));

	// When two capsule lie on top of each other in an X, the extra manifold points are this fraction of the radius from the primary contact point

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMiscShapes.cpp:22

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

{
	extern FRealSingle Chaos_Collision_Manifold_SphereCapsuleSizeThreshold;
	extern FRealSingle Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold;
	extern FRealSingle Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction;
	extern FRealSingle Chaos_Collision_Manifold_CapsuleRadialContactFraction;

	namespace Collisions
	{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMiscShapes.cpp:432

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructCapsuleCapsuleOneShotManifold

Source code excerpt:

			// Note: we only consider the radius of the dynamic object(s) when deciding what "deep" means because the extra contacts are only
			// to prevent excessive rotation from the single contact we have so far, and only the dynamic objects will rotate.
			const FReal AxisDotMinimum = Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold;
			const FReal DeepRadiusFraction = Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction;
			const FReal MinDynamicRadius = FMath::Min(ADynamicRadius, BDynamicRadius);
			const bool bAreAligned = ADotB > AxisDotMinimum;
			const bool bIsDeep = ClosestPhi < -DeepRadiusFraction * MinDynamicRadius;
			if (!bAreAligned && !bIsDeep)
			{