P.Chaos.DrawHierarchy.Bounds

P.Chaos.DrawHierarchy.Bounds

#Overview

name: P.Chaos.DrawHierarchy.Bounds

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.DrawHierarchy.Bounds is to enable or disable drawing of the physics hierarchy bounds in Unreal Engine’s Chaos physics system. This setting variable is part of the debugging and visualization tools for the Chaos physics engine.

The Unreal Engine subsystem that relies on this setting variable is the Chaos physics engine, which is part of the broader physics system in Unreal Engine 5. Specifically, it’s used in the experimental PhysScene_Chaos module, as evidenced by its location in the PhysScene_Chaos.cpp file.

The value of this variable is set as a console variable (CVar) with a default value of 1, meaning it’s enabled by default. It can be changed at runtime through the console or programmatically.

This variable interacts with several other related variables, all prefixed with “CVar_ChaosDrawHierarchy”. These include:

Developers should be aware that this variable is primarily used for debugging and visualization purposes. Enabling it may have performance implications, especially in a shipping build or on lower-end hardware.

Best practices when using this variable include:

  1. Use it primarily during development and debugging phases.
  2. Disable it in shipping builds to avoid unnecessary performance overhead.
  3. Use it in conjunction with other Chaos physics debugging tools for a comprehensive view of the physics system.

Regarding the associated variable CVar_ChaosDrawHierarchyBounds:

The purpose of CVar_ChaosDrawHierarchyBounds is identical to P.Chaos.DrawHierarchy.Bounds. It’s the actual C++ variable that controls the behavior specified by the console variable.

This variable is used directly in the FPhysicsThreadSyncCaller class, specifically in the DebugDrawSolvers function. It’s checked to determine whether to draw the physics hierarchy bounds.

The value of this variable is set by the console variable system and can be accessed using the GetValueOnGameThread() method.

Developers should be aware that changes to this variable will take effect on the next game thread update after the change is made.

Best practices for using CVar_ChaosDrawHierarchyBounds include:

  1. Access its value using GetValueOnGameThread() to ensure thread-safe access.
  2. Consider the performance impact of frequently checking this variable in performance-critical code paths.
  3. Use it in conjunction with other debug drawing options for a comprehensive view of the physics system state.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:40

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyEnable(TEXT("P.Chaos.DrawHierarchy.Enable"), 0, TEXT("Enable / disable drawing of the physics hierarchy"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyCells(TEXT("P.Chaos.DrawHierarchy.Cells"), 0, TEXT("Enable / disable drawing of the physics hierarchy cells"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyBounds(TEXT("P.Chaos.DrawHierarchy.Bounds"), 1, TEXT("Enable / disable drawing of the physics hierarchy bounds"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyObjectBounds(TEXT("P.Chaos.DrawHierarchy.ObjectBounds"), 1, TEXT("Enable / disable drawing of the physics hierarchy object bounds"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyCellElementThresh(TEXT("P.Chaos.DrawHierarchy.CellElementThresh"), 128, TEXT("Num elements to consider \"high\" for cell colouring when rendering."));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyDrawEmptyCells(TEXT("P.Chaos.DrawHierarchy.DrawEmptyCells"), 1, TEXT("Whether to draw cells that are empty when cells are enabled."));
TAutoConsoleVariable<int32> CVar_ChaosUpdateKinematicsOnDeferredSkelMeshes(TEXT("P.Chaos.UpdateKinematicsOnDeferredSkelMeshes"), 1, TEXT("Whether to defer update kinematics for skeletal meshes."));

#endif

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:40

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyEnable(TEXT("P.Chaos.DrawHierarchy.Enable"), 0, TEXT("Enable / disable drawing of the physics hierarchy"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyCells(TEXT("P.Chaos.DrawHierarchy.Cells"), 0, TEXT("Enable / disable drawing of the physics hierarchy cells"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyBounds(TEXT("P.Chaos.DrawHierarchy.Bounds"), 1, TEXT("Enable / disable drawing of the physics hierarchy bounds"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyObjectBounds(TEXT("P.Chaos.DrawHierarchy.ObjectBounds"), 1, TEXT("Enable / disable drawing of the physics hierarchy object bounds"));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyCellElementThresh(TEXT("P.Chaos.DrawHierarchy.CellElementThresh"), 128, TEXT("Num elements to consider \"high\" for cell colouring when rendering."));
TAutoConsoleVariable<int32> CVar_ChaosDrawHierarchyDrawEmptyCells(TEXT("P.Chaos.DrawHierarchy.DrawEmptyCells"), 1, TEXT("Whether to draw cells that are empty when cells are enabled."));
TAutoConsoleVariable<int32> CVar_ChaosUpdateKinematicsOnDeferredSkelMeshes(TEXT("P.Chaos.UpdateKinematicsOnDeferredSkelMeshes"), 1, TEXT("Whether to defer update kinematics for skeletal meshes."));

#endif

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:338

Scope (from outer to inner):

file
class        class FPhysicsThreadSyncCaller : public FTickableGameObject
function     void DebugDrawSolvers

Source code excerpt:

		const bool bDrawCells = CVar_ChaosDrawHierarchyCells.GetValueOnGameThread() != 0;
		const bool bDrawEmptyCells = CVar_ChaosDrawHierarchyDrawEmptyCells.GetValueOnGameThread() != 0;
		const bool bDrawBounds = CVar_ChaosDrawHierarchyBounds.GetValueOnGameThread() != 0;
		const bool bDrawObjectBounds = CVar_ChaosDrawHierarchyObjectBounds.GetValueOnGameThread() != 0;

		UWorld* WorldPtr = nullptr;
		const TIndirectArray<FWorldContext>& WorldContexts = GEngine->GetWorldContexts();
		for(const FWorldContext& Context : WorldContexts)
		{