ai.crowd.DrawDebugCorners

ai.crowd.DrawDebugCorners

#Overview

name: ai.crowd.DrawDebugCorners

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.DrawDebugCorners is to enable or disable the drawing of path corners data for debugging crowd navigation in Unreal Engine 5. This setting variable is part of the AI module, specifically for crowd management and navigation debugging.

This setting variable is used in the AIModule subsystem, particularly in the CrowdManager class which handles crowd navigation for AI agents. It’s primarily used for debugging purposes to visualize the path corners of AI agents in a crowd.

The value of this variable is set through a console variable (CVar) system. It’s initialized to 1 (enabled) by default, but can be changed at runtime through console commands or project settings.

The associated variable DrawDebugCorners interacts directly with ai.crowd.DrawDebugCorners. They share the same value and are used in conjunction to control the debug drawing of path corners.

Developers must be aware that:

  1. This debug feature only works for selected actors, as indicated by the comment in the code.
  2. It requires ai.crowd.DebugSelectedActors to be enabled to function.
  3. It’s part of the ENABLE_DRAW_DEBUG conditional compilation block, so it may not be available in all build configurations.

Best practices when using this variable include:

  1. Use it in conjunction with other debug variables like ai.crowd.DebugSelectedActors for comprehensive debugging.
  2. Remember to disable it in production builds to avoid performance overhead.
  3. Use it alongside the Unreal Engine debugger and visualization tools for a complete picture of crowd agent behavior.

Regarding the associated variable DrawDebugCorners: This is an internal variable used within the FCrowdDebug namespace to actually store the state of the debug drawing. It’s directly linked to the console variable ai.crowd.DrawDebugCorners. The purpose is the same as ai.crowd.DrawDebugCorners - to control the debug drawing of path corners for crowd agents. It’s used in the UCrowdManager::DebugTick function to determine whether to call the DrawDebugCorners function for selected agents. The same awareness points and best practices apply to this variable as they do to ai.crowd.DrawDebugCorners.

#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:54

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:

	/** debug flags, works only for selected actor */
	int32 DrawDebugCorners = 1;
	FAutoConsoleVariableRef CVarDrawDebugCorners(TEXT("ai.crowd.DrawDebugCorners"), DrawDebugCorners,
		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);
	

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
class        class UCrowdManager : public UCrowdManagerBase

Source code excerpt:

#if ENABLE_DRAW_DEBUG
	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;

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

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:


	/** debug flags, works only for selected actor */
	int32 DrawDebugCorners = 1;
	FAutoConsoleVariableRef CVarDrawDebugCorners(TEXT("ai.crowd.DrawDebugCorners"), DrawDebugCorners,
		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);
	

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

Scope (from outer to inner):

file
function     void UCrowdManager::DrawDebugCorners

Source code excerpt:

}

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

	{
		FVector P0 = Recast2UnrealPoint(CrowdAgent->npos);
		for (int32 Idx = 0; Idx < CrowdAgent->ncorners; Idx++)

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

Scope (from outer to inner):

file
function     void UCrowdManager::DebugTick

Source code excerpt:

	if (SelectedAgent && FCrowdDebug::DebugSelectedActors)
	{
		if (FCrowdDebug::DrawDebugCorners)
		{
			DrawDebugCorners(SelectedAgent);
		}

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