r.Debug.DrawCurrentDebugTargetBoundingBox
r.Debug.DrawCurrentDebugTargetBoundingBox
#Overview
name: r.Debug.DrawCurrentDebugTargetBoundingBox
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Draw the bounding box of the currently selected debug target (Default: 1)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Debug.DrawCurrentDebugTargetBoundingBox is to control the drawing of a bounding box around the currently selected debug target in the game world. This setting is primarily used for debugging and visualization purposes in the Unreal Engine’s rendering system.
This setting variable is relied upon by the Engine module, specifically within the HUD (Heads-Up Display) system. It’s used in the AHUD class, which is responsible for drawing 2D information on the screen.
The value of this variable is set through a console variable, which means it can be changed at runtime through the console or configuration files. It’s initialized with a default value of 1, meaning the bounding box drawing is enabled by default.
The associated variable GDrawCurrentDebugTargetBoundingBox directly interacts with r.Debug.DrawCurrentDebugTargetBoundingBox. They share the same value and purpose.
Developers must be aware that:
- This feature is only available when ENABLE_DRAW_DEBUG is defined, typically in development builds.
- The bounding box drawing can impact performance, especially in complex scenes or when many debug targets are present.
- The bounding box is slightly expanded (by 10%) from the actual actor bounds for better visibility.
Best practices when using this variable include:
- Use it primarily for debugging purposes and disable it in release builds.
- Be cautious about performance impact when enabled, especially in complex scenes.
- Consider providing a user-friendly way to toggle this feature on/off during gameplay for easier debugging.
Regarding the associated variable GDrawCurrentDebugTargetBoundingBox:
This is a TAutoConsoleVariable
Developers should be aware that:
- This variable is checked on the game thread (GetValueOnGameThread()), which means changes to it will be reflected in the next frame.
- It’s used within the AHUD::ShowDebugInfo function to determine whether to draw the bounding box.
Best practices for using GDrawCurrentDebugTargetBoundingBox include:
- Use it for conditional compilation or runtime checks related to debug drawing.
- Remember that changes to this variable at runtime will affect all instances where it’s used.
- Consider caching its value if checked frequently to avoid potential performance overhead from repeated console variable lookups.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HUD.cpp:58
Scope: file
Source code excerpt:
#if ENABLE_DRAW_DEBUG
TAutoConsoleVariable<int32> GDrawCurrentDebugTargetBoundingBox(
TEXT("r.Debug.DrawCurrentDebugTargetBoundingBox"),
1,
TEXT("Draw the bounding box of the currently selected debug target (Default: 1)"));
#endif // ENABLE_DRAW_DEBUG
AHUD::AHUD(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
#Associated Variable and Callsites
This variable is associated with another variable named GDrawCurrentDebugTargetBoundingBox
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HUD.cpp:57
Scope: file
Source code excerpt:
#if ENABLE_DRAW_DEBUG
TAutoConsoleVariable<int32> GDrawCurrentDebugTargetBoundingBox(
TEXT("r.Debug.DrawCurrentDebugTargetBoundingBox"),
1,
TEXT("Draw the bounding box of the currently selected debug target (Default: 1)"));
#endif // ENABLE_DRAW_DEBUG
AHUD::AHUD(const FObjectInitializer& ObjectInitializer)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HUD.cpp:447
Scope (from outer to inner):
file
function void AHUD::ShowDebugInfo
Source code excerpt:
// Draw box around Actor being debugged.
#if ENABLE_DRAW_DEBUG
if (GDrawCurrentDebugTargetBoundingBox.GetValueOnGameThread() > 0)
{
FVector BoundsOrigin, BoundsExtent;
ShowDebugTargetActor->GetActorBounds(true, BoundsOrigin, BoundsExtent);
// Expand extent a little bit
BoundsExtent *= 1.1f;