[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26124] trunk/blender/source/blender: Drivers UI: Debug Info

Joshua Leung aligorith at gmail.com
Wed Jan 20 00:38:26 CET 2010


Revision: 26124
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26124
Author:   aligorith
Date:     2010-01-20 00:38:26 +0100 (Wed, 20 Jan 2010)

Log Message:
-----------
Drivers UI: Debug Info

Feature request for ZanQdo, which shows the intermediate values used in driver calculations (i.e. current value of driver, and current value of variables), allowing drivers expressions to be debugged. This is a per-driver setting...

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/fcurve.c
    trunk/blender/source/blender/editors/space_graph/graph_buttons.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c
    trunk/blender/source/blender/makesdna/DNA_anim_types.h
    trunk/blender/source/blender/makesrna/intern/rna_fcurve.c

Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c	2010-01-19 22:44:43 UTC (rev 26123)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c	2010-01-19 23:38:26 UTC (rev 26124)
@@ -1237,14 +1237,17 @@
 		return 0.0f;
 	
 	/* call the relevant callbacks to get the variable value 
-	 * using the variable type info
+	 * using the variable type info, storing the obtained value
+	 * in dvar->curval so that drivers can be debugged
 	 */
 	dvti= get_dvar_typeinfo(dvar->type);
 	
 	if (dvti && dvti->get_value)
-		return dvti->get_value(driver, dvar);
+		dvar->curval= dvti->get_value(driver, dvar);
 	else
-		return 0.0f;
+		dvar->curval= 0.0f;
+	
+	return dvar->curval;
 }
 
 /* Evaluate an Channel-Driver to get a 'time' value to use instead of "evaltime"

Modified: trunk/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2010-01-19 22:44:43 UTC (rev 26123)
+++ trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2010-01-19 23:38:26 UTC (rev 26124)
@@ -318,7 +318,7 @@
 	
 	/* Target ID */
 	row= uiLayoutRow(layout, 0);
-		uiTemplateAnyID(row, (bContext *)C, &dtar_ptr, "id", "id_type", "Value:");
+		uiTemplateAnyID(row, (bContext *)C, &dtar_ptr, "id", "id_type", "Prop:");
 	
 	/* Target Property */
 	// TODO: make this less technical...
@@ -490,6 +490,21 @@
 			if (driver->flag & DRIVER_FLAG_INVALID)
 				uiItemL(col, "ERROR: invalid target channel(s)", ICON_ERROR);
 		}
+		
+	col= uiLayoutColumn(pa->layout, 1);
+		/* debug setting */
+		uiItemR(col, NULL, 0, &driver_ptr, "show_debug_info", 0);
+		
+		/* value of driver */
+		if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
+			uiLayout *row= uiLayoutRow(col, 1);
+			char valBuf[32];
+			
+			uiItemL(row, "Driver Value:", 0);
+			
+			sprintf(valBuf, "%.3f", driver->curval);
+			uiItemL(row, valBuf, 0);
+		}
 	
 	/* add driver variables */
 	col= uiLayoutColumn(pa->layout, 0);
@@ -542,6 +557,19 @@
 					graph_panel_driverVar__transChan(C, box, ale->id, dvar);
 					break;
 			}
+			
+		/* value of variable */
+		if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
+			uiLayout *row;
+			char valBuf[32];
+			
+			box= uiLayoutBox(col);
+			row= uiLayoutRow(box, 1);
+				uiItemL(row, "Value:", 0);
+				
+				sprintf(valBuf, "%.3f", dvar->curval);
+				uiItemL(row, valBuf, 0);
+		}
 	}
 	
 	/* cleanup */

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2010-01-19 22:44:43 UTC (rev 26123)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2010-01-19 23:38:26 UTC (rev 26124)
@@ -4600,7 +4600,6 @@
 {
 	ID *id= &ob->id;
 	AnimData *adt= ob->adt;
-	bArmature *arm= ob->data;
 	bAction	*act= (adt) ? adt->action : NULL;
 	bPose	*pose= ob->pose;
 	bPoseChannel *pchan;

Modified: trunk/blender/source/blender/makesdna/DNA_anim_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_anim_types.h	2010-01-19 22:44:43 UTC (rev 26123)
+++ trunk/blender/source/blender/makesdna/DNA_anim_types.h	2010-01-19 23:38:26 UTC (rev 26124)
@@ -294,9 +294,10 @@
 	char name[64];				/* name of the variable to use in py-expression (must be valid python identifier) */
 	
 	DriverTarget targets[8];	/* MAX_DRIVER_TARGETS, target slots */	
-	int num_targets;			/* number of targets actually used by this variable */
+	short num_targets;			/* number of targets actually used by this variable */
 	
-	int type;					/* type of driver target (eDriverTarget_Types) */		
+	short type;					/* type of driver target (eDriverTarget_Types) */	
+	float curval;				/* result of previous evaluation */
 } DriverVar;
 
 /* Driver Variable Types */
@@ -339,7 +340,7 @@
 	char expression[256];	/* expression to compile for evaluation */
 	void *expr_comp; 		/* PyObject - compiled expression, dont save this */
 	
-	float curval;		/* result of previous evaluation, for subtraction from result under certain circumstances */
+	float curval;		/* result of previous evaluation */
 	float influence;	/* influence of driver on result */ // XXX to be implemented... this is like the constraint influence setting
 	
 		/* general settings */
@@ -374,6 +375,8 @@
 	DRIVER_FLAG_RECOMPILE	= (1<<3),
 		/* the names are cached so they dont need have python unicode versions created each time */
 	DRIVER_FLAG_RENAMEVAR	= (1<<4),
+		/* intermediate values of driver should be shown in the UI for debugging purposes */
+	DRIVER_FLAG_SHOWDEBUG	= (1<<5),
 } eDriver_Flags;
 
 /* F-Curves -------------------------------------- */

Modified: trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2010-01-19 22:44:43 UTC (rev 26123)
+++ trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2010-01-19 23:38:26 UTC (rev 26124)
@@ -856,6 +856,11 @@
 	RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver.");
 	rna_def_channeldriver_variables(brna, prop);
 	
+	/* Settings */
+	prop= RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG);
+	RNA_def_property_ui_text(prop, "Show Debug Info", "Show intermediate values for the driver calculations to allow debugging of drivers.");
+	
 	/* Functions */
 	RNA_api_drivers(srna);
 }





More information about the Bf-blender-cvs mailing list