p.Chaos.DebugDraw.ShowContactGraphUsed

p.Chaos.DebugDraw.ShowContactGraphUsed

#Overview

name: p.Chaos.DebugDraw.ShowContactGraphUsed

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.DebugDraw.ShowContactGraphUsed is to control the debug visualization of used edges in the contact graph when drawing islands in the Chaos physics system. Specifically, it shows collisions with impulse.

This setting variable is primarily used in the Chaos physics subsystem of Unreal Engine 5, particularly in the debug drawing functionality. It’s part of the Experimental Chaos module, which is responsible for physics simulations.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands or configuration files.

This variable interacts closely with two other variables:

  1. bChaosDebugDebugDrawContactGraphUsed: This is the associated C++ variable that directly controls the behavior.
  2. p.Chaos.DebugDraw.ShowContactGraph and p.Chaos.DebugDraw.ShowContactGraphUnused: These are related console variables that control other aspects of contact graph visualization.

Developers should be aware that this variable is specifically for debug purposes and should not be relied upon for gameplay logic. It’s designed to help visualize the physics system’s internal workings, particularly the contact graph used for island generation in the physics simulation.

Best practices when using this variable include:

  1. Use it in conjunction with other debug drawing variables for a comprehensive view of the physics system.
  2. Remember to disable it in production builds to avoid performance overhead.
  3. Use it alongside profiling tools to understand the impact of different physics configurations on performance.

Regarding the associated variable bChaosDebugDebugDrawContactGraphUsed:

The purpose of bChaosDebugDebugDrawContactGraphUsed is to serve as the C++ representation of the console variable p.Chaos.DebugDraw.ShowContactGraphUsed. It directly controls whether the used edges of the contact graph are drawn.

This variable is used in the DrawConstraintGraphImpl function to determine whether to draw lines representing used edges in the contact graph. When true, it causes green lines to be drawn for edges with impulse.

The value of this variable is set by the console variable system, but it can be read and used directly in C++ code for more efficient checks.

Developers should be aware that this variable’s state can change at runtime due to console commands, so any code using it should be prepared for that possibility.

Best practices for using this variable include:

  1. Use it for conditional debug drawing rather than gameplay logic.
  2. Consider wrapping access to this variable in a function that can be easily disabled in shipping builds.
  3. Be aware of its performance impact when enabled, especially in complex scenes with many physics objects.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:101

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw

Source code excerpt:


		bool bChaosDebugDebugDrawContactGraphUsed = false;
		FAutoConsoleVariableRef CVarChaosDebugDrawContactGraphUsed(TEXT("p.Chaos.DebugDraw.ShowContactGraphUsed"), bChaosDebugDebugDrawContactGraphUsed, TEXT("Whether to show the used edges contactgraph when drawing islands (collisions with impulse)"));

		bool bChaosDebugDebugDrawContactGraphUnused = false;
		FAutoConsoleVariableRef CVarChaosDebugDrawContactGraphUnused(TEXT("p.Chaos.DebugDraw.ShowContactGraphUnused"), bChaosDebugDebugDrawContactGraphUnused, TEXT("Whether to show the unused edges contactgraph when drawing islands (collisions with no impulse)"));

		float ChaosDebugDrawConvexExplodeDistance = 0.0f;
		FAutoConsoleVariableRef CVarChaosDebugDrawConvexExplodeDistance(TEXT("p.Chaos.DebugDraw.ConvexExplodeDistance"), ChaosDebugDrawConvexExplodeDistance, TEXT("Explode convex edges by this amount (useful for looking at convex integrity)"));

#Associated Variable and Callsites

This variable is associated with another variable named bChaosDebugDebugDrawContactGraphUsed. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:100

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw

Source code excerpt:

		FAutoConsoleVariableRef CVarChaosDebugDrawContactGraph(TEXT("p.Chaos.DebugDraw.ShowContactGraph"), bChaosDebugDebugDrawContactGraph, TEXT("Whether to show the contactgraph when drawing islands"));

		bool bChaosDebugDebugDrawContactGraphUsed = false;
		FAutoConsoleVariableRef CVarChaosDebugDrawContactGraphUsed(TEXT("p.Chaos.DebugDraw.ShowContactGraphUsed"), bChaosDebugDebugDrawContactGraphUsed, TEXT("Whether to show the used edges contactgraph when drawing islands (collisions with impulse)"));

		bool bChaosDebugDebugDrawContactGraphUnused = false;
		FAutoConsoleVariableRef CVarChaosDebugDrawContactGraphUnused(TEXT("p.Chaos.DebugDraw.ShowContactGraphUnused"), bChaosDebugDebugDrawContactGraphUnused, TEXT("Whether to show the unused edges contactgraph when drawing islands (collisions with no impulse)"));

		float ChaosDebugDrawConvexExplodeDistance = 0.0f;
		FAutoConsoleVariableRef CVarChaosDebugDrawConvexExplodeDistance(TEXT("p.Chaos.DebugDraw.ConvexExplodeDistance"), ChaosDebugDrawConvexExplodeDistance, TEXT("Explode convex edges by this amount (useful for looking at convex integrity)"));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:1733

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw
function     void DrawConstraintGraphImpl
lambda-function

Source code excerpt:

				const FRigidTransform3 Transform1 = FConstGenericParticleHandle(Constraint->GetConstrainedParticles()[1])->GetTransformPQCom() * SpaceTransform;

				if ((bChaosDebugDebugDrawContactGraphUsed && bIsUsed) || (bChaosDebugDebugDrawContactGraphUnused && !bIsUsed))
				{
					FColor Color = bIsUsed ? FColor::Green : FColor::Red;
					FDebugDrawQueue::GetInstance().DrawDebugLine(Transform0.GetLocation(), Transform1.GetLocation(), Color, false, UE_KINDA_SMALL_NUMBER, uint8(Settings.DrawPriority), Settings.LineThickness);
				}

				if (bChaosDebugDebugDrawContactGraph)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:1783

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw
function     void DrawConstraintGraphImpl

Source code excerpt:

			}

			if (bChaosDebugDebugDrawContactGraph || bChaosDebugDebugDrawContactGraphUnused || bChaosDebugDebugDrawContactGraphUsed)
			{
				for (int32 ContainerIndex = 0; ContainerIndex < Graph.GetNumConstraintContainers(); ++ContainerIndex)
				{
					Graph.VisitConstConstraints(ContainerIndex,
						[&Graph, &SpaceTransform, &Settings, &DrawGraphCollision](const Private::FPBDIslandConstraint* IslandConstraint)
						{