p.Chaos.Collision.TriangeMeshDistanceTolerance

p.Chaos.Collision.TriangeMeshDistanceTolerance

#Overview

name: p.Chaos.Collision.TriangeMeshDistanceTolerance

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Collision.TriangeMeshDistanceTolerance is to control the distance tolerance for collision detection with triangle meshes in the Chaos physics system. This setting is used to ignore contact points that are closer than a specified distance to a deeper point during collision detection.

This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics engine. It is specifically utilized in the collision detection subsystem, particularly for triangle mesh collisions.

The value of this variable is set through the console variable system in Unreal Engine. It is initialized with a default value of 0.1f and can be modified at runtime using the console command system.

The associated variable Chaos_Collision_TriMeshDistanceTolerance directly interacts with p.Chaos.Collision.TriangeMeshDistanceTolerance. They share the same value, and Chaos_Collision_TriMeshDistanceTolerance is used in the actual collision detection calculations.

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

Best practices when using this variable include:

  1. Carefully adjusting the value based on the specific needs of your game or simulation.
  2. Testing thoroughly to ensure that the chosen value provides a good balance between performance and collision accuracy.
  3. Considering the scale of your game world when setting this value, as it represents a physical distance.

Regarding the associated variable Chaos_Collision_TriMeshDistanceTolerance:

The purpose of Chaos_Collision_TriMeshDistanceTolerance is to store and provide the actual value used in collision detection calculations for triangle mesh distance tolerance in the Chaos physics system.

This variable is used directly in the collision detection algorithms within the Chaos physics engine, specifically in functions dealing with triangle mesh and heightfield collisions.

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

It interacts closely with other collision-related variables, such as Chaos_Collision_TriMeshPhiToleranceScale, which is used in conjunction to determine overall collision behavior.

Developers should be aware that modifying this variable directly in code is not recommended, as it’s intended to be controlled via the console variable system for consistency and ease of tuning.

Best practices include using this variable in collision detection calculations as intended by the Chaos physics system, and avoiding direct manipulation unless absolutely necessary for custom physics behavior.

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	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;

#Associated Variable and Callsites

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

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

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;

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	extern bool bChaos_Collision_OneSidedTriangleMesh;
	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;

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructQuadraticConvexTriMeshOneShotManifold

Source code excerpt:

			const FReal CullDistance = Constraint.GetCullDistance();
			const FReal PhiTolerance = CalculateTriMeshPhiTolerance(CullDistance);
			const FReal DistanceTolerance = Chaos_Collision_TriMeshDistanceTolerance;
			FContactTriangleCollector MeshContacts(bChaos_Collision_OneSidedTriangleMesh, PhiTolerance, DistanceTolerance, QuadraticTransform);

			if (const FImplicitSphere3* Sphere = Quadratic.template GetObject<FImplicitSphere3>())
			{
				ConstructConvexMeshOneShotManifold(*Sphere, QuadraticTransform, *Mesh, MeshTransform, MeshScale, CullDistance, MeshContacts);
			}

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructQuadraticConvexHeightFieldOneShotManifold

Source code excerpt:

			const FReal CullDistance = Constraint.GetCullDistance();
			const FReal PhiTolerance = CalculateTriMeshPhiTolerance(CullDistance);
			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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructPlanarConvexTriMeshOneShotManifold

Source code excerpt:

			const FReal CullDistance = Constraint.GetCullDistance();
			const FReal PhiTolerance = CalculateTriMeshPhiTolerance(CullDistance);
			const FReal DistanceTolerance = Chaos_Collision_TriMeshDistanceTolerance;

			if (bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh)
			{
				const FVec3 RelativeMovement = FVec3(Constraint.GetRelativeMovement());
				Private::FMeshContactGeneratorSettings ContactGeneratorSettings;

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructPlanarConvexHeightFieldOneShotManifold

Source code excerpt:

			const FReal CullDistance = Constraint.GetCullDistance();
			const FReal PhiTolerance = CalculateTriMeshPhiTolerance(CullDistance);
			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);