P.Chaos.DrawHierarchy.CellElementThresh
P.Chaos.DrawHierarchy.CellElementThresh
#Overview
name: P.Chaos.DrawHierarchy.CellElementThresh
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Num elements to consider \
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of P.Chaos.DrawHierarchy.CellElementThresh is to set a threshold for the number of elements considered “high” for cell coloring when rendering the physics hierarchy in Unreal Engine’s Chaos physics system.
This setting variable is primarily used in the Chaos physics subsystem, which is part of Unreal Engine’s physics engine. It is specifically related to the debug visualization of the physics hierarchy.
The value of this variable is set through a console variable (CVar) named CVar_ChaosDrawHierarchyCellElementThresh. It is initialized with a default value of 128 in the source code.
This variable interacts with other debug drawing variables for the Chaos physics system, such as CVar_ChaosDrawHierarchyBounds, CVar_ChaosDrawHierarchyObjectBounds, and CVar_ChaosDrawHierarchyDrawEmptyCells. It is primarily used in conjunction with these variables to control the debug visualization of the physics hierarchy.
Developers must be aware that this variable affects the visual debugging of the Chaos physics system. It determines the color gradient used to represent the number of elements in each cell of the physics hierarchy. Cells with a number of elements close to or exceeding this threshold will be colored differently, helping developers identify areas of high element density.
Best practices when using this variable include:
- Adjusting the value based on the scale and complexity of your physics scene.
- Using it in conjunction with other debug drawing options for a comprehensive view of the physics hierarchy.
- Being mindful that frequent changes to this value during runtime may impact performance due to debug rendering updates.
Regarding the associated variable CVar_ChaosDrawHierarchyCellElementThresh:
This is the actual console variable that controls the P.Chaos.DrawHierarchy.CellElementThresh setting. It is defined as a TAutoConsoleVariable
The purpose of this variable is the same as P.Chaos.DrawHierarchy.CellElementThresh, as they represent the same setting.
This variable is used directly in the physics scene code to determine the color of cells when rendering the debug visualization. It can be updated dynamically, as seen in the DumpHierarchyStats function, where it can be set to a new value based on console command arguments.
Developers should be aware that changes to this variable will take effect immediately in the debug visualization. They should use the console command system to modify this value during runtime for debugging purposes.
#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:42
Scope: file
Source code excerpt:
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
int32 GEnableKinematicDeferralStartPhysicsCondition = 1;
#Associated Variable and Callsites
This variable is associated with another variable named CVar_ChaosDrawHierarchyCellElementThresh
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:42
Scope: file
Source code excerpt:
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
int32 GEnableKinematicDeferralStartPhysicsCondition = 1;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:233
Scope (from outer to inner):
file
function void DumpHierarchyStats
Source code excerpt:
if(Args.Num() > 0 && Args[0] == TEXT("UPDATERENDER"))
{
CVar_ChaosDrawHierarchyCellElementThresh->Set(MaxElems);
}
}
#endif
}
static FAutoConsoleCommand Command_DumpHierarchyStats(TEXT("p.chaos.dumphierarcystats"), TEXT("Outputs current collision hierarchy stats to the output log"), FConsoleCommandWithArgsDelegate::CreateStatic(DumpHierarchyStats));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:412
Scope: file
Source code excerpt:
const int32 NumEntries = CellList.Num();
const Chaos::FReal TempFraction = FMath::Min<Chaos::FReal>(NumEntries / (Chaos::FReal)CVar_ChaosDrawHierarchyCellElementThresh.GetValueOnGameThread(), 1.0f);
const FColor CellColor = FColor::MakeRedToGreenColorFromScalar(1.0f - TempFraction);
if (NumEntries > 0 || bDrawEmptyCells)
{
DrawDebugBox(WorldPtr, Grid.Location(TVec3<int32>(CellsX, CellsY, CellsZ)), CellExtent / 2.0f, FQuat::Identity, CellColor, false, -1.0f, SDPG_Foreground, 0.5f);