p.Chaos.Solver.DebugDrawMeshContacts
p.Chaos.Solver.DebugDrawMeshContacts
#Overview
name: p.Chaos.Solver.DebugDrawMeshContacts
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Draw Mesh contacts
It is referenced in 11
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.DebugDrawMeshContacts is to enable debug drawing of mesh contacts in the Chaos physics system of Unreal Engine 5. This setting variable is primarily used for debugging and visualizing collision detection and contact generation between mesh objects in the physics simulation.
- The Chaos physics system, which is part of the Experimental module in Unreal Engine 5, relies on this setting variable for debugging purposes.
- The value of this variable is set using an FAutoConsoleVariableRef in the Chaos::CVars namespace, allowing it to be modified through console commands or configuration files.
- This variable interacts with the associated variable ChaosSolverDebugDrawMeshContacts, which shares the same value and is used throughout the codebase.
- Developers must be aware that this variable is only effective when debug drawing is enabled and the CHAOS_DEBUG_DRAW macro is defined.
- Best practices for using this variable include:
- Only enabling it during development and debugging phases, not in production builds.
- Using it in conjunction with other debug drawing tools to get a comprehensive view of the physics simulation.
- Being mindful of performance impact when enabling debug drawing in complex scenes.
Regarding the associated variable ChaosSolverDebugDrawMeshContacts:
- Its purpose is the same as p.Chaos.Solver.DebugDrawMeshContacts, serving as an internal representation of the debug drawing state.
- It is used across multiple files in the Chaos physics system, including ContactTriangles.cpp, MeshContactGenerator.cpp, and CollisionOneShotManifoldsMeshShapes.cpp.
- The value is set through the console variable system and is checked in various debug drawing functions throughout the codebase.
- Developers should be aware that this variable controls the visibility of debug information for mesh contacts, triangle drawing, and contact point visualization.
- Best practices for using this variable include:
- Using it in conjunction with FDebugDrawQueue to ensure proper rendering of debug information.
- Checking its value along with IsDebugDrawingEnabled() to avoid unnecessary debug drawing calculations.
- Considering the performance impact of debug drawing when enabling this feature, especially in complex scenes with many mesh contacts.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:174
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
FAutoConsoleVariableRef CVarChaosSolverDrawSuspensionConstraints(TEXT("p.Chaos.Solver.DebugDrawSuspension"), ChaosSolverDebugDrawSuspensionConstraints, TEXT("Draw Suspension (0 = never; 1 = end of frame)."));
FAutoConsoleVariableRef CVarChaosSolverDrawClusterConstraints(TEXT("p.Chaos.Solver.DebugDraw.Cluster.Constraints"), ChaosSolverDrawClusterConstraints, TEXT("Draw Active Cluster Constraints (0 = never; 1 = end of frame)."));
FAutoConsoleVariableRef CVarChaosSolverDrawMeshContacts(TEXT("p.Chaos.Solver.DebugDrawMeshContacts"), ChaosSolverDebugDrawMeshContacts, TEXT("Draw Mesh contacts"));
FAutoConsoleVariableRef CVarChaosSolverDrawMeshBVHOverlaps(TEXT("p.Chaos.Solver.DebugDrawMeshBVHOverlaps"), ChaosSolverDebugDrawMeshBVHOverlaps, TEXT("Draw BVH of objects overlapping meshes"));
FAutoConsoleVariableRef CVarChaosSolverDebugDrawColorShapeByClientServer(TEXT("p.Chaos.Solver.DebugDraw.ColorShapeByClientServer"), ChaosSolverDebugDrawColorShapeByClientServer, TEXT("Color shape according to client and server: red = server / blue = client "));
FAutoConsoleVariableRef CVarChaosSolverDebugDrawShowServer(TEXT("p.Chaos.Solver.DebugDraw.ShowServer"), ChaosSolverDebugDrawShowServer, TEXT("Draw server related debug data"));
FAutoConsoleVariableRef CVarChaosSolverDebugDrawShowClient(TEXT("p.Chaos.Solver.DebugDraw.ShowClient"), ChaosSolverDebugDrawShowClient, TEXT("Draw client related debug data"));
int32 ChaosSolverDebugDrawPreIntegrationShapes = 0;
#Associated Variable and Callsites
This variable is associated with another variable named ChaosSolverDebugDrawMeshContacts
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ContactTriangles.cpp:6
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
namespace CVars
{
extern int32 ChaosSolverDebugDrawMeshContacts;
}
extern bool bChaos_Collision_EnableEdgePrune;
extern bool bChaos_Collision_EnableLargeMeshManifolds;
extern FRealSingle Chaos_Collision_MeshContactNormalThreshold;
extern bool bChaos_Collision_MeshManifoldSortByDistance;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ContactTriangles.cpp:750
Scope (from outer to inner):
file
namespace Chaos
function void FContactTriangleCollector::DebugDrawContactPoints
Source code excerpt:
{
#if CHAOS_DEBUG_DRAW
if (CVars::ChaosSolverDebugDrawMeshContacts && FDebugDrawQueue::GetInstance().IsDebugDrawingEnabled())
{
TArray<bool> bTriangleDrawn;
bTriangleDrawn.SetNumZeroed(ContactTriangles.Num());
const FReal Duration = 0;
const int32 DrawPriority = 10;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/MeshContactGenerator.cpp:12
Scope (from outer to inner):
file
namespace Chaos::CVars
Source code excerpt:
namespace Chaos::CVars
{
extern int32 ChaosSolverDebugDrawMeshContacts;
bool bMeshContactGeneratorFixContactNormalFixEnabled = true;
FAutoConsoleVariableRef CVarChaosMeshContactGeneratorFixContactNormalFixEnabled(TEXT("p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled"), bMeshContactGeneratorFixContactNormalFixEnabled, TEXT("Until new code path is well tested"));
}
namespace Chaos::Private
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/MeshContactGenerator.cpp:604
Scope (from outer to inner):
file
namespace Chaos::Private
function void FMeshContactGenerator::DebugDrawContacts
Source code excerpt:
{
#if CHAOS_DEBUG_DRAW
if (CVars::ChaosSolverDebugDrawMeshContacts && FDebugDrawQueue::GetInstance().IsDebugDrawingEnabled())
{
check(LineScale > 0);
const FReal Duration = 0;
const int32 DrawPriority = 10;
for (int32 ContactIndex = 0; ContactIndex < Contacts.Num(); ++ContactIndex)
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/MeshContactGenerator.cpp:629
Scope (from outer to inner):
file
namespace Chaos::Private
function void FMeshContactGenerator::DebugDrawTriangles
Source code excerpt:
{
#if CHAOS_DEBUG_DRAW
if (CVars::ChaosSolverDebugDrawMeshContacts && FDebugDrawQueue::GetInstance().IsDebugDrawingEnabled())
{
// NOTE: drawing in two loops so that the visited triangle edges draw over the ignored ones (priority doesn't seem to work)
for (int32 TriangleIndex = 0; TriangleIndex < Triangles.Num(); ++TriangleIndex)
{
const FTriangleExt& Triangle = Triangles[TriangleIndex];
if (Triangle.GetVisitIndex() == INDEX_NONE)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMeshShapes.cpp:45
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
#if CHAOS_DEBUG_DRAW
extern DebugDraw::FChaosDebugDrawSettings ChaosSolverDebugDebugDrawSettings;
extern int32 ChaosSolverDebugDrawMeshContacts;
#endif
}
namespace Collisions
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMeshShapes.cpp:185
Scope (from outer to inner):
file
namespace Chaos
namespace Collisions
function void GenerateConvexTriangleOneShotManifoldMACD
Source code excerpt:
{
#if CHAOS_DEBUG_DRAW
if (CVars::ChaosSolverDebugDrawMeshContacts && FDebugDrawQueue::GetInstance().IsDebugDrawingEnabled())
{
const FVec3 P = ConvexTransform.TransformPositionNoScale(ClosestContact.ShapeContactPoints[1] - ConvexRelativeMovement);
const FVec3 N = ConvexTransform.TransformVectorNoScale(ClosestContact.ShapeContactNormal);
FDebugDrawQueue::GetInstance().DrawDebugLine(P, P + 10.0f * N, FColor::Black, false, CVars::ChaosSolverDebugDebugDrawSettings.DrawDuration, (uint8)CVars::ChaosSolverDebugDebugDrawSettings.DrawPriority, 1.25f * CVars::ChaosSolverDebugDebugDrawSettings.LineThickness);
}
#endif
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMeshShapes.cpp:205
Scope (from outer to inner):
file
namespace Chaos
namespace Collisions
function void GenerateConvexTriangleOneShotManifoldMACD
Source code excerpt:
{
#if CHAOS_DEBUG_DRAW
if (CVars::ChaosSolverDebugDrawMeshContacts && FDebugDrawQueue::GetInstance().IsDebugDrawingEnabled())
{
for (int32 ContactIndex = 0; ContactIndex < OutContactPoints.Num(); ++ContactIndex)
{
FContactPoint& ContactPoint = OutContactPoints[ContactIndex];
const FVec3 P = ConvexTransform.TransformPositionNoScale(ContactPoint.ShapeContactPoints[1] - ConvexRelativeMovement);
const FVec3 N = ConvexTransform.TransformVectorNoScale(ContactPoint.ShapeContactNormal);
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:139
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
int32 ChaosSolverDebugDrawSuspensionConstraints = 0;
int32 ChaosSolverDrawClusterConstraints = 0;
int32 ChaosSolverDebugDrawMeshContacts = 0;
int32 ChaosSolverDebugDrawMeshBVHOverlaps = 0;
int32 ChaosSolverDebugDrawColorShapeByClientServer = 0;
int32 ChaosSolverDebugDrawShowServer = 1;
int32 ChaosSolverDebugDrawShowClient = 1;
DebugDraw::FChaosDebugDrawJointFeatures ChaosSolverDrawJointFeatures = DebugDraw::FChaosDebugDrawJointFeatures::MakeDefault();
FAutoConsoleVariableRef CVarChaosSolverDrawShapes(TEXT("p.Chaos.Solver.DebugDrawShapes"), ChaosSolverDebugDrawShapes, TEXT("Draw Shapes (0 = never; 1 = end of frame)."));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:174
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
FAutoConsoleVariableRef CVarChaosSolverDrawSuspensionConstraints(TEXT("p.Chaos.Solver.DebugDrawSuspension"), ChaosSolverDebugDrawSuspensionConstraints, TEXT("Draw Suspension (0 = never; 1 = end of frame)."));
FAutoConsoleVariableRef CVarChaosSolverDrawClusterConstraints(TEXT("p.Chaos.Solver.DebugDraw.Cluster.Constraints"), ChaosSolverDrawClusterConstraints, TEXT("Draw Active Cluster Constraints (0 = never; 1 = end of frame)."));
FAutoConsoleVariableRef CVarChaosSolverDrawMeshContacts(TEXT("p.Chaos.Solver.DebugDrawMeshContacts"), ChaosSolverDebugDrawMeshContacts, TEXT("Draw Mesh contacts"));
FAutoConsoleVariableRef CVarChaosSolverDrawMeshBVHOverlaps(TEXT("p.Chaos.Solver.DebugDrawMeshBVHOverlaps"), ChaosSolverDebugDrawMeshBVHOverlaps, TEXT("Draw BVH of objects overlapping meshes"));
FAutoConsoleVariableRef CVarChaosSolverDebugDrawColorShapeByClientServer(TEXT("p.Chaos.Solver.DebugDraw.ColorShapeByClientServer"), ChaosSolverDebugDrawColorShapeByClientServer, TEXT("Color shape according to client and server: red = server / blue = client "));
FAutoConsoleVariableRef CVarChaosSolverDebugDrawShowServer(TEXT("p.Chaos.Solver.DebugDraw.ShowServer"), ChaosSolverDebugDrawShowServer, TEXT("Draw server related debug data"));
FAutoConsoleVariableRef CVarChaosSolverDebugDrawShowClient(TEXT("p.Chaos.Solver.DebugDraw.ShowClient"), ChaosSolverDebugDrawShowClient, TEXT("Draw client related debug data"));
int32 ChaosSolverDebugDrawPreIntegrationShapes = 0;