p.Chaos.DebugDraw.BVHLevel
p.Chaos.DebugDraw.BVHLevel
#Overview
name: p.Chaos.DebugDraw.BVHLevel
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Which level of the BVH to draw (-1 = Leaf)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.DebugDraw.BVHLevel is to control the visualization of the Bounding Volume Hierarchy (BVH) in Unreal Engine’s Chaos physics system for debugging purposes. It specifically determines which level of the BVH tree structure should be drawn.
This setting variable is primarily used in the Chaos physics subsystem, which is part of Unreal Engine’s experimental physics module. It’s particularly relevant for developers working on or debugging the physics simulation within the engine.
The value of this variable is set through the Unreal Engine console system, as indicated by the FAutoConsoleVariableRef declaration. It can be changed at runtime using console commands.
The associated variable ChaosDebugDebugDrawBVHLevel interacts directly with p.Chaos.DebugDraw.BVHLevel. They share the same value, with ChaosDebugDebugDrawBVHLevel being the actual variable used in the code logic.
Developers should be aware that:
- A value of -1 (default) means only leaf nodes of the BVH will be drawn.
- Any non-negative integer value will draw the BVH nodes at that specific level.
- This variable works in conjunction with other debug drawing variables like p.Chaos.DebugDraw.BVHShapes and p.Chaos.DebugDraw.BVHBounds.
Best practices when using this variable include:
- Use it in conjunction with other debug drawing tools for a comprehensive view of the physics system.
- Be mindful of performance impact when enabling debug drawing, especially at lower (more detailed) BVH levels.
- Remember to disable debug drawing in production builds.
Regarding the associated variable ChaosDebugDebugDrawBVHLevel:
- It’s the actual int32 variable that stores the BVH level to be drawn.
- It’s used directly in the DrawBVHImpl function to determine which nodes should be visualized.
- Developers should use the console variable p.Chaos.DebugDraw.BVHLevel to modify this value, rather than changing it directly in code.
- When using this variable in code, developers should be aware that its value can change at runtime due to console commands.
#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:130
Scope (from outer to inner):
file
namespace Chaos
namespace DebugDraw
Source code excerpt:
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.
#Associated Variable and Callsites
This variable is associated with another variable named ChaosDebugDebugDrawBVHLevel
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:127
Scope (from outer to inner):
file
namespace Chaos
namespace DebugDraw
Source code excerpt:
FAutoConsoleVariableRef CVarChaosDebugDrawConnectionGraphShowInternalStrains(TEXT("p.Chaos.DebugDraw.ConnectionGraph.ShowInternalStrains"), bChaosDebugDrawConnectionGraphShowInternalStrains, TEXT("When displaying connection graphs show strain values of each node"));
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.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:997
Scope (from outer to inner):
file
namespace Chaos
namespace DebugDraw
function void DrawBVHImpl
lambda-function
Source code excerpt:
{
// Draw the node if it is at the level we are asked to draw, or it is a leaf and we want to draw leaves.
if ((NodeDepth == ChaosDebugDebugDrawBVHLevel) || (BVH->NodeIsLeaf(NodeIndex) && ((ChaosDebugDebugDrawBVHLevel == INDEX_NONE) || (ChaosDebugDebugDrawBVHLevel > NodeDepth))))
{
const FColor Color = GetIndexColor(LeafIndex++);
if (bChaosDebugDebugDrawBVHBounds)
{
const FVec3 NodeBoundsPos = ShapeTransform.TransformPosition(FVec3(NodeBounds.Center()));