ai.crowd.DrawDebugCollisionSegments

ai.crowd.DrawDebugCollisionSegments

#Overview

name: ai.crowd.DrawDebugCollisionSegments

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 ai.crowd.DrawDebugCollisionSegments is to enable or disable the drawing of colliding navmesh edges for debugging purposes in the AI crowd simulation system of Unreal Engine 5. This setting is specifically used for visualization and debugging of the crowd navigation system.

This setting variable is primarily used in the AI Module of Unreal Engine, specifically within the crowd management system. The CrowdManager class in the AIModule is the main component that relies on this setting.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime through the console or programmatically.

The associated variable DrawDebugCollisionSegments interacts directly with ai.crowd.DrawDebugCollisionSegments. They share the same value and are used interchangeably in the code.

Developers should be aware that:

  1. This debug drawing feature requires ai.crowd.DebugSelectedActors to be set for it to work.
  2. It’s primarily a debugging tool and should be disabled in release builds for performance reasons.
  3. The debug drawing is performed in the UCrowdManager::DebugTick() method, which suggests it’s updated every frame when enabled.

Best practices when using this variable include:

  1. Use it in conjunction with other debug visualization tools for a comprehensive view of the crowd simulation.
  2. Remember to disable it in release builds or when not actively debugging.
  3. Be aware of potential performance impact when enabled, especially with large crowds.

Regarding the associated variable DrawDebugCollisionSegments:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:58

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:

	
	int32 DrawDebugCollisionSegments = 1;
	FAutoConsoleVariableRef CVarDrawDebugCollisionSegments(TEXT("ai.crowd.DrawDebugCollisionSegments"), DrawDebugCollisionSegments,
		TEXT("Draw colliding navmesh edges, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	
	int32 DrawDebugPath = 1;
	FAutoConsoleVariableRef CVarDrawDebugPath(TEXT("ai.crowd.DrawDebugPath"), DrawDebugPath,
		TEXT("Draw active paths, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Classes/Navigation/CrowdManager.h:383

Scope (from outer to inner):

file
class        class UCrowdManager : public UCrowdManagerBase

Source code excerpt:

	AIMODULE_API UWorld* GetDebugDrawingWorld() const;
	AIMODULE_API void DrawDebugCorners(const dtCrowdAgent* CrowdAgent) const;
	AIMODULE_API void DrawDebugCollisionSegments(const dtCrowdAgent* CrowdAgent) const;
	AIMODULE_API void DrawDebugPath(const dtCrowdAgent* CrowdAgent) const;
	AIMODULE_API void DrawDebugVelocityObstacles(const dtCrowdAgent* CrowdAgent) const;
	AIMODULE_API void DrawDebugPathOptimization(const dtCrowdAgent* CrowdAgent) const;
	AIMODULE_API void DrawDebugNeighbors(const dtCrowdAgent* CrowdAgent) const;
	AIMODULE_API void DrawDebugSharedBoundary() const;
#endif // ENABLE_DRAW_DEBUG

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:57

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:

		TEXT("Draw path corners data, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	
	int32 DrawDebugCollisionSegments = 1;
	FAutoConsoleVariableRef CVarDrawDebugCollisionSegments(TEXT("ai.crowd.DrawDebugCollisionSegments"), DrawDebugCollisionSegments,
		TEXT("Draw colliding navmesh edges, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	
	int32 DrawDebugPath = 1;
	FAutoConsoleVariableRef CVarDrawDebugPath(TEXT("ai.crowd.DrawDebugPath"), DrawDebugPath,
		TEXT("Draw active paths, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:997

Scope (from outer to inner):

file
function     void UCrowdManager::DrawDebugCollisionSegments

Source code excerpt:

}

void UCrowdManager::DrawDebugCollisionSegments(const dtCrowdAgent* CrowdAgent) const
{
	UWorld* DebugDrawingWorld = GetDebugDrawingWorld();

	FVector Center = Recast2UnrealPoint(CrowdAgent->boundary.getCenter()) + FCrowdDebug::Offset;
	DrawDebugCylinder(DebugDrawingWorld, Center - FCrowdDebug::Offset, Center, UE_REAL_TO_FLOAT_CLAMPED_MAX(CrowdAgent->params.collisionQueryRange), 32, FCrowdDebug::CollisionRange);

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:1180

Scope (from outer to inner):

file
function     void UCrowdManager::DebugTick

Source code excerpt:

		}

		if (FCrowdDebug::DrawDebugCollisionSegments)
		{
			DrawDebugCollisionSegments(SelectedAgent);
		}

		if (FCrowdDebug::DrawDebugPath)
		{
			DrawDebugPath(SelectedAgent);
		}