Files
UnrealEngineUWP/Engine/Source/Editor/CurveEditor/Private/SCurveEditorView.cpp

294 lines
10 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
This is a significant overhaul to the Curve Editor used by Sequencer which adds a plugin-based architecture and extensibility. New tools and toolbar buttons can be added to all usages of the curve editor via user plugins, and the different views for data can be created modularly so new implementations of the editor can register their own way of drawing their data and the tools should just work. Additionally, you can now write your own filters to operate on curve editor data for custom implementations of smoothing, key generation, etc. The curve editor supports three view types by default - an absolute view (default, matches old behavior), a stacked view and a normalized view. Stacked views draw each curve separately (so non-overlapping) and normalized against their own min/max values. The normalized view draws all curves overlapping with each one normalized against its own min/max values. A tree view has been added to help effectively manage large numbers of curves. Selecting curves in the treeview controls which curves are visible in the view area. The treeview also supports pinning curves. These pinned curves will always be visible regardless of your selection in the tree view. A transform tool and a retiming tool have been implemented (via a plugin) which is enabled by default. The transform tool allows you to do a marquee selection of keys and then translate and scale the positions of these keys. The retiming tool allows you to create a 1 dimensional lattice to adjust the timing of your keys with a linear falloff between each lattice point. These tools work across multiple views at the same time which is especially useful if you are representing one dimensional data (such as event keys) in a view, as it allows you to adjust this data at the same time as your animation curves. A smoothing filter has been implemented (via a plugin) to allow running highpass and lowpass filters on your keys. Opening the curve editor in Sequencer/UMG now creates a separate dockable tab which can be resized and docked as desired. A time slider has been added to the Curve Editor which is synchronized to the playback time in Sequencer. This allows you to scrub time in the curve editor without having to find the Sequencer window and adjust time there while looking at your keys and previewing your animation in the viewport at the same time. Rudimentary support has been added for saving and later restoring a set of curves in your current session. This allows you to do a rudimentary copy/paste of entire curves but can also be useful for saving a curve, making adjustments to it and then deciding you want to go back - simply reapply the saved curve! Each curve added supports an intention name (such as "Location.X" or "FieldOfView"), and these intention names will be used when trying to apply curves. This allows you to reliably take all of the curves of a transform on one object and apply them to another object (and ensure that Location.X gets applied to the new Location.X, etc.) this can be helpful if you have a mixed set of curves buffered (such as a location and a field of view). In the event that no curves match by intention you can store and apply a single curve at a time from any intention to any other intention. The Curve Asset editors (float, vector and color curve assets) have been changed to use the new editor. They support the same treeviews, filtering and tools that the Sequencer editor does. In addition, the Color Curve asset editor adds an additional view which provides a 1 dimensional gradient editor as an easier way to visualize and edit colors instead of the channels individually. #rb Max.Chen, Andrew.Rodham #ROBOMERGE-SOURCE: CL 6631811 via CL 6633746 #ROBOMERGE-BOT: (vundefined-6620334) [CL 6633863 by matt hoffman in Main branch]
2019-05-24 14:42:05 -04:00
#include "SCurveEditorView.h"
#include "ICurveEditorBounds.h"
#include "CurveEditor.h"
#include "ICurveEditorModule.h"
#include "CurveEditorScreenSpace.h"
#include "CurveModel.h"
#include "CurveEditorSnapMetrics.h"
#include "SCurveEditorPanel.h"
#include "CurveEditorSettings.h"
#include "CurveEditorHelpers.h"
This is a significant overhaul to the Curve Editor used by Sequencer which adds a plugin-based architecture and extensibility. New tools and toolbar buttons can be added to all usages of the curve editor via user plugins, and the different views for data can be created modularly so new implementations of the editor can register their own way of drawing their data and the tools should just work. Additionally, you can now write your own filters to operate on curve editor data for custom implementations of smoothing, key generation, etc. The curve editor supports three view types by default - an absolute view (default, matches old behavior), a stacked view and a normalized view. Stacked views draw each curve separately (so non-overlapping) and normalized against their own min/max values. The normalized view draws all curves overlapping with each one normalized against its own min/max values. A tree view has been added to help effectively manage large numbers of curves. Selecting curves in the treeview controls which curves are visible in the view area. The treeview also supports pinning curves. These pinned curves will always be visible regardless of your selection in the tree view. A transform tool and a retiming tool have been implemented (via a plugin) which is enabled by default. The transform tool allows you to do a marquee selection of keys and then translate and scale the positions of these keys. The retiming tool allows you to create a 1 dimensional lattice to adjust the timing of your keys with a linear falloff between each lattice point. These tools work across multiple views at the same time which is especially useful if you are representing one dimensional data (such as event keys) in a view, as it allows you to adjust this data at the same time as your animation curves. A smoothing filter has been implemented (via a plugin) to allow running highpass and lowpass filters on your keys. Opening the curve editor in Sequencer/UMG now creates a separate dockable tab which can be resized and docked as desired. A time slider has been added to the Curve Editor which is synchronized to the playback time in Sequencer. This allows you to scrub time in the curve editor without having to find the Sequencer window and adjust time there while looking at your keys and previewing your animation in the viewport at the same time. Rudimentary support has been added for saving and later restoring a set of curves in your current session. This allows you to do a rudimentary copy/paste of entire curves but can also be useful for saving a curve, making adjustments to it and then deciding you want to go back - simply reapply the saved curve! Each curve added supports an intention name (such as "Location.X" or "FieldOfView"), and these intention names will be used when trying to apply curves. This allows you to reliably take all of the curves of a transform on one object and apply them to another object (and ensure that Location.X gets applied to the new Location.X, etc.) this can be helpful if you have a mixed set of curves buffered (such as a location and a field of view). In the event that no curves match by intention you can store and apply a single curve at a time from any intention to any other intention. The Curve Asset editors (float, vector and color curve assets) have been changed to use the new editor. They support the same treeviews, filtering and tools that the Sequencer editor does. In addition, the Color Curve asset editor adds an additional view which provides a 1 dimensional gradient editor as an easier way to visualize and edit colors instead of the channels individually. #rb Max.Chen, Andrew.Rodham #ROBOMERGE-SOURCE: CL 6631811 via CL 6633746 #ROBOMERGE-BOT: (vundefined-6620334) [CL 6633863 by matt hoffman in Main branch]
2019-05-24 14:42:05 -04:00
SCurveEditorView::SCurveEditorView()
: bPinned(0)
, bInteractive(1)
, bFixedOutputBounds(0)
, bAutoSize(1)
, bAllowEmpty(0)
{}
FVector2D SCurveEditorView::ComputeDesiredSize(float LayoutScaleMultiplier) const
{
FVector2D ContentDesiredSize = SCompoundWidget::ComputeDesiredSize(LayoutScaleMultiplier);
return FVector2D(ContentDesiredSize.X, FixedHeight.Get(ContentDesiredSize.Y));
}
void SCurveEditorView::GetInputBounds(double& OutInputMin, double& OutInputMax) const
{
TSharedPtr<FCurveEditor> CurveEditor = WeakCurveEditor.Pin();
if (CurveEditor)
{
CurveEditor->GetBounds().GetInputBounds(OutInputMin, OutInputMax);
// This code assumes no scaling between the container and the view (which is a pretty safe assumption to make)
const FGeometry& ViewGeometry = GetCachedGeometry();
const FGeometry ContainerGeometry = CurveEditor->GetPanel().IsValid() ? CurveEditor->GetPanel()->GetViewContainerGeometry() : ViewGeometry;
This is a significant overhaul to the Curve Editor used by Sequencer which adds a plugin-based architecture and extensibility. New tools and toolbar buttons can be added to all usages of the curve editor via user plugins, and the different views for data can be created modularly so new implementations of the editor can register their own way of drawing their data and the tools should just work. Additionally, you can now write your own filters to operate on curve editor data for custom implementations of smoothing, key generation, etc. The curve editor supports three view types by default - an absolute view (default, matches old behavior), a stacked view and a normalized view. Stacked views draw each curve separately (so non-overlapping) and normalized against their own min/max values. The normalized view draws all curves overlapping with each one normalized against its own min/max values. A tree view has been added to help effectively manage large numbers of curves. Selecting curves in the treeview controls which curves are visible in the view area. The treeview also supports pinning curves. These pinned curves will always be visible regardless of your selection in the tree view. A transform tool and a retiming tool have been implemented (via a plugin) which is enabled by default. The transform tool allows you to do a marquee selection of keys and then translate and scale the positions of these keys. The retiming tool allows you to create a 1 dimensional lattice to adjust the timing of your keys with a linear falloff between each lattice point. These tools work across multiple views at the same time which is especially useful if you are representing one dimensional data (such as event keys) in a view, as it allows you to adjust this data at the same time as your animation curves. A smoothing filter has been implemented (via a plugin) to allow running highpass and lowpass filters on your keys. Opening the curve editor in Sequencer/UMG now creates a separate dockable tab which can be resized and docked as desired. A time slider has been added to the Curve Editor which is synchronized to the playback time in Sequencer. This allows you to scrub time in the curve editor without having to find the Sequencer window and adjust time there while looking at your keys and previewing your animation in the viewport at the same time. Rudimentary support has been added for saving and later restoring a set of curves in your current session. This allows you to do a rudimentary copy/paste of entire curves but can also be useful for saving a curve, making adjustments to it and then deciding you want to go back - simply reapply the saved curve! Each curve added supports an intention name (such as "Location.X" or "FieldOfView"), and these intention names will be used when trying to apply curves. This allows you to reliably take all of the curves of a transform on one object and apply them to another object (and ensure that Location.X gets applied to the new Location.X, etc.) this can be helpful if you have a mixed set of curves buffered (such as a location and a field of view). In the event that no curves match by intention you can store and apply a single curve at a time from any intention to any other intention. The Curve Asset editors (float, vector and color curve assets) have been changed to use the new editor. They support the same treeviews, filtering and tools that the Sequencer editor does. In addition, the Color Curve asset editor adds an additional view which provides a 1 dimensional gradient editor as an easier way to visualize and edit colors instead of the channels individually. #rb Max.Chen, Andrew.Rodham #ROBOMERGE-SOURCE: CL 6631811 via CL 6633746 #ROBOMERGE-BOT: (vundefined-6620334) [CL 6633863 by matt hoffman in Main branch]
2019-05-24 14:42:05 -04:00
const float ContainerWidth = ContainerGeometry.GetLocalSize().X;
const float ViewWidth = ViewGeometry.GetLocalSize().X;
if (ViewWidth > 0.f)
{
const float LeftPixelCrop = ViewGeometry.LocalToAbsolute(FVector2D(0.f, 0.f)).X - ContainerGeometry.LocalToAbsolute(FVector2D(0.f, 0.f)).X;
const float RightPixelCrop = ContainerGeometry.LocalToAbsolute(FVector2D(ContainerWidth, 0.f)).X - ViewGeometry.LocalToAbsolute(FVector2D(ViewWidth, 0.f)).X;
This is a significant overhaul to the Curve Editor used by Sequencer which adds a plugin-based architecture and extensibility. New tools and toolbar buttons can be added to all usages of the curve editor via user plugins, and the different views for data can be created modularly so new implementations of the editor can register their own way of drawing their data and the tools should just work. Additionally, you can now write your own filters to operate on curve editor data for custom implementations of smoothing, key generation, etc. The curve editor supports three view types by default - an absolute view (default, matches old behavior), a stacked view and a normalized view. Stacked views draw each curve separately (so non-overlapping) and normalized against their own min/max values. The normalized view draws all curves overlapping with each one normalized against its own min/max values. A tree view has been added to help effectively manage large numbers of curves. Selecting curves in the treeview controls which curves are visible in the view area. The treeview also supports pinning curves. These pinned curves will always be visible regardless of your selection in the tree view. A transform tool and a retiming tool have been implemented (via a plugin) which is enabled by default. The transform tool allows you to do a marquee selection of keys and then translate and scale the positions of these keys. The retiming tool allows you to create a 1 dimensional lattice to adjust the timing of your keys with a linear falloff between each lattice point. These tools work across multiple views at the same time which is especially useful if you are representing one dimensional data (such as event keys) in a view, as it allows you to adjust this data at the same time as your animation curves. A smoothing filter has been implemented (via a plugin) to allow running highpass and lowpass filters on your keys. Opening the curve editor in Sequencer/UMG now creates a separate dockable tab which can be resized and docked as desired. A time slider has been added to the Curve Editor which is synchronized to the playback time in Sequencer. This allows you to scrub time in the curve editor without having to find the Sequencer window and adjust time there while looking at your keys and previewing your animation in the viewport at the same time. Rudimentary support has been added for saving and later restoring a set of curves in your current session. This allows you to do a rudimentary copy/paste of entire curves but can also be useful for saving a curve, making adjustments to it and then deciding you want to go back - simply reapply the saved curve! Each curve added supports an intention name (such as "Location.X" or "FieldOfView"), and these intention names will be used when trying to apply curves. This allows you to reliably take all of the curves of a transform on one object and apply them to another object (and ensure that Location.X gets applied to the new Location.X, etc.) this can be helpful if you have a mixed set of curves buffered (such as a location and a field of view). In the event that no curves match by intention you can store and apply a single curve at a time from any intention to any other intention. The Curve Asset editors (float, vector and color curve assets) have been changed to use the new editor. They support the same treeviews, filtering and tools that the Sequencer editor does. In addition, the Color Curve asset editor adds an additional view which provides a 1 dimensional gradient editor as an easier way to visualize and edit colors instead of the channels individually. #rb Max.Chen, Andrew.Rodham #ROBOMERGE-SOURCE: CL 6631811 via CL 6633746 #ROBOMERGE-BOT: (vundefined-6620334) [CL 6633863 by matt hoffman in Main branch]
2019-05-24 14:42:05 -04:00
const double ContainerInputPerPixel = (OutInputMax - OutInputMin) / ContainerWidth;
This is a significant overhaul to the Curve Editor used by Sequencer which adds a plugin-based architecture and extensibility. New tools and toolbar buttons can be added to all usages of the curve editor via user plugins, and the different views for data can be created modularly so new implementations of the editor can register their own way of drawing their data and the tools should just work. Additionally, you can now write your own filters to operate on curve editor data for custom implementations of smoothing, key generation, etc. The curve editor supports three view types by default - an absolute view (default, matches old behavior), a stacked view and a normalized view. Stacked views draw each curve separately (so non-overlapping) and normalized against their own min/max values. The normalized view draws all curves overlapping with each one normalized against its own min/max values. A tree view has been added to help effectively manage large numbers of curves. Selecting curves in the treeview controls which curves are visible in the view area. The treeview also supports pinning curves. These pinned curves will always be visible regardless of your selection in the tree view. A transform tool and a retiming tool have been implemented (via a plugin) which is enabled by default. The transform tool allows you to do a marquee selection of keys and then translate and scale the positions of these keys. The retiming tool allows you to create a 1 dimensional lattice to adjust the timing of your keys with a linear falloff between each lattice point. These tools work across multiple views at the same time which is especially useful if you are representing one dimensional data (such as event keys) in a view, as it allows you to adjust this data at the same time as your animation curves. A smoothing filter has been implemented (via a plugin) to allow running highpass and lowpass filters on your keys. Opening the curve editor in Sequencer/UMG now creates a separate dockable tab which can be resized and docked as desired. A time slider has been added to the Curve Editor which is synchronized to the playback time in Sequencer. This allows you to scrub time in the curve editor without having to find the Sequencer window and adjust time there while looking at your keys and previewing your animation in the viewport at the same time. Rudimentary support has been added for saving and later restoring a set of curves in your current session. This allows you to do a rudimentary copy/paste of entire curves but can also be useful for saving a curve, making adjustments to it and then deciding you want to go back - simply reapply the saved curve! Each curve added supports an intention name (such as "Location.X" or "FieldOfView"), and these intention names will be used when trying to apply curves. This allows you to reliably take all of the curves of a transform on one object and apply them to another object (and ensure that Location.X gets applied to the new Location.X, etc.) this can be helpful if you have a mixed set of curves buffered (such as a location and a field of view). In the event that no curves match by intention you can store and apply a single curve at a time from any intention to any other intention. The Curve Asset editors (float, vector and color curve assets) have been changed to use the new editor. They support the same treeviews, filtering and tools that the Sequencer editor does. In addition, the Color Curve asset editor adds an additional view which provides a 1 dimensional gradient editor as an easier way to visualize and edit colors instead of the channels individually. #rb Max.Chen, Andrew.Rodham #ROBOMERGE-SOURCE: CL 6631811 via CL 6633746 #ROBOMERGE-BOT: (vundefined-6620334) [CL 6633863 by matt hoffman in Main branch]
2019-05-24 14:42:05 -04:00
// Offset by the total range first
OutInputMin += ContainerInputPerPixel * LeftPixelCrop;
OutInputMax -= ContainerInputPerPixel * RightPixelCrop;
}
This is a significant overhaul to the Curve Editor used by Sequencer which adds a plugin-based architecture and extensibility. New tools and toolbar buttons can be added to all usages of the curve editor via user plugins, and the different views for data can be created modularly so new implementations of the editor can register their own way of drawing their data and the tools should just work. Additionally, you can now write your own filters to operate on curve editor data for custom implementations of smoothing, key generation, etc. The curve editor supports three view types by default - an absolute view (default, matches old behavior), a stacked view and a normalized view. Stacked views draw each curve separately (so non-overlapping) and normalized against their own min/max values. The normalized view draws all curves overlapping with each one normalized against its own min/max values. A tree view has been added to help effectively manage large numbers of curves. Selecting curves in the treeview controls which curves are visible in the view area. The treeview also supports pinning curves. These pinned curves will always be visible regardless of your selection in the tree view. A transform tool and a retiming tool have been implemented (via a plugin) which is enabled by default. The transform tool allows you to do a marquee selection of keys and then translate and scale the positions of these keys. The retiming tool allows you to create a 1 dimensional lattice to adjust the timing of your keys with a linear falloff between each lattice point. These tools work across multiple views at the same time which is especially useful if you are representing one dimensional data (such as event keys) in a view, as it allows you to adjust this data at the same time as your animation curves. A smoothing filter has been implemented (via a plugin) to allow running highpass and lowpass filters on your keys. Opening the curve editor in Sequencer/UMG now creates a separate dockable tab which can be resized and docked as desired. A time slider has been added to the Curve Editor which is synchronized to the playback time in Sequencer. This allows you to scrub time in the curve editor without having to find the Sequencer window and adjust time there while looking at your keys and previewing your animation in the viewport at the same time. Rudimentary support has been added for saving and later restoring a set of curves in your current session. This allows you to do a rudimentary copy/paste of entire curves but can also be useful for saving a curve, making adjustments to it and then deciding you want to go back - simply reapply the saved curve! Each curve added supports an intention name (such as "Location.X" or "FieldOfView"), and these intention names will be used when trying to apply curves. This allows you to reliably take all of the curves of a transform on one object and apply them to another object (and ensure that Location.X gets applied to the new Location.X, etc.) this can be helpful if you have a mixed set of curves buffered (such as a location and a field of view). In the event that no curves match by intention you can store and apply a single curve at a time from any intention to any other intention. The Curve Asset editors (float, vector and color curve assets) have been changed to use the new editor. They support the same treeviews, filtering and tools that the Sequencer editor does. In addition, the Color Curve asset editor adds an additional view which provides a 1 dimensional gradient editor as an easier way to visualize and edit colors instead of the channels individually. #rb Max.Chen, Andrew.Rodham #ROBOMERGE-SOURCE: CL 6631811 via CL 6633746 #ROBOMERGE-BOT: (vundefined-6620334) [CL 6633863 by matt hoffman in Main branch]
2019-05-24 14:42:05 -04:00
}
}
FCurveEditorScreenSpace SCurveEditorView::GetViewSpace() const
{
double InputMin = 0.0, InputMax = 1.0;
GetInputBounds(InputMin, InputMax);
return FCurveEditorScreenSpace(GetCachedGeometry().GetLocalSize(), InputMin, InputMax, OutputMin, OutputMax);
}
void SCurveEditorView::AddCurve(FCurveModelID CurveID)
{
CurveInfoByID.Add(CurveID, FCurveInfo{CurveInfoByID.Num()});
OnCurveListChanged();
}
void SCurveEditorView::RemoveCurve(FCurveModelID CurveID)
{
if (FCurveInfo* InfoToRemove = CurveInfoByID.Find(CurveID))
{
const int32 CurveIndex = InfoToRemove->CurveIndex;
InfoToRemove = nullptr;
CurveInfoByID.Remove(CurveID);
for (TTuple<FCurveModelID, FCurveInfo>& Info : CurveInfoByID)
{
if (Info.Value.CurveIndex > CurveIndex)
{
--Info.Value.CurveIndex;
}
}
OnCurveListChanged();
}
}
void SCurveEditorView::SetOutputBounds(double InOutputMin, double InOutputMax)
{
if (!bFixedOutputBounds)
{
OutputMin = InOutputMin;
OutputMax = InOutputMax;
}
}
void SCurveEditorView::Zoom(const FVector2D& Amount)
{
FCurveEditorScreenSpace ViewSpace = GetViewSpace();
const double InputOrigin = (ViewSpace.GetInputMax() - ViewSpace.GetInputMin()) * 0.5;
const double OutputOrigin = (ViewSpace.GetOutputMax() - ViewSpace.GetOutputMin()) * 0.5;
ZoomAround(Amount, InputOrigin, OutputOrigin);
}
void SCurveEditorView::ZoomAround(const FVector2D& Amount, double InputOrigin, double OutputOrigin)
{
TSharedPtr<FCurveEditor> CurveEditor = WeakCurveEditor.Pin();
check(CurveEditor.IsValid());
if (Amount.X != 0.f && CurveEditor.IsValid())
{
double InputMin = 0.0, InputMax = 1.0;
CurveEditor->GetBounds().GetInputBounds(InputMin, InputMax);
InputMin = InputOrigin - (InputOrigin - InputMin) * Amount.X;
InputMax = InputOrigin + (InputMax - InputOrigin) * Amount.X;
CurveEditor->GetBounds().SetInputBounds(InputMin, InputMax);
}
if (Amount.Y != 0.f)
{
OutputMin = OutputOrigin - (OutputOrigin - OutputMin) * Amount.Y;
OutputMax = OutputOrigin + (OutputMax - OutputOrigin) * Amount.Y;
}
}
void SCurveEditorView::GetCurveDrawParams(TArray<FCurveDrawParams>& OutDrawParams) const
{
TSharedPtr<FCurveEditor> CurveEditor = WeakCurveEditor.Pin();
if (!CurveEditor)
{
return;
}
// Get the Min/Max values on the X axis, for Time
double InputMin = 0, InputMax = 1;
GetInputBounds(InputMin, InputMax);
ECurveEditorTangentVisibility TangentVisibility = CurveEditor->GetSettings()->GetTangentVisibility();
OutDrawParams.Reserve(CurveInfoByID.Num());
for (const TTuple<FCurveModelID, FCurveInfo>& Pair : CurveInfoByID)
{
FCurveModel* CurveModel = CurveEditor->FindCurve(Pair.Key);
if (!ensureAlways(CurveModel))
{
continue;
}
FCurveEditorScreenSpace CurveSpace = GetCurveSpace(Pair.Key);
const float DisplayRatio = (CurveSpace.PixelsPerOutput() / CurveSpace.PixelsPerInput());
const FKeyHandleSet* SelectedKeys = CurveEditor->GetSelection().GetAll().Find(Pair.Key);
// Create a new set of Curve Drawing Parameters to represent this particular Curve
FCurveDrawParams Params(Pair.Key);
Params.Color = CurveModel->GetColor();
Params.bKeyDrawEnabled = CurveModel->IsKeyDrawEnabled();
// Gather the display metrics to use for each key type. This allows a Curve Model to override
// whether or not the curve supports Keys, Arrive/Leave Tangents, etc. If the Curve Model doesn't
// support a particular capability we can skip drawing them.
CurveModel->GetKeyDrawInfo(ECurvePointType::ArriveTangent, FKeyHandle::Invalid(), Params.ArriveTangentDrawInfo);
CurveModel->GetKeyDrawInfo(ECurvePointType::LeaveTangent, FKeyHandle::Invalid(), Params.LeaveTangentDrawInfo);
// Gather the interpolating points in input/output space
TArray<TTuple<double, double>> InterpolatingPoints;
CurveModel->DrawCurve(*CurveEditor, CurveSpace, InterpolatingPoints);
Params.InterpolatingPoints.Reserve(InterpolatingPoints.Num());
// An Input Offset allows for a fixed offset to all keys, such as displaying them in the middle of a frame instead of at the start.
double InputOffset = CurveModel->GetInputDisplayOffset();
// Convert the interpolating points to screen space
for (TTuple<double, double> Point : InterpolatingPoints)
{
Params.InterpolatingPoints.Add(
FVector2D(
CurveSpace.SecondsToScreen(Point.Get<0>() + InputOffset),
CurveSpace.ValueToScreen(Point.Get<1>())
)
);
}
TArray<FKeyHandle> VisibleKeys;
CurveModel->GetKeys(*CurveEditor, InputMin, InputMax, TNumericLimits<double>::Lowest(), TNumericLimits<double>::Max(), VisibleKeys);
if (VisibleKeys.Num())
{
TArray<FKeyPosition> AllKeyPositions;
TArray<FKeyAttributes> AllKeyAttributes;
AllKeyPositions.SetNum(VisibleKeys.Num());
AllKeyAttributes.SetNum(VisibleKeys.Num());
CurveModel->GetKeyPositions(VisibleKeys, AllKeyPositions);
CurveModel->GetKeyAttributes(VisibleKeys, AllKeyAttributes);
for (int32 Index = 0; Index < VisibleKeys.Num(); ++Index)
{
const FKeyHandle KeyHandle = VisibleKeys[Index];
const FKeyPosition& KeyPosition = AllKeyPositions[Index];
const FKeyAttributes& Attributes = AllKeyAttributes[Index];
bool bShowTangents = TangentVisibility == ECurveEditorTangentVisibility::AllTangents ||
(TangentVisibility == ECurveEditorTangentVisibility::SelectedKeys && SelectedKeys &&
(SelectedKeys->Contains(VisibleKeys[Index], ECurvePointType::Any) ) );
float TimeScreenPos = CurveSpace.SecondsToScreen(KeyPosition.InputValue + InputOffset);
float ValueScreenPos = CurveSpace.ValueToScreen(KeyPosition.OutputValue);
// Add this key
FCurvePointInfo Key(KeyHandle);
Key.ScreenPosition = FVector2D(TimeScreenPos, ValueScreenPos);
Key.LayerBias = 2;
// Add draw info for the specific key
CurveModel->GetKeyDrawInfo(ECurvePointType::Key, KeyHandle, /*Out*/ Key.DrawInfo);
Params.Points.Add(Key);
if (bShowTangents && Attributes.HasArriveTangent())
{
float ArriveTangent = Attributes.GetArriveTangent();
FCurvePointInfo ArriveTangentPoint(KeyHandle);
ArriveTangentPoint.Type = ECurvePointType::ArriveTangent;
if (Attributes.HasTangentWeightMode() && Attributes.HasArriveTangentWeight() &&
(Attributes.GetTangentWeightMode() == RCTWM_WeightedBoth || Attributes.GetTangentWeightMode() == RCTWM_WeightedArrive))
{
FVector2D TangentOffset = CurveEditor::ComputeScreenSpaceTangentOffset(CurveSpace, ArriveTangent, -Attributes.GetArriveTangentWeight());
ArriveTangentPoint.ScreenPosition = Key.ScreenPosition + TangentOffset;
}
else
{
float PixelLength = 60.0f;
ArriveTangentPoint.ScreenPosition = Key.ScreenPosition + CurveEditor::GetVectorFromSlopeAndLength(ArriveTangent * -DisplayRatio, -PixelLength);
}
ArriveTangentPoint.LineDelta = Key.ScreenPosition - ArriveTangentPoint.ScreenPosition;
ArriveTangentPoint.LayerBias = 1;
// Add draw info for the specific tangent
FKeyDrawInfo TangentDrawInfo;
CurveModel->GetKeyDrawInfo(ECurvePointType::ArriveTangent, KeyHandle, /*Out*/ ArriveTangentPoint.DrawInfo);
Params.Points.Add(ArriveTangentPoint);
}
if (bShowTangents && Attributes.HasLeaveTangent())
{
float LeaveTangent = Attributes.GetLeaveTangent();
FCurvePointInfo LeaveTangentPoint(KeyHandle);
LeaveTangentPoint.Type = ECurvePointType::LeaveTangent;
if (Attributes.HasTangentWeightMode() && Attributes.HasLeaveTangentWeight() &&
(Attributes.GetTangentWeightMode() == RCTWM_WeightedBoth || Attributes.GetTangentWeightMode() == RCTWM_WeightedLeave))
{
FVector2D TangentOffset = CurveEditor::ComputeScreenSpaceTangentOffset(CurveSpace, LeaveTangent, Attributes.GetLeaveTangentWeight());
LeaveTangentPoint.ScreenPosition = Key.ScreenPosition + TangentOffset;
}
else
{
float PixelLength = 60.0f;
LeaveTangentPoint.ScreenPosition = Key.ScreenPosition + CurveEditor::GetVectorFromSlopeAndLength(LeaveTangent * -DisplayRatio, PixelLength);
}
LeaveTangentPoint.LineDelta = Key.ScreenPosition - LeaveTangentPoint.ScreenPosition;
LeaveTangentPoint.LayerBias = 1;
// Add draw info for the specific tangent
FKeyDrawInfo TangentDrawInfo;
CurveModel->GetKeyDrawInfo(ECurvePointType::LeaveTangent, KeyHandle, /*Out*/ LeaveTangentPoint.DrawInfo);
Params.Points.Add(LeaveTangentPoint);
}
}
}
OutDrawParams.Add(MoveTemp(Params));
}
}