p.Chaos.Collision.TriangeMeshPhiToleranceScale

p.Chaos.Collision.TriangeMeshPhiToleranceScale

#Overview

name: p.Chaos.Collision.TriangeMeshPhiToleranceScale

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.TriangeMeshPhiToleranceScale is to serve as a multiplier for the cull distance in triangle mesh collision detection within the Chaos physics system of Unreal Engine 5. It is used to determine which contact points to ignore during collision resolution.

This setting variable is primarily used by the Chaos physics subsystem, specifically in the collision detection and resolution module. It’s part of the experimental Chaos namespace, indicating it’s a newer or evolving feature of the engine.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands or configuration files.

The associated variable Chaos_Collision_TriMeshPhiToleranceScale interacts directly with p.Chaos.Collision.TriangeMeshPhiToleranceScale. They share the same value, with Chaos_Collision_TriMeshPhiToleranceScale being the actual variable used in the code, while p.Chaos.Collision.TriangeMeshPhiToleranceScale is the console variable name used to modify it.

Developers should be aware that this variable affects the precision and performance of triangle mesh collision detection. A higher value will result in more contact points being ignored, potentially improving performance but at the cost of accuracy. Conversely, a lower value will consider more contact points, increasing accuracy but potentially impacting performance.

Best practices when using this variable include:

  1. Fine-tuning it based on the specific requirements of your game or simulation.
  2. Testing thoroughly with different values to find the optimal balance between performance and accuracy.
  3. Considering the scale of your game world and adjusting accordingly.

Regarding the associated variable Chaos_Collision_TriMeshPhiToleranceScale:

The purpose of Chaos_Collision_TriMeshPhiToleranceScale is to store the actual value used in the collision detection calculations. It’s the internal representation of the console variable p.Chaos.Collision.TriangeMeshPhiToleranceScale.

This variable is used directly in the Chaos physics subsystem, specifically in triangle mesh collision detection routines. It’s defined in the Chaos namespace and is used in collision-related source files.

The value of this variable is set through the console variable system, allowing for runtime modification.

It interacts with the CalculateTriMeshPhiTolerance function, which uses it to compute the final phi tolerance value based on the cull distance.

Developers should be aware that modifying this variable will directly affect the behavior of triangle mesh collision detection in the Chaos physics system.

Best practices include:

  1. Using the console variable p.Chaos.Collision.TriangeMeshPhiToleranceScale to modify this value rather than changing it directly in code.
  2. Monitoring its impact on both collision accuracy and performance when adjusting it.
  3. Documenting any non-default values used in your project for easier maintenance and debugging.

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FRealSingle Chaos_Collision_TriMeshDistanceTolerance = 0.1f;	// Points closer than this to a deeper point are ignored
	FAutoConsoleVariableRef CVarChaos_Collision_TriMeshDistanceolerance(TEXT("p.Chaos.Collision.TriangeMeshDistanceTolerance"), Chaos_Collision_TriMeshDistanceTolerance, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Collision_TriMeshPhiToleranceScale(TEXT("p.Chaos.Collision.TriangeMeshPhiToleranceScale"), Chaos_Collision_TriMeshPhiToleranceScale, TEXT(""));

	bool bChaos_Collision_UseCapsuleTriMesh2 = true;
	FAutoConsoleVariableRef CVarChaos_Collision_UseCapsuleTriMesh2(TEXT("p.Chaos.Collision.UseCapsuleTriMesh2"), bChaos_Collision_UseCapsuleTriMesh2, TEXT(""));

	bool bChaos_Collision_UseConvexTriMesh2 = true;
	FAutoConsoleVariableRef CVarChaos_Collision_UseConvexTriMesh2(TEXT("p.Chaos.Collision.UseConvexTriMesh2"), bChaos_Collision_UseConvexTriMesh2, TEXT(""));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	// Ueed to reject contacts against tri meshes
	FRealSingle Chaos_Collision_TriMeshPhiToleranceScale = 1.0f;	// A multipler on cull distance. Points farther than this from the deepest point are ignored
	FRealSingle Chaos_Collision_TriMeshDistanceTolerance = 0.1f;	// Points closer than this to a deeper point are ignored
	FAutoConsoleVariableRef CVarChaos_Collision_TriMeshDistanceolerance(TEXT("p.Chaos.Collision.TriangeMeshDistanceTolerance"), Chaos_Collision_TriMeshDistanceTolerance, TEXT(""));
	FAutoConsoleVariableRef CVarChaos_Collision_TriMeshPhiToleranceScale(TEXT("p.Chaos.Collision.TriangeMeshPhiToleranceScale"), Chaos_Collision_TriMeshPhiToleranceScale, TEXT(""));

	bool bChaos_Collision_UseCapsuleTriMesh2 = true;
	FAutoConsoleVariableRef CVarChaos_Collision_UseCapsuleTriMesh2(TEXT("p.Chaos.Collision.UseCapsuleTriMesh2"), bChaos_Collision_UseCapsuleTriMesh2, TEXT(""));

	bool bChaos_Collision_UseConvexTriMesh2 = true;
	FAutoConsoleVariableRef CVarChaos_Collision_UseConvexTriMesh2(TEXT("p.Chaos.Collision.UseConvexTriMesh2"), bChaos_Collision_UseConvexTriMesh2, TEXT(""));

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	extern bool bChaos_Collision_OneSidedHeightField;
	extern FRealSingle Chaos_Collision_TriMeshDistanceTolerance;
	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;

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     inline FReal CalculateTriMeshPhiTolerance

Source code excerpt:

		inline FReal CalculateTriMeshPhiTolerance(const FReal CullDistance)
		{
			return Chaos_Collision_TriMeshPhiToleranceScale * CullDistance;
		}

		template <typename TriMeshType>
		void ConstructSphereTriangleMeshOneShotManifold(const TSphere<FReal, 3>& Sphere, const FRigidTransform3& SphereWorldTransform, const TriMeshType& TriangleMesh, const FRigidTransform3& TriMeshWorldTransform, const FReal Dt, FPBDCollisionConstraint& Constraint)
		{
			// We only build one shot manifolds once