diff options
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/pose_edit.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index ef628208632..a929507929f 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -308,38 +308,44 @@ void POSE_OT_paths_update(wmOperatorType *ot) /* --------- */ /* for the object with pose/action: clear path curves for selected bones only */ -static void ED_pose_clear_paths(Object *ob) +static void ED_pose_clear_paths(Object *ob, bool only_selected) { bPoseChannel *pchan; - + bool skipped = false; + if (ELEM(NULL, ob, ob->pose)) return; /* free the motionpath blocks for all bones - This is easier for users to quickly clear all */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->mpath) { - if (pchan->bone) { + if ((only_selected == false) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))) { animviz_free_motionpath(pchan->mpath); pchan->mpath = NULL; } + else { + skipped = true; + } } } - /* no paths left!*/ - ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS; + /* if nothing was skipped, there should be no paths left! */ + if (skipped == false) + ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS; } -/* operator callback for this */ -static int pose_clear_paths_exec(bContext *C, wmOperator *UNUSED(op)) +/* operator callback - wrapper for the backend function */ +static int pose_clear_paths_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + bool only_selected = RNA_boolean_get(op->ptr, "only_selected"); + /* only continue if there's an object */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; /* use the backend function for this */ - ED_pose_clear_paths(ob); + ED_pose_clear_paths(ob, only_selected); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); @@ -347,19 +353,34 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } +/* operator callback/wrapper */ +static int pose_clear_paths_invoke(bContext *C, wmOperator *op, const wmEvent *evt) +{ + if ((evt->shift) && !RNA_struct_property_is_set(op->ptr, "only_selected")) { + RNA_boolean_set(op->ptr, "only_selected", true); + } + return pose_clear_paths_exec(C, op); +} + void POSE_OT_paths_clear(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Bone Paths"; ot->idname = "POSE_OT_paths_clear"; - ot->description = "Clear path caches for all bones"; + ot->description = "Clear path caches for all bones, hold Shift key for selected bones only"; /* api callbacks */ + ot->invoke = pose_clear_paths_invoke; ot->exec = pose_clear_paths_exec; ot->poll = ED_operator_posemode_exclusive; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", + "Only clear paths from selected bones"); + RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); } /* ********************************************** */ |