UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ObjectCacheContext.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5#include "Containers/Set.h"
6#include "Containers/Map.h"
7#include "Misc/Optional.h"
8#include "UObject/ObjectKey.h"
9#include "Misc/ScopeRWLock.h"
10
11class UObject;
12class UPrimitiveComponent;
13class UStaticMeshComponent;
16class UStaticMesh;
17class UTexture;
19class USkeletalMesh;
20class USkinnedAsset;
23class UInstancedSkinnedMeshComponent;
25
30template< class T > class TObjectCacheIterator
31{
32public:
41
49
50 inline const int32 IsEmpty() const { return ArrayView.IsEmpty(); }
51
56 inline T** begin() const { return ArrayView.begin(); }
57 inline T** end() const { return ArrayView.end(); }
58
59protected:
64};
65
72{
73public:
89#if WITH_EDITOR
91#endif
92
93private:
95 FObjectCacheContext() = default;
96 TMap<IPrimitiveComponent*, TSet<UMaterialInterface*>> PrimitiveComponentToMaterial;
101#if WITH_EDITOR
103#endif
105
106 template <typename UComponentType, typename UAssetType>
107 struct TComponentTypeCache
108 {
111
112 template <typename ObjectIteratorType>
114
115 template <typename ObjectIteratorType, typename GetNumFuncType, typename GetFuncType>
117
118 template <typename ObjectIteratorType, typename GetNumFuncType, typename GetFuncType>
120 };
121
122 TComponentTypeCache<USkinnedMeshComponent, USkinnedAsset> SkinnedMeshCache;
123 TComponentTypeCache<UInstancedSkinnedMeshComponent, UTransformProviderData> InstancedSkinnedMeshCache;
124 TOptional<TArray<IPrimitiveComponent*>> PrimitiveComponents;
125 TComponentTypeCache<IStaticMeshComponent, UStaticMesh> StaticMeshCache;
126};
127
134{
135public:
139private:
140 // Scopes can be stacked over one another, but only the outermost will
141 // own the actual context and destroy it at the end, all inner scopes
142 // will feed off the already existing one and will not own it.
143 bool bIsOwner = false;
144};
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_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition ObjectCacheContext.h:134
ENGINE_API FObjectCacheContext & GetContext()
Definition ObjectCacheContext.cpp:1191
ENGINE_API ~FObjectCacheContextScope()
Definition ObjectCacheContext.cpp:1182
ENGINE_API FObjectCacheContextScope()
Definition ObjectCacheContext.cpp:1172
Definition ObjectCacheContext.h:72
ENGINE_API TObjectCacheIterator< UMaterialInterface > GetMaterialsAffectedByTexture(UTexture *InTexture)
Definition ObjectCacheContext.cpp:936
ENGINE_API TObjectCacheIterator< UMaterialInterface > GetMaterialsAffectedByMaterials(TArrayView< UMaterialInterface * > InMaterials)
Definition ObjectCacheContext.cpp:1076
ENGINE_API TObjectCacheIterator< IStaticMeshComponent > GetStaticMeshComponents()
Definition ObjectCacheContext.cpp:897
ENGINE_API TObjectCacheIterator< UMaterialInterface > GetMaterialsAffectedByTextureCollection(UTextureCollection *InTextureCollection)
Definition ObjectCacheContext.cpp:987
ENGINE_API TObjectCacheIterator< UMaterialInterface > GetUsedMaterials(IPrimitiveComponent *InComponent)
Definition ObjectCacheContext.cpp:848
ENGINE_API TObjectCacheIterator< UTexture > GetUsedTextures(UMaterialInterface *InMaterial)
Definition ObjectCacheContext.cpp:690
ENGINE_API TObjectCacheIterator< IPrimitiveComponent > GetPrimitivesAffectedByMaterial(UMaterialInterface *InMaterial)
Definition ObjectCacheContext.cpp:1161
ENGINE_API TObjectCacheIterator< IPrimitiveComponent > GetPrimitiveComponents()
Definition ObjectCacheContext.cpp:670
ENGINE_API TObjectCacheIterator< USkinnedMeshComponent > GetSkinnedMeshComponents()
Definition ObjectCacheContext.cpp:824
ENGINE_API TObjectCacheIterator< IPrimitiveComponent > GetPrimitivesAffectedByMaterials(TArrayView< UMaterialInterface * > InMaterials)
Definition ObjectCacheContext.cpp:1114
ENGINE_API TObjectCacheIterator< UTextureCollection > GetUsedTextureCollections(UMaterialInterface *InMaterial)
Definition ObjectCacheContext.cpp:727
ENGINE_API TObjectCacheIterator< UInstancedSkinnedMeshComponent > GetInstancedSkinnedMeshComponents()
Definition ObjectCacheContext.cpp:836
Definition ComponentInterfaces.h:59
Definition ComponentInterfaces.h:115
Definition ArrayView.h:139
UE_FORCEINLINE_HINT constexpr ElementType * end() const
Definition ArrayView.h:760
constexpr bool IsEmpty() const
Definition ArrayView.h:370
UE_FORCEINLINE_HINT constexpr ElementType * begin() const
Definition ArrayView.h:759
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition ObjectCacheContext.h:31
T ** end() const
Definition ObjectCacheContext.h:57
T ** begin() const
Definition ObjectCacheContext.h:56
TObjectCacheIterator(TArray< T * > &&InObjectArray)
Definition ObjectCacheContext.h:36
TArray< T * > OwnedArray
Definition ObjectCacheContext.h:61
TObjectCacheIterator(TArrayView< T * > InArrayView)
Definition ObjectCacheContext.h:45
const int32 IsEmpty() const
Definition ObjectCacheContext.h:50
TArrayView< T * > ArrayView
Definition ObjectCacheContext.h:63
Definition MaterialInterface.h:296
Definition Object.h:95
Definition SkeletalMesh.h:440
Definition SkinnedAsset.h:47
Definition SkinnedMeshComponent.h:258
Definition StaticMesh.h:593
Definition TextureCollection.h:47
Definition Texture.h:1219
Definition TransformProviderData.h:38
Definition Optional.h:131