Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2016-02-25 15:07:26 +0300
committerJoshua Leung <aligorith@gmail.com>2016-02-26 09:12:43 +0300
commit7dc419c8feb78dd1a4dad576a984932f81238dcd (patch)
tree51e98963542430454dcc3cf123a75f330bd5dc99 /source/blender/editors/object
parent0b1398930737ec4475706922809d1b88c18ac8fe (diff)
Restore ability to clear motionpaths from selected objects/bones only
In response to user feedback, this commit brings back the ability to limit motionpath clearing to only happening for those on selected objects/bones. By default, the "Clear" operator will clear from all objects/bones, unless the Shift key is held.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_edit.c59
1 files changed, 46 insertions, 13 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 176d75c39ff..e8936e1f571 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1324,26 +1324,44 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
/* --------- */
+/* Helper for ED_objects_clear_paths() */
+static void object_clear_mpath(Object *ob)
+{
+ if (ob->mpath) {
+ animviz_free_motionpath(ob->mpath);
+ ob->mpath = NULL;
+ ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
+ }
+}
+
/* Clear motion paths for all objects */
-void ED_objects_clear_paths(bContext *C)
+void ED_objects_clear_paths(bContext *C, bool only_selected)
{
- /* loop over all edtiable objects in scene */
- CTX_DATA_BEGIN(C, Object *, ob, editable_objects)
- {
- if (ob->mpath) {
- animviz_free_motionpath(ob->mpath);
- ob->mpath = NULL;
- ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
+ if (only_selected) {
+ /* loop over all selected + sedtiable objects in scene */
+ CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
+ {
+ object_clear_mpath(ob);
}
+ CTX_DATA_END;
+ }
+ else {
+ /* loop over all edtiable objects in scene */
+ CTX_DATA_BEGIN(C, Object *, ob, editable_objects)
+ {
+ object_clear_mpath(ob);
+ }
+ CTX_DATA_END;
}
- CTX_DATA_END;
}
/* operator callback for this */
-static int object_clear_paths_exec(bContext *C, wmOperator *UNUSED(op))
-{
+static int object_clear_paths_exec(bContext *C, wmOperator *op)
+{
+ bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
+
/* use the backend function for this */
- ED_objects_clear_paths(C);
+ ED_objects_clear_paths(C, only_selected);
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -1351,19 +1369,34 @@ static int object_clear_paths_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
+/* operator callback/wrapper */
+static int object_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 object_clear_paths_exec(C, op);
+}
+
void OBJECT_OT_paths_clear(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clear Object Paths";
ot->idname = "OBJECT_OT_paths_clear";
- ot->description = "Clear path caches for all objects";
+ ot->description = "Clear path caches for all objects, hold Shift key for selected objects only";
/* api callbacks */
+ ot->invoke = object_clear_paths_invoke;
ot->exec = object_clear_paths_exec;
ot->poll = ED_operator_object_active_editable;
/* 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 objects");
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
}