Fix: Duplicating a Scene does not remove animation from slotted actions
When duplicating a scene in any way other than Full Copy, the VSE data is (apparently) not copied along. To prevent dangling F-Curves, any animation of sequencer strips is removed. This is now done correctly for slotted Actions, instead of looping over the legacy `action->curves` field. Also the F-Curve RNA path that's being tested for is updated. Instead of deleting all F-Curves with `sequences` in the name, the code now correctly looks for `sequence_editor.strips_all`. Pull Request: https://projects.blender.org/blender/blender/pulls/135576
This commit is contained in:
@@ -86,6 +86,8 @@
|
||||
#include "BKE_unit.hh"
|
||||
#include "BKE_workspace.hh"
|
||||
|
||||
#include "ANIM_action.hh"
|
||||
|
||||
#include "DEG_depsgraph.hh"
|
||||
#include "DEG_depsgraph_build.hh"
|
||||
#include "DEG_depsgraph_debug.hh"
|
||||
@@ -1597,14 +1599,26 @@ const char *RE_engine_id_CYCLES = "CYCLES";
|
||||
|
||||
static void remove_sequencer_fcurves(Scene *sce)
|
||||
{
|
||||
AnimData *adt = BKE_animdata_from_id(&sce->id);
|
||||
using namespace blender;
|
||||
|
||||
if (adt && adt->action) {
|
||||
LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &adt->action->curves) {
|
||||
if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
|
||||
action_groups_remove_channel(adt->action, fcu);
|
||||
BKE_fcurve_free(fcu);
|
||||
}
|
||||
std::optional<std::pair<animrig::Action *, animrig::Slot *>> action_and_slot =
|
||||
animrig::get_action_slot_pair(sce->id);
|
||||
if (!action_and_slot) {
|
||||
return;
|
||||
}
|
||||
|
||||
animrig::Channelbag *channelbag = channelbag_for_action_slot(*action_and_slot->first,
|
||||
action_and_slot->second->handle);
|
||||
if (!channelbag) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a copy of the F-Curve pointers, so iteration is safe while they are removed. */
|
||||
Vector<FCurve *> fcurves = channelbag->fcurves();
|
||||
|
||||
for (FCurve *fcurve : fcurves) {
|
||||
if ((fcurve->rna_path) && strstr(fcurve->rna_path, "sequence_editor.strips_all")) {
|
||||
channelbag->fcurve_remove(*fcurve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user