diff options
Diffstat (limited to 'source/blender/editors/armature/poseobject.c')
-rw-r--r-- | source/blender/editors/armature/poseobject.c | 72 |
1 files changed, 52 insertions, 20 deletions
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index b94b3e68318..4aff2f1e915 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -76,6 +76,38 @@ static void error(const char *dummy) {}; static void BIF_undo_push(const char *dummy) {} /* ************* XXX *************** */ + +static int object_pose_context(Object *ob) +{ + if( (ob) && + (ob->type == OB_ARMATURE) && + (ob->pose) && + (ob->mode & OB_MODE_POSE) + ) { + return 1; + } + else { + return 0; + } +} + +Object *ED_object_pose_armature(Object *ob) +{ + if(ob==NULL) + return NULL; + + if(object_pose_context(ob)) + return ob; + + ob= modifiers_isDeformedByArmature(ob); + + if(object_pose_context(ob)) + return ob; + + return NULL; +} + + /* This function is used to indicate that a bone is selected and needs keyframes inserted */ void set_pose_keys (Object *ob) { @@ -220,7 +252,7 @@ static int pose_calculate_paths_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -296,7 +328,7 @@ static int pose_clear_paths_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object */ if ELEM(NULL, ob, ob->pose) @@ -330,7 +362,7 @@ void POSE_OT_paths_clear (wmOperatorType *ot) static int pose_select_constraint_target_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bArmature *arm= ob->data; bConstraint *con; int found= 0; @@ -390,7 +422,7 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot) static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bArmature *arm= ob->data; Bone *curbone, *pabone, *chbone; int direction = RNA_enum_get(op->ptr, "direction"); @@ -570,7 +602,7 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend) static int pose_select_grouped_exec (bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); short extend= RNA_boolean_get(op->ptr, "extend"); short changed = 0; @@ -856,7 +888,7 @@ void free_posebuf(void) static int pose_copy_exec (bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); /* sanity checking */ if ELEM(NULL, ob, ob->pose) { @@ -895,7 +927,7 @@ void POSE_OT_copy (wmOperatorType *ot) static int pose_paste_exec (bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bPoseChannel *chan, *pchan; int flip= RNA_boolean_get(op->ptr, "flipped"); @@ -1077,7 +1109,7 @@ static int pose_group_add_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) @@ -1117,7 +1149,7 @@ static int pose_group_remove_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) @@ -1165,7 +1197,7 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1215,7 +1247,7 @@ static int pose_group_assign_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1280,7 +1312,7 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1352,7 +1384,7 @@ static int pose_group_select_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1390,7 +1422,7 @@ static int pose_group_deselect_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else - ob= CTX_data_active_object(C); + ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1423,7 +1455,7 @@ void POSE_OT_group_deselect (wmOperatorType *ot) static int pose_flip_names_exec (bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bArmature *arm; /* paranoia checks */ @@ -1468,7 +1500,7 @@ void POSE_OT_flip_names (wmOperatorType *ot) static int pose_autoside_names_exec (bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bArmature *arm; char newname[32]; short axis= RNA_enum_get(op->ptr, "axis"); @@ -1567,7 +1599,7 @@ void pose_activate_flipped_bone(Scene *scene) /* Present a popup to get the layers that should be used */ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bArmature *arm= (ob)? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -1588,7 +1620,7 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev /* Set the visible layers for the active armature (edit and pose modes) */ static int pose_armature_layers_exec (bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bArmature *arm= (ob)? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -1677,7 +1709,7 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) /* Set the visible layers for the active armature (edit and pose modes) */ static int pose_bone_layers_exec (bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bArmature *arm= (ob)? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -1798,7 +1830,7 @@ void ARMATURE_OT_bone_layers (wmOperatorType *ot) static int pose_flip_quats_exec (bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale"); /* loop through all selected pchans, flipping and keying (as needed) */ |