p.Chaos.Collision.EnableMACDFallback
p.Chaos.Collision.EnableMACDFallback
#Overview
name: p.Chaos.Collision.EnableMACDFallback
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.EnableMACDFallback is to control the fallback behavior in the Chaos physics engine’s collision detection system, specifically for the Moving Advanced Collision Detection (MACD) algorithm.
This setting variable is primarily used in the Chaos physics engine, which is part of Unreal Engine’s experimental features. It is referenced in the collision detection subsystem, particularly in the manifold generation process for mesh shapes.
The value of this variable is set through the Unreal Engine console variable system. It’s initialized as false by default, but can be changed at runtime using console commands.
The associated variable bChaos_Collision_EnableMACDFallback directly interacts with p.Chaos.Collision.EnableMACDFallback. They share the same value, with the console variable controlling the boolean flag.
Developers must be aware that this variable affects the collision detection behavior, particularly in scenarios involving convex shapes and triangle meshes. When enabled, it allows the MACD algorithm to fall back to a non-MACD path when a shape is outside the triangle plane.
Best practices when using this variable include:
- Use it for debugging or fine-tuning collision detection in specific scenarios.
- Be cautious when enabling it in production, as it may impact performance or collision accuracy.
- Test thoroughly with both enabled and disabled states to ensure desired collision behavior.
Regarding the associated variable bChaos_Collision_EnableMACDFallback:
This boolean flag directly controls the MACD fallback behavior in the code. It’s used in the ConstructConvexMeshOneShotManifoldMACD function to determine whether to use a non-MACD path for collision detection.
The variable is initialized as false, meaning the fallback is disabled by default. It’s important for developers to understand that enabling this flag may change the collision detection behavior, potentially affecting gameplay or simulation accuracy.
When working with this variable, developers should:
- Consider the performance implications of enabling the fallback.
- Use it in conjunction with other Chaos collision settings for comprehensive control over the physics simulation.
- Monitor its effects on different types of collisions, especially those involving complex mesh shapes.
#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:108
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// MACD uses the non-MACD path when the shape is outside the triangle plane
bool bChaos_Collision_EnableMACDFallback = false;
FAutoConsoleVariableRef CVarChaos_Collision_EnableMACDFallback(TEXT("p.Chaos.Collision.EnableMACDFallback"), bChaos_Collision_EnableMACDFallback, TEXT(""));
// Whether to use the new index-less GJK.
// @todo(chaos): This should be removed once soaked for a bit (enabled 7 June 2022)
bool bChaos_Collision_UseGJK2 = false;
FAutoConsoleVariableRef CVarChaos_Collision_UseGJK2(TEXT("p.Chaos.Collision.UseGJK2"), bChaos_Collision_UseGJK2, TEXT(""));
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_Collision_EnableMACDFallback
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifolds.cpp:107
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// MACD uses the non-MACD path when the shape is outside the triangle plane
bool bChaos_Collision_EnableMACDFallback = false;
FAutoConsoleVariableRef CVarChaos_Collision_EnableMACDFallback(TEXT("p.Chaos.Collision.EnableMACDFallback"), bChaos_Collision_EnableMACDFallback, TEXT(""));
// Whether to use the new index-less GJK.
// @todo(chaos): This should be removed once soaked for a bit (enabled 7 June 2022)
bool bChaos_Collision_UseGJK2 = false;
FAutoConsoleVariableRef CVarChaos_Collision_UseGJK2(TEXT("p.Chaos.Collision.UseGJK2"), bChaos_Collision_UseGJK2, TEXT(""));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMeshShapes.cpp:36
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
extern bool bChaos_Collision_EnableMeshManifoldOptimizedLoop;
extern bool bChaos_Collision_EnableMeshManifoldOptimizedLoop_TriMesh;
extern bool bChaos_Collision_EnableMACDFallback;
extern bool bChaos_Collision_UseCapsuleTriMesh2;
extern bool bChaos_Collision_UseConvexTriMesh2;
namespace CVars
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMeshShapes.cpp:296
Scope (from outer to inner):
file
namespace Chaos
namespace Collisions
function void ConstructConvexMeshOneShotManifoldMACD
lambda-function
Source code excerpt:
const FTriangle& Triangle = ContactGenerator.GetTriangle(TriangleIndex);
bool bUseNonMACDPath = false;
if (bChaos_Collision_EnableMACDFallback)
{
const FVec3 TriangleNormal = ContactGenerator.GetTriangleNormal(TriangleIndex);
const FReal Distance = FVec3::DotProduct(Convex.GetCenterOfMass() - Triangle.GetVertex(0), TriangleNormal);
bUseNonMACDPath = Distance > 0;
}