UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GeometryCollectionISMPoolComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Containers/Map.h"
9#include "InstanceDataTypes.h"
10
11#include "GeometryCollectionISMPoolComponent.generated.h"
12
13class AActor;
14class UE_DEPRECATED(5.6, "UGeometryCollectionISMPoolComponent is deprecated, please use UISMPoolComponent instead.") UGeometryCollectionISMPoolComponent;
16
23{
25
38
40 void Reset()
41 {
44 GroupRanges.Empty();
46 }
47
49 bool IsEmpty() const
50 {
51 return GroupRanges.Num() == FreeList.Num();
52 }
53
56 {
57 return TotalInstanceCount;
58 }
59
62 {
63 // First check to see if we can recycle a group from the free list.
64 for (int32 Index = 0; Index < FreeList.Num(); ++Index)
65 {
66 const FInstanceGroupId GroupId = FreeList[Index];
67 // todo: Could also allow allocating a subrange if Count is less than the group range count.
68 if (Count == GroupRanges[GroupId].Count)
69 {
72 return GroupId;
73 }
74 }
75
76 // Create a new group.
77 const int32 StartIndex = TotalInstanceCount;
79 const FInstanceGroupId GroupId = GroupRanges.Add(FInstanceGroupRange(StartIndex, Count));
80 return GroupId;
81 }
82
85 {
86 // Remove the group by putting on free list for reuse.
87 // Actually removing it would require too much shuffling of the render instance index remapping.
88 TotalFreeInstanceCount += GroupRanges[GroupId].Count;
89 FreeList.Add(GroupId);
90 }
91
96};
97
102{
104 {
105 UseHISM = 1 << 1, // HISM is no longer supported. This flag is ignored.
111 AffectShadow = 1 << 7,
116 };
117
124 uint32 GroupHash = 0; // Optional, allows identical SMs to be separated into different groups for finer grained culling
125 float LodScale = 1.f;
128
130 {
131 return Flags == Other.Flags &&
132 NumCustomDataFloats == Other.NumCustomDataFloats &&
133 Position == Other.Position &&
134 StartCullDistance == Other.StartCullDistance &&
135 EndCullDistance == Other.EndCullDistance &&
136 MinLod == Other.MinLod &&
137 LodScale == Other.LodScale &&
138 Tags == Other.Tags &&
139 GroupHash == Other.GroupHash &&
140 StatsCategory == Other.StatsCategory;
141 }
142};
143
156
162{
167
169 {
170 if (!(Desc == Other.Desc))
171 {
172 return false;
173 }
175 {
176 return false;
177 }
178 if (MaterialsOverrides.Num() != Other.MaterialsOverrides.Num())
179 {
180 return false;
181 }
183 {
184 if (!MaterialsOverrides[MatIndex].HasSameIndexAndSerialNumber(Other.MaterialsOverrides[MatIndex]))
185 {
186 return false;
187 }
188 }
189 if (CustomPrimitiveData.Num() != Other.CustomPrimitiveData.Num())
190 {
191 return false;
192 }
193 for (int32 DataIndex = 0; DataIndex < CustomPrimitiveData.Num(); DataIndex++)
194 {
195 if (CustomPrimitiveData[DataIndex] != Other.CustomPrimitiveData[DataIndex])
196 {
197 return false;
198 }
199 }
200
201 return true;
202 }
203};
204
206{
207 uint32 CombinedHash = GetTypeHash(MeshInstance.StaticMesh);
208 CombinedHash = HashCombineFast(CombinedHash, GetTypeHash(MeshInstance.MaterialsOverrides.Num()));
210 {
211 CombinedHash = HashCombineFast(CombinedHash, GetTypeHash(Material));
212 }
213 for (const float CustomFloat : MeshInstance.CustomPrimitiveData)
214 {
215 CombinedHash = HashCombineFast(CombinedHash, GetTypeHash(CustomFloat));
216 }
217 CombinedHash = HashCombineFast(CombinedHash, GetTypeHash(MeshInstance.Desc));
218 return CombinedHash;
219}
220
231
233
257
277
280{
282
284
289
291 void RemoveISM(FISMIndex ISMIndex, bool bKeepAlive, bool bRecycle);
296
300 bool BatchUpdateInstancesTransforms(FGeometryCollectionMeshInfo& MeshInfo, int32 StartInstanceIndex, TArrayView<const FTransform> NewInstancesTransforms, bool bWorldSpace, bool bMarkRenderStateDirty, bool bTeleport, bool bAllowPerInstanceRemoval);
302
304 void Clear();
305
308 void Tick(UGeometryCollectionISMPoolComponent* OwningComponent);
310
317
319
324
327
332
333 // Cached state of lifecycle cvars from the last Tick()
334 bool bCachedKeepAlive = false;
335 bool bCachedRecycle = false;
336
337 // Whether we force ISMs to use parent bounds and disable transform updates
339};
340
341
346class UE_DEPRECATED(5.6, "UGeometryCollectionISMPoolDebugDrawComponent is deprecated, please use UISMPoolDebugDrawComponent instead.") UGeometryCollectionISMPoolDebugDrawComponent;
347
348UCLASS(meta = (BlueprintSpawnableComponent), MinimalAPI)
349class UE_DEPRECATED(5.6, "UGeometryCollectionISMPoolComponent is deprecated, please use UISMPoolComponent instead.") UGeometryCollectionISMPoolComponent: public USceneComponent
350{
352
353public:
354 using FMeshGroupId = int32;
355 using FMeshId = int32;
356
357 //~ Begin UActorComponent Interface
358 virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
360 //~ End UActorComponent Interface
361
367 GEOMETRYCOLLECTIONENGINE_API FMeshGroupId CreateMeshGroup(bool bAllowPerInstanceRemoval = false);
368
370 GEOMETRYCOLLECTIONENGINE_API void DestroyMeshGroup(FMeshGroupId MeshGroupId);
371
373 GEOMETRYCOLLECTIONENGINE_API FMeshId AddMeshToGroup(FMeshGroupId MeshGroupId, const FGeometryCollectionStaticMeshInstance& MeshInstance, int32 InstanceCount, TArrayView<const float> CustomDataFloats);
374
376 GEOMETRYCOLLECTIONENGINE_API bool BatchUpdateInstancesTransforms(FMeshGroupId MeshGroupId, FMeshId MeshId, int32 StartInstanceIndex, TArrayView<const FTransform> NewInstancesTransforms, bool bWorldSpace = false, bool bMarkRenderStateDirty = false, bool bTeleport = false);
377
378 UE_DEPRECATED(5.3, "BatchUpdateInstancesTransforms Array parameter version is deprecated, use the TArrayView version instead")
379 GEOMETRYCOLLECTIONENGINE_API bool BatchUpdateInstancesTransforms(FMeshGroupId MeshGroupId, FMeshId MeshId, int32 StartInstanceIndex, const TArray<FTransform>& NewInstancesTransforms, bool bWorldSpace = false, bool bMarkRenderStateDirty = false, bool bTeleport = false);
380
382 GEOMETRYCOLLECTIONENGINE_API bool BatchUpdateInstanceCustomData(FMeshGroupId MeshGroupId, int32 CustomFloatIndex, float CustomFloatValue);
383
388 GEOMETRYCOLLECTIONENGINE_API void PreallocateMeshInstance(const FGeometryCollectionStaticMeshInstance& MeshInstance);
389
390 GEOMETRYCOLLECTIONENGINE_API void SetTickablePoolManagement(bool bEnablePoolManagement);
391
392 GEOMETRYCOLLECTIONENGINE_API void SetOverrideTransformUpdates(bool bOverrideUpdates);
393
395
396private:
397 uint32 NextMeshGroupId = 0;
398 TMap<FMeshGroupId, FGeometryCollectionMeshGroup> MeshGroups;
400
401 // Expose internals for debug draw support.
405};
EUpdateTransformFlags
Definition ActorComponent.h:95
#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
ELevelTick
Definition EngineBaseTypes.h:70
ETeleportType
Definition EngineTypes.h:2401
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
uint32 GetTypeHash(const FISMComponentDescription &Desc)
Definition GeometryCollectionISMPoolComponent.h:144
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
constexpr uint32 HashCombineFast(uint32 A, uint32 B)
Definition TypeHash.h:74
uint32 GetArrayHash(const T *Ptr, uint64 Size, uint32 PreviousHash=0)
Definition TypeHash.h:200
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition ArrayView.h:139
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT ElementType * GetData() UE_LIFETIMEBOUND
Definition Array.h:1027
UE_FORCEINLINE_HINT void RemoveAtSwap(SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2185
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition UnrealString.h.inl:34
Definition InstancedStaticMeshComponent.h:158
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition EngineBaseTypes.h:571
Definition GeometryCollectionISMPoolComponent.h:280
PRAGMA_ENABLE_DEPRECATION_WARNINGS void UpdateAbsoluteTransforms(const FTransform &BaseTransform, EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport)
Definition GeometryCollectionISMPoolComponent.cpp:551
PRAGMA_DISABLE_DEPRECATION_WARNINGS FISMIndex GetOrAddISM(UGeometryCollectionISMPoolComponent *OwningComponent, const FGeometryCollectionStaticMeshInstance &MeshInstance, bool &bOutISMCreated)
Definition GeometryCollectionISMPoolComponent.cpp:273
PRAGMA_ENABLE_DEPRECATION_WARNINGS void RemoveISM(FISMIndex ISMIndex, bool bKeepAlive, bool bRecycle)
Definition GeometryCollectionISMPoolComponent.cpp:446
int32 FISMIndex
Definition GeometryCollectionISMPoolComponent.h:281
TArray< int32 > FreeListISM
Definition GeometryCollectionISMPoolComponent.h:331
bool bCachedRecycle
Definition GeometryCollectionISMPoolComponent.h:335
PRAGMA_DISABLE_DEPRECATION_WARNINGS FGeometryCollectionMeshInfo AddInstancesToISM(UGeometryCollectionISMPoolComponent *OwningComponent, const FGeometryCollectionStaticMeshInstance &MeshInstance, int32 InstanceCount, TArrayView< const float > CustomDataFloats)
Definition GeometryCollectionISMPoolComponent.cpp:310
PRAGMA_ENABLE_DEPRECATION_WARNINGS void RequestPreallocateMeshInstance(const FGeometryCollectionStaticMeshInstance &MeshInstances)
Definition GeometryCollectionISMPoolComponent.cpp:493
TArray< int32 > FreeList
Definition GeometryCollectionISMPoolComponent.h:329
void BatchUpdateInstanceCustomData(FGeometryCollectionMeshInfo const &MeshInfo, int32 CustomFloatIndex, float CustomFloatValue)
Definition GeometryCollectionISMPoolComponent.cpp:378
PRAGMA_DISABLE_DEPRECATION_WARNINGS void ProcessPreallocationRequests(UGeometryCollectionISMPoolComponent *OwningComponent, int32 MaxPreallocations)
Definition GeometryCollectionISMPoolComponent.cpp:525
TSet< FGeometryCollectionStaticMeshInstance > PrellocationQueue
Definition GeometryCollectionISMPoolComponent.h:326
PRAGMA_ENABLE_DEPRECATION_WARNINGS void RemoveInstancesFromISM(const FGeometryCollectionMeshInfo &MeshInfo)
Definition GeometryCollectionISMPoolComponent.cpp:402
TArray< FGeometryCollectionISM > ISMs
Definition GeometryCollectionISMPoolComponent.h:321
bool bDisableBoundsAndTransformUpdate
Definition GeometryCollectionISMPoolComponent.h:338
TMap< FGeometryCollectionStaticMeshInstance, FISMIndex > MeshToISMIndex
Definition GeometryCollectionISMPoolComponent.h:323
bool bCachedKeepAlive
Definition GeometryCollectionISMPoolComponent.h:334
FGeometryCollectionISMPool()
Definition GeometryCollectionISMPoolComponent.cpp:266
bool BatchUpdateInstancesTransforms(FGeometryCollectionMeshInfo &MeshInfo, int32 StartInstanceIndex, TArrayView< const FTransform > NewInstancesTransforms, bool bWorldSpace, bool bMarkRenderStateDirty, bool bTeleport, bool bAllowPerInstanceRemoval)
Definition GeometryCollectionISMPoolComponent.cpp:320
void Clear()
Definition GeometryCollectionISMPoolComponent.cpp:474
Definition GeometryCollectionISMPoolComponent.h:260
void InitISM(const FGeometryCollectionStaticMeshInstance &InMeshInstance, bool bKeepAlive, bool bOverrideTransformUpdates=false)
Definition GeometryCollectionISMPoolComponent.cpp:132
TArray< FPrimitiveInstanceId > InstanceIds
Definition GeometryCollectionISMPoolComponent.h:275
void CreateISM(USceneComponent *InOwningComponent)
Definition GeometryCollectionISMPoolComponent.cpp:107
FInstanceGroups InstanceGroups
Definition GeometryCollectionISMPoolComponent.h:273
FInstanceGroups::FInstanceGroupId AddInstanceGroup(int32 InstanceCount, TArrayView< const float > CustomDataFloats)
Definition GeometryCollectionISMPoolComponent.cpp:229
TObjectPtr< UInstancedStaticMeshComponent > ISMComponent
Definition GeometryCollectionISMPoolComponent.h:271
FGeometryCollectionStaticMeshInstance MeshInstance
Definition GeometryCollectionISMPoolComponent.h:269
Definition GeometryCollectionISMPoolComponent.h:239
FMeshId AddMesh(const FGeometryCollectionStaticMeshInstance &MeshInstance, int32 InstanceCount, const FGeometryCollectionMeshInfo &ISMInstanceInfo, TArrayView< const float > CustomDataFloats)
Definition GeometryCollectionISMPoolComponent.cpp:67
bool BatchUpdateInstancesTransforms(FGeometryCollectionISMPool &ISMPool, FMeshId MeshId, int32 StartInstanceIndex, TArrayView< const FTransform > NewInstancesTransforms, bool bWorldSpace, bool bMarkRenderStateDirty, bool bTeleport)
Definition GeometryCollectionISMPoolComponent.cpp:80
TArray< FGeometryCollectionMeshInfo > MeshInfos
Definition GeometryCollectionISMPoolComponent.h:252
void RemoveAllMeshes(FGeometryCollectionISMPool &ISMPool)
Definition GeometryCollectionISMPoolComponent.cpp:98
int32 FMeshId
Definition GeometryCollectionISMPoolComponent.h:240
bool bAllowPerInstanceRemoval
Definition GeometryCollectionISMPoolComponent.h:255
void BatchUpdateInstanceCustomData(FGeometryCollectionISMPool &ISMPool, int32 CustomFloatIndex, float CustomFloatValue)
Definition GeometryCollectionISMPoolComponent.cpp:90
Definition GeometryCollectionISMPoolComponent.h:223
int32 ISMIndex
Definition GeometryCollectionISMPoolComponent.h:224
FInstanceGroups::FInstanceGroupId InstanceGroupIndex
Definition GeometryCollectionISMPoolComponent.h:225
TArrayView< const float > CustomDataSlice(int32 InstanceIndex, int32 NumCustomDataFloatsPerInstance)
Definition GeometryCollectionISMPoolComponent.cpp:61
TArray< float > CustomData
Definition GeometryCollectionISMPoolComponent.h:227
void ShadowCopyCustomData(int32 InstanceCount, int32 NumCustomDataFloatsPerInstance, TArrayView< const float > CustomDataFloats)
Definition GeometryCollectionISMPoolComponent.cpp:50
Definition GeometryCollectionISMPoolComponent.h:162
bool operator==(const FGeometryCollectionStaticMeshInstance &Other) const
Definition GeometryCollectionISMPoolComponent.h:168
FISMComponentDescription Desc
Definition GeometryCollectionISMPoolComponent.h:166
TArray< float > CustomPrimitiveData
Definition GeometryCollectionISMPoolComponent.h:165
TWeakObjectPtr< UStaticMesh > StaticMesh
Definition GeometryCollectionISMPoolComponent.h:163
TArray< TWeakObjectPtr< UMaterialInterface > > MaterialsOverrides
Definition GeometryCollectionISMPoolComponent.h:164
Definition GeometryCollectionISMPoolComponent.h:102
int32 StartCullDistance
Definition GeometryCollectionISMPoolComponent.h:121
float LodScale
Definition GeometryCollectionISMPoolComponent.h:125
int32 NumCustomDataFloats
Definition GeometryCollectionISMPoolComponent.h:119
bool operator==(const FISMComponentDescription &Other) const
Definition GeometryCollectionISMPoolComponent.h:129
int32 EndCullDistance
Definition GeometryCollectionISMPoolComponent.h:122
uint32 GroupHash
Definition GeometryCollectionISMPoolComponent.h:124
FName StatsCategory
Definition GeometryCollectionISMPoolComponent.h:127
EFlags
Definition GeometryCollectionISMPoolComponent.h:104
@ DistanceCullPrimitive
Definition GeometryCollectionISMPoolComponent.h:115
@ EvaluateWorldPositionOffset
Definition GeometryCollectionISMPoolComponent.h:110
@ AffectDynamicIndirectLighting
Definition GeometryCollectionISMPoolComponent.h:113
@ WorldPositionOffsetWritesVelocity
Definition GeometryCollectionISMPoolComponent.h:109
@ AffectDistanceFieldLighting
Definition GeometryCollectionISMPoolComponent.h:112
@ ReverseCulling
Definition GeometryCollectionISMPoolComponent.h:107
@ AffectFarShadow
Definition GeometryCollectionISMPoolComponent.h:114
@ StaticMobility
Definition GeometryCollectionISMPoolComponent.h:108
@ GpuLodSelection
Definition GeometryCollectionISMPoolComponent.h:106
@ UseHISM
Definition GeometryCollectionISMPoolComponent.h:105
@ AffectShadow
Definition GeometryCollectionISMPoolComponent.h:111
uint32 Flags
Definition GeometryCollectionISMPoolComponent.h:118
int32 MinLod
Definition GeometryCollectionISMPoolComponent.h:123
FVector Position
Definition GeometryCollectionISMPoolComponent.h:120
TArray< FName > Tags
Definition GeometryCollectionISMPoolComponent.h:126
Definition GeometryCollectionISMPoolComponent.h:28
int32 Start
Definition GeometryCollectionISMPoolComponent.h:35
FInstanceGroupRange(int32 InStart, int32 InCount)
Definition GeometryCollectionISMPoolComponent.h:29
int32 Count
Definition GeometryCollectionISMPoolComponent.h:36
Definition GeometryCollectionISMPoolComponent.h:23
void Reset()
Definition GeometryCollectionISMPoolComponent.h:40
bool IsEmpty() const
Definition GeometryCollectionISMPoolComponent.h:49
TArray< FInstanceGroupId > FreeList
Definition GeometryCollectionISMPoolComponent.h:95
int32 TotalInstanceCount
Definition GeometryCollectionISMPoolComponent.h:92
void RemoveGroup(FInstanceGroupId GroupId)
Definition GeometryCollectionISMPoolComponent.h:84
int32 TotalFreeInstanceCount
Definition GeometryCollectionISMPoolComponent.h:93
FInstanceGroupId AddGroup(int32 Count)
Definition GeometryCollectionISMPoolComponent.h:61
int32 GetMaxInstanceIndex() const
Definition GeometryCollectionISMPoolComponent.h:55
TArray< FInstanceGroupRange > GroupRanges
Definition GeometryCollectionISMPoolComponent.h:94
int32 FInstanceGroupId
Definition GeometryCollectionISMPoolComponent.h:24
Definition ResourceSize.h:31
Definition ObjectPtr.h:488
Definition WeakObjectPtrTemplates.h:25
FORCEINLINE bool HasSameIndexAndSerialNumber(const TWeakObjectPtr &Other) const
Definition WeakObjectPtrTemplates.h:273
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79