Driver set-up could be reworked to avoid Python expressions entirely and take advantage of multithreading

Issue #393 closed
Xin created an issue

See: https://docs.blender.org/manual/en/latest/animation/drivers/drivers_panel.html#simple-expressions

Attached there is an example showing how to avoid Python expressions for rig properties which currently rely on “evalMorphs…” Python functions. Doing this would also get rid of any need for “runtime_stripped…” files. These drivers can be run even with Python disabled. So for people who send scenes to render farms, this would be better too.

To see the .blend example, run the script inside the .blend. The script is also in a text file outside the blend. The image shows the general structure of the set-up made by the example script (maybe you can think of a better one). The example only covers rig properties, but a similar approach with some modifications could work for all drivers.

I don’t know how difficult it would be to re-work the driver set-up this way in the addon, but it doesn’t need to be implemented overnight and it could be a long-term process.

As a quick optimization right now, without much additional work, check the expressions for many Shape Keys, they could be made quicker (and avoid Python) by stripping brackets and indexing, from:

[1 if x< -1 else -x if x< 0  else 0 for x in [-0.764*A]][0]     

to:

1 if (-0.764*A)<-1 else -(-0.764*A) if (-0.764*A)<0 else 0

Comments (4)

  1. Xin reporter

    The “Sum Values” Driver type has no apparent limit to the number of inputs. So you can keep adding inputs to it. Even if there was one, you can chain them, take the output from the sum of the first X values and use it as a single input in a final sum going over the rest of the terms. Performance would be way better, since this is all executed in C++ on multiple threads.

  2. Log in to comment