p.Chaos.Collision.MaxManifoldPoints
p.Chaos.Collision.MaxManifoldPoints
#Overview
name: p.Chaos.Collision.MaxManifoldPoints
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Collision.MaxManifoldPoints is to control the maximum number of manifold points per contact in the Chaos physics system’s collision handling. It is primarily used for the collision system within Unreal Engine’s Chaos physics solver.
This setting variable is relied upon by the Chaos physics subsystem, specifically within the collision handling module. It’s part of the Experimental Chaos runtime, which is Unreal Engine’s new physics engine.
The value of this variable is set through a console variable (CVar) system. It’s initialized to -1, which means there’s no limit on the number of manifold points by default. Developers can change this value at runtime using console commands or through configuration files.
The associated variable Chaos_Collision_MaxManifoldPoints directly interacts with p.Chaos.Collision.MaxManifoldPoints. They share the same value, with Chaos_Collision_MaxManifoldPoints being the actual variable used in the code, while p.Chaos.Collision.MaxManifoldPoints is the console variable name.
Developers must be aware that setting this variable to a value other than -1 will limit the number of contact points in collision manifolds. This can affect the accuracy of collision resolution, potentially leading to less stable or less realistic physics simulations if set too low.
Best practices when using this variable include:
- Leave it at -1 unless there’s a specific performance issue related to having too many manifold points.
- If limiting manifold points, carefully test the physics behavior to ensure it doesn’t negatively impact gameplay or visual quality.
- Use this in conjunction with other physics settings to fine-tune performance vs. accuracy trade-offs.
Regarding the associated variable Chaos_Collision_MaxManifoldPoints:
- It’s the actual integer variable used in the code to store the maximum number of manifold points.
- It’s declared in the Chaos namespace and is used directly in the collision constraint logic.
- The variable is checked in the SetOneShotManifoldContacts function to potentially clip the number of contact points.
- If the number of contacts exceeds the set maximum (and the maximum is not -1), the contacts are clipped, and an error is logged.
Developers should be cautious when modifying this variable, as it directly affects the core collision handling in the Chaos physics system. Any changes should be thoroughly tested across various collision scenarios to ensure they don’t introduce unexpected behavior or performance issues.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionConstraint.cpp:69
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// Maximum number of manifold points per contact (-1 for unlimited)
int32 Chaos_Collision_MaxManifoldPoints = -1;
FAutoConsoleVariableRef CVarChaos_Collision_MaxManifoldPoints(TEXT("p.Chaos.Collision.MaxManifoldPoints"), Chaos_Collision_MaxManifoldPoints, TEXT(""));
struct FCollisionTolerances
{
// Multiplied by the contact margin to produce a distance within which contacts are considered to be the same point
FReal ContactPositionToleranceScale = FReal(0.8);
#Associated Variable and Callsites
This variable is associated with another variable named Chaos_Collision_MaxManifoldPoints
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionConstraint.cpp:68
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// Maximum number of manifold points per contact (-1 for unlimited)
int32 Chaos_Collision_MaxManifoldPoints = -1;
FAutoConsoleVariableRef CVarChaos_Collision_MaxManifoldPoints(TEXT("p.Chaos.Collision.MaxManifoldPoints"), Chaos_Collision_MaxManifoldPoints, TEXT(""));
struct FCollisionTolerances
{
// Multiplied by the contact margin to produce a distance within which contacts are considered to be the same point
FReal ContactPositionToleranceScale = FReal(0.8);
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/PBDCollisionConstraint.h:39
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
CHAOS_API bool ContactConstraintSortPredicate(const FPBDCollisionConstraint& L, const FPBDCollisionConstraint& R);
extern int32 Chaos_Collision_MaxManifoldPoints;
/*
* @brief Material properties for a collision constraint
*/
class FPBDCollisionConstraintMaterial
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/PBDCollisionConstraint.h:611
Scope (from outer to inner):
file
namespace Chaos
class class FPBDCollisionConstraint final : public FPBDCollisionConstraintHandle
function inline void SetOneShotManifoldContacts
Source code excerpt:
// If we have too many manifold points, clip the array. This is considered and error but
// is important for avoiding OOM or massive slowdowns when something goes wrong
const int32 MaxManifoldPoints = Chaos_Collision_MaxManifoldPoints;
if ((MaxManifoldPoints >= 0) && (NumContacts > MaxManifoldPoints))
{
NumContacts = MaxManifoldPoints;
LogOneShotManifoldError(MaxManifoldPoints, ContactPoints);
}