Commit: 76eac1ae70001f5b2b0fe1d064f260db8509b246
Author: Joshua Leung
Date:   Sat Feb 6 17:57:50 2016 +1300
Branches: master
https://developer.blender.org/rB76eac1ae70001f5b2b0fe1d064f260db8509b246

Motion Paths: Use custom poll functions for "Update" operator

===================================================================

M       source/blender/editors/armature/pose_edit.c
M       source/blender/editors/object/object_edit.c

===================================================================

diff --git a/source/blender/editors/armature/pose_edit.c 
b/source/blender/editors/armature/pose_edit.c
index 9e8028b..ad0532b 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -262,6 +262,16 @@ void POSE_OT_paths_calculate(wmOperatorType *ot)
 
 /* --------- */
 
+static int pose_update_paths_poll(bContext *C)
+{
+       if (ED_operator_posemode_exclusive(C)) {
+               bPoseChannel *pchan = CTX_data_active_pose_bone(C);
+               return (pchan && pchan->mpath);
+       }
+       
+       return false;
+}
+
 static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
@@ -289,7 +299,7 @@ void POSE_OT_paths_update(wmOperatorType *ot)
        
        /* api callbakcs */
        ot->exec = pose_update_paths_exec;
-       ot->poll = ED_operator_posemode_exclusive; /* TODO: this should 
probably check for active bone and/or existing paths */
+       ot->poll = pose_update_paths_poll;
        
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/object/object_edit.c 
b/source/blender/editors/object/object_edit.c
index 9940ad8..176d75c 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1281,6 +1281,16 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot)
 
 /* --------- */
 
+static int object_update_paths_poll(bContext *C)
+{
+       if (ED_operator_object_active_editable(C)) {
+               Object *ob = CTX_data_active_object(C);
+               return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
+       }
+       
+       return false;
+}
+
 static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
@@ -1306,7 +1316,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
        
        /* api callbakcs */
        ot->exec = object_update_paths_exec;
-       ot->poll = ED_operator_object_active_editable; /* TODO: this should 
probably check for existing paths */
+       ot->poll = object_update_paths_poll;
        
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to