2014-03-14 14:13:41 -04:00
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
# include "ComponentVisualizersPrivatePCH.h"
# include "SplineComponentVisualizer.h"
2014-06-27 14:18:10 -04:00
# include "ScopedTransaction.h"
2014-03-14 14:13:41 -04:00
2014-05-16 09:37:22 -04:00
IMPLEMENT_HIT_PROXY ( HSplineVisProxy , HComponentVisProxy ) ;
IMPLEMENT_HIT_PROXY ( HSplineKeyProxy , HSplineVisProxy ) ;
2014-07-23 09:40:19 -04:00
IMPLEMENT_HIT_PROXY ( HSplineSegmentProxy , HSplineVisProxy ) ;
2014-05-16 09:37:22 -04:00
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
# define LOCTEXT_NAMESPACE "SplineComponentVisualizer"
/** Define commands for the spline component visualizer */
class FSplineComponentVisualizerCommands : public TCommands < FSplineComponentVisualizerCommands >
{
public :
FSplineComponentVisualizerCommands ( ) : TCommands < FSplineComponentVisualizerCommands >
(
" SplineComponentVisualizer " , // Context name for fast lookup
LOCTEXT ( " SplineComponentVisualizer " , " Spline Component Visualizer " ) , // Localized context name for displaying
NAME_None , // Parent
FEditorStyle : : GetStyleSetName ( )
)
{
}
2014-06-13 06:14:46 -04:00
virtual void RegisterCommands ( ) override
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
{
2014-07-23 09:40:19 -04:00
UI_COMMAND ( DeleteKey , " Delete Spline Point " , " Delete the currently selected spline point. " , EUserInterfaceActionType : : Button , FInputGesture ( EKeys : : Delete ) ) ;
UI_COMMAND ( DuplicateKey , " Duplicate Spline Point " , " Duplicate the currently selected spline point. " , EUserInterfaceActionType : : Button , FInputGesture ( ) ) ;
UI_COMMAND ( AddKey , " Add Spline Point Here " , " Add a new spline point at the cursor location. " , EUserInterfaceActionType : : Button , FInputGesture ( ) ) ;
UI_COMMAND ( ResetToUnclampedTangent , " Unclamped Tangent " , " Reset the tangent for this spline point to its default unclamped value. " , EUserInterfaceActionType : : Button , FInputGesture ( ) ) ;
UI_COMMAND ( ResetToClampedTangent , " Clamped Tangent " , " Reset the tangent for this spline point to its default clamped value. " , EUserInterfaceActionType : : Button , FInputGesture ( ) ) ;
UI_COMMAND ( SetKeyToCurve , " Curve " , " Set spline point to Curve type " , EUserInterfaceActionType : : RadioButton , FInputGesture ( ) ) ;
UI_COMMAND ( SetKeyToLinear , " Linear " , " Set spline point to Linear type " , EUserInterfaceActionType : : RadioButton , FInputGesture ( ) ) ;
UI_COMMAND ( SetKeyToConstant , " Constant " , " Set spline point to Constant type " , EUserInterfaceActionType : : RadioButton , FInputGesture ( ) ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
public :
/** Delete key */
TSharedPtr < FUICommandInfo > DeleteKey ;
/** Duplicate key */
TSharedPtr < FUICommandInfo > DuplicateKey ;
2014-07-23 09:40:19 -04:00
/** Add key */
TSharedPtr < FUICommandInfo > AddKey ;
2014-06-27 14:18:10 -04:00
/** Reset to unclamped tangent */
TSharedPtr < FUICommandInfo > ResetToUnclampedTangent ;
/** Reset to clamped tangent */
TSharedPtr < FUICommandInfo > ResetToClampedTangent ;
/** Set spline key to Curve type */
TSharedPtr < FUICommandInfo > SetKeyToCurve ;
/** Set spline key to Linear type */
TSharedPtr < FUICommandInfo > SetKeyToLinear ;
/** Set spline key to Constant type */
TSharedPtr < FUICommandInfo > SetKeyToConstant ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
} ;
FSplineComponentVisualizer : : FSplineComponentVisualizer ( )
: FComponentVisualizer ( )
, SelectedKeyIndex ( INDEX_NONE )
2014-07-23 09:40:19 -04:00
, SelectedSegmentIndex ( INDEX_NONE )
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
, bAllowDuplication ( true )
{
FSplineComponentVisualizerCommands : : Register ( ) ;
SplineComponentVisualizerActions = MakeShareable ( new FUICommandList ) ;
}
void FSplineComponentVisualizer : : OnRegister ( )
{
const auto & Commands = FSplineComponentVisualizerCommands : : Get ( ) ;
SplineComponentVisualizerActions - > MapAction (
Commands . DeleteKey ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnDeleteKey ) ,
2014-10-01 11:14:01 -04:00
FCanExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : CanDeleteKey ) ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
SplineComponentVisualizerActions - > MapAction (
Commands . DuplicateKey ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnDuplicateKey ) ,
2014-07-23 09:40:19 -04:00
FCanExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : IsKeySelectionValid ) ) ;
SplineComponentVisualizerActions - > MapAction (
Commands . AddKey ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnAddKey ) ,
FCanExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : CanAddKey ) ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
SplineComponentVisualizerActions - > MapAction (
2014-06-27 14:18:10 -04:00
Commands . ResetToUnclampedTangent ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnResetToAutomaticTangent , CIM_CurveAuto ) ,
FCanExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : CanResetToAutomaticTangent , CIM_CurveAuto ) ) ;
SplineComponentVisualizerActions - > MapAction (
Commands . ResetToClampedTangent ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnResetToAutomaticTangent , CIM_CurveAutoClamped ) ,
FCanExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : CanResetToAutomaticTangent , CIM_CurveAutoClamped ) ) ;
SplineComponentVisualizerActions - > MapAction (
Commands . SetKeyToCurve ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnSetKeyType , CIM_CurveAuto ) ,
FCanExecuteAction ( ) ,
FIsActionChecked : : CreateSP ( this , & FSplineComponentVisualizer : : IsKeyTypeSet , CIM_CurveAuto ) ) ;
SplineComponentVisualizerActions - > MapAction (
Commands . SetKeyToLinear ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnSetKeyType , CIM_Linear ) ,
FCanExecuteAction ( ) ,
FIsActionChecked : : CreateSP ( this , & FSplineComponentVisualizer : : IsKeyTypeSet , CIM_Linear ) ) ;
SplineComponentVisualizerActions - > MapAction (
Commands . SetKeyToConstant ,
FExecuteAction : : CreateSP ( this , & FSplineComponentVisualizer : : OnSetKeyType , CIM_Constant ) ,
FCanExecuteAction ( ) ,
FIsActionChecked : : CreateSP ( this , & FSplineComponentVisualizer : : IsKeyTypeSet , CIM_Constant ) ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
FSplineComponentVisualizer : : ~ FSplineComponentVisualizer ( )
{
FSplineComponentVisualizerCommands : : Unregister ( ) ;
}
2014-05-16 09:37:22 -04:00
2014-03-14 14:13:41 -04:00
void FSplineComponentVisualizer : : DrawVisualization ( const UActorComponent * Component , const FSceneView * View , FPrimitiveDrawInterface * PDI )
{
if ( const USplineComponent * SplineComp = Cast < const USplineComponent > ( Component ) )
{
2014-06-27 14:18:10 -04:00
if ( ! SplineComp - > bAllowSplineEditingPerInstance )
{
return ;
}
2014-07-23 09:40:19 -04:00
USplineComponent * EditedSplineComp = GetEditedSplineComponent ( ) ;
const FColor NormalColor ( 255 , 255 , 255 ) ;
2014-06-11 00:20:55 -04:00
const FColor SelectedColor ( 255 , 0 , 0 ) ;
const float GrabHandleSize = 12.0f ;
2014-05-16 09:37:22 -04:00
const FInterpCurveVector & SplineInfo = SplineComp - > SplineInfo ;
FVector OldKeyPos ( 0 ) ;
float OldKeyTime = 0.f ;
2014-10-01 11:14:01 -04:00
for ( int32 KeyIdx = 0 ; KeyIdx < SplineInfo . Points . Num ( ) ; KeyIdx + + )
2014-05-16 09:37:22 -04:00
{
float NewKeyTime = SplineInfo . Points [ KeyIdx ] . InVal ;
FVector NewKeyPos = SplineComp - > ComponentToWorld . TransformPosition ( SplineInfo . Eval ( NewKeyTime , FVector : : ZeroVector ) ) ;
2014-07-23 09:40:19 -04:00
const FColor KeyColor = ( SplineComp = = EditedSplineComp & & KeyIdx = = SelectedKeyIndex ) ? SelectedColor : NormalColor ;
2014-05-16 09:37:22 -04:00
// Draw the keypoint
2014-10-01 11:14:01 -04:00
if ( ! SplineComp - > IsClosedLoop ( ) | | KeyIdx < SplineInfo . Points . Num ( ) - 1 )
{
PDI - > SetHitProxy ( new HSplineKeyProxy ( Component , KeyIdx ) ) ;
PDI - > DrawPoint ( NewKeyPos , KeyColor , GrabHandleSize , SDPG_Foreground ) ;
PDI - > SetHitProxy ( NULL ) ;
}
2014-05-16 09:37:22 -04:00
2014-06-11 00:20:55 -04:00
// If not the first keypoint, draw a line to the previous keypoint.
2014-05-16 09:37:22 -04:00
if ( KeyIdx > 0 )
{
2014-07-23 09:40:19 -04:00
const FColor LineColor = ( SplineComp = = EditedSplineComp & & KeyIdx = = SelectedKeyIndex + 1 ) ? SelectedColor : NormalColor ;
PDI - > SetHitProxy ( new HSplineSegmentProxy ( Component , KeyIdx - 1 ) ) ;
2014-05-16 09:37:22 -04:00
// For constant interpolation - don't draw ticks - just draw dotted line.
if ( SplineInfo . Points [ KeyIdx - 1 ] . InterpMode = = CIM_Constant )
{
2014-07-23 09:40:19 -04:00
DrawDashedLine ( PDI , OldKeyPos , NewKeyPos , LineColor , 20 , SDPG_World ) ;
2014-05-16 09:37:22 -04:00
}
else
{
2014-07-23 09:40:19 -04:00
int32 NumSteps = FMath : : CeilToInt ( ( NewKeyTime - OldKeyTime ) * 32.0f ) ;
2014-05-16 09:37:22 -04:00
float DrawSubstep = ( NewKeyTime - OldKeyTime ) / NumSteps ;
// Find position on first keyframe.
float OldTime = OldKeyTime ;
FVector OldPos = OldKeyPos ;
// Then draw a line for each substep.
for ( int32 StepIdx = 1 ; StepIdx < NumSteps + 1 ; StepIdx + + )
{
float NewTime = OldKeyTime + StepIdx * DrawSubstep ;
FVector NewPos = SplineComp - > ComponentToWorld . TransformPosition ( SplineInfo . Eval ( NewTime , FVector : : ZeroVector ) ) ;
2014-07-23 09:40:19 -04:00
PDI - > DrawLine ( OldPos , NewPos , LineColor , SDPG_Foreground ) ;
2014-05-16 09:37:22 -04:00
OldTime = NewTime ;
OldPos = NewPos ;
}
}
2014-07-23 09:40:19 -04:00
PDI - > SetHitProxy ( NULL ) ;
2014-05-16 09:37:22 -04:00
}
OldKeyTime = NewKeyTime ;
OldKeyPos = NewKeyPos ;
}
2014-03-14 14:13:41 -04:00
}
}
2014-05-16 09:37:22 -04:00
2014-07-23 09:40:19 -04:00
bool FSplineComponentVisualizer : : VisProxyHandleClick ( FLevelEditorViewportClient * InViewportClient , HComponentVisProxy * VisProxy , const FViewportClick & Click )
2014-05-16 09:37:22 -04:00
{
bool bEditing = false ;
if ( VisProxy & & VisProxy - > Component . IsValid ( ) )
{
const USplineComponent * SplineComp = CastChecked < const USplineComponent > ( VisProxy - > Component . Get ( ) ) ;
SplineCompPropName = GetComponentPropertyName ( SplineComp ) ;
if ( SplineCompPropName ! = NAME_None )
{
SplineOwningActor = SplineComp - > GetOwner ( ) ;
if ( VisProxy - > IsA ( HSplineKeyProxy : : StaticGetType ( ) ) )
{
HSplineKeyProxy * KeyProxy = ( HSplineKeyProxy * ) VisProxy ;
SelectedKeyIndex = KeyProxy - > KeyIndex ;
2014-07-23 09:40:19 -04:00
SelectedSegmentIndex = INDEX_NONE ;
bEditing = true ;
}
else if ( VisProxy - > IsA ( HSplineSegmentProxy : : StaticGetType ( ) ) )
{
// Divide segment into subsegments and test each subsegment against ray representing click position and camera direction.
// Closest encounter with the spline determines the spline position.
const int32 NumSubdivisions = 16 ;
HSplineSegmentProxy * SegmentProxy = ( HSplineSegmentProxy * ) VisProxy ;
SelectedKeyIndex = SegmentProxy - > SegmentIndex ;
SelectedSegmentIndex = SegmentProxy - > SegmentIndex ;
float SubsegmentStartKey = static_cast < float > ( SelectedSegmentIndex ) ;
FVector SubsegmentStart = SplineComp - > ComponentToWorld . TransformPosition ( SplineComp - > SplineInfo . Eval ( SubsegmentStartKey , FVector : : ZeroVector ) ) ;
float ClosestDistance = TNumericLimits < float > : : Max ( ) ;
FVector BestLocation = SubsegmentStart ;
for ( int32 Step = 1 ; Step < NumSubdivisions ; Step + + )
{
const float SubsegmentEndKey = SelectedSegmentIndex + Step / static_cast < float > ( NumSubdivisions ) ;
const FVector SubsegmentEnd = SplineComp - > ComponentToWorld . TransformPosition ( SplineComp - > SplineInfo . Eval ( SubsegmentEndKey , FVector : : ZeroVector ) ) ;
FVector SplineClosest ;
FVector RayClosest ;
FMath : : SegmentDistToSegmentSafe ( SubsegmentStart , SubsegmentEnd , Click . GetOrigin ( ) , Click . GetOrigin ( ) + Click . GetDirection ( ) * 50000.0f , SplineClosest , RayClosest ) ;
const float Distance = FVector : : DistSquared ( SplineClosest , RayClosest ) ;
if ( Distance < ClosestDistance )
{
ClosestDistance = Distance ;
BestLocation = SplineClosest ;
}
SubsegmentStartKey = SubsegmentEndKey ;
SubsegmentStart = SubsegmentEnd ;
}
SelectedSplinePosition = BestLocation ;
2014-05-16 09:37:22 -04:00
bEditing = true ;
}
}
else
{
SplineOwningActor = NULL ;
}
}
return bEditing ;
}
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
USplineComponent * FSplineComponentVisualizer : : GetEditedSplineComponent ( ) const
2014-05-16 09:37:22 -04:00
{
return Cast < USplineComponent > ( GetComponentFromPropertyName ( SplineOwningActor . Get ( ) , SplineCompPropName ) ) ;
}
2014-07-23 09:40:19 -04:00
bool FSplineComponentVisualizer : : GetWidgetLocation ( const FEditorViewportClient * ViewportClient , FVector & OutLocation ) const
2014-05-16 09:37:22 -04:00
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
if ( SplineComp & & SelectedKeyIndex ! = INDEX_NONE )
{
if ( SelectedKeyIndex < SplineComp - > SplineInfo . Points . Num ( ) )
{
OutLocation = SplineComp - > ComponentToWorld . TransformPosition ( SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . OutVal ) ;
return true ;
}
}
return false ;
}
2014-07-23 09:40:19 -04:00
bool FSplineComponentVisualizer : : GetCustomInputCoordinateSystem ( const FEditorViewportClient * ViewportClient , FMatrix & OutMatrix ) const
{
if ( ViewportClient - > GetWidgetCoordSystemSpace ( ) = = COORD_Local )
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
if ( SplineComp & & SelectedKeyIndex ! = INDEX_NONE )
{
if ( SelectedKeyIndex < SplineComp - > SplineInfo . Points . Num ( ) )
{
const auto & Point = SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] ;
2014-10-01 11:14:01 -04:00
const FVector Tangent = Point . ArriveTangent . IsNearlyZero ( ) ? FVector ( 1.0f , 0.0f , 0.0f ) : Point . ArriveTangent . SafeNormal ( ) ;
const FVector Bitangent = ( Tangent . Z = = 1.0f ) ? FVector ( 1.0f , 0.0f , 0.0f ) : FVector ( - Tangent . Y , Tangent . X , 0.0f ) . SafeNormal ( ) ;
2014-07-23 09:40:19 -04:00
const FVector Normal = FVector : : CrossProduct ( Tangent , Bitangent ) ;
OutMatrix = FMatrix ( Tangent , Bitangent , Normal , FVector : : ZeroVector ) * FQuatRotationTranslationMatrix ( SplineComp - > ComponentToWorld . GetRotation ( ) , FVector : : ZeroVector ) ;
return true ;
}
}
}
return false ;
}
2014-06-18 10:16:16 -04:00
bool FSplineComponentVisualizer : : HandleInputDelta ( FEditorViewportClient * ViewportClient , FViewport * Viewport , FVector & DeltaTranslate , FRotator & DeltaRotate , FVector & DeltaScale )
2014-05-16 09:37:22 -04:00
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
2014-10-01 11:14:01 -04:00
const int32 NumPoints = SplineComp - > SplineInfo . Points . Num ( ) ;
if ( SplineComp & &
2014-05-16 09:37:22 -04:00
SelectedKeyIndex ! = INDEX_NONE & &
2014-10-01 11:14:01 -04:00
SelectedKeyIndex < NumPoints )
2014-05-16 09:37:22 -04:00
{
if ( ViewportClient - > IsAltPressed ( ) & & bAllowDuplication )
{
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
OnDuplicateKey ( ) ;
2014-05-16 09:37:22 -04:00
// Don't duplicate again until we release LMB
bAllowDuplication = false ;
}
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
FInterpCurvePoint < FVector > & EditedPoint = SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] ;
if ( ! DeltaTranslate . IsZero ( ) )
{
// Find key position in world space
FVector CurrentWorldPos = SplineComp - > ComponentToWorld . TransformPosition ( EditedPoint . OutVal ) ;
// Move in world space
FVector NewWorldPos = CurrentWorldPos + DeltaTranslate ;
// Convert back to local space
EditedPoint . OutVal = SplineComp - > ComponentToWorld . InverseTransformPosition ( NewWorldPos ) ;
}
if ( ! DeltaRotate . IsZero ( ) )
{
// Set point tangent as user controlled
EditedPoint . InterpMode = CIM_CurveUser ;
// Rotate tangent according to delta rotation
const FVector NewTangent = DeltaRotate . RotateVector ( EditedPoint . LeaveTangent ) ;
EditedPoint . LeaveTangent = NewTangent ;
EditedPoint . ArriveTangent = NewTangent ;
}
2014-07-23 09:40:19 -04:00
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
if ( ! DeltaScale . IsZero ( ) )
{
// Set point tangent as user controlled
EditedPoint . InterpMode = CIM_CurveUser ;
// Break tangent into direction and length so we can change its scale (the 'tension')
// independently of its direction.
FVector Direction ;
float Length ;
EditedPoint . LeaveTangent . ToDirectionAndLength ( Direction , Length ) ;
// Figure out which component has changed, and use it
float DeltaScaleValue = ( DeltaScale . X ! = 0.0f ) ? DeltaScale . X : ( ( DeltaScale . Y ! = 0.0f ) ? DeltaScale . Y : DeltaScale . Z ) ;
// Change scale, avoiding singularity by never allowing a scale of 0, hence preserving direction.
Length + = DeltaScaleValue * 10.0f ;
if ( Length = = 0.0f )
{
Length = SMALL_NUMBER ;
}
const FVector NewTangent = Direction * Length ;
EditedPoint . LeaveTangent = NewTangent ;
EditedPoint . ArriveTangent = NewTangent ;
}
2014-05-16 09:37:22 -04:00
2014-10-01 11:14:01 -04:00
// Duplicate first point to last point if it is a closed loop
if ( SplineComp - > IsClosedLoop ( ) & & SelectedKeyIndex = = 0 & & NumPoints > 0 )
{
SplineComp - > SplineInfo . Points [ NumPoints - 1 ] . OutVal = EditedPoint . OutVal ;
SplineComp - > SplineInfo . Points [ NumPoints - 1 ] . LeaveTangent = EditedPoint . LeaveTangent ;
SplineComp - > SplineInfo . Points [ NumPoints - 1 ] . ArriveTangent = EditedPoint . ArriveTangent ;
}
2014-06-11 00:20:55 -04:00
NotifyComponentModified ( ) ;
2014-05-19 11:37:55 -04:00
2014-05-16 09:37:22 -04:00
return true ;
}
return false ;
}
2014-06-18 10:16:16 -04:00
bool FSplineComponentVisualizer : : HandleInputKey ( FEditorViewportClient * ViewportClient , FViewport * Viewport , FKey Key , EInputEvent Event )
2014-05-16 09:37:22 -04:00
{
bool bHandled = false ;
Improvements to SplineComponent, and added a new way of handling UI Command Lists.
#add Added a new FUICommandList::ProcessCommandBindings overload, which can be called from a Viewport Client's InputKey() method (in the absence of an FKeyboardEvent object).
#add Fixed key binding handling in SplineComponentVisualizer so that it works through the FUICommandList, instead of being hardcoded.
#change USplineComponent - changed method by which spline reparam table is created (now uses the old method of splitting each segment into a fixed number of steps, instead of using fixed arc length reparameterization, which doesn't lead to such good results where the distance between control points varies largely throughout the spline). The ReparamStepsPerSegment parameter remains, although I'd like to remove it when I can hit upon a better way to adaptively step through the spline. Merged UpdateSplineReparamTable and AutoSetTangents into a single UpdateSpline method.
#add Added a parameter to FInterpCurve::AutoSetTangents - bStationaryEndpoints - which determines whether the endpoints should be assigned zero tangents, or whether the tangents should be set in order to extrapolate the curve beyond the endpoints, essentially providing a constant velocity at the start/end.
#add Added bStationaryEndpoints as an editable parameter to USplineComponent. Use this if you only wish to traverse the spline at constant velocity, as it will lead to more accurate results.
#codereview James.Golding, Michael.Noland
[CL 2112073 by Richard TalbotWatkin in Main branch]
2014-06-20 14:38:07 -04:00
if ( Key = = EKeys : : LeftMouseButton & & Event = = IE_Released )
2014-05-16 09:37:22 -04:00
{
// Reset duplication flag on LMB release
bAllowDuplication = true ;
}
Improvements to SplineComponent, and added a new way of handling UI Command Lists.
#add Added a new FUICommandList::ProcessCommandBindings overload, which can be called from a Viewport Client's InputKey() method (in the absence of an FKeyboardEvent object).
#add Fixed key binding handling in SplineComponentVisualizer so that it works through the FUICommandList, instead of being hardcoded.
#change USplineComponent - changed method by which spline reparam table is created (now uses the old method of splitting each segment into a fixed number of steps, instead of using fixed arc length reparameterization, which doesn't lead to such good results where the distance between control points varies largely throughout the spline). The ReparamStepsPerSegment parameter remains, although I'd like to remove it when I can hit upon a better way to adaptively step through the spline. Merged UpdateSplineReparamTable and AutoSetTangents into a single UpdateSpline method.
#add Added a parameter to FInterpCurve::AutoSetTangents - bStationaryEndpoints - which determines whether the endpoints should be assigned zero tangents, or whether the tangents should be set in order to extrapolate the curve beyond the endpoints, essentially providing a constant velocity at the start/end.
#add Added bStationaryEndpoints as an editable parameter to USplineComponent. Use this if you only wish to traverse the spline at constant velocity, as it will lead to more accurate results.
#codereview James.Golding, Michael.Noland
[CL 2112073 by Richard TalbotWatkin in Main branch]
2014-06-20 14:38:07 -04:00
if ( Event = = IE_Pressed )
2014-05-16 09:37:22 -04:00
{
Improvements to SplineComponent, and added a new way of handling UI Command Lists.
#add Added a new FUICommandList::ProcessCommandBindings overload, which can be called from a Viewport Client's InputKey() method (in the absence of an FKeyboardEvent object).
#add Fixed key binding handling in SplineComponentVisualizer so that it works through the FUICommandList, instead of being hardcoded.
#change USplineComponent - changed method by which spline reparam table is created (now uses the old method of splitting each segment into a fixed number of steps, instead of using fixed arc length reparameterization, which doesn't lead to such good results where the distance between control points varies largely throughout the spline). The ReparamStepsPerSegment parameter remains, although I'd like to remove it when I can hit upon a better way to adaptively step through the spline. Merged UpdateSplineReparamTable and AutoSetTangents into a single UpdateSpline method.
#add Added a parameter to FInterpCurve::AutoSetTangents - bStationaryEndpoints - which determines whether the endpoints should be assigned zero tangents, or whether the tangents should be set in order to extrapolate the curve beyond the endpoints, essentially providing a constant velocity at the start/end.
#add Added bStationaryEndpoints as an editable parameter to USplineComponent. Use this if you only wish to traverse the spline at constant velocity, as it will lead to more accurate results.
#codereview James.Golding, Michael.Noland
[CL 2112073 by Richard TalbotWatkin in Main branch]
2014-06-20 14:38:07 -04:00
bHandled = SplineComponentVisualizerActions - > ProcessCommandBindings ( Key , FSlateApplication : : Get ( ) . GetModifierKeys ( ) , false ) ;
2014-05-16 09:37:22 -04:00
}
return bHandled ;
}
void FSplineComponentVisualizer : : EndEditing ( )
{
SplineOwningActor = NULL ;
SplineCompPropName = NAME_None ;
SelectedKeyIndex = INDEX_NONE ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
void FSplineComponentVisualizer : : OnDuplicateKey ( )
{
2014-07-23 09:40:19 -04:00
const FScopedTransaction Transaction ( LOCTEXT ( " DuplicateSplinePoint " , " Duplicate Spline Point " ) ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
2014-06-27 14:18:10 -04:00
if ( AActor * Owner = SplineComp - > GetOwner ( ) )
{
Owner - > Modify ( ) ;
}
2014-10-01 11:14:01 -04:00
const bool bWasLoop = SplineComp - > IsClosedLoop ( ) ;
SplineComp - > SetClosedLoop ( false ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
FInterpCurvePoint < FVector > KeyToDupe = SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] ;
KeyToDupe . InterpMode = CIM_CurveAuto ;
int32 NewKeyIndex = SplineComp - > SplineInfo . Points . Insert ( KeyToDupe , SelectedKeyIndex ) ;
// move selection to 'next' key
SelectedKeyIndex + + ;
// Update Input value for all keys
SplineComp - > RefreshSplineInputs ( ) ;
2014-10-01 11:14:01 -04:00
SplineComp - > SetClosedLoop ( bWasLoop ) ;
2014-06-11 00:20:55 -04:00
NotifyComponentModified ( ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
2014-06-27 14:18:10 -04:00
2014-07-23 09:40:19 -04:00
bool FSplineComponentVisualizer : : CanAddKey ( ) const
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
return ( SplineComp & &
SelectedSegmentIndex ! = INDEX_NONE & &
SelectedSegmentIndex < SplineComp - > SplineInfo . Points . Num ( ) - 1 ) ;
}
void FSplineComponentVisualizer : : OnAddKey ( )
{
const FScopedTransaction Transaction ( LOCTEXT ( " AddSplinePoint " , " Add Spline Point " ) ) ;
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
if ( AActor * Owner = SplineComp - > GetOwner ( ) )
{
Owner - > Modify ( ) ;
}
2014-10-01 11:14:01 -04:00
const bool bWasLoop = SplineComp - > IsClosedLoop ( ) ;
SplineComp - > SetClosedLoop ( false ) ;
2014-07-23 09:40:19 -04:00
FInterpCurvePoint < FVector > NewKey ;
NewKey . InVal = SelectedSegmentIndex ;
NewKey . OutVal = SplineComp - > ComponentToWorld . InverseTransformPosition ( SelectedSplinePosition ) ;
NewKey . InterpMode = CIM_CurveAuto ;
int32 NewKeyIndex = SplineComp - > SplineInfo . Points . Insert ( NewKey , SelectedSegmentIndex + 1 ) ;
// move selection to 'next' key
SelectedKeyIndex = SelectedSegmentIndex + 1 ;
SelectedSegmentIndex = INDEX_NONE ;
// Update Input value for all keys
SplineComp - > RefreshSplineInputs ( ) ;
2014-10-01 11:14:01 -04:00
SplineComp - > SetClosedLoop ( bWasLoop ) ;
2014-07-23 09:40:19 -04:00
NotifyComponentModified ( ) ;
}
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
void FSplineComponentVisualizer : : OnDeleteKey ( )
{
2014-07-23 09:40:19 -04:00
const FScopedTransaction Transaction ( LOCTEXT ( " DeleteSplinePoint " , " Delete Spline Point " ) ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
2014-06-27 14:18:10 -04:00
if ( AActor * Owner = SplineComp - > GetOwner ( ) )
{
Owner - > Modify ( ) ;
}
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
2014-10-01 11:14:01 -04:00
const bool bWasLoop = SplineComp - > IsClosedLoop ( ) ;
SplineComp - > SetClosedLoop ( false ) ;
2014-06-27 14:18:10 -04:00
SplineComp - > SplineInfo . Points . RemoveAt ( SelectedKeyIndex ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
SplineComp - > RefreshSplineInputs ( ) ; // update input value for each key
2014-06-27 14:18:10 -04:00
2014-10-01 11:14:01 -04:00
SplineComp - > SetClosedLoop ( bWasLoop ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
SelectedKeyIndex = INDEX_NONE ; // deselect any keys
2014-07-23 09:40:19 -04:00
SelectedSegmentIndex = INDEX_NONE ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
2014-06-11 00:20:55 -04:00
NotifyComponentModified ( ) ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
2014-06-27 14:18:10 -04:00
2014-10-01 11:14:01 -04:00
bool FSplineComponentVisualizer : : CanDeleteKey ( ) const
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
return ( SplineComp & &
SplineComp - > SplineInfo . Points . Num ( ) > = 2 & &
SelectedSegmentIndex = = INDEX_NONE & &
SelectedKeyIndex ! = INDEX_NONE & &
SelectedKeyIndex < SplineComp - > SplineInfo . Points . Num ( ) ) ;
}
2014-07-23 09:40:19 -04:00
bool FSplineComponentVisualizer : : IsKeySelectionValid ( ) const
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
return ( SplineComp & &
2014-07-23 09:40:19 -04:00
SelectedSegmentIndex = = INDEX_NONE & &
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
SelectedKeyIndex ! = INDEX_NONE & &
SelectedKeyIndex < SplineComp - > SplineInfo . Points . Num ( ) ) ;
}
2014-06-27 14:18:10 -04:00
void FSplineComponentVisualizer : : OnResetToAutomaticTangent ( EInterpCurveMode Mode )
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
2014-06-27 14:18:10 -04:00
if ( SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . InterpMode ! = Mode )
{
const FScopedTransaction Transaction ( LOCTEXT ( " ResetToAutomaticTangent " , " Reset to Automatic Tangent " ) ) ;
if ( AActor * Owner = SplineComp - > GetOwner ( ) )
{
Owner - > Modify ( ) ;
}
2014-10-01 11:14:01 -04:00
const bool bWasLoop = SplineComp - > IsClosedLoop ( ) ;
SplineComp - > SetClosedLoop ( false ) ;
2014-06-27 14:18:10 -04:00
SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . InterpMode = Mode ;
2014-10-01 11:14:01 -04:00
SplineComp - > SetClosedLoop ( bWasLoop ) ;
2014-06-27 14:18:10 -04:00
NotifyComponentModified ( ) ;
}
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
2014-06-27 14:18:10 -04:00
bool FSplineComponentVisualizer : : CanResetToAutomaticTangent ( EInterpCurveMode Mode ) const
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
return ( SplineComp & &
SelectedKeyIndex ! = INDEX_NONE & &
SelectedKeyIndex < SplineComp - > SplineInfo . Points . Num ( ) & &
2014-06-27 14:18:10 -04:00
SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . IsCurveKey ( ) & &
SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . InterpMode ! = Mode ) ;
}
void FSplineComponentVisualizer : : OnSetKeyType ( EInterpCurveMode Mode )
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
if ( SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . InterpMode ! = Mode )
{
2014-07-23 09:40:19 -04:00
const FScopedTransaction Transaction ( LOCTEXT ( " SetSplinePointType " , " Set Spline Point Type " ) ) ;
2014-06-27 14:18:10 -04:00
if ( AActor * Owner = SplineComp - > GetOwner ( ) )
{
Owner - > Modify ( ) ;
}
2014-10-01 11:14:01 -04:00
const bool bWasLoop = SplineComp - > IsClosedLoop ( ) ;
SplineComp - > SetClosedLoop ( false ) ;
2014-06-27 14:18:10 -04:00
SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . InterpMode = Mode ;
2014-10-01 11:14:01 -04:00
SplineComp - > SetClosedLoop ( bWasLoop ) ;
2014-06-27 14:18:10 -04:00
NotifyComponentModified ( ) ;
}
}
bool FSplineComponentVisualizer : : IsKeyTypeSet ( EInterpCurveMode Mode ) const
{
2014-07-23 09:40:19 -04:00
if ( IsKeySelectionValid ( ) )
2014-06-27 14:18:10 -04:00
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
const auto & SelectedPoint = SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] ;
return ( ( Mode = = CIM_CurveAuto & & SelectedPoint . IsCurveKey ( ) ) | | SelectedPoint . InterpMode = = Mode ) ;
}
return false ;
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
TSharedPtr < SWidget > FSplineComponentVisualizer : : GenerateContextMenu ( ) const
{
FMenuBuilder MenuBuilder ( true , SplineComponentVisualizerActions ) ;
{
MenuBuilder . BeginSection ( " SplineKeyEdit " ) ;
{
2014-07-23 09:40:19 -04:00
if ( SelectedSegmentIndex ! = INDEX_NONE )
2014-06-27 14:18:10 -04:00
{
2014-07-23 09:40:19 -04:00
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . AddKey ) ;
}
else if ( SelectedKeyIndex ! = INDEX_NONE )
{
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . DeleteKey ) ;
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . DuplicateKey ) ;
2014-06-27 14:18:10 -04:00
MenuBuilder . AddSubMenu (
2014-07-23 09:40:19 -04:00
LOCTEXT ( " SplinePointType " , " Spline Point Type " ) ,
LOCTEXT ( " KeyTypeTooltip " , " Define the type of the spline point. " ) ,
FNewMenuDelegate : : CreateSP ( this , & FSplineComponentVisualizer : : GenerateSplinePointTypeSubMenu ) ) ;
// Only add the Automatic Tangents submenu if the key is a curve type
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
if ( SplineComp & &
SelectedKeyIndex < SplineComp - > SplineInfo . Points . Num ( ) & &
SplineComp - > SplineInfo . Points [ SelectedKeyIndex ] . IsCurveKey ( ) )
{
MenuBuilder . AddSubMenu (
LOCTEXT ( " ResetToAutomaticTangent " , " Reset to Automatic Tangent " ) ,
LOCTEXT ( " ResetToAutomaticTangentTooltip " , " Reset the spline point tangent to an automatically generated value. " ) ,
FNewMenuDelegate : : CreateSP ( this , & FSplineComponentVisualizer : : GenerateTangentTypeSubMenu ) ) ;
}
2014-06-27 14:18:10 -04:00
}
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
}
MenuBuilder . EndSection ( ) ;
}
TSharedPtr < SWidget > MenuWidget = MenuBuilder . MakeWidget ( ) ;
return MenuWidget ;
}
2014-06-27 14:18:10 -04:00
void FSplineComponentVisualizer : : GenerateSplinePointTypeSubMenu ( FMenuBuilder & MenuBuilder ) const
{
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . SetKeyToCurve ) ;
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . SetKeyToLinear ) ;
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . SetKeyToConstant ) ;
}
void FSplineComponentVisualizer : : GenerateTangentTypeSubMenu ( FMenuBuilder & MenuBuilder ) const
{
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . ResetToUnclampedTangent ) ;
MenuBuilder . AddMenuEntry ( FSplineComponentVisualizerCommands : : Get ( ) . ResetToClampedTangent ) ;
}
2014-06-11 00:20:55 -04:00
void FSplineComponentVisualizer : : NotifyComponentModified ( )
{
USplineComponent * SplineComp = GetEditedSplineComponent ( ) ;
Improvements to SplineComponent, and added a new way of handling UI Command Lists.
#add Added a new FUICommandList::ProcessCommandBindings overload, which can be called from a Viewport Client's InputKey() method (in the absence of an FKeyboardEvent object).
#add Fixed key binding handling in SplineComponentVisualizer so that it works through the FUICommandList, instead of being hardcoded.
#change USplineComponent - changed method by which spline reparam table is created (now uses the old method of splitting each segment into a fixed number of steps, instead of using fixed arc length reparameterization, which doesn't lead to such good results where the distance between control points varies largely throughout the spline). The ReparamStepsPerSegment parameter remains, although I'd like to remove it when I can hit upon a better way to adaptively step through the spline. Merged UpdateSplineReparamTable and AutoSetTangents into a single UpdateSpline method.
#add Added a parameter to FInterpCurve::AutoSetTangents - bStationaryEndpoints - which determines whether the endpoints should be assigned zero tangents, or whether the tangents should be set in order to extrapolate the curve beyond the endpoints, essentially providing a constant velocity at the start/end.
#add Added bStationaryEndpoints as an editable parameter to USplineComponent. Use this if you only wish to traverse the spline at constant velocity, as it will lead to more accurate results.
#codereview James.Golding, Michael.Noland
[CL 2112073 by Richard TalbotWatkin in Main branch]
2014-06-20 14:38:07 -04:00
SplineComp - > UpdateSpline ( ) ;
2014-06-11 00:20:55 -04:00
// Notify that the spline info has been modified
UProperty * SplineInfoProperty = FindField < UProperty > ( USplineComponent : : StaticClass ( ) , GET_MEMBER_NAME_CHECKED ( USplineComponent , SplineInfo ) ) ;
FPropertyChangedEvent PropertyChangedEvent ( SplineInfoProperty ) ;
SplineComp - > PostEditChangeProperty ( PropertyChangedEvent ) ;
// Notify of change so any CS is re-run
if ( SplineOwningActor . IsValid ( ) )
{
SplineOwningActor . Get ( ) - > PostEditMove ( true ) ;
}
GEditor - > RedrawLevelEditingViewports ( true ) ;
}
Improvements to SplineComponent and its visualization.
#branch UE4
#proj Editor.ComponentVisualizers, Editor.UnrealEd, Runtime.Core, Runtime.Engine
#change FInterpCurve now uses a binary search to obtain the correct key. Removed the optional out-parameter on Eval, EvalDerivative, etc. Removed FORCEINLINEs on large methods.
#change USplineComponent now builds the remap table with points spaced at equal distances, which leads to better results. Added internal methods to obtain the segment length, and the interpolation parameter along the segment at a given distance.
#add Added Duration to USplineComponent.
#add Added a number of different methods for obtaining position, tangent and rotation at a specified distance, or a specified time (optionally at constant velocity).
#add Added methods for building the spline procedurally.
#add Supports right-click context menu on ComponentVisualizers in the standard interface.
#add Key tangents can be manually edited.
#change FLevelEditorViewportClient::ProcessClick now handles right clicks to the Unreal gizmo in the same manner as left clicks, i.e. the method recurses using a version of the hit proxy with the gizmo removed, so we can look at what's underneath. This allows for "genuine" context menus, i.e. depending on what was clicked, instead of using a single default provided by the current level editor.
#reviewedby James.Golding
[CL 2089561 by Richard TalbotWatkin in Main branch]
2014-05-30 07:58:16 -04:00
# undef LOCTEXT_NAMESPACE