diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-11-21 06:38:11 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-11-21 06:38:11 +0300 |
commit | 48f298f09dbe7819e0a2a5530be7891507824005 (patch) | |
tree | d310d3bd90f30ebc67c8497c67b7260e209e1c46 /source/blender/editors | |
parent | d47fbece5130fccc7aaaee6046f99a38d3762636 (diff) |
Fix/Request T46798: Alt+I removes keyframes from all bones, not only selected in Pose Mode
Technically this was more of a feature request, but now the Alt-I operator will
only remove keyframes related to selected bones in Pose Mode. In Object Mode,
it will continue to operate on all keyframes of the object.
This change makes this operator more meaningful when animating in the 3D view.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 479b4272755..0d105f9b6e2 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1645,14 +1645,45 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) for (fcu = act->curves.first; fcu; fcu = fcn) { fcn = fcu->next; - + + /* don't touch protected F-Curves */ if (BKE_fcurve_is_protected(fcu)) { BKE_reportf(op->reports, RPT_WARNING, "Not deleting keyframe for locked F-Curve '%s', object '%s'", fcu->rna_path, id->name + 2); continue; } - + + /* special exception for bones, as this makes this operator more convenient to use + * NOTE: This is only done in pose mode. In object mode, we're dealign with the entire object. + */ + if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) { + bPoseChannel *pchan; + char *bone_name; + + /* get bone-name, and check if this bone is selected */ + bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); + pchan = BKE_pose_channel_find_name(ob->pose, bone_name); + if (bone_name) MEM_freeN(bone_name); + + /* skip if bone is not selected */ + if ((pchan) && (pchan->bone)) { + /* bones are only selected/editable if visible... */ + bArmature *arm = (bArmature *)ob->data; + + /* skipping - not visible on currently visible layers */ + if ((arm->layer & pchan->bone->layer) == 0) + continue; + /* skipping - is currently hidden */ + if (pchan->bone->flag & BONE_HIDDEN_P) + continue; + + /* selection flag... */ + if ((pchan->bone->flag & BONE_SELECTED) == 0) + continue; + } + } + /* delete keyframes on current frame * WARNING: this can delete the next F-Curve, hence the "fcn" copying */ @@ -1661,7 +1692,11 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) } /* report success (or failure) */ - BKE_reportf(op->reports, RPT_INFO, "Object '%s' successfully had %d keyframes removed", id->name + 2, success); + if (success) + BKE_reportf(op->reports, RPT_INFO, "Object '%s' successfully had %d keyframes removed", id->name + 2, success); + else + BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2); + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; @@ -1676,7 +1711,7 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Keyframe"; - ot->description = "Remove keyframes on current frame for selected objects"; + ot->description = "Remove keyframes on current frame for selected objects and bones"; ot->idname = "ANIM_OT_keyframe_delete_v3d"; /* callbacks */ |