ai.crowd.DrawDebugNeighbors

ai.crowd.DrawDebugNeighbors

#Overview

name: ai.crowd.DrawDebugNeighbors

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.DrawDebugNeighbors is to enable or disable the drawing of current neighbors data for crowd simulation in Unreal Engine 5. This setting is primarily used for debugging and visualization purposes within the AI module, specifically for crowd management.

This setting variable is primarily used by the AI module, particularly within the CrowdManager subsystem. It’s part of the crowd simulation functionality in Unreal Engine 5.

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 using console commands.

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

Developers should be aware that:

  1. This debug feature requires ai.crowd.DebugSelectedActors to be set for it to work properly.
  2. It’s primarily a debugging tool and should be disabled in release builds for performance reasons.
  3. The debug visualization is drawn in the world space, so it may affect rendering performance when enabled.

Best practices when using this variable include:

  1. Use it sparingly and only when debugging crowd behavior.
  2. Combine it with other debug variables like ai.crowd.DebugSelectedActors for more comprehensive debugging.
  3. Remember to disable it when not actively debugging to avoid performance impacts.
  4. Use it in conjunction with other crowd debugging tools for a complete understanding of the crowd simulation.

Regarding the associated variable DrawDebugNeighbors:

Developers should treat DrawDebugNeighbors as an internal implementation detail of the CrowdManager and interact with it through the ai.crowd.DrawDebugNeighbors console variable for consistency and proper integration with the engine’s debugging systems.

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

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:

	
	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);

	/** debug flags, don't depend on agent */
	int32 DrawDebugBoundaries = 0;
	FAutoConsoleVariableRef CVarDrawDebugBoundaries(TEXT("ai.crowd.DrawDebugBoundaries"), DrawDebugBoundaries,
		TEXT("Draw shared navmesh boundaries used by crowd simulation.\n0: Disable, 1: Enable"), ECVF_Default);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
class        class UCrowdManager : public UCrowdManagerBase

Source code excerpt:

	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:73

Scope (from outer to inner):

file
namespace    FCrowdDebug

Source code excerpt:

		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);

	/** debug flags, don't depend on agent */
	int32 DrawDebugBoundaries = 0;
	FAutoConsoleVariableRef CVarDrawDebugBoundaries(TEXT("ai.crowd.DrawDebugBoundaries"), DrawDebugBoundaries,
		TEXT("Draw shared navmesh boundaries used by crowd simulation.\n0: Disable, 1: Enable"), ECVF_Default);

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

Scope (from outer to inner):

file
function     void UCrowdManager::DrawDebugNeighbors

Source code excerpt:

}

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

	FVector Center = Recast2UnrealPoint(CrowdAgent->npos) + 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:1200

Scope (from outer to inner):

file
function     void UCrowdManager::DebugTick

Source code excerpt:

		}

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

	if (FCrowdDebug::DrawDebugBoundaries)
	{
		DrawDebugSharedBoundary();