UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MovieScenePreAnimatedObjectStorage.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
12
13
14namespace UE
15{
16namespace MovieScene
17{
18
30{
32
34
35 template<typename T>
37 {
38 return Forward<T>(In);
39 }
40
41 /* Defined as a template rather than a variadic function to prevent error C4840 */
42 template<typename... T>
44 {
45 return FindGroupImpl(BoundObject);
46 }
47 template<typename... T>
49 {
50 return FindGroupImpl(BoundObject);
51 }
52
53 /* Defined as a template rather than a variadic function to prevent error C4840 */
54 template<typename... T>
56 {
57 return MakeGroupImpl(BoundObject);
58 }
59 template<typename... T>
61 {
62 return MakeGroupImpl(BoundObject);
63 }
64
67
70
71 template<typename ...T>
76 template<typename KeyType>
78 {
79 InOutKey.Object = NewObject;
80 }
81 template<typename ObjectType>
83 {
84 if (ObjectType* CastResult = Cast<ObjectType>(NewObject.ResolveObjectPtr()))
85 {
87 }
88 }
94};
95
96template<typename ObjectTraits>
98 : TPreAnimatedStateStorage<ObjectTraits>
100{
101 using KeyType = typename ObjectTraits::KeyType;
102 using StorageType = typename ObjectTraits::StorageType;
103
104 static_assert(ObjectTraits::SupportsGrouping, "Pre-animated object state storage should support grouping by object");
105
108
109public:
110
112 {
113 return this;
114 }
115
117 {
118 const int32 Num = Params.Num;
119 const bool bWantsRestore = Params.bWantsRestoreState;
120
121 if (!this->ParentExtension->IsCapturingGlobalState() && !bWantsRestore)
122 {
123 return;
124 }
125
127 for (int32 Index = 0; Index < Num; ++Index)
128 {
129 UObject* BoundObject = BoundObjects[Index];
130 KeyType Key{ BoundObject };
131
132 FPreAnimatedStorageGroupHandle GroupHandle = this->Traits.MakeGroup(BoundObject);
133 FPreAnimatedStorageIndex StorageIndex = this->GetOrCreateStorageIndex(Key);
134
135 FPreAnimatedStateEntry Entry{ GroupHandle, FPreAnimatedStateCachedValueHandle{ this->StorageID, StorageIndex } };
136 EntityMetaData->BeginTrackingEntity(Entry, EntityIDs[Index], InstanceHandles[Index], bWantsRestore);
137 }
138 }
139
141 {
142 KeyType Key{ BoundObject };
143
144 FPreAnimatedStorageIndex StorageIndex = this->GetOrCreateStorageIndex(Key);
145 FPreAnimatedStorageGroupHandle GroupHandle = this->Traits.MakeGroup(BoundObject);
146 return FPreAnimatedStateEntry{ GroupHandle, FPreAnimatedStateCachedValueHandle{ this->StorageID, StorageIndex } };
147 }
148
149 void BeginTrackingEntity(FMovieSceneEntityID EntityID, bool bWantsRestoreState, FRootInstanceHandle RootInstanceHandle, UObject* BoundObject) override
150 {
151 if (!this->ParentExtension->IsCapturingGlobalState() && !bWantsRestoreState)
152 {
153 return;
154 }
155
157
158 FPreAnimatedStateEntry Entry = MakeEntry(BoundObject);
159 EntityMetaData->BeginTrackingEntity(Entry, EntityID, RootInstanceHandle, bWantsRestoreState);
160 }
161
163 {
164 for (UObject* BoundObject : BoundObjects)
165 {
166 if (BoundObject)
167 {
168 CachePreAnimatedValue(Params, BoundObject);
169 }
170 }
171 }
172
174 {
175 if (this->ShouldTrackCaptureSource(TrackingMode, BoundObject))
176 {
177 FPreAnimatedStateEntry Entry = MakeEntry(BoundObject);
178
179 this->TrackCaptureSource(Entry, TrackingMode);
180
181 CachePreAnimatedValue(Params, Entry, BoundObject);
182 }
183 }
184
186 {
187 const FPreAnimatedStorageIndex StorageIndex = Entry.ValueHandle.StorageIndex;
188
190 if (!this->IsStorageRequirementSatisfied(StorageIndex, StorageRequirement))
191 {
192 StorageType NewValue = this->Traits.CachePreAnimatedValue(BoundObject);
193 this->AssignPreAnimatedValue(StorageIndex, StorageRequirement, MoveTemp(NewValue));
194 }
195
196 if (Params.bForcePersist)
197 {
198 this->ForciblyPersistStorage(StorageIndex);
199 }
200 }
201
202 template<typename OnCacheValue /* StorageType(const KeyType&) */>
204 {
205 if (this->ShouldTrackCaptureSource(TrackingMode, BoundObject))
206 {
207 FPreAnimatedStateEntry Entry = MakeEntry(BoundObject);
208
209 this->TrackCaptureSource(Entry, TrackingMode);
210 const FPreAnimatedStorageIndex StorageIndex = Entry.ValueHandle.StorageIndex;
211
213 if (!this->IsStorageRequirementSatisfied(StorageIndex, StorageRequirement))
214 {
215 KeyType Key{ BoundObject };
216 StorageType NewValue = CacheCallback(Key);
217 this->AssignPreAnimatedValue(StorageIndex, StorageRequirement, MoveTemp(NewValue));
218 }
219
220 if (Params.bForcePersist)
221 {
222 this->ForciblyPersistStorage(StorageIndex);
223 }
224 }
225 }
226};
227
228} // namespace MovieScene
229} // namespace UE
230
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
@ Num
Definition MetalRHIPrivate.h:234
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition MovieScene.Build.cs:6
Definition ArrayView.h:139
Definition ObjectKey.h:228
Definition SharedPointer.h:692
Definition Object.h:95
EPreAnimatedStorageRequirement
Definition MovieScenePreAnimatedStateTypes.h:32
EPreAnimatedCaptureSourceTracking
Definition MovieScenePreAnimatedStateStorage.h:45
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
Definition ObjectKey.h:19
Definition Tuple.h:652
Definition MovieScenePreAnimatedObjectStorage.h:30
@ SupportsReplaceObject
Definition MovieScenePreAnimatedObjectStorage.h:31
@ NeedsInitialize
Definition MovieScenePreAnimatedObjectStorage.h:31
@ SupportsGrouping
Definition MovieScenePreAnimatedObjectStorage.h:31
MOVIESCENE_API FPreAnimatedStorageGroupHandle MakeGroupImpl(UObject *BoundObject)
Definition MovieScenePreAnimatedObjectStorage.cpp:27
FPreAnimatedStorageGroupHandle FindGroup(UObject *BoundObject, T &&... Unused)
Definition MovieScenePreAnimatedObjectStorage.h:43
FPreAnimatedStorageGroupHandle MakeGroup(UObject *BoundObject, T &&... Unused)
Definition MovieScenePreAnimatedObjectStorage.h:55
void ReplaceObject(TTuple< FObjectKey, T... > &InOutKey, const FObjectKey &NewObject)
Definition MovieScenePreAnimatedObjectStorage.h:72
FPreAnimatedStorageGroupHandle MakeGroup(const FObjectComponent &BoundObject, T &&... Unused)
Definition MovieScenePreAnimatedObjectStorage.h:60
MOVIESCENE_API FPreAnimatedStorageGroupHandle FindGroupImpl(UObject *BoundObject)
Definition MovieScenePreAnimatedObjectStorage.cpp:17
TSharedPtr< FPreAnimatedObjectGroupManager > ObjectGroupManager
Definition MovieScenePreAnimatedObjectStorage.h:93
void ReplaceObject(TObjectKey< ObjectType > &InOutKey, const FObjectKey &NewObject)
Definition MovieScenePreAnimatedObjectStorage.h:82
void ReplaceObject(FObjectKey &InOutKey, const FObjectKey &NewObject)
Definition MovieScenePreAnimatedObjectStorage.h:89
void ReplaceObject(KeyType &InOutKey, const FObjectKey &NewObject)
Definition MovieScenePreAnimatedObjectStorage.h:77
FPreAnimatedStorageGroupHandle FindGroup(const FObjectComponent &BoundObject, T &&... Unused)
Definition MovieScenePreAnimatedObjectStorage.h:48
T ResolveComponent(T &&In)
Definition MovieScenePreAnimatedObjectStorage.h:36
Definition MovieScenePreAnimatedStateTypes.h:27
Definition MovieSceneEntityIDs.h:302
Definition BuiltInComponentTypes.h:256
Definition MovieScenePreAnimatedCaptureSources.h:115
MOVIESCENE_API void BeginTrackingEntity(const FPreAnimatedStateEntry &Entry, FMovieSceneEntityID EntityID, FRootInstanceHandle RootInstanceHandle, bool bWantsRestoreState)
Definition MovieScenePreAnimatedCaptureSources.cpp:26
Definition MovieScenePreAnimatedStateTypes.h:134
FPreAnimatedStorageIndex StorageIndex
Definition MovieScenePreAnimatedStateTypes.h:139
Definition MovieScenePreAnimatedStateTypes.h:158
FPreAnimatedStateCachedValueHandle ValueHandle
Definition MovieScenePreAnimatedStateTypes.h:162
Definition MovieScenePreAnimatedStateExtension.h:73
bool IsCapturingGlobalState() const
Definition MovieScenePreAnimatedStateExtension.h:205
MOVIESCENE_API FPreAnimatedEntityCaptureSource * GetOrCreateEntityMetaData()
Definition MovieScenePreAnimatedStateExtension.cpp:243
MOVIESCENE_API EPreAnimatedStorageRequirement GetStorageRequirement(const FPreAnimatedStateEntry &Entry) const
Definition MovieScenePreAnimatedStateExtension.cpp:127
Definition MovieScenePreAnimatedStateStorage.h:94
Definition MovieScenePreAnimatedStateTypes.h:86
Definition MovieScenePreAnimatedStorageID.h:14
Definition MovieScenePreAnimatedStateTypes.h:42
Definition MovieScenePreAnimatedStateTypes.h:19
Definition MovieSceneSequenceInstanceHandle.h:58
Definition IMovieScenePreAnimatedStorage.h:52
Definition MovieScenePreAnimatedObjectStorage.h:100
FPreAnimatedStateEntry MakeEntry(UObject *BoundObject)
Definition MovieScenePreAnimatedObjectStorage.h:140
IPreAnimatedObjectEntityStorage * AsObjectStorage() override
Definition MovieScenePreAnimatedObjectStorage.h:111
void CachePreAnimatedValue(const FCachePreAnimatedValueParams &Params, UObject *BoundObject, OnCacheValue &&CacheCallback, EPreAnimatedCaptureSourceTracking TrackingMode=EPreAnimatedCaptureSourceTracking::CacheIfTracked)
Definition MovieScenePreAnimatedObjectStorage.h:203
typename ObjectTraits::StorageType StorageType
Definition MovieScenePreAnimatedObjectStorage.h:102
TPreAnimatedStateStorage_ObjectTraits()
Definition MovieScenePreAnimatedObjectStorage.h:106
void BeginTrackingEntity(FMovieSceneEntityID EntityID, bool bWantsRestoreState, FRootInstanceHandle RootInstanceHandle, UObject *BoundObject) override
Definition MovieScenePreAnimatedObjectStorage.h:149
void CachePreAnimatedValues(const FCachePreAnimatedValueParams &Params, TArrayView< UObject *const > BoundObjects) override
Definition MovieScenePreAnimatedObjectStorage.h:162
void CachePreAnimatedValue(const FCachePreAnimatedValueParams &Params, const FPreAnimatedStateEntry &Entry, UObject *BoundObject)
Definition MovieScenePreAnimatedObjectStorage.h:185
void CachePreAnimatedValue(const FCachePreAnimatedValueParams &Params, UObject *BoundObject, EPreAnimatedCaptureSourceTracking TrackingMode=EPreAnimatedCaptureSourceTracking::CacheIfTracked)
Definition MovieScenePreAnimatedObjectStorage.h:173
void BeginTrackingEntities(const FPreAnimatedTrackerParams &Params, TRead< FMovieSceneEntityID > EntityIDs, TRead< FRootInstanceHandle > InstanceHandles, TRead< UObject * > BoundObjects) override
Definition MovieScenePreAnimatedObjectStorage.h:116
typename ObjectTraits::KeyType KeyType
Definition MovieScenePreAnimatedObjectStorage.h:101
Definition MovieScenePreAnimatedStateStorage.h:143
bool IsStorageRequirementSatisfied(FPreAnimatedStorageIndex StorageIndex, EPreAnimatedStorageRequirement StorageRequirement) const
Definition MovieScenePreAnimatedStateStorage.h:436
FPreAnimatedStorageID StorageID
Definition MovieScenePreAnimatedStateStorage.h:942
FPreAnimatedStateExtension * ParentExtension
Definition MovieScenePreAnimatedStateStorage.h:936
void AssignPreAnimatedValue(FPreAnimatedStorageIndex StorageIndex, EPreAnimatedStorageRequirement StorageRequirement, StorageType &&InNewValue)
Definition MovieScenePreAnimatedStateStorage.h:403
bool ShouldTrackCaptureSource(EPreAnimatedCaptureSourceTracking TrackingMode, KeyArgs &&... InKeyArgs)
Definition MovieScenePreAnimatedStateStorage.h:822
void TrackCaptureSource(const FPreAnimatedStateEntry &Entry, EPreAnimatedCaptureSourceTracking TrackingMode)
Definition MovieScenePreAnimatedStateStorage.h:861
ObjectTraits Traits
Definition MovieScenePreAnimatedStateStorage.h:947
FPreAnimatedStorageIndex GetOrCreateStorageIndex(const KeyType &InKey)
Definition MovieScenePreAnimatedStateStorage.h:376
void ForciblyPersistStorage(FPreAnimatedStorageIndex StorageIndex)
Definition MovieScenePreAnimatedStateStorage.h:510
Definition MovieSceneComponentPtr.h:195