Fix T63904: Remove Animation should remove empty actions from objects.

This commit is contained in:
Alexander Gavrilov 2019-05-02 14:51:43 +03:00
parent 667af6cf41
commit 6047653ec0
Notes: blender-bot 2023-02-14 11:42:40 +01:00
Referenced by issue #63904, Remove Animation operator does not remove animation data on object with no keyframes.
3 changed files with 26 additions and 4 deletions

View File

@ -649,16 +649,30 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
* channel list that are empty, and linger around long after the data they
* are for has disappeared (and probably won't come back).
*/
if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
id_us_min(&act->id);
adt->action = NULL;
}
ANIM_remove_empty_action_from_animdata(adt);
}
/* free the F-Curve itself */
free_fcurve(fcu);
}
/* If the action has no F-Curves, unlink it from AnimData if it did not
* come from a NLA Strip being tweaked. */
bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt)
{
if (adt->action != NULL) {
bAction *act = adt->action;
if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
id_us_min(&act->id);
adt->action = NULL;
return true;
}
}
return false;
}
/* ************************************************************************** */
/* OPERATORS */

View File

@ -2209,6 +2209,11 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
changed = true;
}
}
/* Delete the action itself if it is empty. */
if (ANIM_remove_empty_action_from_animdata(adt)) {
changed = true;
}
}
}
CTX_DATA_END;

View File

@ -612,6 +612,9 @@ void ANIM_set_active_channel(bAnimContext *ac,
* as appropriate according to animation context */
void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, struct AnimData *adt, struct FCurve *fcu);
/* Unlink the action from animdata if it's empty. */
bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt);
/* ************************************************ */
/* DRAWING API */
/* anim_draw.c */