// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Channels/ChannelCurveModel.h" #include "Channels/MovieSceneChannelHandle.h" #include "Channels/MovieSceneDoubleChannel.h" #include "Channels/MovieSceneFloatChannel.h" #include "Containers/Array.h" #include "Containers/ArrayView.h" #include "Containers/UnrealString.h" #include "CoreTypes.h" #include "CurveEditorTypes.h" #include "Curves/KeyHandle.h" #include "IBufferedCurveModel.h" #include "Misc/NotNull.h" #include "MovieSceneSection.h" #include "Templates/SharedPointer.h" #include "Templates/Tuple.h" #include "UObject/UnrealType.h" #include "UObject/WeakObjectPtr.h" #include "UObject/WeakObjectPtrTemplates.h" class FCurveEditor; class ISequencer; class UMovieSceneSection; struct FCurveAttributes; struct FCurveEditorScreenSpace; struct FKeyAttributes; struct FKeyDrawInfo; struct FKeyPosition; namespace UE::MovieSceneTools { template class FMovieSceneCachedCurve; } /** * Buffered curve implementation for a bezier curve model, stores a copy of the bezier curve channel in order to draw itself. */ template class FBezierChannelBufferedCurveModel : public IBufferedCurveModel { public: /** Create a copy of the channel while keeping the reference to the section */ FBezierChannelBufferedCurveModel(const ChannelType* InChannel, TWeakObjectPtr InWeakSection, TArray&& InKeyPositions, TArray&& InKeyAttributes, const FString& InLongDisplayName, const double InValueMin, const double InValueMax); virtual void DrawCurve(const FCurveEditor& InCurveEditor, const FCurveEditorScreenSpace& InScreenSpace, TArray>& OutInterpolatingPoints) const override; virtual bool Evaluate(double InTime, double& OutValue) const override; private: ChannelType Channel; TWeakObjectPtr WeakSection; }; /** * Implementation of a bezier curve model. */ template class FBezierChannelCurveModel : public FChannelCurveModel { using Super = FChannelCurveModel; public: FBezierChannelCurveModel(TMovieSceneChannelHandle InChannel, UMovieSceneSection* InOwningSection, TWeakPtr InWeakSequencer); FBezierChannelCurveModel(TMovieSceneChannelHandle InChannel, UMovieSceneSection* InOwningSection, UObject* InOwningObject, TWeakPtr InWeakSequencer); // FCurveModel virtual void DrawCurve(const FCurveEditor& CurveEditor, const FCurveEditorScreenSpace& ScreenSpace, TArray>& InterpolatingPoints) const override; virtual UE::CurveEditor::ICurveEditorCurveCachePool* DrawCurveToCachePool(const TSharedRef& CurveEditor, const UE::CurveEditor::FCurveDrawParamsHandle& CurveDrawParamsHandle, const FCurveEditorScreenSpace& ScreenSpace) override; virtual bool HasChangedAndResetTest() override; virtual void GetKeyDrawInfo(ECurvePointType PointType, const FKeyHandle InKeyHandle, FKeyDrawInfo& OutDrawInfo) const override; virtual void GetKeyAttributes(TArrayView InKeys, TArrayView OutAttributes) const override; virtual void GetKeyAttributesExcludingAutoComputed(TArrayView InKeys, TArrayView OutAttributes) const override; virtual void SetKeyAttributes(TArrayView InKeys, TArrayView InAttributes, EPropertyChangeType::Type ChangeType = EPropertyChangeType::Unspecified) override; virtual TPair GetInterpolationMode(const double& InTime, ERichCurveInterpMode DefaultInterpolationMode, ERichCurveTangentMode DefaultTangentMode) const override; virtual void GetCurveAttributes(FCurveAttributes& OutCurveAttributes) const override; virtual void SetCurveAttributes(const FCurveAttributes& InCurveAttributes) override; virtual void GetValueRange(double& MinValue, double& MaxValue) const override; virtual void GetValueRange(double InMinTime, double InMaxTime, double& MinValue, double& MaxValue) const override; protected: // FChannelCurveModel virtual double GetKeyValue(TArrayView Values, int32 Index) const override; virtual void SetKeyValue(int32 Index, double KeyValue) const override; TSharedPtr> CachedCurve; /** * Updates all dependent systems after a change has been made to owning object. * Calls MarkAsChanged, dirties the package, and FCurveModel::OnCurvesModified. */ void OnPostOwnerChanged(TNotNull InSignedOwner); private: void FeaturePointMethod(double StartTime, double EndTime, double StartValue, double Mu, int Depth, int MaxDepth, double& MaxV, double& MinVal) const; };