ClusterUnion.StressSolver.EnableDebugDraw

ClusterUnion.StressSolver.EnableDebugDraw

#Overview

name: ClusterUnion.StressSolver.EnableDebugDraw

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 ClusterUnion.StressSolver.EnableDebugDraw is to enable visual debug information for the stress solver execution in the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics simulation module. It’s specifically related to the ClusterUnion stress solver, which likely deals with stress calculations for clustered physics objects.

The value of this variable is set through the Unreal Engine console system, as it’s defined using FAutoConsoleVariableRef. This means it can be changed at runtime through console commands.

The associated variable bClusterUnionStressSolverEnableDebugDraw directly interacts with it. They share the same value, and bClusterUnionStressSolverEnableDebugDraw is used in the actual code to control debug drawing.

Developers must be aware that this variable is intended for debugging purposes only. It should not be relied upon for gameplay features or shipped in final builds. Also, enabling debug drawing may have performance implications, especially in complex scenes with many physics objects.

Best practices when using this variable include:

  1. Only enable it when actively debugging physics issues related to the ClusterUnion stress solver.
  2. Disable it in production builds to avoid any performance overhead.
  3. Use it in conjunction with other debugging tools to get a comprehensive view of the physics system’s behavior.

Regarding the associated variable bClusterUnionStressSolverEnableDebugDraw:

The purpose of bClusterUnionStressSolverEnableDebugDraw is to act as the actual boolean flag that controls whether debug drawing is enabled for the ClusterUnion stress solver.

This variable is used directly in the Chaos physics system code to conditionally execute debug drawing operations.

Its value is set by the console variable system, mirroring the value of ClusterUnion.StressSolver.EnableDebugDraw.

It interacts primarily with debug drawing functions, likely from FDebugDrawQueue based on the code snippets provided.

Developers should be aware that this variable is only effective when CHAOS_DEBUG_DRAW is defined, which is likely only in debug builds.

Best practices for using this variable include:

  1. Use it as a quick toggle for debug visualization when investigating stress solver issues.
  2. Remember to check for both this flag and CHAOS_DEBUG_DRAW when adding new debug drawing code.
  3. Consider the performance impact of the debug drawing code guarded by this variable, even if it’s only in debug builds.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionStressSolver.cpp:8

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

{
	bool bClusterUnionStressSolverEnableDebugDraw = false;
	FAutoConsoleVariableRef CVarClusterUnionStressSolverEnableDebugDraw(TEXT("ClusterUnion.StressSolver.EnableDebugDraw"), bClusterUnionStressSolverEnableDebugDraw, TEXT("When enabled, this will draw visual debug information for about the stress solver execution."));

	float ClusterUnionStressSolverStrengthScalar = 1.f;
	FAutoConsoleVariableRef CVarClusterUnionStressSolverStrengthScalar(TEXT("ClusterUnion.StressSolver.StrengthScalar"), ClusterUnionStressSolverStrengthScalar, TEXT("Materioal strength scalar ( <1: weaker, >1: stronger)"));

	float ComputeAreaFromBoundingBoxOverlap(const Chaos::FAABB3& BoxA, const Chaos::FAABB3& BoxB)
	{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionStressSolver.cpp:7

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

namespace
{
	bool bClusterUnionStressSolverEnableDebugDraw = false;
	FAutoConsoleVariableRef CVarClusterUnionStressSolverEnableDebugDraw(TEXT("ClusterUnion.StressSolver.EnableDebugDraw"), bClusterUnionStressSolverEnableDebugDraw, TEXT("When enabled, this will draw visual debug information for about the stress solver execution."));

	float ClusterUnionStressSolverStrengthScalar = 1.f;
	FAutoConsoleVariableRef CVarClusterUnionStressSolverStrengthScalar(TEXT("ClusterUnion.StressSolver.StrengthScalar"), ClusterUnionStressSolverStrengthScalar, TEXT("Materioal strength scalar ( <1: weaker, >1: stronger)"));

	float ComputeAreaFromBoundingBoxOverlap(const Chaos::FAABB3& BoxA, const Chaos::FAABB3& BoxB)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionStressSolver.cpp:182

Scope (from outer to inner):

file
namespace    Chaos
function     FClusterUnionStressSolver::FConnectionEvalResult FClusterUnionStressSolver::EvaluateConnectionStress

Source code excerpt:

		// log and debug draw
#if CHAOS_DEBUG_DRAW
		if (bClusterUnionStressSolverEnableDebugDraw)
		{
			constexpr uint8 DepthPriority = 10;
			constexpr float PointThickness = 5.f;
			constexpr float LineThickness = 2.f;

			if (Result.HasFailed())

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ClusterUnionStressSolver.cpp:219

Scope (from outer to inner):

file
namespace    Chaos
function     void FClusterUnionStressSolver::EvaluateNode

Source code excerpt:


#if CHAOS_DEBUG_DRAW
		if (bClusterUnionStressSolverEnableDebugDraw)
		{
			FDebugDrawQueue::GetInstance().DrawDebugPoint(Node.Particle->XCom(), FColor::Yellow, false, UE_KINDA_SMALL_NUMBER, DepthPriority, PointThickness * 1.5f);
			const FString ValueStr = FString::SanitizeFloat((float)Node.Value);
			FDebugDrawQueue::GetInstance().DrawDebugString(Node.Particle->XCom(), ValueStr, nullptr, FColor::Purple, UE_KINDA_SMALL_NUMBER, false, 1.0f);
		}
#endif