Sequencer: skip redundant F-curve GSet allocation
This commit is contained in:
@@ -2457,6 +2457,9 @@ static void sequencer_copy_animation(Scene *scene, Sequence *seq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves);
|
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves);
|
||||||
|
if (fcurves == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
||||||
BLI_addtail(&fcurves_clipboard, BKE_fcurve_copy(fcu));
|
BLI_addtail(&fcurves_clipboard, BKE_fcurve_copy(fcu));
|
||||||
|
|||||||
@@ -48,9 +48,13 @@ GSet *SEQ_fcurves_by_strip_get(const Sequence *seq, ListBase *fcurve_base)
|
|||||||
char rna_path[SEQ_RNAPATH_MAXSTR];
|
char rna_path[SEQ_RNAPATH_MAXSTR];
|
||||||
size_t rna_path_len = sequencer_rna_path_prefix(rna_path, seq->name + 2);
|
size_t rna_path_len = sequencer_rna_path_prefix(rna_path, seq->name + 2);
|
||||||
|
|
||||||
GSet *fcurves = BLI_gset_ptr_new(__func__);
|
/* Only allocate `fcurves` if it's needed as it's possible there is no animation for `seq`. */
|
||||||
|
GSet *fcurves = NULL;
|
||||||
LISTBASE_FOREACH (FCurve *, fcurve, fcurve_base) {
|
LISTBASE_FOREACH (FCurve *, fcurve, fcurve_base) {
|
||||||
if (STREQLEN(fcurve->rna_path, rna_path, rna_path_len)) {
|
if (STREQLEN(fcurve->rna_path, rna_path, rna_path_len)) {
|
||||||
|
if (fcurves == NULL) {
|
||||||
|
fcurves = BLI_gset_ptr_new(__func__);
|
||||||
|
}
|
||||||
BLI_gset_add(fcurves, fcurve);
|
BLI_gset_add(fcurves, fcurve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,8 +69,11 @@ void SEQ_offset_animdata(Scene *scene, Sequence *seq, int ofs)
|
|||||||
if (!seq_animation_curves_exist(scene) || ofs == 0) {
|
if (!seq_animation_curves_exist(scene) || ofs == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves);
|
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves);
|
||||||
|
if (fcurves == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
if (fcu->bezt) {
|
if (fcu->bezt) {
|
||||||
@@ -95,8 +102,11 @@ void SEQ_free_animdata(Scene *scene, Sequence *seq)
|
|||||||
if (!seq_animation_curves_exist(scene)) {
|
if (!seq_animation_curves_exist(scene)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves);
|
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves);
|
||||||
|
if (fcurves == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
||||||
BLI_remlink(&scene->adt->action->curves, fcu);
|
BLI_remlink(&scene->adt->action->curves, fcu);
|
||||||
BKE_fcurve_free(fcu);
|
BKE_fcurve_free(fcu);
|
||||||
@@ -129,8 +139,11 @@ void SEQ_animation_duplicate(Scene *scene, Sequence *seq, ListBase *list)
|
|||||||
if (BLI_listbase_is_empty(list)) {
|
if (BLI_listbase_is_empty(list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, list);
|
GSet *fcurves = SEQ_fcurves_by_strip_get(seq, list);
|
||||||
|
if (fcurves == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) {
|
||||||
FCurve *fcu_cpy = BKE_fcurve_copy(fcu);
|
FCurve *fcu_cpy = BKE_fcurve_copy(fcu);
|
||||||
BLI_addtail(&scene->adt->action->curves, fcu_cpy);
|
BLI_addtail(&scene->adt->action->curves, fcu_cpy);
|
||||||
|
|||||||
Reference in New Issue
Block a user