[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46334] trunk/blender: Bugfixes for Motion Path drawing/updating in light of the recent changes:

Joshua Leung aligorith at gmail.com
Sun May 6 06:18:16 CEST 2012


Revision: 46334
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46334
Author:   aligorith
Date:     2012-05-06 04:18:13 +0000 (Sun, 06 May 2012)
Log Message:
-----------
Bugfixes for Motion Path drawing/updating in light of the recent changes:
* Added proper "update" operators in place of the abuse of the calculate
operators, so now the display ranges won't get overwritten everytime (with the
default values) you go to update the paths.

* Display range settings in properties editor now actually work. Before, the "In
Range" mode only displayed the entire paths.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py
    trunk/blender/source/blender/editors/armature/armature_intern.h
    trunk/blender/source/blender/editors/armature/armature_ops.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/blender/editors/object/object_intern.h
    trunk/blender/source/blender/editors/object/object_ops.c
    trunk/blender/source/blender/editors/space_view3d/drawanimviz.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_animviz.py	2012-05-06 04:18:13 UTC (rev 46334)
@@ -65,12 +65,10 @@
             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')
+                col.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA')
             else:
-                col.operator("object.paths_calculate", text="Update", icon='OBJECT_DATA')
+                col.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA')
         else:
             col.label(text="Not available yet...", icon='ERROR')
             col.label(text="Calculate Paths first", icon='INFO')

Modified: trunk/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_intern.h	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/source/blender/editors/armature/armature_intern.h	2012-05-06 04:18:13 UTC (rev 46334)
@@ -117,6 +117,7 @@
 void POSE_OT_group_deselect(struct wmOperatorType *ot);
 
 void POSE_OT_paths_calculate(struct wmOperatorType *ot);
+void POSE_OT_paths_update(struct wmOperatorType *ot);
 void POSE_OT_paths_clear(struct wmOperatorType *ot);
 
 void POSE_OT_autoside_names(struct wmOperatorType *ot);

Modified: trunk/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_ops.c	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/source/blender/editors/armature/armature_ops.c	2012-05-06 04:18:13 UTC (rev 46334)
@@ -133,6 +133,7 @@
 	WM_operatortype_append(POSE_OT_group_deselect);
 	
 	WM_operatortype_append(POSE_OT_paths_calculate);
+	WM_operatortype_append(POSE_OT_paths_update);
 	WM_operatortype_append(POSE_OT_paths_clear);
 	
 	WM_operatortype_append(POSE_OT_autoside_names);

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2012-05-06 04:18:13 UTC (rev 46334)
@@ -197,6 +197,7 @@
 	BLI_freelistN(&targets);
 }
 
+
 /* show popup to determine settings */
 static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {	
@@ -291,6 +292,41 @@
 
 /* --------- */
 
+static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+	Scene *scene = CTX_data_scene(C);
+	
+	if (ELEM(NULL, ob, scene))
+		return OPERATOR_CANCELLED;
+		
+	/* calculate the bones that now have motionpaths... */
+	// TODO: only make for the selected bones?
+	ED_pose_recalculate_paths(scene, ob);
+	
+	/* notifiers for updates */
+	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+	
+	return OPERATOR_FINISHED;
+}
+
+void POSE_OT_paths_update(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Update Bone Paths";
+	ot->idname = "POSE_OT_paths_update";
+	ot->description = "Recalculate paths for bones that already have them";
+	
+	/* api callbakcs */
+	ot->exec = pose_update_paths_exec;
+	ot->poll = ED_operator_posemode; /* TODO: this should probably check for active bone and/or existing paths */
+	
+	/* flags */
+	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* --------- */
+
 /* for the object with pose/action: clear path curves for selected bones only */
 static void ED_pose_clear_paths(Object *ob)
 {

Modified: trunk/blender/source/blender/editors/object/object_edit.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_edit.c	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/source/blender/editors/object/object_edit.c	2012-05-06 04:18:13 UTC (rev 46334)
@@ -1125,6 +1125,7 @@
 	BLI_freelistN(&targets);
 }
 
+
 /* show popup to determine settings */
 static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
@@ -1200,6 +1201,39 @@
 
 /* --------- */
 
+static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Scene *scene = CTX_data_scene(C);
+	
+	if (scene == NULL)
+		return OPERATOR_CANCELLED;
+		
+	/* calculate the paths for objects that have them (and are tagged to get refreshed) */
+	ED_objects_recalculate_paths(C, scene);
+	
+	/* notifiers for updates */
+	WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+	
+	return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_paths_update(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Update Object Paths";
+	ot->idname = "OBJECT_OT_paths_update";
+	ot->description = "Recalculate paths for selected objects";
+	
+	/* api callbakcs */
+	ot->exec = object_update_paths_exec;
+	ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */
+	
+	/* flags */
+	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* --------- */
+
 /* Clear motion paths for selected objects only */
 void ED_objects_clear_paths(bContext *C)
 {

Modified: trunk/blender/source/blender/editors/object/object_intern.h
===================================================================
--- trunk/blender/source/blender/editors/object/object_intern.h	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/source/blender/editors/object/object_intern.h	2012-05-06 04:18:13 UTC (rev 46334)
@@ -84,6 +84,7 @@
 void OBJECT_OT_shade_smooth(struct wmOperatorType *ot);
 void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
 void OBJECT_OT_paths_calculate(struct wmOperatorType *ot);
+void OBJECT_OT_paths_update(struct wmOperatorType *ot);
 void OBJECT_OT_paths_clear(struct wmOperatorType *ot);
 void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot);
 

Modified: trunk/blender/source/blender/editors/object/object_ops.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_ops.c	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/source/blender/editors/object/object_ops.c	2012-05-06 04:18:13 UTC (rev 46334)
@@ -77,6 +77,7 @@
 	WM_operatortype_append(OBJECT_OT_shade_smooth);
 	WM_operatortype_append(OBJECT_OT_shade_flat);
 	WM_operatortype_append(OBJECT_OT_paths_calculate);
+	WM_operatortype_append(OBJECT_OT_paths_update);
 	WM_operatortype_append(OBJECT_OT_paths_clear);
 	WM_operatortype_append(OBJECT_OT_forcefield_toggle);
 

Modified: trunk/blender/source/blender/editors/space_view3d/drawanimviz.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawanimviz.c	2012-05-06 01:27:48 UTC (rev 46333)
+++ trunk/blender/source/blender/editors/space_view3d/drawanimviz.c	2012-05-06 04:18:13 UTC (rev 46334)
@@ -88,38 +88,50 @@
 	//RegionView3D *rv3d= ar->regiondata;
 	bMotionPathVert *mpv, *mpv_start;
 	int i, stepsize = avs->path_step;
-	int sfra, efra, len;
+	int sfra, efra, sind, len;
 	
-	
 	/* get frame ranges */
 	if (avs->path_type == MOTIONPATH_TYPE_ACFRA) {
-		int sind;
-		
 		/* With "Around Current", we only choose frames from around 
-		 * the current frame to draw. However, this range is still 
-		 * restricted by the limits of the original path.
+		 * the current frame to draw.
 		 */
 		sfra = CFRA - avs->path_bc;
 		efra = CFRA + avs->path_ac;
-		if (sfra < mpath->start_frame) sfra = mpath->start_frame;
-		if (efra > mpath->end_frame) efra = mpath->end_frame;
-		
-		len = efra - sfra;
-		
-		sind = sfra - mpath->start_frame;
-		mpv_start = (mpath->points + sind);
 	}
 	else {
+		/* Use the current display range */
+		sfra = avs->path_sf;
+		efra = avs->path_ef;
+	}
+	
+	/* no matter what, we can only show what is in the cache and no more 
+	 * - abort if whole range is past ends of path
+	 * - otherwise clamp endpoints to extents of path
+	 */
+	if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) {
+		/* whole path is out of bounds */
+		return;
+	}
+	
+	if (sfra < mpath->start_frame) {
+		/* start clamp */
 		sfra = mpath->start_frame;
-		efra = sfra + mpath->length;
-		len = mpath->length;
-		mpv_start = mpath->points;
 	}
-
+	if (efra > mpath->end_frame) {
+		/* end clamp */
+		efra = mpath->end_frame;
+	}
+	
+	len = efra - sfra;
+	
 	if (len <= 0) {
 		return;
 	}
-
+	
+	/* get pointers to parts of path */
+	sind = sfra - mpath->start_frame;
+	mpv_start = (mpath->points + sind);
+	
 	/* draw curve-line of path */
 	glShadeModel(GL_SMOOTH);
 	




More information about the Bf-blender-cvs mailing list