ai.DestroyNavDataInCleanUpAndMarkPendingKill
ai.DestroyNavDataInCleanUpAndMarkPendingKill
#Overview
name: ai.DestroyNavDataInCleanUpAndMarkPendingKill
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If set to 1 NavData will be destroyed in CleanUpAndMarkPendingKill rather than being marked as garbage.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ai.DestroyNavDataInCleanUpAndMarkPendingKill is to control the behavior of NavData destruction in the Unreal Engine’s navigation system. Specifically, it determines whether NavData should be destroyed immediately or marked as garbage for later collection when the CleanUpAndMarkPendingKill function is called.
This setting variable is primarily used by the Navigation System module in Unreal Engine. It’s referenced in the NavigationData.cpp file, which is part of the runtime navigation system.
The value of this variable is set as a console variable (CVar) with a default value of 1. It can be changed at runtime through the console or programmatically.
The associated variable CVarDestroyNavDataInCleanUpAndMarkPendingKill directly interacts with ai.DestroyNavDataInCleanUpAndMarkPendingKill. They share the same value and purpose.
Developers must be aware that:
- When set to 1 (default), NavData will be immediately destroyed in CleanUpAndMarkPendingKill.
- When set to 0, NavData will be marked as garbage for later collection instead of immediate destruction.
- The behavior change affects memory management and potentially the performance of the navigation system.
Best practices when using this variable include:
- Consider the implications on memory management and performance before changing the default value.
- Test thoroughly if changing this value, as it may affect the behavior of the navigation system.
- Be consistent across your project if you decide to change this value.
Regarding the associated variable CVarDestroyNavDataInCleanUpAndMarkPendingKill:
This is the actual console variable that implements the behavior controlled by ai.DestroyNavDataInCleanUpAndMarkPendingKill. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime.
The variable is used in the CleanUpAndMarkPendingKill function of the ANavigationData class. When the value is 1 and the world is valid, it calls Destroy() on the NavData. Otherwise, it sets the actor to hidden in the game.
Developers should be aware that this variable’s value is checked on any thread (GetValueOnAnyThread()), which means it should be treated as potentially thread-unsafe. Care should be taken when modifying this value in a multi-threaded environment.
The best practice is to treat CVarDestroyNavDataInCleanUpAndMarkPendingKill as an implementation detail of the ai.DestroyNavDataInCleanUpAndMarkPendingKill setting, and interact with the latter when possible.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavigationData.cpp:22
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDestroyNavDataInCleanUpAndMarkPendingKill(
TEXT("ai.DestroyNavDataInCleanUpAndMarkPendingKill"),
1,
TEXT("If set to 1 NavData will be destroyed in CleanUpAndMarkPendingKill rather than being marked as garbage.\n"),
ECVF_Default);
//----------------------------------------------------------------------//
// FPathFindingQuery
#Associated Variable and Callsites
This variable is associated with another variable named CVarDestroyNavDataInCleanUpAndMarkPendingKill
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavigationData.cpp:21
Scope: file
Source code excerpt:
#define NAVDATAVER_LATEST 13
static TAutoConsoleVariable<int32> CVarDestroyNavDataInCleanUpAndMarkPendingKill(
TEXT("ai.DestroyNavDataInCleanUpAndMarkPendingKill"),
1,
TEXT("If set to 1 NavData will be destroyed in CleanUpAndMarkPendingKill rather than being marked as garbage.\n"),
ECVF_Default);
//----------------------------------------------------------------------//
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavigationData.cpp:506
Scope (from outer to inner):
file
function void ANavigationData::CleanUpAndMarkPendingKill
Source code excerpt:
/* Need to check if the world is valid since, when this is called from Serialize, the World won't be set and Destroy will do nothing,
* in which case it will crash when it tries to register with the NavSystem in UNavigationSystemV1::ProcessRegistrationCandidates. */
if (CVarDestroyNavDataInCleanUpAndMarkPendingKill.GetValueOnAnyThread() && IsValid(GetWorld()))
{
Destroy();
}
else
{
SetActorHiddenInGame(true);