UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NavigationOctree.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
6#include "CoreMinimal.h"
7#endif
8
9#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_5
10#include "Stats/Stats.h"
14#endif // UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_5
15
18#include "EngineStats.h"
21#include "Math/GenericOctree.h"
23
26class UActorComponent;
27enum class ENavDataGatheringMode : uint8;
30
31LLM_DECLARE_TAG(NavigationOctree);
32
34{
37
38#if WITH_EDITORONLY_DATA
39 UE_DEPRECATED(5.5, "ID no longer used.")
41#endif // WITH_EDITORONLY_DATA
42
43 UE_DEPRECATED(5.5, "Use the constructor taking a FNavigationElement instead.")
44 explicit FNavigationOctreeElement(UObject& SourceObject)
46#if WITH_EDITORONLY_DATA
47 , OwnerUniqueId(SourceObject.GetUniqueID())
48#endif // WITH_EDITORONLY_DATA
49 {
50 }
51
53 : Bounds(SourceObject.Get().GetBounds())
55 {
56 }
57
62
68
78
80 {
81 if (this != &Other)
82 {
85 }
86 return *this;
87 }
88
89 FORCEINLINE bool IsEmpty() const
90 {
91 const FBox BBox = Bounds.GetBox();
92 return Data->IsEmpty() && (BBox.IsValid == 0 || BBox.GetSize().IsNearlyZero());
93 }
94
99
109
114
116 {
117 return (int32)Data->GetAllocatedSize();
118 }
119
121 {
122 Data->Shrink();
123 }
124
129
130 UE_DEPRECATED(5.5, "Use GetSourceElement instead.")
132 {
133 return const_cast<UObject*>(Data.Get().SourceElement.Get().GetWeakUObject().Get());
134 }
135
140};
141
143{
145 enum { MaxElementsPerLeaf = 16 };
147 enum { MaxNodeDepth = 12 };
148
150
152 {
153 return NavData.Bounds;
154 }
155
157 {
158 return A.Data.Get().SourceElement.Get().GetHandle() == B.Data.Get().SourceElement.Get().GetHandle();
159 }
160
161 FORCEINLINE static void ApplyOffset(FNavigationOctreeElement& Element, const FVector& InOffset)
162 {
163 ensureMsgf(false, TEXT("Not implemented yet"));
164 }
165
166#if NAVSYS_DEBUG
168#endif // NAVSYS_DEBUG
170};
171
172class FNavigationOctree : public TOctree2<FNavigationOctreeElement, FNavigationOctreeSemantics>, public TSharedFromThis<FNavigationOctree, ESPMode::ThreadSafe>
173{
174public:
175 UE_DEPRECATED(5.5, "Use FGeometryExportDelegate.")
180
183
188
204
218
221
224 UE_DEPRECATED(5.5, "Use the overloaded version with only FBox and FNavigationOctreeElement instead.")
226
228 NAVIGATIONSYSTEM_API void AppendToNode(const FOctreeElementId2& Id, const TSharedRef<const FNavigationElement>& ElementRef, const FBox& Bounds, FNavigationOctreeElement& Data);
229 UE_DEPRECATED(5.5, "Use the overloaded version with FNavigationElement instead.")
231
234
237
239
241
243
248
250
251 // Lazy data gathering methods
252 NAVIGATIONSYSTEM_API bool IsLazyGathering(const FNavigationElement& NavigationElement) const;
253 UE_DEPRECATED(5.5, "Use the overloaded version with FNavigationElement instead.")
255
257
259 UE_DEPRECATED(5.5, "Use the overloaded version with FNavigationElement instead.")
261
262 UE_DEPRECATED(5.5, "This method is no longer used by the navigation system.")
264 {
265 return Object.GetUniqueID();
266 }
267
268#if !UE_BUILD_SHIPPING
270#endif // !UE_BUILD_SHIPPING
271protected:
274
275 UE_DEPRECATED(5.5, "Use the version taking a FNavigationElementHandle instead.")
278
279#if WITH_EDITORONLY_DATA
280 UE_DEPRECATED(5.5, "Use ElementToOctreeId instead.")
282#endif // WITH_EDITORONLY_DATA
287#if !UE_BUILD_SHIPPING
289#endif // !UE_BUILD_SHIPPING
290private:
291 SIZE_T OctreeSizeBytes = 0;
292};
#define FORCENOINLINE
Definition AndroidPlatform.h:142
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define INC_MEMORY_STAT_BY(StatId, Amount)
Definition Stats.h:700
#define DEC_MEMORY_STAT_BY(StatId, Amount)
Definition Stats.h:705
TSharedRef< InObjectType, InMode > MakeShared(InArgTypes &&... Args)
Definition SharedPointer.h:2009
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:57
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define LLM_SCOPE_BYTAG(...)
Definition LowLevelMemTracker.h:1099
#define LLM_DECLARE_TAG(...)
Definition LowLevelMemTracker.h:1116
ENavDataGatheringMode
Definition NavDataGatheringMode.h:9
FNavigationRelevantDataFilter FNavigationOctreeFilter
Definition NavigationOctree.h:29
ENavDataGatheringModeConfig
Definition NavigationTypes.h:80
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NavigationOctree.h:173
uint32 bGatherGeometry
Definition NavigationOctree.h:285
NAVIGATIONSYSTEM_API void SetElementIdImpl(const uint32 OwnerUniqueId, FOctreeElementId2 Id)
virtual NAVIGATIONSYSTEM_API ~FNavigationOctree()
Definition NavigationOctree.cpp:45
FGeometryExportDelegate GeometryExportDelegate
Definition NavigationOctree.h:182
NAVIGATIONSYSTEM_API FNavigationRelevantData * GetMutableDataForID(const FOctreeElementId2 &Id)
Definition NavigationOctree.cpp:348
TMap< FNavigationElementHandle, FOctreeElementId2 > ElementToOctreeId
Definition NavigationOctree.h:283
ENavDataGatheringMode DefaultGeometryGatheringMode
Definition NavigationOctree.h:284
NAVIGATIONSYSTEM_API void SetDataGatheringMode(ENavDataGatheringModeConfig Mode)
Definition NavigationOctree.cpp:54
NAVIGATIONSYSTEM_API bool IsLazyGathering(const FNavigationElement &NavigationElement) const
Definition NavigationOctree.cpp:159
NAVIGATIONSYSTEM_API void AppendToNode(const FOctreeElementId2 &Id, const TSharedRef< const FNavigationElement > &ElementRef, const FBox &Bounds, FNavigationOctreeElement &Data)
Definition NavigationOctree.cpp:290
NAVIGATIONSYSTEM_API void UpdateNode(const FOctreeElementId2 &Id, const FBox &NewBounds)
Definition NavigationOctree.cpp:325
ENavGeometryStoringMode GetNavGeometryStoringMode() const
Definition NavigationOctree.h:244
NAVIGATIONSYSTEM_API void SetNavigableGeometryStoringMode(ENavGeometryStoringMode NavGeometryMode)
Definition NavigationOctree.cpp:60
void AddElement(const FNavigationOctreeElement &Element)
Definition NavigationOctree.h:193
static FORCEINLINE uint32 HashObject(const UObject &Object)
Definition NavigationOctree.h:263
NAVIGATIONSYSTEM_API void DemandLazyDataGathering(FNavigationRelevantData &ElementData)
Definition NavigationOctree.cpp:65
NAVIGATIONSYSTEM_API void AddNode(const FBox &Bounds, FNavigationOctreeElement &OctreeElement)
Definition NavigationOctree.cpp:177
uint32 NodesMemory
Definition NavigationOctree.h:286
NAVIGATIONSYSTEM_API void DemandChildLazyDataGathering(FNavigationRelevantData &ElementData, const FNavigationElement &ChildElement) const
Definition NavigationOctree.cpp:132
NAVIGATIONSYSTEM_API const FNavigationRelevantData * GetDataForID(const FOctreeElementId2 &Id) const
Definition NavigationOctree.cpp:343
NAVIGATIONSYSTEM_API void SetGatheringNavModifiersTimeLimitWarning(const float Threshold)
Definition NavigationOctree.cpp:146
void RemoveElement(FOctreeElementId2 ElementId)
Definition NavigationOctree.h:209
ENavGeometryStoringMode
Definition NavigationOctree.h:184
@ SkipNavGeometry
Definition NavigationOctree.h:185
@ StoreNavGeometry
Definition NavigationOctree.h:186
PRAGMA_DISABLE_DEPRECATION_WARNINGS FNavRelevantGeometryExportDelegate NavRelevantGeometryExportDelegate
Definition NavigationOctree.h:178
float GatheringNavModifiersTimeLimitWarning
Definition NavigationOctree.h:288
NAVIGATIONSYSTEM_API void RemoveNode(const FOctreeElementId2 &Id)
Definition NavigationOctree.cpp:333
Definition UnrealType.h:3087
Definition GenericOctreePublic.h:15
Definition NavRelevantInterface.h:49
Definition UnrealString.h.inl:34
Definition GenericOctree.h:378
void AddElement(typename TCallTraits< ElementType >::ConstReference Element)
Definition GenericOctree.h:821
void RemoveElement(FOctreeElementId2 ElementId)
Definition GenericOctree.h:832
SIZE_T GetSizeBytes() const
Definition GenericOctree.h:974
Definition SharedPointer.h:1640
Definition SharedPointer.h:153
ObjectType & Get() const
Definition SharedPointer.h:474
Definition ContainerAllocationPolicies.h:894
Definition ActorComponent.h:152
Definition Object.h:95
@ false
Definition radaudio_common.h:23
Definition NavigationModifier.h:279
Definition NavigationTypes.h:453
Definition NavigationTypes.h:525
Definition NavigationElement.h:36
Definition NavigationElement.h:94
TWeakObjectPtr< const UObject > GetWeakUObject() const
Definition NavigationElement.h:382
Definition NavigationOctreeController.h:27
Definition NavigationOctree.h:34
FBoxSphereBounds Bounds
Definition NavigationOctree.h:35
TSharedRef< FNavigationRelevantData, ESPMode::ThreadSafe > Data
Definition NavigationOctree.h:36
FORCEINLINE bool ShouldUseGeometry(const FNavDataConfig &NavConfig) const
Definition NavigationOctree.h:110
FORCEINLINE void ValidateAndShrink()
Definition NavigationOctree.h:125
FORCEINLINE int32 GetAllocatedSize() const
Definition NavigationOctree.h:115
FORCEINLINE FCompositeNavModifier GetModifierForAgent(const FNavAgentProperties *NavAgent=nullptr) const
Definition NavigationOctree.h:105
FORCEINLINE bool IsEmpty() const
Definition NavigationOctree.h:89
FNavigationOctreeElement & operator=(const FNavigationOctreeElement &Other)
Definition NavigationOctree.h:79
FORCEINLINE bool IsMatchingFilter(const FNavigationOctreeFilter &Filter) const
Definition NavigationOctree.h:95
FNavigationOctreeElement(const TSharedRef< const FNavigationElement > &SourceObject)
Definition NavigationOctree.h:52
FNavigationOctreeElement(FNavigationOctreeElement &&Other) noexcept
Definition NavigationOctree.h:63
FORCEINLINE UObject * GetOwner(bool bEvenIfPendingKill=false) const
Definition NavigationOctree.h:131
FNavigationOctreeElement & operator=(FNavigationOctreeElement &&Other)
Definition NavigationOctree.h:69
FNavigationOctreeElement(const FNavigationOctreeElement &Other)
Definition NavigationOctree.h:58
FORCEINLINE void Shrink()
Definition NavigationOctree.h:120
const TSharedRef< const FNavigationElement > & GetSourceElement() const
Definition NavigationOctree.h:136
Definition NavigationOctree.h:143
@ MaxElementsPerLeaf
Definition NavigationOctree.h:145
static FORCEINLINE const FBoxSphereBounds & GetBoundingBox(const FNavigationOctreeElement &NavData)
Definition NavigationOctree.h:151
@ MaxNodeDepth
Definition NavigationOctree.h:147
TOctree2< FNavigationOctreeElement, FNavigationOctreeSemantics > FOctree
Definition NavigationOctree.h:144
static FORCEINLINE void ApplyOffset(FNavigationOctreeElement &Element, const FVector &InOffset)
Definition NavigationOctree.h:161
@ MinInclusiveElementsPerNode
Definition NavigationOctree.h:146
static void SetElementId(FOctree &OctreeOwner, const FNavigationOctreeElement &Element, FOctreeElementId2 Id)
Definition NavigationOctree.cpp:364
static FORCEINLINE bool AreElementsEqual(const FNavigationOctreeElement &A, const FNavigationOctreeElement &B)
Definition NavigationOctree.h:156
TInlineAllocator< MaxElementsPerLeaf > ElementAllocator
Definition NavigationOctree.h:149
Definition NavigationRelevantData.h:16
Definition NavigationRelevantData.h:40
bool IsEmpty() const
Definition NavigationRelevantData.h:132
ENGINE_API bool IsMatchingFilter(const FNavigationRelevantDataFilter &Filter) const
Definition NavigationTypes.cpp:245
SIZE_T GetAllocatedSize() const
Definition NavigationRelevantData.h:133
TSharedRef< const FNavigationElement > SourceElement
Definition NavigationRelevantData.h:79
ENGINE_API void Shrink()
Definition NavigationTypes.cpp:257
void ValidateAndShrink()
Definition NavigationRelevantData.h:159
ENGINE_API FCompositeNavModifier GetModifierForAgent(const FNavAgentProperties *NavAgent=nullptr) const
Definition NavigationTypes.cpp:235
FFilterNavDataDelegate ShouldUseGeometryDelegate
Definition NavigationRelevantData.h:67
FORCEINLINE T * Get(bool bEvenIfPendingKill) const
Definition WeakObjectPtrTemplates.h:132
Definition BoxSphereBounds.h:25
UE_FORCEINLINE_HINT TBox< T > GetBox() const
Definition BoxSphereBounds.h:226
double FReal
Definition Vector.h:55