p.Chaos.DebugDraw.CollisionDuration

p.Chaos.DebugDraw.CollisionDuration

#Overview

name: p.Chaos.DebugDraw.CollisionDuration

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.DebugDraw.CollisionDuration is to control the duration for which collision debug drawings remain visible on the screen in the Chaos physics system of Unreal Engine 5. It is part of the debug visualization system for the Chaos physics engine.

This setting variable is primarily used by the Chaos physics module, specifically within the debug drawing functionality. Based on the callsites, it is utilized in the ChaosDebugDraw.cpp file, which is part of the Experimental Chaos runtime module.

The value of this variable is set through a console variable (CVar) system, as seen in the FAutoConsoleVariableRef declaration. It can be modified at runtime through console commands or programmatically.

The associated variable ChaosDebugDrawCollisionDuration directly interacts with p.Chaos.DebugDraw.CollisionDuration. They share the same value and purpose.

Developers must be aware that:

  1. The value is in seconds.
  2. A value of 0 means the debug draw will only remain for one frame.
  3. This variable affects performance, as longer durations may result in more persistent debug drawings.

Best practices when using this variable include:

  1. Use it only for debugging purposes in development builds.
  2. Set it to an appropriate duration that balances visibility and performance.
  3. Remember to disable or set to 0 in production builds to avoid unnecessary overhead.

Regarding the associated variable ChaosDebugDrawCollisionDuration:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:113

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw

Source code excerpt:


		float ChaosDebugDrawCollisionDuration = 0.0f;
		FAutoConsoleVariableRef CVarChaosDebugDrawCollisionDuration(TEXT("p.Chaos.DebugDraw.CollisionDuration"), ChaosDebugDrawCollisionDuration, TEXT("How long Collision debug draw should remain on screen in seconds. 0 for 1 frame."));

		bool bChaosDebugDrawCollisionAnchors = 0.0f;
		FAutoConsoleVariableRef CVarChaosDebugDrawCollisionAnchors(TEXT("p.Chaos.DebugDraw.ShowCollisionAnchors"), bChaosDebugDrawCollisionAnchors, TEXT(""));

		int32 ChaosConnectionGraphDrawLevelOffset = 0;
		FAutoConsoleVariableRef CVarChaosConnectionGraphDrawLevelOffset(TEXT("p.Chaos.DebugDraw.ConnectionGraphLevelOffset"), ChaosConnectionGraphDrawLevelOffset, TEXT("If 0, draws the connection graph between children particles of active particles. If 1, draws the connection grpah between grand-children particles of active particles, etc."));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:112

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw

Source code excerpt:

		FAutoConsoleVariableRef CVarChaosDebugDrawCCDDuration(TEXT("p.Chaos.DebugDraw.CCDDuration"), ChaosDebugDrawCCDDuration, TEXT("How long CCD debug draw should remain on screen in seconds. 0 for 1 frame."));

		float ChaosDebugDrawCollisionDuration = 0.0f;
		FAutoConsoleVariableRef CVarChaosDebugDrawCollisionDuration(TEXT("p.Chaos.DebugDraw.CollisionDuration"), ChaosDebugDrawCollisionDuration, TEXT("How long Collision debug draw should remain on screen in seconds. 0 for 1 frame."));

		bool bChaosDebugDrawCollisionAnchors = 0.0f;
		FAutoConsoleVariableRef CVarChaosDebugDrawCollisionAnchors(TEXT("p.Chaos.DebugDraw.ShowCollisionAnchors"), bChaosDebugDrawCollisionAnchors, TEXT(""));

		int32 ChaosConnectionGraphDrawLevelOffset = 0;
		FAutoConsoleVariableRef CVarChaosConnectionGraphDrawLevelOffset(TEXT("p.Chaos.DebugDraw.ConnectionGraphLevelOffset"), ChaosConnectionGraphDrawLevelOffset, TEXT("If 0, draws the connection graph between children particles of active particles. If 1, draws the connection grpah between grand-children particles of active particles, etc."));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:2222

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw
function     void DrawCollision

Source code excerpt:

			if (FDebugDrawQueue::IsDebugDrawingEnabled())
			{
				DrawCollisionImpl(SpaceTransform, Collision, ColorScale, ChaosDebugDrawCollisionDuration, GetChaosDebugDrawSettings(Settings));
			}
		}

		void DrawCollisions(const FRigidTransform3& SpaceTransform, const FPBDCollisionConstraints& Collisions, FRealSingle ColorScale, const FChaosDebugDrawSettings* Settings)
		{
			if (FDebugDrawQueue::IsDebugDrawingEnabled())

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:2232

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw
function     void DrawCollisions

Source code excerpt:

				for (int32 ConstraintIndex = 0; ConstraintIndex < Collisions.NumConstraints(); ++ConstraintIndex)
				{
					DrawCollisionImpl(SpaceTransform, Collisions.GetConstraint(ConstraintIndex), ColorScale, ChaosDebugDrawCollisionDuration, GetChaosDebugDrawSettings(Settings));
				}
			}
		}

		void DrawCollisions(const FRigidTransform3& SpaceTransform, const Private::FCollisionConstraintAllocator& CollisionAllocator, FRealSingle ColorScale, const FChaosDebugDrawSettings* Settings)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:2244

Scope (from outer to inner):

file
namespace    Chaos
namespace    DebugDraw
function     void DrawCollisions
lambda-function

Source code excerpt:

					[&](const FPBDCollisionConstraint& Collision)
					{
						DrawCollisionImpl(SpaceTransform, &Collision, ColorScale, ChaosDebugDrawCollisionDuration, GetChaosDebugDrawSettings(Settings));
						return ECollisionVisitorResult::Continue;
					}, ECollisionVisitorFlags::VisitAllCurrent);
			}
		}

		void DrawParticleMass(const FRigidTransform3& SpaceTransform, const TParticleView<FKinematicGeometryParticles>& ParticlesView, const FChaosDebugDrawSettings* Settings)