Files
UnrealEngineUWP/Engine/Source/Editor/Sequencer/Public/SequencerKeyCollection.h
Marc Audy 11f5b21210 Merging //UE5/Release-Engine-Staging @ 13752110 to Main (//UE5/Main)
#rnx

[CL 13753156 by Marc Audy in ue5-main branch]
2020-06-23 18:40:00 -04:00

128 lines
4.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreTypes.h"
#include "Containers/ContainersFwd.h"
#include "Misc/Guid.h"
#include "Templates/SharedPointer.h"
#include "Misc/FrameNumber.h"
class UMovieSceneSection;
class FSequencerDisplayNode;
class IKeyArea;
template<typename> struct TOptional;
template<typename> class TRange;
/** Enumeration used to define how to search for keys */
enum class EFindKeyDirection
{
Backwards, Forwards
};
struct FSequencerKeyCollectionSignature
{
FSequencerKeyCollectionSignature()
{}
/** Initialize this key collection from the specified nodes. Only gathers keys from those explicitly specified. */
SEQUENCER_API static FSequencerKeyCollectionSignature FromNodes(const TArray<FSequencerDisplayNode*>& InNodes, FFrameNumber InDuplicateThreshold);
/** Initialize this key collection from the specified nodes. Gathers keys from all child nodes. */
SEQUENCER_API static FSequencerKeyCollectionSignature FromNodesRecursive(const TArray<FSequencerDisplayNode*>& InNodes, FFrameNumber InDuplicateThreshold);
/** Initialize this key collection from the specified node and section index. */
SEQUENCER_API static FSequencerKeyCollectionSignature FromNodeRecursive(FSequencerDisplayNode& InNode, UMovieSceneSection* InSection, FFrameNumber InDuplicateThreshold);
/** Compare this signature for inequality with another */
SEQUENCER_API friend bool operator!=(const FSequencerKeyCollectionSignature& A, const FSequencerKeyCollectionSignature& B);
/** Compare this signature for equality with another */
SEQUENCER_API friend bool operator==(const FSequencerKeyCollectionSignature& A, const FSequencerKeyCollectionSignature& B);
/** Access the map of keyareas and signatures this signature was generated for */
const TMap<TSharedRef<IKeyArea>, FGuid>& GetKeyAreas() const
{
return KeyAreaToSignature;
}
/** Access duplicate threshold that this signature was generated for */
FFrameNumber GetDuplicateThreshold() const
{
return DuplicateThresholdTime;
}
private:
/** Check whether this signature contains content that cannot be cached (such content causes this signature to never compare equal with another) */
bool HasUncachableContent() const;
/** The time at which proximal keys are considered duplicates */
FFrameNumber DuplicateThresholdTime;
/** Map of key areas to the section signature with with this signature was generated */
TMap<TSharedRef<IKeyArea>, FGuid> KeyAreaToSignature;
};
/**
* A collection of keys gathered recursively from a particular node or nodes
*/
class FSequencerKeyCollection
{
public:
/**
* Search forwards or backwards for the first key within the specified range
*
* @param Range The range to search within
* @param Direction Whether to return the first or last key that reside in the given range
* @return (Optional) the time of the key that matched the range
*/
SEQUENCER_API TOptional<FFrameNumber> FindFirstKeyInRange(const TRange<FFrameNumber>& Range, EFindKeyDirection Direction) const;
/**
* Get a view of all key times that reside within the specified range
*
* @param Range The range to search within
* @return A (possibly empty) array view of all the times that lie within the range
*/
SEQUENCER_API TArrayView<const FFrameNumber> GetKeysInRange(const TRange<FFrameNumber>& Range) const;
/**
* Search forwards or backwards for the next key from the specified frame number
* @param FrameNumber The frame number to search from
* @param Direction Whether to return the next key or previous key from that time
* @return (Optional) Frame number of the key that's next or previous from that time
*/
SEQUENCER_API TOptional<FFrameNumber> GetNextKey(FFrameNumber FrameNumber, EFindKeyDirection Direction) const;
/**
* Access the signature this collection was generated with
*
* @return The signature that this collection was generated with
*/
const FSequencerKeyCollectionSignature& GetSignature() const
{
return Signature;
}
public:
/**
* Update this key collection using the specified signature
*
* @param InSignature The signature to generate keys for, containing all key areas to use for the generation
* @return true if this collection was updated, or false if it was already up to date
*/
bool Update(const FSequencerKeyCollectionSignature& InSignature);
private:
/** Times grouped by the supplied threshold */
TArray<FFrameNumber> GroupedTimes;
/** The signature with which the above array was generated */
FSequencerKeyCollectionSignature Signature;
};