diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-01-20 03:54:06 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-01-20 03:54:06 +0300 |
commit | 26bc442881ab45cabd3d5c2578862e2de3c3e8d2 (patch) | |
tree | 38c843e01c2b2a2e523b7747235c56615635d028 /source/blender/blenkernel/intern/fcurve.c | |
parent | e80fe46d7d106a0a32a30ff122e4845adb335d2f (diff) |
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
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 60d670e5f71..9b6063f0eec 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1270,12 +1270,12 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) 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 */ - int tot = 0; float value = 0.0f; + int tot = 0; /* loop through targets, adding (hopefully we don't get any overflow!) */ for (dvar= driver->variables.first; dvar; dvar=dvar->next) { @@ -1285,10 +1285,9 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) /* 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 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) value= tmp_val; } } + + /* store value in driver */ + driver->curval= value; } break; @@ -1332,13 +1334,15 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) if ( (driver->expression[0] == '\0') || (driver->flag & DRIVER_FLAG_INVALID) ) { - return 0.0f; + driver->curval= 0.0f; + } + 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); } - - /* this evaluates the expression using Python,and returns its result: - * - on errors it reports, then returns 0.0f - */ - return BPY_pydriver_eval(driver); #endif /* DISABLE_PYTHON*/ } break; @@ -1349,12 +1353,11 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) * 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 ********************************* */ |