p.Chaos.Collision.MeshContactNormalRejectionThreshold
p.Chaos.Collision.MeshContactNormalRejectionThreshold
#Overview
name: p.Chaos.Collision.MeshContactNormalRejectionThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Don\'t correct edge and vertex normals if they are beyond the valid range by more than this
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Collision.MeshContactNormalRejectionThreshold is to control the threshold for rejecting edge and vertex normal corrections in mesh collision detection within the Chaos physics system of Unreal Engine 5. It specifically sets a limit beyond which normal corrections will not be applied.
This setting variable is primarily used by the Chaos physics subsystem, particularly in the mesh collision detection and contact generation modules. Based on the callsites, it’s evident that this variable is utilized in the experimental Chaos namespace, indicating its use in the advanced physics simulation features of Unreal Engine 5.
The value of this variable is set to 0.7f by default, which corresponds to approximately a 45-degree angle. It can be modified at runtime through the Unreal Engine console using the command “p.Chaos.Collision.MeshContactNormalRejectionThreshold”.
The variable interacts closely with other collision-related settings, particularly Chaos_Collision_MeshContactNormalThreshold. Together, these variables fine-tune the behavior of mesh collision detection.
Developers should be aware that this variable directly impacts the accuracy and performance of mesh collision detection. A higher value will allow for more normal corrections, potentially increasing accuracy but at the cost of performance. Conversely, a lower value might improve performance but could lead to less accurate collision responses.
Best practices when using this variable include:
- Carefully balancing between accuracy and performance based on the specific needs of the game or simulation.
- Testing thoroughly with different values to find the optimal setting for the particular use case.
- Considering the interplay between this variable and other collision-related settings.
Regarding the associated variable Chaos_Collision_MeshContactNormalRejectionThreshold:
This variable serves the same purpose as p.Chaos.Collision.MeshContactNormalRejectionThreshold and is used internally within the Chaos physics system. It’s directly set by the console variable and used in the FMeshContactGeneratorSettings structure to configure mesh contact generation.
The variable is utilized in the MeshContactGenerator and CollisionOneShotManifolds components of the Chaos system. It’s crucial for determining when to apply normal corrections during mesh collision detection.
Developers should note that modifying p.Chaos.Collision.MeshContactNormalRejectionThreshold will directly affect this internal variable. They should treat them as essentially the same setting, with the ‘p.’ prefixed version being the exposed, user-modifiable version.
Best practices for this associated variable align with those of the main console variable, focusing on finding the right balance between collision accuracy and performance for the specific requirements of the game or simulation being developed.
#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:92
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FRealSingle Chaos_Collision_MeshContactNormalRejectionThreshold = 0.7f; // ~45deg
FAutoConsoleVariableRef CVarChaos_Collision_MeshContactNormalRejectionThreshold(TEXT("p.Chaos.Collision.MeshContactNormalRejectionThreshold"), Chaos_Collision_MeshContactNormalRejectionThreshold, TEXT("Don't correct edge and vertex normals if they are beyond the valid range by more than this"));
bool bChaos_Collision_MeshManifoldSortByDistance = false;
FAutoConsoleVariableRef CVarChaos_Collision_LargeMeshManifoldSortByDistance(TEXT("p.Chaos.Collision.SortMeshManifoldByDistance"), bChaos_Collision_MeshManifoldSortByDistance, TEXT("Sort large mesh manifold points by |RxN| for improved solver stability (less rotation in first iteration)"));
int32 Chaos_Collision_MeshManifoldHashSize = 256;
FAutoConsoleVariableRef CVarChaos_Collision_MeshManifoldHashSize(TEXT("p.Chaos.Collision.MeshManifoldHashSize"), Chaos_Collision_MeshManifoldHashSize, TEXT("Hash table size to use in vertex and edge maps in convex-mesh collision"));
#Associated Variable and Callsites
This variable is associated with another variable named Chaos_Collision_MeshContactNormalRejectionThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/MeshContactGenerator.cpp:6
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
{
extern FRealSingle Chaos_Collision_MeshContactNormalThreshold;
extern FRealSingle Chaos_Collision_MeshContactNormalRejectionThreshold;
extern int32 Chaos_Collision_MeshManifoldHashSize;
}
namespace Chaos::CVars
{
extern int32 ChaosSolverDebugDrawMeshContacts;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/MeshContactGenerator.cpp:24
Scope (from outer to inner):
file
namespace Chaos::Private
function FMeshContactGeneratorSettings::FMeshContactGeneratorSettings
Source code excerpt:
HashSize = FMath::RoundUpToPowerOfTwo(Chaos_Collision_MeshManifoldHashSize);
FaceNormalDotThreshold = Chaos_Collision_MeshContactNormalThreshold;
EdgeNormalDotRejectTolerance = Chaos_Collision_MeshContactNormalRejectionThreshold;
BarycentricTolerance = FReal(1.e-3);
MaxContactsBufferSize = 1000;
bCullBackFaces = true;
bFixNormals = true;
bSortForSolver = false;
bUseTwoPassLoop = true;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifolds.cpp:91
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FAutoConsoleVariableRef CVarChaos_Collision_MeshContactNormalThreshold(TEXT("p.Chaos.Collision.MeshContactNormalThreshold"), Chaos_Collision_MeshContactNormalThreshold, TEXT("Treat contact with a dot product between the normal and the triangle face greater than this as face collisions"));
FRealSingle Chaos_Collision_MeshContactNormalRejectionThreshold = 0.7f; // ~45deg
FAutoConsoleVariableRef CVarChaos_Collision_MeshContactNormalRejectionThreshold(TEXT("p.Chaos.Collision.MeshContactNormalRejectionThreshold"), Chaos_Collision_MeshContactNormalRejectionThreshold, TEXT("Don't correct edge and vertex normals if they are beyond the valid range by more than this"));
bool bChaos_Collision_MeshManifoldSortByDistance = false;
FAutoConsoleVariableRef CVarChaos_Collision_LargeMeshManifoldSortByDistance(TEXT("p.Chaos.Collision.SortMeshManifoldByDistance"), bChaos_Collision_MeshManifoldSortByDistance, TEXT("Sort large mesh manifold points by |RxN| for improved solver stability (less rotation in first iteration)"));
int32 Chaos_Collision_MeshManifoldHashSize = 256;
FAutoConsoleVariableRef CVarChaos_Collision_MeshManifoldHashSize(TEXT("p.Chaos.Collision.MeshManifoldHashSize"), Chaos_Collision_MeshManifoldHashSize, TEXT("Hash table size to use in vertex and edge maps in convex-mesh collision"));