UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ActorPartitionSubsystem.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7#include "Misc/HashBuilder.h"
8#include "Misc/Guid.h"
10#include "ActorPartitionSubsystem.generated.h"
11
13class UWorldPartition;
14
15#if WITH_EDITOR
16
17static inline constexpr auto DefaultPartitionActorCreated = [](APartitionActor*) {};
18
23{
25
26 /* Class of Actor we are getting from the subsystem. */
28
29 /* Tells Subsystem if it needs to create Actor if it doesn't exist. */
30 bool bCreate;
31
32 /* Depending on the world LocationHint can be used to find/create the Actor. */
34
35 /* Depending on the world LevelHint can be used to find/create the Actor. */
37
38 /* Guid can be used to distinguish between actors of the same type. */
40
41 /* If greater than 0, use this instead of the Actor CDO Grid size*/
42 int32 GridSize;
43
44 /* If true existing actors will be searched in the cell bounds only */
45 bool bBoundsSearch;
46
47 /* If set, a callback to use if an actor is created. */
49};
50
56{
58 : Class(InClass)
61 {}
62
63 bool operator == (const FActorPartitionIdentifier& Other) const { return Class == Other.Class && GridGuid == Other.GridGuid && ContextHash == Other.ContextHash; }
64
66 {
67 return GetTypeHash(Id.Class.Get()->GetName()) ^ GetTypeHash(Id.GridGuid) ^ GetTypeHash(Id.ContextHash);
68 }
69
70 const TSubclassOf<APartitionActor>& GetClass() const { return Class; }
71 const FGuid& GetGridGuid() const { return GridGuid; }
72 uint32 GetContextHash() const { return ContextHash; }
73 static const uint32 EmptyContextHash = 0;
74private:
78};
79
80#endif
81
86UCLASS(MinimalAPI)
88{
90
91public:
93
95 {
97 {}
98
100 : X(InX)
101 , Y(InY)
102 , Z(InZ)
103 , Level(InLevel)
104 {}
105
110
111 bool operator==(const FCellCoord& Other) const
112 {
113 return (X == Other.X) && (Y == Other.Y) && (Z == Other.Z) && (Level == Other.Level);
114 }
115
116 friend uint32 GetTypeHash(const FCellCoord& CellCoord)
117 {
118 FHashBuilder HashBuilder;
119 HashBuilder << CellCoord.X << CellCoord.Y << CellCoord.Z << PointerHash(CellCoord.Level);
120 return HashBuilder.GetHash();
121 }
122
124 {
125 return FCellCoord(
126 FMath::FloorToInt(InPos.X / InGridSize),
127 FMath::FloorToInt(InPos.Y / InGridSize),
128 FMath::FloorToInt(InPos.Z / InGridSize),
129 InLevel
130 );
131 }
132
134 {
135 const int64 GridSize = (int64)InGridSize;
136 const int64 CellCoordX = InPos.X < 0 ? (InPos.X - (GridSize - 1)) / GridSize : InPos.X / GridSize;
137 const int64 CellCoordY = InPos.Y < 0 ? (InPos.Y - (GridSize - 1)) / GridSize : InPos.Y / GridSize;
138
140 }
141
143 {
144 return FBox(
145 FVector(
146 static_cast<FVector::FReal>(InCellCoord.X * InGridSize),
147 static_cast<FVector::FReal>(InCellCoord.Y * InGridSize),
148 static_cast<FVector::FReal>(InCellCoord.Z * InGridSize)
149 ),
150 FVector(
154 )
155 );
156 }
157 };
158
159#if WITH_EDITOR
160 ENGINE_API APartitionActor* GetActor(const FActorPartitionGetParams& GetParam);
161
173
175 ENGINE_API virtual void Deinitialize() override;
176
178
184#endif
185 ENGINE_API bool IsLevelPartition() const;
186
187protected:
188 ENGINE_API virtual bool DoesSupportWorldType(const EWorldType::Type WorldType) const override;
189
190private:
191
192#if WITH_EDITOR
194
195 void OnActorPartitionHashInvalidated(const FCellCoord& Hash);
196 void OnWorldPartitionInitialized(UWorldPartition* InWorldPartition);
197
200
203
205#endif
206};
207
208#if WITH_EDITOR
213{
214public:
216 virtual ~FBaseActorPartition() {}
217
221
224protected:
225 UWorld* World;
226
228
229 friend class FActorPartitionGridHelper;
230};
231
232
234{
235public:
238};
239#endif
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
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_EVENT_OneParam(OwningType, EventName, Param1Type)
Definition DelegateCombinations.h:51
#define X(Name, Desc)
Definition FormatStringSan.h:47
#define FVector
Definition IOSSystemIncludes.h:8
UE::Math::TBox< double > FBox
Definition MathFwd.h:55
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
uint32 PointerHash(const void *Key)
Definition TypeHash.h:91
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition PartitionActor.h:17
Definition IDelegateInstance.h:14
Definition HashBuilder.h:18
UE_FORCEINLINE_HINT uint32 GetHash() const
Definition HashBuilder.h:87
Definition SubsystemCollection.h:15
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition SubclassOf.h:30
Definition UniquePtr.h:107
Definition ActorPartitionSubsystem.h:88
Definition Class.h:3793
Definition Level.h:423
Definition WorldPartition.h:142
Definition WorldSubsystem.h:16
Definition World.h:918
Chaos::FGeometryParticle * GetActor(const FActorShape &Hit)
Definition ChaosInterfaceWrapperCore.h:135
Type
Definition EngineTypes.h:1264
uint32 GetTypeHash(const FKey &Key)
Definition BlackboardKey.h:35
UClass * GetClass(UObject *Obj)
Definition ObjectFwd.cpp:8
Definition Guid.h:109
Definition ActorPartitionSubsystem.h:95
int64 Z
Definition ActorPartitionSubsystem.h:108
int64 X
Definition ActorPartitionSubsystem.h:106
static FBox GetCellBounds(const FCellCoord &InCellCoord, uint32 InGridSize)
Definition ActorPartitionSubsystem.h:142
static FCellCoord GetCellCoord(FVector InPos, ULevel *InLevel, uint32 InGridSize)
Definition ActorPartitionSubsystem.h:123
friend uint32 GetTypeHash(const FCellCoord &CellCoord)
Definition ActorPartitionSubsystem.h:116
ULevel * Level
Definition ActorPartitionSubsystem.h:109
FCellCoord(int64 InX, int64 InY, int64 InZ, ULevel *InLevel)
Definition ActorPartitionSubsystem.h:99
int64 Y
Definition ActorPartitionSubsystem.h:107
bool operator==(const FCellCoord &Other) const
Definition ActorPartitionSubsystem.h:111
static FCellCoord GetCellCoord(FIntPoint InPos, ULevel *InLevel, uint32 InGridSize)
Definition ActorPartitionSubsystem.h:133
FCellCoord()
Definition ActorPartitionSubsystem.h:96
Definition IntPoint.h:25
double FReal
Definition Vector.h:55