[Bf-blender-cvs] [c5f59f58547] master: Tweaks to make it easier to update bone motion paths (without the active bone needing to have any paths itself)

Joshua Leung noreply at git.blender.org
Sun Nov 19 14:09:25 CET 2017


Commit: c5f59f5854732f7d2c2020ca7ec67f1eaa043b78
Author: Joshua Leung
Date:   Mon Nov 20 01:00:27 2017 +1300
Branches: master
https://developer.blender.org/rBc5f59f5854732f7d2c2020ca7ec67f1eaa043b78

Tweaks to make it easier to update bone motion paths (without the active bone needing to have any paths itself)

This commit introduces the following changes:
* Modified the poll callback on the "Update Paths" operator for bones
  so that it only checks if there are bones that have motion paths
  (instead of checking whether the active bone has paths).

  This makes it easier to update paths without having to first select one
  that has them - useful when the paths are all on hidden/hard-to-select bones.

* Add a readonly property, "has_motion_paths" to the animviz.motion_path
  RNA struct, providing easier access to the internal flag used above.
  This makes it possible for the UI to display the "Update" button without
  having to check various bones for motion paths.


Notes:
* The flag being used in these changes already existed, and was only really
  intended for internal use. However, since it was already used in many places
  for determining if auto-update of all bone paths was needed (e.g. after certain
  editing ops), it should be safe to use here too.

* The update_paths operator currently bakes all paths when activated, so there's
  currently no loss of functionality with changing to not checking if the active
  bone has any paths (e.g. we couldn't only update the active bone only either).
  That is still listed as a todo in the code.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/armature/pose_edit.c
M	source/blender/makesrna/intern/rna_animviz.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 562df68945d..3792ac13d18 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -852,12 +852,12 @@ class VIEW3D_PT_tools_posemode(View3DPanel, Panel):
 
         draw_keyframing_tools(context, layout)
 
-        pchan = context.active_pose_bone
-        mpath = pchan.motion_path if pchan else None
+        ob = context.object
+        avs = ob.pose.animation_visualization
 
         col = layout.column(align=True)
         col.label(text="Motion Paths:")
-        if mpath:
+        if avs.motion_path.has_motion_paths:
             row = col.row(align=True)
             row.operator("pose.paths_update", text="Update")
             row.operator("pose.paths_clear", text="", icon='X')
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index c49a370c286..57c01157f8e 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -265,8 +265,8 @@ 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);
+		Object *ob = CTX_data_active_object(C);
+		return (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
 	}
 	
 	return false;
diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c
index 0ae07874853..2ba067629a9 100644
--- a/source/blender/makesrna/intern/rna_animviz.c
+++ b/source/blender/makesrna/intern/rna_animviz.c
@@ -174,6 +174,7 @@ static void rna_def_animviz_motion_path(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Use Bone Heads",
 	                         "For PoseBone paths, use the bone head location when calculating this path");
 	
+	/* FIXME: Motion Paths are not currently editable... */
 	prop = RNA_def_property(srna, "is_modified", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOTIONPATH_FLAG_EDIT);
 	RNA_def_property_ui_text(prop, "Edit Path", "Path is being edited");
@@ -364,6 +365,12 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
 	                         "(only for 'Around Current Frame' Onion-skinning method)");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */
 
+	
+	/* Readonly Property - Do any motion paths exist/need updating? (Mainly for bone paths) */
+	prop = RNA_def_property(srna, "has_motion_paths", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "path_bakeflag", MOTIONPATH_BAKE_HAS_PATHS);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* NOTE: This is really an internal state var for convenience, so don't allow edits! */
+	RNA_def_property_ui_text(prop, "Has Motion Paths", "Are there any bone paths that will need updating (read-only)");
 }
 
 /* --- */



More information about the Bf-blender-cvs mailing list