p.Chaos.DebugDraw.BVHBounds

p.Chaos.DebugDraw.BVHBounds

#Overview

name: p.Chaos.DebugDraw.BVHBounds

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.DebugDraw.BVHBounds is to control the debug drawing of Bounding Volume Hierarchy (BVH) node bounds in the Chaos physics system of Unreal Engine 5. This setting is primarily used for visualization and debugging purposes in the physics simulation.

This setting variable is relied upon by the Chaos physics system, which is an experimental physics engine in Unreal Engine 5. It’s specifically used in the debug drawing functionality of the Chaos module.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be modified at runtime through the console or configuration files. Its default value is set to true in the code.

The associated variable bChaosDebugDebugDrawBVHBounds interacts directly with p.Chaos.DebugDraw.BVHBounds. They share the same value, and bChaosDebugDebugDrawBVHBounds is used in the actual implementation of the debug drawing functionality.

Developers must be aware that this variable is specifically for debug visualization purposes. It should not be relied upon for gameplay or simulation logic. Enabling this variable may have performance implications, especially in complex scenes with many physics objects.

Best practices when using this variable include:

  1. Use it only during development and debugging phases.
  2. Disable it in release builds to avoid unnecessary performance overhead.
  3. Combine it with other debug drawing options (like p.Chaos.DebugDraw.BVHShapes and p.Chaos.DebugDraw.BVHLevel) for a more comprehensive debug view.

Regarding the associated variable bChaosDebugDebugDrawBVHBounds:

The purpose of bChaosDebugDebugDrawBVHBounds is to act as the runtime flag that determines whether BVH node bounds should be drawn. It’s used directly in the drawing logic of the Chaos physics system.

This variable is used in the Chaos module of Unreal Engine, specifically in the debug drawing functionality.

Its value is set by the console variable p.Chaos.DebugDraw.BVHBounds, which allows for runtime modification.

It interacts directly with p.Chaos.DebugDraw.BVHBounds, sharing the same value.

Developers should be aware that this is an internal variable used for the actual implementation of the debug drawing feature. It shouldn’t be modified directly but rather through the p.Chaos.DebugDraw.BVHBounds console variable.

Best practices include using this variable for reference when implementing custom debug visualization features, and ensuring it’s not accidentally modified in production code.

#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:132

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw

Source code excerpt:

		FAutoConsoleVariableRef CVarChaosDebugDebugDrawBVHLevel(TEXT("p.Chaos.DebugDraw.BVHLevel"), ChaosDebugDebugDrawBVHLevel, TEXT("Which level of the BVH to draw (-1 = Leaf)"));
		FAutoConsoleVariableRef CVarChaosDebugDebugDrawBVHShapes(TEXT("p.Chaos.DebugDraw.BVHShapes"), bChaosDebugDebugDrawBVHShapes, TEXT("Whether to draw the shapes in each BVH node (colorized)"));
		FAutoConsoleVariableRef CVarChaosDebugDebugDrawBVHBounds(TEXT("p.Chaos.DebugDraw.BVHBounds"), bChaosDebugDebugDrawBVHBounds, TEXT("Whether to draw the BVH node bounds (colorized)"));

		// NOTE: These settings should never really be used - they are the fallback defaults
		// if the user does not specify settings in the debug draw call.
		// See PBDRigidsColver.cpp and ImmediatePhysicsSimulation_Chaos.cpp for example.
		FChaosDebugDrawSettings ChaosDefaultDebugDebugDrawSettings(
			/* ArrowSize =					*/ 1.5f,

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw

Source code excerpt:

		int32 ChaosDebugDebugDrawBVHLevel = -1;
		bool bChaosDebugDebugDrawBVHShapes = false;
		bool bChaosDebugDebugDrawBVHBounds = true;
		FAutoConsoleVariableRef CVarChaosDebugDebugDrawBVHLevel(TEXT("p.Chaos.DebugDraw.BVHLevel"), ChaosDebugDebugDrawBVHLevel, TEXT("Which level of the BVH to draw (-1 = Leaf)"));
		FAutoConsoleVariableRef CVarChaosDebugDebugDrawBVHShapes(TEXT("p.Chaos.DebugDraw.BVHShapes"), bChaosDebugDebugDrawBVHShapes, TEXT("Whether to draw the shapes in each BVH node (colorized)"));
		FAutoConsoleVariableRef CVarChaosDebugDebugDrawBVHBounds(TEXT("p.Chaos.DebugDraw.BVHBounds"), bChaosDebugDebugDrawBVHBounds, TEXT("Whether to draw the BVH node bounds (colorized)"));

		// NOTE: These settings should never really be used - they are the fallback defaults
		// if the user does not specify settings in the debug draw call.
		// See PBDRigidsColver.cpp and ImmediatePhysicsSimulation_Chaos.cpp for example.
		FChaosDebugDrawSettings ChaosDefaultDebugDebugDrawSettings(
			/* ArrowSize =					*/ 1.5f,

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw
function     void DrawBVHImpl
lambda-function

Source code excerpt:

						const FColor Color = GetIndexColor(LeafIndex++);

						if (bChaosDebugDebugDrawBVHBounds)
						{
							const FVec3 NodeBoundsPos = ShapeTransform.TransformPosition(FVec3(NodeBounds.Center()));
							const FVec3 NodeBoundsExtents = 0.5f * FVec3(NodeBounds.Extents()) - FVec3(BoundsDrawShrink);
							FDebugDrawQueue::GetInstance().DrawDebugBox(NodeBoundsPos, NodeBoundsExtents, ShapeTransform.GetRotation(), Color, false, Duration, uint8(Settings.DrawPriority), Settings.LineThickness);
						}