Fixed adding keys to a curve model sometimes causing tangents to get incorrectly calculated. This was causing issues with Buffered curves.

#jira UE-75157
#rb Max.Chen


#ROBOMERGE-SOURCE: CL 7269268 via CL 7269269 via CL 7269958 via CL 7270008 via CL 7275787
#ROBOMERGE-BOT: (v369-7254125)

[CL 7275892 by matt hoffman in Main branch]
This commit is contained in:
matt hoffman
2019-07-11 11:40:44 -04:00
parent 69a0813e54
commit 92d3fbdd79
2 changed files with 17 additions and 16 deletions

View File

@@ -41,6 +41,9 @@ void FRichCurveEditorModel::AddKeys(TArrayView<const FKeyPosition> InKeyPosition
{
Owner->Modify();
TArray<FKeyHandle> NewKeyHandles;
NewKeyHandles.SetNumUninitialized(InKeyPositions.Num());
for (int32 Index = 0; Index < InKeyPositions.Num(); ++Index)
{
FKeyPosition Position = InKeyPositions[Index];
@@ -49,20 +52,16 @@ void FRichCurveEditorModel::AddKeys(TArrayView<const FKeyPosition> InKeyPosition
FKeyHandle NewHandle = RichCurve->AddKey(Position.InputValue, Position.OutputValue);
FRichCurveKey* NewKey = &RichCurve->GetKey(NewHandle);
if (Attributes.HasInterpMode()) { NewKey->InterpMode = Attributes.GetInterpMode(); }
if (Attributes.HasTangentMode()) { NewKey->TangentMode = Attributes.GetTangentMode(); }
if (Attributes.HasArriveTangent()) { NewKey->ArriveTangent = Attributes.GetArriveTangent(); }
if (Attributes.HasLeaveTangent()) { NewKey->LeaveTangent = Attributes.GetLeaveTangent(); }
if (Attributes.HasArriveTangentWeight()) { NewKey->ArriveTangentWeight = Attributes.GetArriveTangent(); }
if (Attributes.HasLeaveTangentWeight()) { NewKey->LeaveTangentWeight = Attributes.GetLeaveTangent(); }
NewKeyHandles[Index] = NewHandle;
if (OutKeyHandles)
{
(*OutKeyHandles)[Index] = NewHandle;
}
}
RichCurve->AutoSetTangents();
// We reuse SetKeyAttributes here as there is complex logic determining which parts of the attributes are valid to pass on.
// For now we need to duplicate the new key handle array due to API mismatch. This will auto-calculate tangents if required.
SetKeyAttributes(NewKeyHandles, InKeyAttributes);
}
}