diff options
author | Richard Antalik <richardantalik@gmail.com> | 2022-03-29 05:10:37 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2022-03-29 05:19:27 +0300 |
commit | e74420124f3a429ad8a1492e56a7e1561d86d6f7 (patch) | |
tree | 9a79809f3a9eab7bf4186196bc607b55c8096d3b /source/blender/sequencer | |
parent | f99beb730aa822d8b0b77bf85dbe0db5c7b757a3 (diff) |
Fix T96699: Splitting strip does not copy animation
Since e49bf4019b49, animation is handled explicitly. Split operator
wasn't updated.
Re-use backup-duplicate-restore animation functions, that other
operators use for splitting.
Diffstat (limited to 'source/blender/sequencer')
-rw-r--r-- | source/blender/sequencer/SEQ_animation.h | 12 | ||||
-rw-r--r-- | source/blender/sequencer/intern/animation.c | 29 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_edit.c | 11 |
3 files changed, 51 insertions, 1 deletions
diff --git a/source/blender/sequencer/SEQ_animation.h b/source/blender/sequencer/SEQ_animation.h index 455e77fb4a3..f2c66393b65 100644 --- a/source/blender/sequencer/SEQ_animation.h +++ b/source/blender/sequencer/SEQ_animation.h @@ -19,6 +19,18 @@ struct Sequence; void SEQ_free_animdata(struct Scene *scene, struct Sequence *seq); void SEQ_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs); struct GSet *SEQ_fcurves_by_strip_get(const struct Sequence *seq, struct ListBase *fcurve_base); +/** + * Move all `F-curves` from `scene` to `list`. + */ +void SEQ_animation_backup_original(struct Scene *scene, struct ListBase *list); +/** + * Move all `F-curves` from `list` to `scene`. + */ +void SEQ_animation_restore_original(struct Scene *scene, struct ListBase *list); +/** + * Duplicate `F-curves` used by `seq` from `list` to `scene`. + */ +void SEQ_animation_duplicate(struct Scene *scene, struct Sequence *seq, struct ListBase *list); #ifdef __cplusplus } diff --git a/source/blender/sequencer/intern/animation.c b/source/blender/sequencer/intern/animation.c index 47453ceda2b..27f7316e042 100644 --- a/source/blender/sequencer/intern/animation.c +++ b/source/blender/sequencer/intern/animation.c @@ -104,3 +104,32 @@ void SEQ_free_animdata(Scene *scene, Sequence *seq) GSET_FOREACH_END(); BLI_gset_free(fcurves, NULL); } + +void SEQ_animation_backup_original(Scene *scene, ListBase *list) +{ + if (scene->adt == NULL || scene->adt->action == NULL || + BLI_listbase_is_empty(&scene->adt->action->curves)) { + return; + } + + BLI_movelisttolist(list, &scene->adt->action->curves); +} + +void SEQ_animation_restore_original(Scene *scene, ListBase *list) +{ + if (scene->adt == NULL || scene->adt->action == NULL || BLI_listbase_is_empty(list)) { + return; + } + + BLI_movelisttolist(&scene->adt->action->curves, list); +} + +void SEQ_animation_duplicate(Scene *scene, Sequence *seq, ListBase *list) +{ + GSet *fcurves = SEQ_fcurves_by_strip_get(seq, list); + GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) { + FCurve *fcu_cpy = BKE_fcurve_copy(fcu); + BLI_addtail(&scene->adt->action->curves, fcu_cpy); + } + GSET_FOREACH_END(); +} diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c index 60f3f35314e..2f76b6240cf 100644 --- a/source/blender/sequencer/intern/strip_edit.c +++ b/source/blender/sequencer/intern/strip_edit.c @@ -457,11 +457,18 @@ Sequence *SEQ_edit_strip_split(Main *bmain, return NULL; } - /* Move strips in collection from seqbase to new ListBase. */ + /* Store `F-curves`, so original ones aren't renamed. */ + ListBase fcurves_original_backup = {NULL, NULL}; + SEQ_animation_backup_original(scene, &fcurves_original_backup); + ListBase left_strips = {NULL, NULL}; SEQ_ITERATOR_FOREACH (seq, collection) { + /* Move strips in collection from seqbase to new ListBase. */ BLI_remlink(seqbase, seq); BLI_addtail(&left_strips, seq); + + /* Duplicate curves from backup, so they can be renamed along with split strips. */ + SEQ_animation_duplicate(scene, seq, &fcurves_original_backup); } SEQ_collection_free(collection); @@ -511,6 +518,8 @@ Sequence *SEQ_edit_strip_split(Main *bmain, SEQ_ensure_unique_name(seq_rename, scene); } + SEQ_animation_restore_original(scene, &fcurves_original_backup); + return return_seq; } |