ai.crowd.DrawDebugPathOptimization

ai.crowd.DrawDebugPathOptimization

#Overview

name: ai.crowd.DrawDebugPathOptimization

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.DrawDebugPathOptimization is to enable or disable the drawing of path optimization data for crowd agents in Unreal Engine’s AI module. This setting is primarily used for debugging and visualization purposes within the crowd simulation system.

This setting variable is relied upon by the AI Module, specifically within the crowd navigation and management subsystem. It is used in the UCrowdManager class, which is responsible for managing crowd behaviors and pathfinding.

The value of this variable is set through a console variable (CVar) named “ai.crowd.DrawDebugPathOptimization”. It is initialized with a default value of 1 (enabled) but can be changed at runtime through the console or game code.

The associated variable DrawDebugPathOptimization interacts with it directly, as they share the same value. This associated variable is used within the UCrowdManager class to determine whether to draw debug information for path optimization.

Developers must be aware that this debug drawing feature requires “ai.crowd.DebugSelectedActors” to be enabled as well. It’s important to note that enabling debug drawing can have performance implications, especially in scenes with many crowd agents.

Best practices when using this variable include:

  1. Only enable it during development and debugging phases.
  2. Disable it in release builds to avoid unnecessary performance overhead.
  3. Use it in conjunction with other debug drawing options to get a comprehensive view of crowd agent behavior.
  4. Be mindful of the performance impact when enabling this in complex scenes.

Regarding the associated variable DrawDebugPathOptimization:

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

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:

	
	int32 DrawDebugPathOptimization = 1;
	FAutoConsoleVariableRef CVarDrawDebugPathOptimization(TEXT("ai.crowd.DrawDebugPathOptimization"), DrawDebugPathOptimization,
		TEXT("Draw path optimization data, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	
	int32 DrawDebugNeighbors = 1;
	FAutoConsoleVariableRef CVarDrawDebugNeighbors(TEXT("ai.crowd.DrawDebugNeighbors"), DrawDebugNeighbors,
		TEXT("Draw current neighbors data, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
class        class UCrowdManager : public UCrowdManagerBase

Source code excerpt:

	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

#endif
};

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

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:

		TEXT("Draw velocity obstacle sampling, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	
	int32 DrawDebugPathOptimization = 1;
	FAutoConsoleVariableRef CVarDrawDebugPathOptimization(TEXT("ai.crowd.DrawDebugPathOptimization"), DrawDebugPathOptimization,
		TEXT("Draw path optimization data, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
	
	int32 DrawDebugNeighbors = 1;
	FAutoConsoleVariableRef CVarDrawDebugNeighbors(TEXT("ai.crowd.DrawDebugNeighbors"), DrawDebugNeighbors,
		TEXT("Draw current neighbors data, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);

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

Scope (from outer to inner):

file
function     void UCrowdManager::DrawDebugPathOptimization

Source code excerpt:

}

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

	FVector Pt0 = Recast2UnrealPoint(DetourAgentDebug->optStart) + FCrowdDebug::Offset * 1.25f;
	FVector Pt1 = Recast2UnrealPoint(DetourAgentDebug->optEnd) + FCrowdDebug::Offset * 1.25f;

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

Scope (from outer to inner):

file
function     void UCrowdManager::DebugTick

Source code excerpt:

		}

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

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