UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
HLODRuntimeSubsystem.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
5#include "Containers/Array.h"
6#include "Containers/Map.h"
7#include "UObject/ObjectKey.h"
8#include "Containers/Ticker.h"
10#include "HLODRuntimeSubsystem.generated.h"
11
16class UWorldPartition;
19class UWorld;
20
24
25UE_DEPRECATED(5.6, "Use FWorldPartitionHLODObjectRegisteredEvent instead")
29
33UCLASS(MinimalAPI)
35{
37
38public:
40
41 //~ Begin USubsystem Interface.
43 ENGINE_API virtual void Deinitialize() override;
44 //~ End USubsystem Interface.
45
46 //~ Begin UWorldSubsystem Interface.
47 ENGINE_API virtual bool DoesSupportWorldType(const EWorldType::Type WorldType) const override;
48 //~ End UWorldSubsystem Interface.
49
52
53 ENGINE_API void OnCellShown(const UWorldPartitionRuntimeCell* InCell);
54 ENGINE_API void OnCellHidden(const UWorldPartitionRuntimeCell* InCell);
55
56 ENGINE_API bool CanMakeVisible(const UWorldPartitionRuntimeCell* InCell);
57 ENGINE_API bool CanMakeInvisible(const UWorldPartitionRuntimeCell* InCell);
58
59 ENGINE_API FWorldPartitionHLODForEachHLODObjectInCellEvent& GetForEachHLODObjectInCellEvent();
60
61 static ENGINE_API bool IsHLODEnabled();
62
63 ENGINE_API const TArray<IWorldPartitionHLODObject*>& GetHLODObjectsForCell(const UWorldPartitionRuntimeCell* InCell) const;
66
67 ENGINE_API void OnExternalStreamingObjectInjected(URuntimeHashExternalStreamingObjectBase* ExternalStreamingObject);
68 ENGINE_API void OnExternalStreamingObjectRemoved(URuntimeHashExternalStreamingObjectBase* ExternalStreamingObject);
69
70 ENGINE_API void OnCVarsChanged();
71
72#if !UE_BUILD_SHIPPING
73 uint32 GetNumOutdatedHLODObjects() const { return OutdatedHLODObjects.Num(); }
74#endif
75
76 UE_DEPRECATED(5.6, "Use RegisterHLODObject instead")
78 UE_DEPRECATED(5.6, "Use UnregisterHLODObject instead")
80
81 UE_DEPRECATED(5.6, "Use GetHLODObjectsForCell instead")
82 const TArray<AWorldPartitionHLOD*>& GetHLODActorsForCell(const UWorldPartitionRuntimeCell* InCell) const
83 {
85 return Empty;
86 }
87
88#if !UE_BUILD_SHIPPING
89 UE_DEPRECATED(5.6, "Use GetNumOutdatedHLODObjects instead")
90 uint32 GetNumOutdatedHLODActors() const { return 0; }
91#endif
92
94 UE_DEPRECATED(5.6, "Use OnHLODObjectRegisteredEvent instead")
95 FWorldPartitionHLODActorRegisteredEvent& OnHLODActorRegisteredEvent() { return HLODActorRegisteredEvent; }
96 UE_DEPRECATED(5.6, "Use OnHLODObjectUnregisteredEvent instead")
97 FWorldPartitionHLODActorUnregisteredEvent& OnHLODActorUnregisteredEvent() { return HLODActorUnregisteredEvent; }
99
100#if WITH_EDITOR
101 UE_DEPRECATED(5.5, "Use UWorldPartitionHLODEditorSubsystem::WriteHLODStatsCSV()")
102 static bool WriteHLODStatsCSV(UWorld* InWorld, const FString& InFilename) { return false; }
103#endif
104
105 UE_DEPRECATED(5.4, "You should perform this logic on the game side.")
106 void SetHLODAlwaysLoadedCullDistance(int32 InCullDistance) {}
107
108private:
109 void ForEachHLODObjectInCell(const UWorldPartitionRuntimeCell* InCell, TFunction<void(IWorldPartitionHLODObject*)> InFunc);
110 FWorldPartitionHLODForEachHLODObjectInCellEvent ForEachHLODObjectInCellEvent;
111
112 struct FCellData
113 {
114 bool bIsCellVisible = false;
115 TArray<IWorldPartitionHLODObject*> LoadedHLODs; // HLOD representation of the cell itself
116 };
117
118 struct FWorldPartitionHLODRuntimeData
119 {
120 TMap<FGuid, FCellData> CellsData;
121 };
122
123 TMap<TObjectPtr<UWorldPartition>, FWorldPartitionHLODRuntimeData> WorldPartitionsHLODRuntimeData;
124 ENGINE_API const FCellData* GetCellData(const UWorldPartitionRuntimeCell* InCell) const;
125 ENGINE_API FCellData* GetCellData(const UWorldPartitionRuntimeCell* InCell);
127 ENGINE_API FCellData* GetCellData(const UWorldPartition* InWorldPartition, const FGuid& InCellGuid);
128
129 // Keep track of the state of warmup for an HLOD object
130 struct FWorldPartitionHLODWarmupState
131 {
132 uint32 WarmupLastRequestedFrame = INDEX_NONE;
133 uint32 WarmupCallsUntilReady = INDEX_NONE;
134 FBox WarmupBounds;
135 };
137 FHLODWarmupStateMap HLODObjectsToWarmup;
138
139 // Keep track of all HLOD objects currently warming up for a given level
140 // If there are any, the OnCleanupLevelDelegateHandle member should be bound
141 struct FHLODLevelState
142 {
143 TSet<IWorldPartitionHLODObject*> HLODObjectsWarmingUp;
144 FDelegateHandle OnCleanupLevelDelegateHandle;
145 };
146 typedef TMap<ULevel*, FHLODLevelState> FHLODLevelStateMap;
147 FHLODLevelStateMap HLODLevelWarmupStates;
148
149 FWorldPartitionHLODWarmupState& AddHLODObjectToWarmup(IWorldPartitionHLODObject* InHLODObject);
150 void RemoveHLODObjectFromWarmup(IWorldPartitionHLODObject* InHLODObject);
151 void OnCleanupLevel(ULevel* InCell);
152
153 ENGINE_API void OnBeginRenderViews(const FSceneViewFamily& InViewFamily);
155 ENGINE_API bool ShouldPerformWarmup() const;
156 ENGINE_API bool ShouldPerformWarmupForCell(const UWorldPartitionRuntimeCell* InCell) const;
157 bool bCachedShouldPerformWarmup;
158
160 static ENGINE_API class FAutoConsoleCommand EnableHLODCommand;
161
162 static ENGINE_API bool WorldPartitionHLODEnabled;
163
166
167 ENGINE_API void OnWorldPartitionInitialized(UWorldPartition* InWorldPartition);
168 ENGINE_API void OnWorldPartitionUninitialized(UWorldPartition* InWorldPartition);
169
170 FWorldPartitionHLODObjectRegisteredEvent HLODObjectRegisteredEvent;
171 FWorldPartitionHLODObjectUnregisteredEvent HLODObjectUnregisteredEvent;
172
174 FWorldPartitionHLODActorRegisteredEvent HLODActorRegisteredEvent;
175 FWorldPartitionHLODActorUnregisteredEvent HLODActorUnregisteredEvent;
177
178 // Referenced Cell GUID -> HLOD Actor
179 TMap<FGuid, TSet<IWorldPartitionHLODObject*>> StandaloneHLODObjectsReferencingUnloadedCells;
180
181 // Cell GUID -> WorldPartition
182 TMap<FGuid, TObjectPtr<UWorldPartition>> StandaloneHLODCellToWorldPartitionMap;
183
184#if !UE_BUILD_SHIPPING
185 TSet<IWorldPartitionHLODObject*> OutdatedHLODObjects;
186#endif
187};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:58
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition HLODActor.h:67
Definition IConsoleManager.h:2026
Definition IDelegateInstance.h:14
Definition HLODRuntimeSubsystem.cpp:110
Definition UnrealType.h:3087
Definition SceneView.h:2212
Definition SubsystemCollection.h:15
Definition IWorldPartitionHLODObject.h:13
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition Level.h:423
Definition WorldPartitionRuntimeHash.h:61
Definition HLODRuntimeSubsystem.h:35
FWorldPartitionHLODObjectRegisteredEvent & OnHLODObjectRegisteredEvent()
Definition HLODRuntimeSubsystem.h:64
uint32 GetNumOutdatedHLODObjects() const
Definition HLODRuntimeSubsystem.h:73
FWorldPartitionHLODObjectUnregisteredEvent & OnHLODObjectUnregisteredEvent()
Definition HLODRuntimeSubsystem.h:65
Definition WorldPartitionRuntimeCell.h:236
Definition WorldPartition.h:142
Definition WorldSubsystem.h:16
Definition World.h:918
TEnumAsByte< EWorldType::Type > WorldType
Definition World.h:1231
Type
Definition EngineTypes.h:1264
Definition Guid.h:109