Drivers: "Scripted Expression" drivers (i.e. PyDrivers) work again

Now it is possible to write a Python Expression using the variable names for driver targets (see mockup from initial commit) to substitute the appropriate values into the expression.

In the __global__ namespace for PyDriver evaluation, the following modules are available:
* __builtins__ - i.e. the builtin Python functions
* bpy - new Python API
* math or m - math module

For example:
Consider a driver with three targets, named: A, B, C
Now, you could write an expression like:
   C if A < 5 else B
or even:
   2*C if A < 5 or A > 20 else m.PI*B

Of course, you don't have to have three targets, the above was just an example.

TODO:
* Bring back way to load pydrivers.py
* Blender.Noise equivalent would be nice to have

P.S.  I hope I haven't made any terrible Python API coding errors here (i.e. mem leaks, etc.)
This commit is contained in:
2009-04-20 09:17:43 +00:00
parent 6482206078
commit 332e001989
7 changed files with 208 additions and 6 deletions

View File

@@ -126,7 +126,6 @@ extern "C" {
void BPY_pydriver_update(void);
float BPY_pydriver_eval(struct ChannelDriver *driver);
struct Object **BPY_pydriver_get_objects(struct ChannelDriver *driver);
int BPY_button_eval(char *expr, double *value);