p.Chaos.ImmPhys.DebugDrawOnSimulate

p.Chaos.ImmPhys.DebugDrawOnSimulate

#Overview

name: p.Chaos.ImmPhys.DebugDrawOnSimulate

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.ImmPhys.DebugDrawOnSimulate is to enable debug drawing for the Chaos Immediate Physics simulation after the simulation completes. This setting variable is part of the debug drawing system for the Chaos physics engine in Unreal Engine 5.

This setting variable is primarily used in the Chaos Immediate Physics module, which is part of the physics engine subsystem in Unreal Engine 5. It’s specifically used in the ImmediatePhysicsChaos component.

The value of this variable is set through the console variable system in Unreal Engine. It’s declared as an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands or configuration files.

The associated variable bChaosImmediate_DebugDrawOnSimulate interacts directly with p.Chaos.ImmPhys.DebugDrawOnSimulate. They share the same value and are used interchangeably in the code.

Developers must be aware that this debug drawing feature is only available when CHAOS_DEBUG_DRAW is defined. It’s important to note that enabling debug drawing can have performance implications, so it should be used judiciously, especially in production builds.

Best practices when using this variable include:

  1. Only enable it when necessary for debugging purposes.
  2. Be aware of the performance impact when enabled.
  3. Use it in conjunction with other debug drawing options (like p.Chaos.ImmPhys.DebugDrawParticles, p.Chaos.ImmPhys.DebugDrawShapes, etc.) for a more comprehensive debug view.

Regarding the associated variable bChaosImmediate_DebugDrawOnSimulate:

The purpose of bChaosImmediate_DebugDrawOnSimulate is to act as the internal boolean flag that controls whether debug drawing is enabled for the Chaos Immediate Physics simulation.

This variable is used directly in the Chaos Immediate Physics simulation code to determine whether to call the DebugDraw() function after the simulation completes.

The value of this variable is set by the console variable p.Chaos.ImmPhys.DebugDrawOnSimulate.

It interacts with the CHAOS_DEBUG_DRAW macro, which must be defined for the debug drawing code to be compiled and used.

Developers should be aware that this variable is only effective when CHAOS_DEBUG_DRAW is defined. They should also note that it’s declared at file scope, which means it’s accessible throughout the file but not outside of it.

Best practices for using this variable include:

  1. Use it in conjunction with the console variable p.Chaos.ImmPhys.DebugDrawOnSimulate for runtime control.
  2. Be mindful of the performance impact when enabling debug drawing in performance-critical code paths.
  3. Consider wrapping debug drawing code in additional conditional checks if fine-grained control is needed.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsSimulation_Chaos.cpp:175

Scope: file

Source code excerpt:

bool bChaosImmediate_DebugDrawSimulationSpace = 0;
Chaos::DebugDraw::FChaosDebugDrawJointFeatures ChaosImmediate_DebugDrawJointFeatures = Chaos::DebugDraw::FChaosDebugDrawJointFeatures::MakeDefault();
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawEnabled(TEXT("p.Chaos.ImmPhys.DebugDrawOnSimulate"), bChaosImmediate_DebugDrawOnSimulate, TEXT("Enables debug drawing after the simulation completes."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawParticles(TEXT("p.Chaos.ImmPhys.DebugDrawParticles"), bChaosImmediate_DebugDrawParticles, TEXT("Whether to draw particles when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawShapes(TEXT("p.Chaos.ImmPhys.DebugDrawShapes"), bChaosImmediate_DebugDrawShapes, TEXT("Whether to draw shapes when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawBounds(TEXT("p.Chaos.ImmPhys.DebugDrawBounds"), bChaosImmediate_DebugDrawBounds, TEXT("Whether to draw bounds when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawCollisions(TEXT("p.Chaos.ImmPhys.DebugDrawCollisions"), bChaosImmediate_DebugDrawCollisions, TEXT("Whether to draw collisions when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawJoints(TEXT("p.Chaos.ImmPhys.DebugDrawJoints"), bChaosImmediate_DebugDrawJoints, TEXT("Whether to draw joints when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawSimulationSpace(TEXT("p.Chaos.ImmPhys.DebugDrawSimulationSpace"), bChaosImmediate_DebugDrawSimulationSpace, TEXT("Whether to draw the simulation frame of reference, acceleration and velocity when debug drawing."), ECVF_Default);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsSimulation_Chaos.cpp:164

Scope: file

Source code excerpt:

// DebugDraw CVars
#if CHAOS_DEBUG_DRAW
bool bChaosImmediate_DebugDrawOnSimulate = false;
bool bChaosImmediate_DebugDrawParticles = false;
bool bChaosImmediate_DebugDrawShapes = false;
bool bChaosImmediate_DebugDrawShowStatics = true;
bool bChaosImmediate_DebugDrawShowKinematics = true;
bool bChaosImmediate_DebugDrawShowDynamics = true;
bool bChaosImmediate_DebugDrawBounds = false;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsSimulation_Chaos.cpp:175

Scope: file

Source code excerpt:

bool bChaosImmediate_DebugDrawSimulationSpace = 0;
Chaos::DebugDraw::FChaosDebugDrawJointFeatures ChaosImmediate_DebugDrawJointFeatures = Chaos::DebugDraw::FChaosDebugDrawJointFeatures::MakeDefault();
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawEnabled(TEXT("p.Chaos.ImmPhys.DebugDrawOnSimulate"), bChaosImmediate_DebugDrawOnSimulate, TEXT("Enables debug drawing after the simulation completes."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawParticles(TEXT("p.Chaos.ImmPhys.DebugDrawParticles"), bChaosImmediate_DebugDrawParticles, TEXT("Whether to draw particles when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawShapes(TEXT("p.Chaos.ImmPhys.DebugDrawShapes"), bChaosImmediate_DebugDrawShapes, TEXT("Whether to draw shapes when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawBounds(TEXT("p.Chaos.ImmPhys.DebugDrawBounds"), bChaosImmediate_DebugDrawBounds, TEXT("Whether to draw bounds when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawCollisions(TEXT("p.Chaos.ImmPhys.DebugDrawCollisions"), bChaosImmediate_DebugDrawCollisions, TEXT("Whether to draw collisions when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawJoints(TEXT("p.Chaos.ImmPhys.DebugDrawJoints"), bChaosImmediate_DebugDrawJoints, TEXT("Whether to draw joints when debug drawing."), ECVF_Default);
FAutoConsoleVariableRef CVarChaosImmPhysDebugDrawSimulationSpace(TEXT("p.Chaos.ImmPhys.DebugDrawSimulationSpace"), bChaosImmediate_DebugDrawSimulationSpace, TEXT("Whether to draw the simulation frame of reference, acceleration and velocity when debug drawing."), ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsSimulation_Chaos.cpp:970

Scope (from outer to inner):

file
namespace    ImmediatePhysics_Chaos
function     void FSimulation::Simulate

Source code excerpt:


#if CHAOS_DEBUG_DRAW
		if (bChaosImmediate_DebugDrawOnSimulate)
		{
			DebugDraw();
		}
#endif
	}