p.Chaos.DebugDraw.Enabled

p.Chaos.DebugDraw.Enabled

#Overview

name: p.Chaos.DebugDraw.Enabled

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

It is referenced in 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.DebugDraw.Enabled is to control the debug drawing functionality for the Chaos physics system in Unreal Engine 5. This setting variable is primarily used for visualizing low-level physics solver information and various debug elements related to the Chaos physics simulation.

The Chaos physics system, which is part of Unreal Engine’s experimental features, relies on this setting variable. It is used across multiple subsystems and modules, including:

  1. ChaosSolverEngine
  2. ChaosFleshEngine
  3. ChaosVehiclesCore

The value of this variable is set using a console command or through the engine’s configuration system. It is defined as a boolean value, with false being the default state.

Several other variables interact with p.Chaos.DebugDraw.Enabled, including:

  1. p.Chaos.DebugDraw.MaxLines
  2. p.Chaos.DebugDraw.Radius
  3. p.Chaos.DebugDraw.Deformable.SkeletalMeshBindingPositions
  4. p.Chaos.DebugDraw.Deformable.KinematicParticle
  5. p.Chaos.DebugDraw.Deformable.RigidCollisionGeometry

Developers must be aware that enabling this debug drawing can have performance implications, especially in complex scenes or when dealing with a large number of physics objects. The debug drawing is primarily intended for development and debugging purposes, not for use in final, shipped products.

Best practices when using this variable include:

  1. Only enable it when actively debugging physics-related issues.
  2. Use it in conjunction with other debug variables to focus on specific aspects of the physics simulation.
  3. Be mindful of the performance impact, especially when working with large-scale simulations.
  4. Disable it in release builds or when profiling performance unrelated to physics debugging.
  5. Use the associated variables like MaxLines and Radius to control the extent of debug drawing and minimize performance impact.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/ChaosSolverEngine/Private/Chaos/ChaosDebugDrawComponent.cpp:25

Scope: file

Source code excerpt:


bool bChaosDebugDraw_Enabled = false;
FAutoConsoleVariableRef CVarChaos_DebugDraw_Enabled(TEXT("p.Chaos.DebugDraw.Enabled"), bChaosDebugDraw_Enabled, TEXT("Whether to debug draw low level physics solver information"), FConsoleVariableDelegate::CreateStatic(ChaosDebugDraw_Enabled_Changed));

int ChaosDebugDraw_MaxElements = 20000;
FAutoConsoleVariableRef CVarChaos_DebugDraw_MaxElements(TEXT("p.Chaos.DebugDraw.MaxLines"), ChaosDebugDraw_MaxElements, TEXT("Set the maximum number of debug draw lines that can be rendered (to limit perf drops)"));

float ChaosDebugDraw_Radius = 3000.0f;
FAutoConsoleVariableRef CVarChaos_DebugDraw_Radius(TEXT("p.Chaos.DebugDraw.Radius"), ChaosDebugDraw_Radius, TEXT("Set the radius from the camera where debug draw capture stops (0 means infinite)"));

#Loc: <Workspace>/Engine/Plugins/Experimental/ChaosFlesh/Source/ChaosFleshEngine/Private/ChaosFlesh/ChaosDeformableTetrahedralComponent.cpp:333

Scope (from outer to inner):

file
function     void UDeformableTetrahedralComponent::UpdateFromSimulation

Source code excerpt:

			}

			// p.Chaos.DebugDraw.Enabled 1
			// p.Chaos.DebugDraw.Deformable.SkeletalMeshBindingPositions 1
			if (CVarParams.bDoDrawSkeletalMeshBindingPositions)
			{
				DebugDrawSkeletalMeshBindingPositions();
			}
		}

#Loc: <Workspace>/Engine/Plugins/Experimental/ChaosFlesh/Source/ChaosFleshEngine/Public/ChaosFlesh/ChaosDeformableTypes.h:41

Scope (from outer to inner):

file
function     bool IsDebugDrawingEnabled

Source code excerpt:

	{
#if WITH_EDITOR
		// p.Chaos.DebugDraw.Enabled 1
		return Chaos::FDebugDrawQueue::GetInstance().IsDebugDrawingEnabled();
#else
		return false;
#endif
	}
};

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Deformable/ChaosDeformableSolver.cpp:1073

Scope (from outer to inner):

file
lambda-function

Source code excerpt:

#if WITH_EDITOR
											//debug draw
											//p.Chaos.DebugDraw.Enabled 1
											//p.Chaos.DebugDraw.Deformable.KinematicParticle 1
											if (GDeformableDebugParams.IsDebugDrawingEnabled() && GDeformableDebugParams.bDoDrawKinematicParticles)
											{
												auto DoubleVert = [](FVector3f V) { return FVector3d(V.X, V.Y, V.Z); };
												Chaos::FDebugDrawQueue::GetInstance().DrawDebugPoint(DoubleVert(MParticles.GetX(Index)), FColor::Red, false, -1.0f, 0, 5);
											}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Deformable/ChaosDeformableSolver.cpp:1093

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FDeformableSolver::InitializeKinematicConstraint
lambda-function

Source code excerpt:

#if WITH_EDITOR
								//debug draw
								//p.Chaos.DebugDraw.Enabled 1
								//p.Chaos.DebugDraw.Deformable.KinematicParticle 1
								if (GDeformableDebugParams.IsDebugDrawingEnabled() && GDeformableDebugParams.bDoDrawKinematicParticles)
								{
									auto DoubleVert = [](FVector3f V) { return FVector3d(V.X, V.Y, V.Z); };
									Chaos::FDebugDrawQueue::GetInstance().DrawDebugPoint(DoubleVert(MParticles.GetX(Index)), FColor::Red, false, -1.0f, 0, 5);
								}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Deformable/ChaosDeformableSolver.cpp:1489

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FDeformableSolver::AdvanceDt

Source code excerpt:

			// debug draw
	
			//p.Chaos.DebugDraw.Enabled 1
			if (GDeformableDebugParams.IsDebugDrawingEnabled())
			{
				for (TPair< FThreadingProxy::FKey, TUniquePtr<FThreadingProxy> >& BaseProxyPair : Proxies)
				{
					if (FFleshThreadingProxy* Proxy = BaseProxyPair.Value->As<FFleshThreadingProxy>())
					{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Deformable/ChaosDeformableSolver.cpp:1672

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FDeformableSolver::DebugDrawSimulationData

Source code excerpt:


		//debug draw
		//p.Chaos.DebugDraw.Enabled 1
		//p.Chaos.DebugDraw.Deformable.RigidCollisionGeometry 1
		if (Evolution && GDeformableDebugParams.bDoDrawRigidCollisionGeometry)
		{
			Evolution->CollisionParticlesActiveView().RangeFor(
				[this, ToFVec3, ToFVector, ToFQuat](FSolverCollisionParticles& CollisionParticles, int32 CollisionOffset, int32 CollisionRange)
				{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Deformable/ChaosDeformableSolverTypes.h:150

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     bool IsDebugDrawingEnabled

Source code excerpt:

		{ 
#if WITH_EDITOR
			// p.Chaos.DebugDraw.Enabled 1
			return Chaos::FDebugDrawQueue::GetInstance().IsDebugDrawingEnabled();
#else
			return false;
#endif
		}
	};

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/ChaosVehicles/ChaosVehiclesCore/Public/SimModule/SimulationModuleBase.h:222

Scope (from outer to inner):

file
function     class CHAOSVEHICLESCORE_API ISimulationModuleBase { public: const static int INVALID_IDX = -1; ISimulationModuleBase

Source code excerpt:


		/**
		 * Option to draw debug for this module requires CVar p.Chaos.DebugDraw.Enabled 1
		 */
		virtual void DrawDebugInfo() {}

		/**
		 * Option to return debug text for drawing on the HUD in the Game Thread
		 */
		virtual bool GetDebugString(FString& StringOut) const;