[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26126] trunk/blender/source/blender/ blenkernel/intern/fcurve.c: Bugfix for Driver Evaluation:

Joshua Leung aligorith at gmail.com
Wed Jan 20 01:54:08 CET 2010


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

Log Message:
-----------
Bugfix for Driver Evaluation:
* Current value for drivers didn't get stored, which meant that the debug value never got updated to reflect the current state.
* Min/Max variable types were not working

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/fcurve.c

Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c	2010-01-20 00:31:34 UTC (rev 26125)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c	2010-01-20 00:54:06 UTC (rev 26126)
@@ -1270,12 +1270,12 @@
 			if (driver->variables.first == driver->variables.last) {
 				/* just one target, so just use that */
 				dvar= driver->variables.first;
-				return driver_get_variable_value(driver, dvar);
+				driver->curval= driver_get_variable_value(driver, dvar);
 			}
 			else {
 				/* more than one target, so average the values of the targets */
+				float value = 0.0f;
 				int tot = 0;
-				float value = 0.0f;
 				
 				/* loop through targets, adding (hopefully we don't get any overflow!) */
 				for (dvar= driver->variables.first; dvar; dvar=dvar->next) {
@@ -1285,10 +1285,9 @@
 				
 				/* perform operations on the total if appropriate */
 				if (driver->type == DRIVER_TYPE_AVERAGE)
-					return (value / (float)tot);
+					driver->curval= (value / (float)tot);
 				else
-					return value;
-				
+					driver->curval= value;
 			}
 		}
 			break;
@@ -1322,6 +1321,9 @@
 					value= tmp_val;
 				}
 			}
+			
+			/* store value in driver */
+			driver->curval= value;
 		}
 			break;
 			
@@ -1332,13 +1334,15 @@
 			if ( (driver->expression[0] == '\0') ||
 				 (driver->flag & DRIVER_FLAG_INVALID) )
 			{
-				return 0.0f;
+				driver->curval= 0.0f;
 			}
-			
-			/* this evaluates the expression using Python,and returns its result:
-			 * 	- on errors it reports, then returns 0.0f
-			 */
-			return BPY_pydriver_eval(driver);
+			else
+			{
+				/* this evaluates the expression using Python,and returns its result:
+				 * 	- on errors it reports, then returns 0.0f
+				 */
+				driver->curval= BPY_pydriver_eval(driver);
+			}
 #endif /* DISABLE_PYTHON*/
 		}
 			break;
@@ -1349,12 +1353,11 @@
 			 *	This is currently used as the mechanism which allows animated settings to be able
 			 * 	to be changed via the UI.
 			 */
-			return driver->curval;
 		}
 	}
 	
-	/* return 0.0f, as couldn't find relevant data to use */
-	return 0.0f;
+	/* return value for driver */
+	return driver->curval;
 }
 
 /* ***************************** Curve Calculations ********************************* */





More information about the Bf-blender-cvs mailing list