Files
UnrealEngineUWP/Engine/Source/Editor/MovieSceneTools/Private/Channels/FloatChannelCurveModel.cpp
christopher waters 99ec480304 Cleaning up dependencies with select heavy-hitter headers in MovieScene and addressing the fallout from that.
MovieScene was targeted as its headers were at the top of profiling ShooterGame builds.
Tested with -disableunity and -nopch. Current timings take ShooterGameEditor rebuild from 480s to 440s

#jira none
#rb josh.adams
#preflight 624c97a63661c8f04a191889

[CL 19634779 by christopher waters in ue5-main branch]
2022-04-05 18:58:45 -04:00

86 lines
3.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Channels/FloatChannelCurveModel.h"
#include "Channels/FloatChannelKeyProxy.h"
#include "CurveEditorScreenSpace.h"
#include "MovieScene.h"
/**
* Buffered curve implementation for a float channel curve model, stores a copy of the float channel in order to draw itself.
*/
class FFloatChannelBufferedCurveModel : public IBufferedCurveModel
{
public:
/** Create a copy of the float channel while keeping the reference to the section */
FFloatChannelBufferedCurveModel(const FMovieSceneFloatChannel* InMovieSceneFloatChannel, TWeakObjectPtr<UMovieSceneSection> InWeakSection,
TArray<FKeyPosition>&& InKeyPositions, TArray<FKeyAttributes>&& InKeyAttributes, const FString& InLongDisplayName, const double InValueMin, const double InValueMax)
: IBufferedCurveModel(MoveTemp(InKeyPositions), MoveTemp(InKeyAttributes), InLongDisplayName, InValueMin, InValueMax)
, Channel(*InMovieSceneFloatChannel)
, WeakSection(InWeakSection)
{}
virtual void DrawCurve(const FCurveEditor& InCurveEditor, const FCurveEditorScreenSpace& InScreenSpace, TArray<TTuple<double, double>>& OutInterpolatingPoints) const override
{
UMovieSceneSection* Section = WeakSection.Get();
if (Section && Section->GetTypedOuter<UMovieScene>())
{
FFrameRate TickResolution = Section->GetTypedOuter<UMovieScene>()->GetTickResolution();
const double StartTimeSeconds = InScreenSpace.GetInputMin();
const double EndTimeSeconds = InScreenSpace.GetInputMax();
const double TimeThreshold = FMath::Max(0.0001, 1.0 / InScreenSpace.PixelsPerInput());
const double ValueThreshold = FMath::Max(0.0001, 1.0 / InScreenSpace.PixelsPerOutput());
Channel.PopulateCurvePoints(StartTimeSeconds, EndTimeSeconds, TimeThreshold, ValueThreshold, TickResolution, OutInterpolatingPoints);
}
}
private:
FMovieSceneFloatChannel Channel;
TWeakObjectPtr<UMovieSceneSection> WeakSection;
};
FFloatChannelCurveModel::FFloatChannelCurveModel(TMovieSceneChannelHandle<FMovieSceneFloatChannel> InChannel, UMovieSceneSection* OwningSection, TWeakPtr<ISequencer> InWeakSequencer)
: FBezierChannelCurveModel<FMovieSceneFloatChannel, FMovieSceneFloatValue, float>(InChannel, OwningSection, InWeakSequencer)
{
}
void FFloatChannelCurveModel::CreateKeyProxies(TArrayView<const FKeyHandle> InKeyHandles, TArrayView<UObject*> OutObjects)
{
for (int32 Index = 0; Index < InKeyHandles.Num(); ++Index)
{
UFloatChannelKeyProxy* NewProxy = NewObject<UFloatChannelKeyProxy>(GetTransientPackage(), NAME_None);
NewProxy->Initialize(InKeyHandles[Index], GetChannelHandle(), Cast<UMovieSceneSection>(GetOwningObject()));
OutObjects[Index] = NewProxy;
}
}
TUniquePtr<IBufferedCurveModel> FFloatChannelCurveModel::CreateBufferedCurveCopy() const
{
FMovieSceneFloatChannel* Channel = GetChannelHandle().Get();
if (Channel)
{
TArray<FKeyHandle> TargetKeyHandles;
TMovieSceneChannelData<FMovieSceneFloatValue> ChannelData = Channel->GetData();
TRange<FFrameNumber> TotalRange = ChannelData.GetTotalRange();
ChannelData.GetKeys(TotalRange, nullptr, &TargetKeyHandles);
TArray<FKeyPosition> KeyPositions;
KeyPositions.SetNumUninitialized(GetNumKeys());
TArray<FKeyAttributes> KeyAttributes;
KeyAttributes.SetNumUninitialized(GetNumKeys());
GetKeyPositions(TargetKeyHandles, KeyPositions);
GetKeyAttributes(TargetKeyHandles, KeyAttributes);
double ValueMin = 0.f, ValueMax = 1.f;
GetValueRange(ValueMin, ValueMax);
return MakeUnique<FFloatChannelBufferedCurveModel>(Channel, Cast<UMovieSceneSection>(GetOwningObject()), MoveTemp(KeyPositions), MoveTemp(KeyAttributes), GetLongDisplayName().ToString(), ValueMin, ValueMax);
}
return nullptr;
}