p.Chaos.DebugDraw.BVHShapes

p.Chaos.DebugDraw.BVHShapes

#Overview

name: p.Chaos.DebugDraw.BVHShapes

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.BVHShapes is to control the debug drawing of shapes within each Bounding Volume Hierarchy (BVH) node in the Chaos physics system of Unreal Engine 5. This setting is specifically used for visualization and debugging purposes in the physics simulation.

This setting variable is primarily used in the Chaos physics system, which is an experimental physics engine in Unreal Engine 5. It is part of the debug drawing functionality for the BVH structure used in physics simulations.

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

The associated variable bChaosDebugDebugDrawBVHShapes directly interacts with p.Chaos.DebugDraw.BVHShapes. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable is specifically for debug visualization purposes. Enabling it may have performance implications, especially in complex scenes with many physics objects. It should typically be used only during development and debugging, not in release builds.

Best practices for using this variable include:

  1. Use it in conjunction with other debug drawing options like p.Chaos.DebugDraw.BVHLevel and p.Chaos.DebugDraw.BVHBounds for a comprehensive view of the BVH structure.
  2. Be mindful of performance impact when enabling this in complex scenes.
  3. Use it primarily during development and debugging phases, not in production or release builds.
  4. Consider creating a debug menu or console command to toggle this and other debug drawing options easily during runtime.

Regarding the associated variable bChaosDebugDebugDrawBVHShapes:

The purpose of bChaosDebugDebugDrawBVHShapes is identical to p.Chaos.DebugDraw.BVHShapes. It’s a boolean flag that determines whether to draw the shapes in each BVH node with color coding.

This variable is used directly in the Chaos physics system’s debug drawing implementation. It’s checked in the DrawBVHImpl function to determine whether to render the shapes within BVH nodes.

The value of this variable is set in tandem with p.Chaos.DebugDraw.BVHShapes through the console variable system.

Developers should treat this variable the same way as p.Chaos.DebugDraw.BVHShapes, being aware that it’s for debug visualization and may impact performance when enabled.

Best practices for bChaosDebugDebugDrawBVHShapes are the same as those for p.Chaos.DebugDraw.BVHShapes, focusing on its use during development and debugging, and being mindful of its performance impact.

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw

Source code excerpt:

		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(

#Associated Variable and Callsites

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

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

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(

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw
function     void DrawBVHImpl
lambda-function

Source code excerpt:

						}

						if (bChaosDebugDebugDrawBVHShapes)
						{
							BVH->VisitNodeObjects(NodeIndex, 
								[Particle, &ShapeTransform, &Color, Duration, &Settings](const FImplicitObject * Implicit, const FRigidTransform3f& RelativeTransformf, const FAABB3f& RelativeBoundsf, const int32 RootObjectIndex, const int32 LeafObjectIndex) -> void
								{
									const int32 ShapeIndex = (RootObjectIndex != INDEX_NONE) ? RootObjectIndex : 0;
									const FShapeInstance* Shape = Particle->ShapeInstances()[ShapeIndex].Get();