[Bf-blender-cvs] [7c611e2] master: Code Cleanup: Deduplicate logic for getting AnimData block associated with Action Editor modes
Joshua Leung
noreply at git.blender.org
Sat Feb 28 14:37:18 CET 2015
Commit: 7c611e22049bb92f6efbbc1e2337fbfe22f841c4
Author: Joshua Leung
Date: Sat Feb 28 12:42:10 2015 +1300
Branches: master
https://developer.blender.org/rB7c611e22049bb92f6efbbc1e2337fbfe22f841c4
Code Cleanup: Deduplicate logic for getting AnimData block associated with Action Editor modes
===================================================================
M source/blender/editors/space_action/action_edit.c
===================================================================
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 4607d6e..c4ed44c 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -83,6 +83,26 @@
/* ************************************************************************** */
/* ACTION MANAGEMENT */
+/* Helper function to find the active AnimData block from the Action Editor context */
+static AnimData *actedit_animdata_from_context(bContext *C)
+{
+ SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
+ Object *ob = CTX_data_active_object(C);
+ AnimData *adt = NULL;
+
+ /* Get AnimData block to use */
+ if (saction->mode == SACTCONT_ACTION) {
+ /* Currently, "Action Editor" means object-level only... */
+ adt = ob->adt;
+ }
+ else if (saction->mode == SACTCONT_SHAPEKEY) {
+ Key *key = BKE_key_from_object(ob);
+ adt = key->adt;
+ }
+
+ return adt;
+}
+
/* Create new action */
static bAction *action_create_new(bContext *C, bAction *oldact)
{
@@ -230,18 +250,7 @@ static int action_pushdown_poll(bContext *C)
static int action_pushdown_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
- Object *ob = CTX_data_active_object(C);
- AnimData *adt = NULL;
-
- /* Get AnimData block to use */
- if (saction->mode == SACTCONT_ACTION) {
- /* Currently, "Action Editor" means object-level only... */
- adt = ob->adt;
- }
- else if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = BKE_key_from_object(ob);
- adt = key->adt;
- }
+ AnimData *adt = actedit_animdata_from_context(C);
/* Do the deed... */
if (adt) {
@@ -289,18 +298,7 @@ void ACTION_OT_push_down(wmOperatorType *ot)
static int action_stash_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
- Object *ob = CTX_data_active_object(C);
- AnimData *adt = NULL;
-
- /* Get AnimData block to use */
- if (saction->mode == SACTCONT_ACTION) {
- /* Currently, "Action Editor" means object-level only... */
- adt = ob->adt;
- }
- else if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = BKE_key_from_object(ob);
- adt = key->adt;
- }
+ AnimData *adt = actedit_animdata_from_context(C);
/* Perform stashing operation */
if (adt) {
More information about the Bf-blender-cvs
mailing list