UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WorldPartitionHelpers.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
6#include "Engine/World.h"
7#include "Engine/Level.h"
9
10#if WITH_EDITOR
12#endif
13
14class UWorld;
15class UWorldPartition;
16
17#if WITH_EDITOR
20#endif
21
23{
25
26 template <class T>
27 inline UWorldPartition* GetWorldPartition(const T* InObject)
28 {
29 return IsValid(InObject) ? GetWorldPartitionFromObject(InObject) : nullptr;
30 }
31
32 template <>
34 {
35 if (IsValid(InLevel))
36 {
37 if (const IWorldPartitionCell* Cell = InLevel->GetWorldPartitionRuntimeCell())
38 {
39 return Cell->GetOuterWorld()->GetWorldPartition();
40 }
41 else if (const UWorld* OuterWorld = Cast<UWorld>(InLevel->GetOuter()))
42 {
43 return OuterWorld->GetWorldPartition();
44 }
45 }
46
47 return nullptr;
48 }
49
50 template <>
52 {
53 return IsValid(InWorld) ? GetWorldPartition<ULevel>(InWorld->PersistentLevel) : nullptr;
54 }
55
56 template <>
58 {
59 return IsValid(InActor) ? GetWorldPartition<ULevel>(InActor->GetLevel()) : nullptr;
60 }
61}
62
64{
65public:
67 template <class T>
68 static inline UWorldPartition* GetWorldPartition(const T* InObject)
69 {
71 }
72
74 static ENGINE_API void ServerExecConsoleCommand(UWorld* InWorld, const FString& InConsoleCommandName, const TArray<FString>& InArgs);
75
76#if WITH_EDITOR
77private:
79
80 template<class ActorClass>
81 struct TDeprecated
82 {
83 UE_DEPRECATED(5.4, "Use ForEachIntersectingActorDescInstance instead")
85
86 UE_DEPRECATED(5.4, "Use ForEachActorDescInstance instead")
88 };
89
90public:
91 template <class ActorClass = AActor>
93 {
94 TDeprecated<ActorClass>::DeprecatedForEachIntersectingActorDesc();
95 }
96
97 template<class ActorClass = AActor>
99 {
100 TDeprecated<ActorClass>::DeprecatedForEachActorDesc();
101 }
102
103 UE_DEPRECATED(5.4, "Use ForEachIntersectingActorDescInstance")
105 UE_DEPRECATED(5.4, "Use ForEachActorDescInstance")
107
108
109 template <class ActorClass = AActor>
111 {
112 ForEachIntersectingActorDescInstance(WorldPartition, Box, ActorClass::StaticClass(), Func);
113 }
114
115 template<class ActorClass = AActor>
117 {
118 ForEachActorDescInstance(WorldPartition, ActorClass::StaticClass(), Func);
119 }
120
123
124 /* Struct of optional parameters passed to foreach actordesc functions. */
126 {
128
129 /* Perform a garbage collection per-actor, useful to test if the caller properly handle GCs. */
130 bool bGCPerActor;
131
132 /* Prevent clearing of actor references. */
133 bool bKeepReferences;
134
135 /* The classes used to filter actors loading. */
136 TArray<TSubclassOf<AActor>> ActorClasses;
137
138 /* If not empty, iteration will be done only on those actors. */
140
141 /* Custom filter function used to filter actors loading. */
142 TUniqueFunction<bool(const FWorldPartitionActorDesc*)> FilterActorDesc;
143
144 /* Called right before releasing actor references and performing garbage collection. */
145 TUniqueFunction<void()> OnPreGarbageCollect;
146 };
147
148 /* Struct of optional output from foreach actordesc functions. */
150 {
151 /* Reference to all actors and actor references loaded by the foreach actordesc function */
153 };
154
155 UE_DEPRECATED(5.4, "Use ForEachActorWithLoading with FWorldPartitionActorDescInstance")
157
158 UE_DEPRECATED(5.4, "Use ForEachActorWithLoading with FWorldPartitionActorDescInstance")
160
163
164
165 static ENGINE_API bool HasExceededMaxMemory();
166 static ENGINE_API bool ShouldCollectGarbage();
167 static ENGINE_API void DoCollectGarbage();
168
169 // Simulate an engine frame tick
171
172 // Runtime/Editor conversions
174
175 UE_DEPRECATED(5.4, "Use UAssetRegistryHelpers::FixupRedirectedAssetPath instead.")
176 static ENGINE_API bool FixupRedirectedAssetPath(FName& InOutAssetPath);
177
178 UE_DEPRECATED(5.4, "Use UAssetRegistryHelpers::FixupRedirectedAssetPath instead.")
179 static ENGINE_API bool FixupRedirectedAssetPath(FSoftObjectPath& InOutSoftObjectPath);
180
181 // Returns all loaded actors for a specific level, including unregistered and garbage ones
183
184 // Returns all loaded and registered actors for a specific level
186#endif // WITH_EDITOR
187
188 // Editor/Runtime conversions
190};
191
192
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
Definition Actor.h:257
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition WorldPartitionActorDescInstance.h:18
Definition WorldPartitionActorDesc.h:282
Definition WorldPartitionHelpers.h:64
static UWorldPartition * GetWorldPartition(const T *InObject)
Definition WorldPartitionHelpers.h:68
static ENGINE_API void ServerExecConsoleCommand(UWorld *InWorld, const FString &InConsoleCommandName, const TArray< FString > &InArgs)
Definition WorldPartitionHelpers.cpp:53
static ENGINE_API bool ConvertEditorPathToRuntimePath(const FSoftObjectPath &InPath, FSoftObjectPath &OutPath)
Definition WorldPartitionHelpers.cpp:368
Definition WorldPartitionRuntimeCellInterface.h:19
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition SubclassOf.h:30
Definition FunctionFwd.h:19
Definition AssetRegistryHelpers.h:61
Definition Class.h:3793
Definition Level.h:423
Definition Object.h:95
Definition WorldPartition.h:142
Definition World.h:918
Definition WorldPartitionHelpers.cpp:26
UWorldPartition * GetWorldPartitionFromObject(const UObject *InObject)
Definition WorldPartitionHelpers.cpp:27
UWorldPartition * GetWorldPartition(const T *InObject)
Definition WorldPartitionHelpers.h:27
Definition WorldPartition.cpp:74
Definition Guid.h:109
Definition SoftObjectPath.h:56