p.Chaos.Collision.EnableLargeMeshManifolds
p.Chaos.Collision.EnableLargeMeshManifolds
#Overview
name: p.Chaos.Collision.EnableLargeMeshManifolds
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to allow large mesh manifolds for collisions against meshes (required for good behaviour)
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Collision.EnableLargeMeshManifolds
is to control whether large mesh manifolds are allowed for collisions against meshes in the Chaos physics system. This setting is crucial for achieving good behavior in mesh-based collision detection and response.
This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics implementation. It’s specifically related to the collision detection and manifold generation subsystems within Chaos.
The value of this variable is set through the Unreal Engine console variable system. It’s defined as a boolean value, initialized to 1 (true) by default, indicating that large mesh manifolds are enabled by default.
The associated variable bChaos_Collision_EnableLargeMeshManifolds
directly interacts with this console variable. They share the same value, and bChaos_Collision_EnableLargeMeshManifolds
is used throughout the code to check the current state of this setting.
Developers must be aware that this variable significantly affects the behavior of mesh-based collisions. When enabled, it allows for more detailed and accurate collision manifolds, which can improve the quality of collision response but may also increase computational cost.
Best practices when using this variable include:
- Keep it enabled for most scenarios, as it’s required for good behavior according to the comments.
- Consider disabling it only if performance is a critical issue and you’re willing to trade off some collision accuracy.
- When disabled, be aware that it may remove too many interior contacts in certain collision scenarios.
- Test thoroughly when changing this setting, as it can have wide-ranging effects on collision behavior.
Regarding the associated variable bChaos_Collision_EnableLargeMeshManifolds
:
This boolean variable is used directly in the code to control the behavior of collision processing. It’s used in several key areas:
- In
FContactTriangleCollector::ProcessContacts
, it controls whether vertex contacts are pruned and whether the manifold contact points are reduced to 4. - In the collision utility functions, it affects whether manifold updates are enabled for mesh collisions.
Developers should be aware that changing the value of p.Chaos.Collision.EnableLargeMeshManifolds
will directly affect the behavior controlled by bChaos_Collision_EnableLargeMeshManifolds
. They should consider the implications on collision detection accuracy, performance, and the potential need for additional testing when modifying this setting.
#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:86
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
bool bChaos_Collision_EnableLargeMeshManifolds = 1;
FAutoConsoleVariableRef CVarChaos_Collision_EnableLargeMeshManifolds(TEXT("p.Chaos.Collision.EnableLargeMeshManifolds"), bChaos_Collision_EnableLargeMeshManifolds, TEXT("Whether to allow large mesh manifolds for collisions against meshes (required for good behaviour)"));
FRealSingle Chaos_Collision_MeshContactNormalThreshold = 0.998f; // ~3deg
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"));
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_Collision_EnableLargeMeshManifolds
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ContactTriangles.cpp:9
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
}
extern bool bChaos_Collision_EnableEdgePrune;
extern bool bChaos_Collision_EnableLargeMeshManifolds;
extern FRealSingle Chaos_Collision_MeshContactNormalThreshold;
extern bool bChaos_Collision_MeshManifoldSortByDistance;
void FContactTriangleCollector::SetNumContacts(const int32 NumContacts)
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ContactTriangles.cpp:207
Scope (from outer to inner):
file
namespace Chaos
function void FContactTriangleCollector::ProcessContacts
Source code excerpt:
{
const bool bPruneEdges = true;
const bool bPruneVertices = !bChaos_Collision_EnableLargeMeshManifolds; // @todo(chaos): fix - when set, removes too many interior contacts
PruneEdgeAndVertexContactPoints(bPruneEdges, bPruneVertices);
}
DebugDrawContactPoints(FColor::Cyan, 0.3);
// Remove contacts that should not be able to occur if we are a one-sided mesh
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ContactTriangles.cpp:230
Scope (from outer to inner):
file
namespace Chaos
function void FContactTriangleCollector::ProcessContacts
Source code excerpt:
DebugDrawContactPoints(FColor::Yellow, 0.7);
if (!bChaos_Collision_EnableLargeMeshManifolds)
{
// Reduce to 4 contact points from here
ReduceManifoldContactPointsTriangeMesh();
}
DebugDrawContactPoints(FColor::Green, 0.9);
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifolds.cpp:85
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FAutoConsoleVariableRef CVarChaos_Collision_EdgePrunePlaneDistance(TEXT("p.Chaos.Collision.EdgePrunePlaneDistance"), Chaos_Collision_EdgePrunePlaneDistance, TEXT(""));
bool bChaos_Collision_EnableLargeMeshManifolds = 1;
FAutoConsoleVariableRef CVarChaos_Collision_EnableLargeMeshManifolds(TEXT("p.Chaos.Collision.EnableLargeMeshManifolds"), bChaos_Collision_EnableLargeMeshManifolds, TEXT("Whether to allow large mesh manifolds for collisions against meshes (required for good behaviour)"));
FRealSingle Chaos_Collision_MeshContactNormalThreshold = 0.998f; // ~3deg
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"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/CollisionUtil.h:8
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
{
extern bool bChaos_Collision_EnableBoundsChecks;
extern bool bChaos_Collision_EnableLargeMeshManifolds;
namespace Private
{
// Get the implicit object type for the implicit object on the particle, taking into account the fact that the implicit
// may be set to use a LevelSet, but only if the particle has collision particles
inline EImplicitObjectType GetImplicitCollisionType(const FGeometryParticleHandle* Particle, const FImplicitObject* Implicit)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/CollisionUtil.h:72
Scope (from outer to inner):
file
namespace Chaos
namespace Private
function inline FImplicitBoundsTestFlags CalculateImplicitBoundsTestFlags
Source code excerpt:
// If we don't allow large mesh manifolds we can't reuse manifolds for meshes because we may have
// thrown away some points that we needed at the new transform
if (!bChaos_Collision_EnableLargeMeshManifolds)
{
Flags.bEnableManifoldUpdate = Flags.bEnableManifoldUpdate && !bIsMesh0 && !bIsMesh1;
}
// Mark probe flag now so we know which GenerateCollisions to use
// @todo(chaos): it looks like this can be changed by a collision modifier so we should not be caching it