p.Chaos.Collision.Manifold.EdgeNormalThreshold

p.Chaos.Collision.Manifold.EdgeNormalThreshold

#Overview

name: p.Chaos.Collision.Manifold.EdgeNormalThreshold

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.EdgeNormalThreshold is to define a threshold for determining whether a contact point between two colliding objects should be considered a plane contact or an edge contact in the Chaos physics engine. This setting is crucial for the collision detection and response system within Unreal Engine’s physics simulation.

This setting variable is primarily used in the Chaos physics engine, which is part of Unreal Engine’s experimental physics system. It’s specifically utilized in the collision manifold generation process, which is a key component of the physics simulation.

The value of this variable is set to 0.9f by default, which corresponds to an angle of about 25 degrees. It’s defined in the Chaos namespace within the CollisionOneShotManifolds.cpp file.

The associated variable Chaos_Collision_Manifold_EdgeContactNormalThreshold interacts directly with p.Chaos.Collision.Manifold.EdgeNormalThreshold. They share the same value and are used interchangeably in the code.

Developers must be aware that this threshold significantly affects how collision contacts are classified and subsequently handled by the physics engine. A higher threshold will result in more contacts being classified as edge contacts, while a lower threshold will lead to more plane contacts.

Best practices when using this variable include:

  1. Carefully adjusting the value based on the specific needs of your simulation.
  2. Testing thoroughly after any changes, as it can significantly impact physics behavior.
  3. Considering the performance implications, as different contact classifications may affect computational load.

Regarding the associated variable Chaos_Collision_Manifold_EdgeContactNormalThreshold:

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	FRealSingle Chaos_Collision_Manifold_EdgeContactNormalThreshold = 0.9f;	// About 25deg
	FAutoConsoleVariableRef CVarChaos_Manifold_EdgeContactNormalThreshold(TEXT("p.Chaos.Collision.Manifold.EdgeNormalThreshold"), Chaos_Collision_Manifold_EdgeContactNormalThreshold, TEXT(""));

	// We use a smaller margin for triangle to convex. Ideally we would have none at all in this case
	// LWC_TODO: This needs to be a larger value for float builds (probably 1)
	FRealSingle Chaos_Collision_Manifold_TriangleConvexMarginMultiplier = 0.5f;
	FAutoConsoleVariableRef CVarChaos_Manifold_TriangleConvexMarginMultipler(TEXT("p.Chaos.Collision.Manifold.TriangleConvexMarginMultiplier"), Chaos_Collision_Manifold_TriangleConvexMarginMultiplier, TEXT(""));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FAutoConsoleVariableRef CVarChaos_Manifold_TriangleContactNormalThreshold(TEXT("p.Chaos.Collision.Manifold.TriangleNormalThreshold"), Chaos_Collision_Manifold_TriangleContactNormalThreshold, TEXT(""));

	FRealSingle Chaos_Collision_Manifold_EdgeContactNormalThreshold = 0.9f;	// About 25deg
	FAutoConsoleVariableRef CVarChaos_Manifold_EdgeContactNormalThreshold(TEXT("p.Chaos.Collision.Manifold.EdgeNormalThreshold"), Chaos_Collision_Manifold_EdgeContactNormalThreshold, TEXT(""));

	// We use a smaller margin for triangle to convex. Ideally we would have none at all in this case
	// LWC_TODO: This needs to be a larger value for float builds (probably 1)
	FRealSingle Chaos_Collision_Manifold_TriangleConvexMarginMultiplier = 0.5f;
	FAutoConsoleVariableRef CVarChaos_Manifold_TriangleConvexMarginMultipler(TEXT("p.Chaos.Collision.Manifold.TriangleConvexMarginMultiplier"), Chaos_Collision_Manifold_TriangleConvexMarginMultiplier, TEXT(""));

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructPlanarConvexTriangleOneShotManifold

Source code excerpt:

					const FVec3 EdgeNormal = FVec3::CrossProduct(ConvexEdgePos1 - ConvexEdgePos0, TriangleEdgePos1 - TriangleEdgePos0).GetSafeNormal();
					const FReal EdgeNormalDotContactNormal = FVec3::DotProduct(EdgeNormal, GJKContactPoint.ShapeContactNormal);
					bIsPlaneContact = (FMath::Abs(EdgeNormalDotContactNormal) < Chaos_Collision_Manifold_EdgeContactNormalThreshold);

					if (!bIsPlaneContact)
					{
						const FReal EdgePhi = FVec3::DotProduct(ConvexEdgeNearPos - TriangleEdgeNearPos, GJKContactPoint.ShapeContactNormal);

						// We now have an accurate separation, so reject points beyond cull distance.