p.Chaos.Solver.DebugDrawPreIntegrationShapes

p.Chaos.Solver.DebugDrawPreIntegrationShapes

#Overview

name: p.Chaos.Solver.DebugDrawPreIntegrationShapes

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.Solver.DebugDrawPreIntegrationShapes is to enable debug drawing of shapes prior to the integration step in the Chaos physics solver. This setting is part of the debugging and visualization system for the Chaos physics engine in Unreal Engine 5.

This setting variable is primarily used in the Chaos physics subsystem, which is part of the experimental physics system in Unreal Engine 5. It’s specifically utilized within the PBDRigidsSolver (Position Based Dynamics Rigids Solver) module.

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

The associated variable ChaosSolverDebugDrawPreIntegrationShapes interacts directly with p.Chaos.Solver.DebugDrawPreIntegrationShapes. They share the same value and are used interchangeably in the code.

Developers should be aware that this is a debugging feature and should be used primarily during development and testing phases. Enabling this feature may have performance implications, especially in complex scenes with many physics objects.

Best practices for using this variable include:

  1. Only enable it when necessary for debugging physics issues.
  2. Be mindful of performance impact in complex scenes.
  3. Use in conjunction with other debug drawing options for a comprehensive view of the physics state.
  4. Remember to disable it in release builds or when publishing the game.

Regarding the associated variable ChaosSolverDebugDrawPreIntegrationShapes:

The purpose of ChaosSolverDebugDrawPreIntegrationShapes is to serve as the internal representation of the console variable p.Chaos.Solver.DebugDrawPreIntegrationShapes within the C++ code.

This variable is used directly in the PreIntegrateDebugDraw function of the FPBDRigidsSolver class to determine whether to perform debug drawing of shapes before the integration step.

The value of this variable is set by the console variable system when p.Chaos.Solver.DebugDrawPreIntegrationShapes is modified.

It interacts with other debug drawing variables and functions within the Chaos solver, such as ChaosSolverDrawShapesShowKinematic and ChaosSolverDrawShapesShowDynamic.

Developers should be aware that this variable directly controls the behavior of the debug drawing system and should be used in conjunction with the console variable for consistency.

Best practices for using this variable include:

  1. Avoid modifying it directly in code; instead, use the console variable system.
  2. Use it as a condition for debug drawing operations to ensure consistency with user settings.
  3. Consider wrapping access to this variable in debug-only code blocks to prevent any overhead in release builds.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:182

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		int32 ChaosSolverDebugDrawPreIntegrationShapes = 0;
		int32 ChaosSolverDebugDrawPreIntegrationCollisions = 0;
		FAutoConsoleVariableRef CVarChaosSolverDrawPreIntegrationShapes(TEXT("p.Chaos.Solver.DebugDrawPreIntegrationShapes"), ChaosSolverDebugDrawPreIntegrationShapes, TEXT("Draw Shapes prior to integrate."));
		FAutoConsoleVariableRef CVarChaosSolverDrawPreIntegrationCollisions(TEXT("p.Chaos.Solver.DebugDrawPreIntegrationCollisions"), ChaosSolverDebugDrawPreIntegrationCollisions, TEXT("Draw Collisions prior to integrate."));

		int32 ChaosSolverDebugDrawPostIntegrationShapes = 0;
		int32 ChaosSolverDebugDrawPostIntegrationCollisions = 0;
		FAutoConsoleVariableRef CVarChaosSolverDrawPostIntegrationShapes(TEXT("p.Chaos.Solver.DebugDrawPostIntegrationShapes"), ChaosSolverDebugDrawPostIntegrationShapes, TEXT("Draw Shapes prior to constraint solve phase."));
		FAutoConsoleVariableRef CVarChaosSolverDrawPostIntegrationCollisions(TEXT("p.Chaos.Solver.DebugDrawPostIntegrationCollisions"), ChaosSolverDebugDrawPostIntegrationCollisions, TEXT("Draw Collisions prior to constraint solve phase."));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:180

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		FAutoConsoleVariableRef CVarChaosSolverDebugDrawShowClient(TEXT("p.Chaos.Solver.DebugDraw.ShowClient"), ChaosSolverDebugDrawShowClient, TEXT("Draw client related debug data"));

		int32 ChaosSolverDebugDrawPreIntegrationShapes = 0;
		int32 ChaosSolverDebugDrawPreIntegrationCollisions = 0;
		FAutoConsoleVariableRef CVarChaosSolverDrawPreIntegrationShapes(TEXT("p.Chaos.Solver.DebugDrawPreIntegrationShapes"), ChaosSolverDebugDrawPreIntegrationShapes, TEXT("Draw Shapes prior to integrate."));
		FAutoConsoleVariableRef CVarChaosSolverDrawPreIntegrationCollisions(TEXT("p.Chaos.Solver.DebugDrawPreIntegrationCollisions"), ChaosSolverDebugDrawPreIntegrationCollisions, TEXT("Draw Collisions prior to integrate."));

		int32 ChaosSolverDebugDrawPostIntegrationShapes = 0;
		int32 ChaosSolverDebugDrawPostIntegrationCollisions = 0;
		FAutoConsoleVariableRef CVarChaosSolverDrawPostIntegrationShapes(TEXT("p.Chaos.Solver.DebugDrawPostIntegrationShapes"), ChaosSolverDebugDrawPostIntegrationShapes, TEXT("Draw Shapes prior to constraint solve phase."));
		FAutoConsoleVariableRef CVarChaosSolverDrawPostIntegrationCollisions(TEXT("p.Chaos.Solver.DebugDrawPostIntegrationCollisions"), ChaosSolverDebugDrawPostIntegrationCollisions, TEXT("Draw Collisions prior to constraint solve phase."));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:2488

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsSolver::PreIntegrateDebugDraw

Source code excerpt:

		QUICK_SCOPE_CYCLE_COUNTER(SolverDebugDraw);

		if (ChaosSolverDebugDrawPreIntegrationShapes == 1)
		{
			ChaosSolverDebugDebugDrawSettings.ShapesColorsPerState = DebugDraw::GetDefaultShapesColorsPreIntegrate();

			DebugDrawShapes(false, !!ChaosSolverDrawShapesShowKinematic, !!ChaosSolverDrawShapesShowDynamic);
		}
		if (ChaosSolverDebugDrawPreIntegrationCollisions == 1)