UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WorldPartitionHandle.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
8
9#if WITH_EDITOR
14
15class AActor;
18
19template<class U>
21
22template<class U>
24
26{
27 friend struct FWorldPartitionReferenceImpl;
28
29public:
33 class IContext
34 {
36
37 public:
39 ENGINE_API virtual ~IContext();
40
41 private:
42 virtual void RegisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) = 0;
43 virtual void UnregisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) = 0;
44 };
45
49 class FImmediate : public IContext
50 {
51 private:
52 ENGINE_API virtual void RegisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) override;
53 ENGINE_API virtual void UnregisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) override;
54 };
55
61 class FDeferred : public IContext
62 {
63 public:
65
69
70 private:
71 ENGINE_API virtual void RegisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) override;
72 ENGINE_API virtual void UnregisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) override;
73
75 {
78 };
79
81
84 bool bNeedsClearTransactions = false;
85 };
86
90 class FNull : public IContext
91 {
92 private:
93 virtual void RegisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) override {}
94 virtual void UnregisterActor(FWorldPartitionActorDescInstance* InActorDescInstance) override {}
95 };
96
97 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance version instead")
99 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance version instead")
101
102private:
105
107 static IContext* ActiveContext;
108};
109
110template <typename Impl>
112{
113public:
114 inline TWorldPartitionHandle()
115 : ContainerInstance(nullptr)
116 , ActorDescInstance(nullptr)
117 {}
118
122 {
123 if (IsValid())
124 {
125 IncRefCount();
126 }
127 }
128
131 , ActorDescInstance(nullptr)
132 {
133 if (ContainerInstance != nullptr)
134 {
135 ActorDescInstance = Impl::GetActorDescInstance(ContainerInstance.Get(), Impl::GetActorDescInstanceGuid(InActorDescInstance));
136 }
137
138 if (IsValid())
139 {
140 IncRefCount();
141 }
142 }
143
147 {
148 if (IsValid())
149 {
150 IncRefCount();
151 }
152 }
153
154 template<class U>
157 , ActorDescInstance(nullptr)
158 {
159 if (ContainerInstance != nullptr)
160 {
161 ActorDescInstance = Impl::GetActorDescInstance(ContainerInstance.Get(), ActorGuid);
162 }
163
164 if (IsValid())
165 {
166 IncRefCount();
167 }
168 }
169
170 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance version")
172 : ContainerInstance(nullptr)
173 , ActorDescInstance(nullptr)
174 {
175 }
176
177 UE_DEPRECATED(5.4, "Use FActorDescContainerInstance version")
179 : ContainerInstance(nullptr)
180 , ActorDescInstance(nullptr)
181 {
182 }
183
184 template<class U>
186 {
187 UE_DEPRECATED(5.4, "Use TActorDescContainerInstanceCollection version")
188 static void Deprecated() {}
189 };
190
191 template<class U>
193 : ContainerInstance(nullptr)
194 , ActorDescInstance(nullptr)
195 {
196 TActorDescContainerCollectionDeprecated<U>::Deprecated();
197 }
198
200 : ContainerInstance(nullptr)
201 , ActorDescInstance(nullptr)
202 {
203 *this = Other;
204 }
205
207 : ContainerInstance(nullptr)
208 , ActorDescInstance(nullptr)
209 {
210 *this = MoveTemp(Other);
211 }
212
214 {
215 return Impl::ToHandle(*this);
216 }
217
219 {
220 return Impl::ToReference(*this);
221 }
222
223 template <typename T>
225 : ActorDescInstance(nullptr)
226 {
227 *this = MoveTemp(Other);
228 }
229
231 {
232 if (IsValid())
233 {
234 DecRefCount();
235 }
236 }
237
238 inline TWorldPartitionHandle& operator=(const TWorldPartitionHandle& Other)
239 {
240 if (this != &Other)
241 {
242 if (IsValid())
243 {
244 DecRefCount();
245 }
246
247 ContainerInstance = Other.ContainerInstance;
248 ActorDescInstance = Other.ActorDescInstance;
249
250 if (IsValid())
251 {
252 IncRefCount();
253 }
254 }
255
256 return *this;
257 }
258
260 {
261 if (this != &Other)
262 {
263 if (IsValid())
264 {
265 DecRefCount();
266 }
267
268 ContainerInstance = Other.ContainerInstance;
269 ActorDescInstance = Other.ActorDescInstance;
270
271 Other.ContainerInstance = nullptr;
272 Other.ActorDescInstance = nullptr;
273 }
274
275 return *this;
276 }
277
278 // Conversions
279 template <typename T>
281 {
282 if (IsValid())
283 {
284 DecRefCount();
285 }
286
287 ContainerInstance = Other.ContainerInstance;
288 ActorDescInstance = Other.ActorDescInstance;
289
290 if (IsValid())
291 {
292 IncRefCount();
293 }
294
295 return *this;
296 }
297
298 template <typename T>
300 {
301 if (IsValid())
302 {
303 DecRefCount();
304 }
305
306 ContainerInstance = Other.ContainerInstance;
307 ActorDescInstance = Other.ActorDescInstance;
308
309 if (IsValid())
310 {
311 IncRefCount();
312 Other.DecRefCount();
313
314 Other.ContainerInstance = nullptr;
315 Other.ActorDescInstance = nullptr;
316 }
317
318 return *this;
319 }
320
321 inline FWorldPartitionActorDescInstance* operator->() const
322 {
323 return GetInstance();
324 }
325
327 {
328 return GetInstance();
329 }
330
331 inline FWorldPartitionActorDescInstance* GetInstance() const
332 {
333 return IsValid() ? ActorDescInstance->Get() : nullptr;
334 }
335
336 inline bool IsValid() const
337 {
338 return ContainerInstance.IsValid() && ActorDescInstance && ActorDescInstance->IsValid();
339 }
340
341 inline bool IsLoaded() const
342 {
343 return IsValid() && Impl::IsLoaded(ActorDescInstance->Get());
344 }
345
346 inline AActor* GetActor() const
347 {
348 return IsValid() ? Impl::GetActor(ActorDescInstance->Get()) : nullptr;
349 }
350
351 UE_DEPRECATED(5.4, "Use GetInstance instead")
353 {
354 if (ContainerInstance.IsValid() && ActorDescInstance && ActorDescInstance->IsValid())
355 {
356 return Impl::GetActorDesc(ActorDescInstance->Get());
357 }
358
359 return nullptr;
360 }
361
362 inline void Reset()
363 {
364 if (IsValid())
365 {
366 DecRefCount();
367 }
368
369 ContainerInstance = nullptr;
370 ActorDescInstance = nullptr;
371 }
372
374 {
375 return ::PointerHash(HandleBase.ActorDescInstance);
376 }
377
378 inline bool operator==(const TWorldPartitionHandle& Other) const
379 {
380 return ActorDescInstance == Other.ActorDescInstance;
381 }
382
383 inline bool operator!=(const TWorldPartitionHandle& Other) const
384 {
385 return !(*this == Other);
386 }
387
388 // Conversions
389 template <typename T>
390 inline bool operator==(const TWorldPartitionHandle<T>& Other) const
391 {
392 return GetInstance() == Other.GetInstance();
393 }
394
395 template <typename T>
396 inline bool operator!=(const TWorldPartitionHandle<T>& Other) const
397 {
398 return !(*this == Other);
399 }
400
401public:
402 inline void IncRefCount()
403 {
404 Impl::IncRefCount(ActorDescInstance->Get());
405 }
406
407 inline void DecRefCount()
408 {
409 Impl::DecRefCount(ActorDescInstance->Get());
410 }
411
414};
415
417{
418 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
420 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
421 static UActorDescContainer* GetActorDescContainer(TUniquePtr<FWorldPartitionActorDesc>* ActorDesc) { return nullptr; }
422 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
424 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
426
427 template<class U>
428 static UActorDescContainer* GetActorDescContainer(TActorDescContainerCollection<U>* ContainerCollection, const FGuid& ActorGuid)
429 {
430 return nullptr;
431 }
432
439
441
442 template<class U>
444 {
445 return ContainerCollection ? ContainerCollection->GetActorDescContainerInstance(ActorGuid) : nullptr;
446 }
447};
448
450{
451 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
453 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
455
458
460};
461
463{
464 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
466 UE_DEPRECATED(5.4, "Use FWorldPartitionActorDescInstance")
468
471
473};
474
481
487
494{
496 {
497 if (InHandle.IsLoaded())
498 {
500 }
501 }
502
504 {
506 }
507
508private:
510};
511#endif
UE_FORCEINLINE_HINT FLinearColor operator*(float Scalar, const FLinearColor &Color)
Definition Color.h:473
#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
UE_FORCEINLINE_HINT bool operator!=(const FIndexedPointer &Other) const
Definition LockFreeList.h:76
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition Union.h:29
Definition WorldPartitionActorDescInstance.h:18
Definition WorldPartitionActorDesc.h:282
Definition ActorDescContainerCollection.h:14
Definition ActorDescContainerInstanceCollection.h:15
Definition UnrealString.h.inl:34
Definition UniquePtr.h:107
Definition ActorDescContainerInstance.h:23
Definition ActorDescContainer.h:40
Chaos::FGeometryParticle * GetActor(const FActorShape &Hit)
Definition ChaosInterfaceWrapperCore.h:135
uint32 GetTypeHash(const FKey &Key)
Definition BlackboardKey.h:35
Definition ExpressionParserTypes.h:21
bool operator==(const FCachedAssetKey &A, const FCachedAssetKey &B)
Definition AssetDataMap.h:501
RefType ToReference(FMutableReference In)
@ Reference
Definition Protocol6.h:40
Definition Guid.h:109
Definition WeakObjectPtrTemplates.h:25