diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2019-12-17 17:20:11 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2019-12-17 17:22:29 +0300 |
commit | 7830ea29c2ea6c30cec1dcd6d6c11a1f228e9cd7 (patch) | |
tree | 969bbfaf42037b93996c08bff3ca75211e515a53 /source/blender/editors/curve | |
parent | 3a5562151fdfc3c1531350ffd99534b50fbb0f37 (diff) |
Fix T68665: FCurve group disappear on Curve/Surface object data
When going from EDIT to OBJECT mode, Blender updates the object data from
the edit-mode data. This took care of renaming FCurves that animate Curve
control points when control points are added/removed, but this didn't keep
the FCurve groups intact. Since the FCurve groups are tightly connected to
the Action channels, it's hard to keep the group pointers intact during
this process. Instead of making the code even more complex in an attempt to
do that, I implemented a function (`BKE_action_groups_reconstruct()`) that
rebuilds the group channel pointers.
The call to `action_groups_add_channel()` had to be removed because it
updates the the next/prev pointers of the FCurve while we're looping over
them, causing infinite loops.
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f18b6e91d0f..e7803fdaafb 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -922,11 +922,15 @@ static void fcurve_path_rename(AnimData *adt, nfcu = copy_fcurve(fcu); spath = nfcu->rna_path; nfcu->rna_path = BLI_sprintfN("%s%s", rna_path, suffix); + + /* copy_fcurve() sets nfcu->grp to NULL. To maintain the groups, we need to keep the pointer. + * As a result, the group's 'channels' pointers will be wrong, which is fixed by calling + * `action_groups_reconstruct(action)` later, after all fcurves have been renamed. */ + nfcu->grp = fcu->grp; BLI_addtail(curves, nfcu); if (fcu->grp) { action_groups_remove_channel(adt->action, fcu); - action_groups_add_channel(adt->action, fcu->grp, nfcu); } else if ((adt->action) && (&adt->action->curves == orig_curves)) { BLI_remlink(&adt->action->curves, fcu); @@ -1077,6 +1081,9 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) } *orig_curves = curves; + if (adt != NULL) { + BKE_action_groups_reconstruct(adt->action); + } } /* return 0 if animation data wasn't changed, 1 otherwise */ |