UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MovieSceneCommonHelpers.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "UObject/ObjectKey.h"
9#include "Curves/KeyHandle.h"
10#include "Misc/FrameNumber.h"
12
13#include "TrackInstancePropertyBindings.h" // For backwards compatibility
14
15class AActor;
17class UMovieScene;
21class USceneComponent;
22class USoundBase;
23template <class TClass> class TSubclassOf;
25struct FRichCurve;
32
33namespace UE::MovieScene
34{
35 struct FSharedPlaybackState;
36}
37
39{
40public:
41
42 /*
43 * Helper struct to cache the package dirty state and then to restore it
44 * after this leaves scope. This is for a few minor areas where calling
45 * functions on actors dirties them, but Sequencer doesn't actually want
46 * the package to be dirty as it causes Sequencer to unnecessairly dirty
47 * actors.
48 */
50 {
53
54 private:
55 class USceneComponent* Component;
56 bool bPackageWasDirty;
57 };
58
63
68
77
86
89
92
93 /*
94 * Fix up consecutive sections so that there are no gaps
95 *
96 * @param Sections All the sections
97 * @param Section The section that was modified
98 * @param bDelete Was this a deletion?
99 * @param bCleanUp Should we cleanup any invalid sections?
100 * @return Whether the list of sections was modified as part of the clean-up
101 */
103
115
116 /*
117 * Sort consecutive sections so that they are in order based on start time
118 */
120
121 /*
122 * Gather up descendant movie scenes from the incoming sequence
123 */
125
126 /*
127 * Gather up descendant movie scene sub-sections from the incoming movie scene
128 */
130
139
147
155
163
164 /*
165 * Get the duration for the given sound
166
167 * @param Sound The sound to get the duration for
168 * @return The duration in seconds
169 */
171
179
187
192
193 /*
194 * Get weight needed to modify the global difference in order to correctly key this section due to it possibly being blended by other sections.
195 * @param Section The Section who's weight we are calculating.
196 * @param Time we are at.
197 * @return Returns the weight that needs to be applied to the global difference to correctly key this section.
198 */
200
201 /*
202 * Return a name unique to the binding names in the given movie scene
203 * @param InMovieScene The movie scene to look for existing possessables.
204 * @param InName The requested name to make unique.
205 * @return The unique name
206 */
207 static MOVIESCENE_API FString MakeUniqueBindingName(UMovieScene* InMovieScene, const FString& InName);
208
209 /*
210 * Return a name unique to the spawnable names in the given movie scene
211 * @param InMovieScene The movie scene to look for existing spawnables.
212 * @param InName The requested name to make unique.
213 * @return The unique name
214 */
215 static MOVIESCENE_API FString MakeUniqueSpawnableName(UMovieScene* InMovieScene, const FString& InName);
216
225
226 /*
227 * Returns whether the given ObjectId is valid and is currently bound to at least 1 spawnable give the current context.
228 * More specifically, if a FMovieSceneSpawnable exists with this ObjectId, true will be returned.
229 * If a Level Sequence binding reference exists with a Custom Binding implementing MovieSceneSpawnableBindingBase, true will be returned.
230 * If a Level Sequence binding reference exists with a Custom Binding implementing MovieSceneReplaceableBindingBase and the Context is an editor world, then true will be returned.
231 * Otherwise, false will be returned.
232 */
234
235 /*
236 * Returns whether the given ObjectId is valid and is the given bindingindex is currently bound to a spawnable give the current context.
237 * More specifically, if a FMovieSceneSpawnable exists with this ObjectId, true will be returned.
238 * If a Level Sequence binding reference for this guid with the given BindingIndex exists with a Custom Binding implementing MovieSceneSpawnableBindingBase, true will be returned.
239 * If a Level Sequence binding reference for this guid with the given BindingIndex exists with a Custom Binding implementing MovieSceneReplaceableBindingBase and the Context is an editor world, then true will be returned.
240 * Otherwise, false will be returned.
241 */
242 static MOVIESCENE_API bool IsBoundToSpawnable(UMovieSceneSequence* Sequence, const FGuid& ObjectId, TSharedRef<const UE::MovieScene::FSharedPlaybackState> SharedPlaybackState, int32 BindingIndex = 0);
243
244 /*
245 * Attempts to create a new custom spawnable binding for the passed in UObject*.
246 * Where possible, it is preferred to call FSequencerUtilities::CreateOrReplaceBinding as it handles more cases. This should only be called in cases where there is no editor or sequencer context.
247 * FactoryCreatedActor may be passed in as an alternative option for creating the binding in the case an actor factory was able to create an actor from this object.
248 */
249
251
252
253 /*
254 * Returns the objects currently bound to the given objectid and binding index (optional).
255 */
257
258 UE_DEPRECATED(5.7, "This method has been deprecated. Please use GetBoundObjects which returns an array of bound objects.")
259 static MOVIESCENE_API UObject* GetSingleBoundObject(UMovieSceneSequence* Sequence, const FGuid& ObjectId, TSharedRef<const UE::MovieScene::FSharedPlaybackState> SharedPlaybackState, int32 BindingIndex = 0);
260
261 /*
262 * If the binding for the given ObjectId supports object templates, returns the template, otherwise returns nullptr
263 */
264 static MOVIESCENE_API UObject* GetObjectTemplate(UMovieSceneSequence* Sequence, const FGuid& ObjectId, TSharedRef<const UE::MovieScene::FSharedPlaybackState> SharedPlaybackState, int32 BindingIndex = 0);
265
266 /*
267 * If the binding for the given ObjectId supports object templates, sets the template and returns true, otherwise returns false
268 */
269 static MOVIESCENE_API bool SetObjectTemplate(UMovieSceneSequence* Sequence, const FGuid& ObjectId, UObject* InSourceObject, TSharedRef<const UE::MovieScene::FSharedPlaybackState> SharedPlaybackState, int32 BindingIndex = 0);
270
271 /*
272 * Returns whether the binding for the given ObjectId supports object templates
273 */
274 static MOVIESCENE_API bool SupportsObjectTemplate(UMovieSceneSequence* Sequence, const FGuid& ObjectId, TSharedRef<const UE::MovieScene::FSharedPlaybackState> SharedPlaybackState, int32 BindingIndex = 0);
275
276 /*
277 * If the binding for the given ObjectId supports object templates, copies the object template into the binding and returns true, otherwise returns false
278 */
279 static MOVIESCENE_API bool CopyObjectTemplate(UMovieSceneSequence* Sequence, const FGuid& ObjectId, UObject* InSourceObject, TSharedRef<const UE::MovieScene::FSharedPlaybackState> SharedPlaybackState, int32 BindingIndex = 0);
280#if WITH_EDITORONLY_DATA
281 /*
282 * Returns the bound object class for the binding for the given ObjectId.
283 */
284 static MOVIESCENE_API const UClass* GetBoundObjectClass(UMovieSceneSequence* Sequence, const FGuid& ObjectId, int32 BindingIndex = 0);
285#endif
286
287 /* Returns a sorted list of all custom binding type classes currently known. Slow, may desire to cache result*/
289
290 /* For cases where the user does not have a IMovieScenePlayer with a shared playback state, creates a transient one. Use sparingly. */
292
293 /* Finds the resolution context to use to resolve the given guid. */
295
296 /* Given a movie scene track and an optional section inside it, returns an optional single condition that needs to be evaluated.
297 * If multiple conditions exist in the given scope (for example a track condition, a track row condition for the row the section is on, and a section),
298 * a UMovieSceneGroupCondition will be generated, and the caller is responsible for holding a reference to this new UObject.
299 * If bFromCompilation is true, then any generated conditions will be stored on the movie scene.
300 */
302
303 /* Helper function for evaluating a condition in a movie scene, taking advantage of any cacheing that may apply. */
305};
306
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#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
EMovieSceneKeyInterpolation
Definition KeyParams.h:12
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Actor.h:257
Definition NameTypes.h:617
Definition Text.h:385
Definition MovieSceneCommonHelpers.h:39
static MOVIESCENE_API USceneComponent * SceneComponentFromRuntimeObject(UObject *Object)
Definition MovieSceneCommonHelpers.cpp:545
static MOVIESCENE_API void SortConsecutiveSections(TArray< UMovieSceneSection * > &Sections)
Definition MovieSceneCommonHelpers.cpp:256
static MOVIESCENE_API UObject * ResolveSceneComponentBoundObject(UObject *Object)
Definition MovieSceneCommonHelpers.cpp:540
static MOVIESCENE_API TArray< UObject * > GetBoundObjects(const FMovieSceneSequenceID &SequenceID, const FGuid &ObjectId, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState, int32 BindingIndex=0)
Definition MovieSceneCommonHelpers.cpp:918
static TSharedRef< UE::MovieScene::FSharedPlaybackState > MOVIESCENE_API CreateTransientSharedPlaybackState(UObject *WorldContext, UMovieSceneSequence *Sequence)
Definition MovieSceneCommonHelpers.cpp:1152
static bool SortLowerBounds(TRangeBound< FFrameNumber > A, TRangeBound< FFrameNumber > B)
Definition MovieSceneCommonHelpers.h:175
static MOVIESCENE_API bool FixupConsecutiveSections(TArray< UMovieSceneSection * > &Sections, UMovieSceneSection &Section, bool bDelete, bool bCleanUp=false)
Definition MovieSceneCommonHelpers.cpp:261
static MOVIESCENE_API UMovieSceneSection * FindPreviousSection(TArrayView< UMovieSceneSection *const > Sections, FFrameNumber Time)
Definition MovieSceneCommonHelpers.cpp:209
static MOVIESCENE_API UMovieSceneSection * FindNearestSectionAtTime(TArrayView< UMovieSceneSection *const > Sections, FFrameNumber Time, int32 RowIndex=INDEX_NONE)
Definition MovieSceneCommonHelpers.cpp:125
static void MOVIESCENE_API GetPrioritySortedCustomBindingTypes(TArray< const TSubclassOf< UMovieSceneCustomBinding > > &OutCustomBindingTypes)
Definition MovieSceneCommonHelpers.cpp:1126
static MOVIESCENE_API FString MakeUniqueBindingName(UMovieScene *InMovieScene, const FString &InName)
Definition MovieSceneCommonHelpers.cpp:690
static MOVIESCENE_API float CalculateWeightForBlending(UMovieSceneSection *SectionToKey, FFrameNumber Time)
Definition MovieSceneCommonHelpers.cpp:624
static MOVIESCENE_API bool EvaluateSequenceCondition(const FGuid &BindingID, const FMovieSceneSequenceID &SequenceID, const UMovieSceneCondition *Condition, UObject *ConditionOwnerObject, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState)
Definition MovieSceneCommonHelpers.cpp:1256
static MOVIESCENE_API bool IsSectionKeyable(const UMovieSceneSection *)
Definition MovieSceneCommonHelpers.cpp:92
static bool SortUpperBounds(TRangeBound< FFrameNumber > A, TRangeBound< FFrameNumber > B)
Definition MovieSceneCommonHelpers.h:183
static MOVIESCENE_API void GetDescendantMovieScenes(UMovieSceneSequence *InSequence, TArray< UMovieScene * > &InMovieScenes)
Definition MovieSceneCommonHelpers.cpp:495
static MOVIESCENE_API void GetDescendantSubSections(const UMovieScene *InMovieScene, TArray< UMovieSceneSubSection * > &InSubSections)
Definition MovieSceneCommonHelpers.cpp:519
static MOVIESCENE_API UCameraComponent * CameraComponentFromRuntimeObject(UObject *RuntimeObject)
Definition MovieSceneCommonHelpers.cpp:586
static MOVIESCENE_API bool IsBoundToSpawnable(UMovieSceneSequence *Sequence, const FGuid &ObjectId, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState, int32 BindingIndex=0)
Definition MovieSceneCommonHelpers.cpp:820
static MOVIESCENE_API UMovieSceneSection * FindSectionAtTime(TArrayView< UMovieSceneSection *const > Sections, FFrameNumber Time, int32 RowIndex=INDEX_NONE)
Definition MovieSceneCommonHelpers.cpp:108
static MOVIESCENE_API bool FixupConsecutiveBlendingSections(TArray< UMovieSceneSection * > &Sections, UMovieSceneSection &Section, bool bDelete, bool bCleanUp=false)
Definition MovieSceneCommonHelpers.cpp:347
static MOVIESCENE_API bool IsBoundToAnySpawnable(UMovieSceneSequence *Sequence, const FGuid &ObjectId, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState)
Definition MovieSceneCommonHelpers.cpp:797
static MOVIESCENE_API bool SupportsObjectTemplate(UMovieSceneSequence *Sequence, const FGuid &ObjectId, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState, int32 BindingIndex=0)
Definition MovieSceneCommonHelpers.cpp:1030
static MOVIESCENE_API UObject * MakeSpawnableTemplateFromInstance(UObject &InSourceObject, UMovieScene *InMovieScene, FName InName)
Definition MovieSceneCommonHelpers.cpp:758
static MOVIESCENE_API FGuid TryCreateCustomSpawnableBinding(UMovieSceneSequence *Sequence, UObject *CustomBindingObject)
Definition MovieSceneCommonHelpers.cpp:845
static MOVIESCENE_API UObject * GetObjectTemplate(UMovieSceneSequence *Sequence, const FGuid &ObjectId, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState, int32 BindingIndex=0)
Definition MovieSceneCommonHelpers.cpp:974
static MOVIESCENE_API bool SetObjectTemplate(UMovieSceneSequence *Sequence, const FGuid &ObjectId, UObject *InSourceObject, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState, int32 BindingIndex=0)
Definition MovieSceneCommonHelpers.cpp:1001
static MOVIESCENE_API const UMovieSceneCondition * GetSequenceCondition(const UMovieSceneTrack *Track, const UMovieSceneSection *Section, bool bFromCompilation=false)
Definition MovieSceneCommonHelpers.cpp:1196
static MOVIESCENE_API UObject * GetResolutionContext(UMovieSceneSequence *Sequence, const FGuid &ObjectId, const FMovieSceneSequenceID &SequenceID, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState)
Definition MovieSceneCommonHelpers.cpp:1168
static MOVIESCENE_API UCameraComponent * CameraComponentFromActor(const AActor *InActor)
Definition MovieSceneCommonHelpers.cpp:563
static MOVIESCENE_API float GetSoundDuration(USoundBase *Sound)
Definition MovieSceneCommonHelpers.cpp:608
static MOVIESCENE_API bool CopyObjectTemplate(UMovieSceneSequence *Sequence, const FGuid &ObjectId, UObject *InSourceObject, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState, int32 BindingIndex=0)
Definition MovieSceneCommonHelpers.cpp:1060
static MOVIESCENE_API bool SortOverlappingSections(const UMovieSceneSection *A, const UMovieSceneSection *B)
Definition MovieSceneCommonHelpers.cpp:249
static MOVIESCENE_API FText GetDisplayPathName(const UMovieSceneTrack *Track)
Definition MovieSceneCommonHelpers.cpp:31
static MOVIESCENE_API void SetRuntimeObjectMobility(UObject *Object, EComponentMobility::Type ComponentMobility=EComponentMobility::Movable)
static MOVIESCENE_API UObject * GetSingleBoundObject(UMovieSceneSequence *Sequence, const FGuid &ObjectId, TSharedRef< const UE::MovieScene::FSharedPlaybackState > SharedPlaybackState, int32 BindingIndex=0)
Definition MovieSceneCommonHelpers.cpp:902
static MOVIESCENE_API UMovieSceneSection * FindNextSection(TArrayView< UMovieSceneSection *const > Sections, FFrameNumber Time)
Definition MovieSceneCommonHelpers.cpp:169
static MOVIESCENE_API FString MakeUniqueSpawnableName(UMovieScene *InMovieScene, const FString &InName)
Definition MovieSceneCommonHelpers.cpp:726
Definition MovieScene.Build.cs:6
Definition ArrayView.h:139
Definition Array.h:670
Definition RangeBound.h:36
static const TRangeBound & MinLower(const TRangeBound &A, const TRangeBound &B)
Definition RangeBound.h:300
static const TRangeBound & MinUpper(const TRangeBound &A, const TRangeBound &B)
Definition RangeBound.h:318
Definition SharedPointer.h:153
Definition SubclassOf.h:30
Definition Class.h:3793
Definition MovieSceneCondition.h:88
Definition MovieSceneCustomBinding.h:62
Definition MovieSceneSection.h:243
Definition MovieSceneSequence.h:73
Definition MovieSceneSubSection.h:96
Definition MovieSceneTrack.h:206
Definition MovieScene.h:358
Definition Object.h:95
Definition SoundBase.h:109
Type
Definition EngineTypes.h:3789
@ Movable
Definition EngineTypes.h:3812
Definition ConstraintsManager.h:14
Definition AdvancedWidgetsModule.cpp:13
Definition FrameNumber.h:18
Definition Guid.h:109
Definition MovieSceneChannel.h:112
Definition MovieSceneSequenceID.h:13
Definition RichCurve.h:200
Definition MovieSceneCommonHelpers.h:50
virtual MOVIESCENE_API ~FMovieSceneScopedPackageDirtyGuard()
Definition MovieSceneCommonHelpers.cpp:1277