[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46158] trunk/blender: Motion Paths GUI Cleanup

Joshua Leung aligorith at gmail.com
Tue May 1 18:19:14 CEST 2012


Revision: 46158
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46158
Author:   aligorith
Date:     2012-05-01 16:19:13 +0000 (Tue, 01 May 2012)
Log Message:
-----------
Motion Paths GUI Cleanup

This commit refactors the way that the Motion Paths GUI works. The key problems
this tries to address are:
1) Mode error - Confusion about whether we're dealing with the Object or Pose
level Motion Paths panel
2) Display settings vs Baking Settings

In line with the original design intentions for the 2.5/6 Properties Editor,
I've now split out the actual baking-related settings away from the Properties
Editor:
* Now, when clicking "Calculate Paths" from the toolbar, you'll be prompted with
a dialog to select the start/end frames (and for bones, whether to bake from
heads or tails). This is less confusing than relying on firstly setting the
range via the display range settings (and baking using that), since many people
apparently only used the "around current" mode, and were confused why things
weren't working

* Added a display of the frame ranges of the current baked Motion Path on the
active Object/Bone. This makes it clearer/easier to debug if the path suddenly
starts disappearing after a certain frame.

* Replaced Calculate/Clear Paths in the panels with a single "Update" button if
there's already a baked Motion Path.

Hopefully these changes (in combination with some of the other bugfixes) will
make it more obvious how everything works.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py
    trunk/blender/release/scripts/startup/bl_ui/properties_data_armature.py
    trunk/blender/release/scripts/startup/bl_ui/properties_object.py
    trunk/blender/source/blender/blenkernel/intern/anim.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/blender/makesrna/RNA_enum_types.h
    trunk/blender/source/blender/makesrna/intern/rna_animviz.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py	2012-05-01 15:59:28 UTC (rev 46157)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py	2012-05-01 16:19:13 UTC (rev 46158)
@@ -31,16 +31,18 @@
     bl_label = "Motion Paths"
     bl_options = {'DEFAULT_CLOSED'}
 
-    def draw_settings(self, context, avs, bones=False):
+    def draw_settings(self, context, avs, mpath, bones=False):
         layout = self.layout
 
         mps = avs.motion_path
-
+        
+        # Display Range
         layout.prop(mps, "type", expand=True)
 
         split = layout.split()
 
         col = split.column()
+        col.label(text="Display Range:")
         sub = col.column(align=True)
         if (mps.type == 'CURRENT_FRAME'):
             sub.prop(mps, "frame_before", text="Before")
@@ -48,18 +50,46 @@
         elif (mps.type == 'RANGE'):
             sub.prop(mps, "frame_start", text="Start")
             sub.prop(mps, "frame_end", text="End")
-
+            
         sub.prop(mps, "frame_step", text="Step")
+        
+        col = split.column()
         if bones:
-            col.row().prop(mps, "bake_location", expand=True)
-
+            col.label(text="Cache for Bone:")
+        else:
+            col.label(text="Cache:")
+            
+        if mpath:
+            sub = col.column(align=True)
+            sub.enabled = False
+            sub.prop(mpath, "frame_start", text="From")
+            sub.prop(mpath, "frame_end", text="To")
+            
+            sub = col.column() # align=True
+            sub.operator_context = 'EXEC_DEFAULT'
+            if bones:
+                col.operator("pose.paths_calculate", text="Update", icon='BONE_DATA')
+            else:
+                col.operator("object.paths_calculate", text="Update", icon='OBJECT_DATA')
+        else:
+            col.label(text="Not available yet...", icon='ERROR')
+            col.label(text="Calculate Paths first", icon='INFO')
+        
+        
+        # Display Settings
+        split = layout.split()
+        
         col = split.column()
-        col.label(text="Display:")
+        col.label(text="Show:")
         col.prop(mps, "show_frame_numbers", text="Frame Numbers")
+        
+        col = split.column()
         col.prop(mps, "show_keyframe_highlight", text="Keyframes")
+        sub = col.column()
+        sub.enabled = mps.show_keyframe_highlight
         if bones:
-            col.prop(mps, "show_keyframe_action_all", text="+ Non-Grouped Keyframes")
-        col.prop(mps, "show_keyframe_numbers", text="Keyframe Numbers")
+            sub.prop(mps, "show_keyframe_action_all", text="+ Non-Grouped Keyframes")
+        sub.prop(mps, "show_keyframe_numbers", text="Keyframe Numbers")
 
 
 # FIXME: this panel still needs to be ported so that it will work correctly with animviz

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_armature.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_armature.py	2012-05-01 15:59:28 UTC (rev 46157)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_armature.py	2012-05-01 16:19:13 UTC (rev 46158)
@@ -308,16 +308,14 @@
         layout = self.layout
 
         ob = context.object
+        avs = ob.pose.animation_visualisation
+        
+        pchan = context.active_pose_bone
+        mpath = pchan.motion_path if pchan else None
+        
+        self.draw_settings(context, avs, mpath, bones=True)
 
-        self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
 
-        layout.separator()
-
-        split = layout.split()
-        split.operator("pose.paths_calculate", text="Calculate Paths")
-        split.operator("pose.paths_clear", text="Clear Paths")
-
-
 class DATA_PT_onion_skinning(OnionSkinButtonsPanel):  # , Panel): # inherit from panel when ready
     #bl_label = "Bones Onion Skinning"
     bl_context = "data"

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_object.py	2012-05-01 15:59:28 UTC (rev 46157)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_object.py	2012-05-01 16:19:13 UTC (rev 46158)
@@ -299,16 +299,12 @@
         layout = self.layout
 
         ob = context.object
+        avs = ob.animation_visualisation
+        mpath = ob.motion_path
+        
+        self.draw_settings(context, avs, mpath)
 
-        self.draw_settings(context, ob.animation_visualisation)
 
-        layout.separator()
-
-        row = layout.row()
-        row.operator("object.paths_calculate", text="Calculate Paths")
-        row.operator("object.paths_clear", text="Clear Paths")
-
-
 class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel):  # , Panel): # inherit from panel when ready
     #bl_label = "Object Onion Skinning"
     bl_context = "object"

Modified: trunk/blender/source/blender/blenkernel/intern/anim.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim.c	2012-05-01 15:59:28 UTC (rev 46157)
+++ trunk/blender/source/blender/blenkernel/intern/anim.c	2012-05-01 16:19:13 UTC (rev 46158)
@@ -198,9 +198,7 @@
 			}
 			else {
 				/* clear the existing path (as the range has changed), and reallocate below */
-				if (mpath->points)
-					MEM_freeN(mpath->points);
-				mpath->points = NULL;
+				animviz_free_motionpath_cache(mpath);
 			}
 		}
 	}

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2012-05-01 15:59:28 UTC (rev 46157)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2012-05-01 16:19:13 UTC (rev 46158)
@@ -197,24 +197,54 @@
 	BLI_freelistN(&targets);
 }
 
+/* show popup to determine settings */
+static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *evt)
+{	
+	Object *ob = object_pose_armature_get(CTX_data_active_object(C));
+	
+	if (ELEM(NULL, ob, ob->pose))
+		return OPERATOR_CANCELLED;
+	
+	/* set default settings from existing/stored settings */
+	{
+		bAnimVizSettings *avs = &ob->pose->avs;
+		PointerRNA avs_ptr;
+		
+		RNA_int_set(op->ptr, "start_frame", avs->path_sf);
+		RNA_int_set(op->ptr, "end_frame", avs->path_ef);
+		
+		RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
+		RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location"));
+	}
+	
+	/* show popup dialog to allow editing of range... */
+	// FIXME: hardcoded dimensions here are just arbitrary
+	return WM_operator_props_dialog_popup(C, op, 200, 200);
+}
+
 /* For the object with pose/action: create path curves for selected bones 
  * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range
  */
-static int pose_calculate_paths_exec (bContext *C, wmOperator *op)
+static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
 {
-	ScrArea *sa= CTX_wm_area(C);
+	Object *ob = object_pose_armature_get(CTX_data_active_object(C));
 	Scene *scene= CTX_data_scene(C);
-	Object *ob;
 	
-	/* since this call may also be used from the buttons window, we need to check for where to get the object */
-	if (sa->spacetype == SPACE_BUTS) 
-		ob= ED_object_context(C);
-	else
-		ob= object_pose_armature_get(CTX_data_active_object(C));
-		
 	if (ELEM(NULL, ob, ob->pose))
 		return OPERATOR_CANCELLED;
 	
+	/* grab baking settings from operator settings */
+	{
+		bAnimVizSettings *avs = &ob->pose->avs;
+		PointerRNA avs_ptr;
+		
+		avs->path_sf = RNA_int_get(op->ptr, "start_frame");
+		avs->path_ef = RNA_int_get(op->ptr, "end_frame");
+		
+		RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
+		RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location"));
+	}
+	
 	/* set up path data for bones being calculated */
 	CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
 	{
@@ -228,7 +258,7 @@
 	ED_pose_recalculate_paths(scene, ob);
 	
 	/* notifiers for updates */
-	WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
 	
 	return OPERATOR_FINISHED; 
 }
@@ -241,11 +271,22 @@
 	ot->description = "Calculate paths for the selected bones";
 	
 	/* api callbacks */
+	ot->invoke = pose_calculate_paths_invoke;
 	ot->exec = pose_calculate_paths_exec;
 	ot->poll = ED_operator_posemode;
 	
 	/* flags */
 	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+	
+	/* properties */
+	RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", 
+	            "First frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0);
+	RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", 
+	            "Last frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0);
+	
+	RNA_def_enum(ot->srna, "bake_location", motionpath_bake_location_items, 0, 
+	             "Bake Location", 
+				 "Which point on the bones is used when calculating paths");
 }
 
 /* --------- */
@@ -279,14 +320,7 @@
 /* operator callback for this */
 static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op))
 {
-	ScrArea *sa= CTX_wm_area(C);
-	Object *ob;
-	
-	/* since this call may also be used from the buttons window, we need to check for where to get the object */
-	if (sa->spacetype == SPACE_BUTS) 
-		ob= ED_object_context(C);
-	else
-		ob= object_pose_armature_get(CTX_data_active_object(C));
+	Object *ob = object_pose_armature_get(CTX_data_active_object(C));
 		
 	/* only continue if there's an object */
 	if (ELEM(NULL, ob, ob->pose))
@@ -296,7 +330,7 @@
 	ED_pose_clear_paths(ob);
 	
 	/* notifiers for updates */
-	WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
 	
 	return OPERATOR_FINISHED; 
 }

Modified: trunk/blender/source/blender/editors/object/object_edit.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_edit.c	2012-05-01 15:59:28 UTC (rev 46157)
+++ trunk/blender/source/blender/editors/object/object_edit.c	2012-05-01 16:19:13 UTC (rev 46158)
@@ -1125,14 +1125,43 @@
 	BLI_freelistN(&targets);
 }
 
+/* show popup to determine settings */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list