@@ -68,6 +68,51 @@ static bool magic_get_frame_number(UMovieScene *MovieScene, PyObject *py_obj, FF
6868}
6969
7070#if WITH_EDITOR
71+ #if ENGINE_MINOR_VERSION > 21
72+ static void ImportTransformChannel (const FRichCurve& Source, FMovieSceneFloatChannel* Dest, FFrameRate DestFrameRate, bool bNegateTangents)
73+ {
74+ TMovieSceneChannelData<FMovieSceneFloatValue> ChannelData = Dest->GetData ();
75+ ChannelData.Reset ();
76+ double DecimalRate = DestFrameRate.AsDecimal ();
77+ for (int32 KeyIndex = 0 ; KeyIndex < Source.Keys .Num (); ++KeyIndex)
78+ {
79+ float ArriveTangent = Source.Keys [KeyIndex].ArriveTangent ;
80+ if (KeyIndex > 0 )
81+ {
82+ ArriveTangent = ArriveTangent / ((Source.Keys [KeyIndex].Value - Source.Keys [KeyIndex - 1 ].Value ) * DecimalRate);
83+ }
84+
85+ float LeaveTangent = Source.Keys [KeyIndex].LeaveTangent ;
86+ if (KeyIndex < Source.Keys .Num () - 1 )
87+ {
88+ LeaveTangent = LeaveTangent / ((Source.Keys [KeyIndex + 1 ].Value - Source.Keys [KeyIndex].Value ) * DecimalRate);
89+ }
90+
91+ if (bNegateTangents)
92+ {
93+ ArriveTangent = -ArriveTangent;
94+ LeaveTangent = -LeaveTangent;
95+ }
96+
97+ FFrameNumber KeyTime = (Source.Keys [KeyIndex].Value * DestFrameRate).RoundToFrame ();
98+ if (ChannelData.FindKey (KeyTime) == INDEX_NONE)
99+ {
100+ FMovieSceneFloatValue NewKey (Source.Keys [KeyIndex].Value );
101+
102+ NewKey.InterpMode = Source.Keys [KeyIndex].InterpMode ;
103+ NewKey.TangentMode = Source.Keys [KeyIndex].TangentMode ;
104+ NewKey.Tangent .ArriveTangent = ArriveTangent / DestFrameRate.AsDecimal ();
105+ NewKey.Tangent .LeaveTangent = LeaveTangent / DestFrameRate.AsDecimal ();
106+ NewKey.Tangent .TangentWeightMode = RCTWM_WeightedNone;
107+ NewKey.Tangent .ArriveTangentWeight = 0 .0f ;
108+ NewKey.Tangent .LeaveTangentWeight = 0 .0f ;
109+ ChannelData.AddKey (KeyTime, NewKey);
110+ }
111+ }
112+
113+ Dest->AutoSetTangents ();
114+ }
115+ #else
71116static void ImportTransformChannel (const FInterpCurveFloat& Source, FMovieSceneFloatChannel* Dest, FFrameRate DestFrameRate, bool bNegateTangents)
72117{
73118 TMovieSceneChannelData<FMovieSceneFloatValue> ChannelData = Dest->GetData ();
@@ -103,18 +148,27 @@ static void ImportTransformChannel(const FInterpCurveFloat& Source, FMovieSceneF
103148
104149 Dest->AutoSetTangents ();
105150}
151+ #endif
106152
107153static bool ImportFBXTransform (FString NodeName, UMovieScene3DTransformSection* TransformSection, UnFbx::FFbxCurvesAPI& CurveAPI)
108154{
109155
110156
111157 // Look for transforms explicitly
158+ FTransform DefaultTransform;
159+
160+ #if ENGINE_MINOR_VERSION > 21
161+ FRichCurve Translation[3 ];
162+ FRichCurve EulerRotation[3 ];
163+ FRichCurve Scale[3 ];
164+ #else
112165 FInterpCurveFloat Translation[3 ];
113166 FInterpCurveFloat EulerRotation[3 ];
114167 FInterpCurveFloat Scale[3 ];
115- FTransform DefaultTransform;
168+ # endif
116169 CurveAPI.GetConvertedTransformCurveData (NodeName, Translation[0 ], Translation[1 ], Translation[2 ], EulerRotation[0 ], EulerRotation[1 ], EulerRotation[2 ], Scale[0 ], Scale[1 ], Scale[2 ], DefaultTransform);
117170
171+
118172 TransformSection->Modify ();
119173
120174 FFrameRate FrameRate = TransformSection->GetTypedOuter <UMovieScene>()->GetTickResolution ();
@@ -1594,9 +1648,15 @@ PyObject *py_ue_sequencer_import_fbx_transform(ue_PyUObject *self, PyObject * ar
15941648 continue ;
15951649
15961650 // Look for transforms explicitly
1651+ #if ENGINE_MINOR_VERSION > 21
1652+ FRichCurve Translation[3 ];
1653+ FRichCurve EulerRotation[3 ];
1654+ FRichCurve Scale[3 ];
1655+ #else
15971656 FInterpCurveFloat Translation[3 ];
15981657 FInterpCurveFloat EulerRotation[3 ];
15991658 FInterpCurveFloat Scale[3 ];
1659+ #endif
16001660 FTransform DefaultTransform;
16011661#if ENGINE_MINOR_VERSION >= 18
16021662 CurveAPI.GetConvertedTransformCurveData (NodeName, Translation[0 ], Translation[1 ], Translation[2 ], EulerRotation[0 ], EulerRotation[1 ], EulerRotation[2 ], Scale[0 ], Scale[1 ], Scale[2 ], DefaultTransform);
0 commit comments