p.Chaos.Collision.Manifold.FrictionExactPositionTolerance

p.Chaos.Collision.Manifold.FrictionExactPositionTolerance

#Overview

name: p.Chaos.Collision.Manifold.FrictionExactPositionTolerance

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.Manifold.FrictionExactPositionTolerance is to define a distance threshold for determining when a shape-relative contact point can be considered the same point during collision detection in the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used by the Chaos physics subsystem, specifically in the collision detection and manifold generation components. It’s part of the Experimental Chaos module in Unreal Engine 5.

The value of this variable is set to 0.2f by default, as seen in the source code. It’s defined as a console variable, which means it can be adjusted at runtime through the console or configuration files.

This variable interacts closely with another variable called Chaos_Manifold_FrictionNearPositionTolerance. While FrictionExactPositionTolerance defines a strict threshold, FrictionNearPositionTolerance provides a more lenient threshold for considering contact points as the same.

Developers must be aware that this variable directly affects the precision of collision detection in the Chaos physics system. A smaller value will result in more precise collision detection but may increase computational cost, while a larger value might improve performance at the cost of accuracy.

Best practices when using this variable include:

  1. Carefully adjusting its value based on the scale and requirements of your game world.
  2. Testing thoroughly after any changes to ensure desired physics behavior.
  3. Considering the balance between this variable and FrictionNearPositionTolerance for optimal results.

Regarding the associated variable Chaos_Manifold_FrictionExactPositionTolerance:

The purpose of Chaos_Manifold_FrictionExactPositionTolerance is to store the actual value used in the physics calculations. It’s the backing variable for the console variable p.Chaos.Collision.Manifold.FrictionExactPositionTolerance.

This variable is used directly in the collision detection logic, specifically in the FindSavedManifoldPoint function of the FPBDCollisionConstraint class. It’s used to calculate a squared distance tolerance for determining if a contact point is exactly the same as a previously saved point.

The value of this variable is initially set to 0.2f but can be modified through the associated console variable.

Developers should be aware that modifying this variable directly in code won’t have the desired effect, as it’s meant to be controlled through the console variable system. Always use the console variable for adjustments.

Best practices include using this variable in conjunction with Chaos_Manifold_FrictionNearPositionTolerance for a two-tiered approach to contact point matching, which can help balance precision and performance 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/Collision/PBDCollisionConstraint.cpp:34

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FRealSingle Chaos_Manifold_FrictionExactPositionTolerance = 0.2f;	// Distance a shape-relative contact point can move and we can still be sure it's the same point (don't look for better options)
	FRealSingle Chaos_Manifold_FrictionNearPositionTolerance = 1.0f;	// Distance a shape-relative contact point can move and still be considered the same point, if no better option exists
	FAutoConsoleVariableRef CVarChaos_Manifold_FrictionExactPositionTolerance(TEXT("p.Chaos.Collision.Manifold.FrictionExactPositionTolerance"), Chaos_Manifold_FrictionExactPositionTolerance, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Manifold_FrictionNearPositionTolerance(TEXT("p.Chaos.Collision.Manifold.FrictionNearPositionTolerance"), Chaos_Manifold_FrictionNearPositionTolerance, TEXT(""));


	FRealSingle Chaos_GBFCharacteristicTimeRatio = 1.0f;
	FAutoConsoleVariableRef CVarChaos_GBFCharacteristicTimeRatio(TEXT("p.Chaos.Collision.GBFCharacteristicTimeRatio"), Chaos_GBFCharacteristicTimeRatio, TEXT("The ratio between characteristic time and Dt"));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

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

	FRealSingle Chaos_Manifold_FrictionExactPositionTolerance = 0.2f;	// Distance a shape-relative contact point can move and we can still be sure it's the same point (don't look for better options)
	FRealSingle Chaos_Manifold_FrictionNearPositionTolerance = 1.0f;	// Distance a shape-relative contact point can move and still be considered the same point, if no better option exists
	FAutoConsoleVariableRef CVarChaos_Manifold_FrictionExactPositionTolerance(TEXT("p.Chaos.Collision.Manifold.FrictionExactPositionTolerance"), Chaos_Manifold_FrictionExactPositionTolerance, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Manifold_FrictionNearPositionTolerance(TEXT("p.Chaos.Collision.Manifold.FrictionNearPositionTolerance"), Chaos_Manifold_FrictionNearPositionTolerance, TEXT(""));


	FRealSingle Chaos_GBFCharacteristicTimeRatio = 1.0f;
	FAutoConsoleVariableRef CVarChaos_GBFCharacteristicTimeRatio(TEXT("p.Chaos.Collision.GBFCharacteristicTimeRatio"), Chaos_GBFCharacteristicTimeRatio, TEXT("The ratio between characteristic time and Dt"));

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

Scope (from outer to inner):

file
namespace    Chaos
function     int32 FPBDCollisionConstraint::FindSavedManifoldPoint

Source code excerpt:

			if (!ManifoldPoint.Flags.bDisabled)
			{
				const FRealSingle ExactDistanceToleranceSq = FMath::Square(Chaos_Manifold_FrictionExactPositionTolerance);
				const FRealSingle NearDistanceToleranceSq = FMath::Square(Chaos_Manifold_FrictionNearPositionTolerance);

				// Ignore popints farther than NearDistanceTolerance
				FRealSingle BestDistanceSq = NearDistanceToleranceSq;

				int32 MatchAllowedPointIndex = INDEX_NONE;