[Navmesh] Fix bShouldDiscardSubLevelNavData

Moving conditions allowing the property to take effect from ARecastNavMesh::PostInitProperties() to ARecastNavMesh::PostLoad() and delaying the check to discard navdata if there is no navigation system yet.
Removing previous ShouldDiscardSubLevelNavData() function that would fallback to read value from NavSysCDO when there is no navigation system.
#rb Yoan.StAmant, Maxime.Mercier
#jira UE-113463
[RN] fix Warning: UNavigationSystemV1 bShouldDiscardSubLevelNavData property was not working in some cases. With this fix navdata from sublevel will be properly discarted if the property is true (it's default value).
#preflight 62323fb4736af8e0822c951b

#ROBOMERGE-AUTHOR: aris.theophanidis
#ROBOMERGE-SOURCE: CL 19412570 via CL 19414029 via CL 19427618 via CL 19427717
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v930-19419903)

[CL 19429581 by aris theophanidis in ue5-main branch]
This commit is contained in:
aris theophanidis
2022-03-17 19:10:55 -04:00
parent ffea836292
commit 4eb193aafc
7 changed files with 65 additions and 46 deletions

View File

@@ -192,25 +192,6 @@ namespace FNavigationSystem
return false;
}
bool ShouldDiscardSubLevelNavData(ANavigationData& NavData)
{
const UWorld* World = NavData.GetWorld();
if (World && World->GetNavigationSystem())
{
const UNavigationSystemV1* NavSys = Cast<UNavigationSystemV1>(World->GetNavigationSystem());
if (NavSys)
{
return NavSys->ShouldDiscardSubLevelNavData(&NavData);
}
}
const UNavigationSystemV1* NavSysCDO = (*GEngine->NavigationSystemClass != nullptr)
? (GEngine->NavigationSystemClass->GetDefaultObject<const UNavigationSystemV1>())
: (const UNavigationSystemV1*)nullptr;
return NavSysCDO == nullptr || NavSysCDO->ShouldDiscardSubLevelNavData(&NavData);
}
void MakeAllComponentsNeverAffectNav(AActor& Actor)
{
const TSet<UActorComponent*> Components = Actor.GetComponents();
@@ -872,6 +853,8 @@ void UNavigationSystemV1::OnBeginTearingDown(UWorld* World)
void UNavigationSystemV1::OnWorldInitDone(FNavigationSystemRunMode Mode)
{
UNavigationSystemBase::OnNavigationInitStartStaticDelegate().Broadcast(*this);
OperationMode = Mode;
DoInitialSetup();
@@ -2252,6 +2235,8 @@ void UNavigationSystemV1::ProcessCustomLinkPendingRegistration()
UNavigationSystemV1::ERegistrationResult UNavigationSystemV1::RegisterNavData(ANavigationData* NavData)
{
UE_LOG(LogNavigation, Verbose, TEXT("%s %s"), ANSI_TO_TCHAR(__FUNCTION__), *GetFullNameSafe(NavData));
if (NavData == NULL)
{
return RegistrationError;
@@ -2371,6 +2356,8 @@ UNavigationSystemV1::ERegistrationResult UNavigationSystemV1::RegisterNavData(AN
void UNavigationSystemV1::UnregisterNavData(ANavigationData* NavData)
{
UE_LOG(LogNavigation, Verbose, TEXT("%s %s"), ANSI_TO_TCHAR(__FUNCTION__), *GetFullNameSafe(NavData));
NavDataSet.RemoveSingle(NavData);
if (NavData == NULL)