Cleanup: Remove F-Curve handling from undo in Curve edit mode

This commit removes the F-Curve handling from the legacy Curve edit mode
undo code.

The legacy Curve edit mode uses the per-mode undo system. This tried to
deal with changes in the animation data as well, but did so in a very
limited way. Only F-Curves were copied & restored, which means the
Action Groups were effectively deleted as soon as you undo something.
Furthermore, the code wasn't updated for slotted Actions yet, so
effectively it was a no-op, because it only saw the always-empty legacy
`Action::curves` field.

Fixing this properly would mean discarding this undo code, and moving to
the global undo system, as the animation editors allow changing the
animation of anything in the scene, not just the Curve data-block that
is being edited. Since the legacy curve ID type is, well, legacy, I
don't think it's worth going this route.

This is a non-functional change, as `action->curves` is always empty,
and so nothing was backed up or restored anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/135585
This commit is contained in:
Sybren A. Stüvel
2025-03-07 10:40:16 +01:00
parent 5849d9aec3
commit b71fed904b

View File

@@ -49,7 +49,17 @@ struct UndoCurve {
ListBase nubase;
int actvert;
GHash *undoIndex;
ListBase fcurves, drivers;
/* Historical note: Once upon a time, this code also made a backup of F-Curves, in an attempt to
* enable undo of animation changes. This was very limited, as it only backed up the animation
* of the curve ID; all the other IDs whose animation was shown in the dope sheet, timeline, etc.
* was ignored. It also ignored the NLA, and deleted Action groups even when the animation was
* not touched by the user.
*
* With the introduction of slotted Actions, a decision had to be made to either port this
* behavior or remove it. The latter was chosen. For more information, see #135585. */
ListBase drivers;
int actnu;
int flag;
@@ -76,11 +86,6 @@ static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short
}
if (ad) {
if (ad->action) {
BKE_fcurves_free(&ad->action->curves);
BKE_fcurves_copy(&ad->action->curves, &ucu->fcurves);
}
BKE_fcurves_free(&ad->drivers);
BKE_fcurves_copy(&ad->drivers, &ucu->drivers);
}
@@ -110,7 +115,7 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
EditNurb *editnurb = cu->editnurb, tmpEditnurb;
AnimData *ad = BKE_animdata_from_id(&cu->id);
/* TODO: include size of fcurve & undoIndex */
/* TODO: include size of drivers & undoIndex */
// ucu->undo_size = 0;
if (editnurb->keyindex) {
@@ -119,10 +124,6 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
}
if (ad) {
if (ad->action) {
BKE_fcurves_copy(&ucu->fcurves, &ad->action->curves);
}
BKE_fcurves_copy(&ucu->drivers, &ad->drivers);
}
@@ -155,7 +156,6 @@ static void undocurve_free_data(UndoCurve *uc)
BKE_curve_editNurb_keyIndex_free(&uc->undoIndex);
BKE_fcurves_free(&uc->fcurves);
BKE_fcurves_free(&uc->drivers);
}