diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-09-24 19:22:30 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-09-25 15:20:59 +0300 |
commit | 2ef68edad8b9832d55c185d4db948417e74ae8c2 (patch) | |
tree | a4928697b380c077db1f9bf3cef1f04f831dd1e8 /source/blender/blenkernel/intern/anim_data.c | |
parent | 2e1339bc0b55bcde8d2f3936011c645aab8b263c (diff) |
Cleanup: animation, deduplicate "can edit action" logic
Move "action editable" check from RNA code to Blender kernel
`BKE_animdata_action_editable()`.
No functional changes.
Diffstat (limited to 'source/blender/blenkernel/intern/anim_data.c')
-rw-r--r-- | source/blender/blenkernel/intern/anim_data.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index 24908469a77..30b75734e77 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -180,17 +180,14 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) { AnimData *adt = BKE_animdata_from_id(id); - /* animdata validity check */ + /* Animdata validity check. */ if (adt == NULL) { BKE_report(reports, RPT_WARNING, "No AnimData to set action on"); return false; } - /* active action is only editable when it is not a tweaking strip - * see rna_AnimData_action_editable() in rna_animation.c - */ - if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) { - /* cannot remove, otherwise things turn to custard */ + if (!BKE_animdata_action_editable(adt)) { + /* Cannot remove, otherwise things turn to custard. */ BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA"); return false; } @@ -200,8 +197,6 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) id_us_min((ID *)adt->action); } - /* Assume that AnimData's action can in fact be edited. */ - if (act == NULL) { /* Just clearing the action. */ adt->action = NULL; @@ -227,6 +222,14 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) return true; } +bool BKE_animdata_action_editable(const AnimData *adt) +{ + /* Active action is only editable when it is not a tweaking strip. */ + const bool is_tweaking_strip = (adt->flag & ADT_NLA_EDIT_ON) || adt->actstrip != NULL || + adt->tmpact != NULL; + return !is_tweaking_strip; +} + /* Freeing -------------------------------------------- */ /* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */ |