Blender Git Commit Log

Git Commits -> Revision bf2a54b

Revision bf2a54b by Alexander Gavrilov (master)
September 18, 2018, 10:25 (GMT)
Support evaluating simple driver expressions without Python interpreter.

Recently @sergey found that hard-coding evaluation of certain very
common driver expressions without calling the Python interpreter
produces a 30-40% performance improvement. Since hard-coding is
obviously not suitable for production, I implemented a proper
parser and interpreter for simple arithmetic expressions in C.

The evaluator supports +, -, *, /, (), ==, !=, <, <=, >, >=,
and, or, not, ternary if; driver variables, frame, pi, True, False,
and a subset of standard math functions that seem most useful.

Booleans are represented as numbers, since within the supported
operation set it seems to be impossible to distinguish True/False
from 1.0/0.0. Boolean operations properly implement lazy evaluation
with jumps, and comparisons support chaining like 'a < b < c...'.

Expressions are parsed into a very simple stack machine program
that can then be safely evaluated in multiple threads.

Reviewers: sergey, campbellbarton

Differential Revision: https://developer.blender.org/D3698

Commit Details:

Full Hash: bf2a54b0584c1e568af7ecf67ae2a623bc5263fe
Parent Commit: 34ee9ab
Lines Changed: +1495, -26

3 Added Paths:

/source/blender/blenlib/BLI_simple_expr.h (+96, -0) (View)
/source/blender/blenlib/intern/simple_expr.c (+924, -0) (View)
/tests/gtests/blenlib/BLI_simple_expr_test.cc (+310, -0) (View)

10 Modified Paths:

/source/blender/blenkernel/BKE_fcurve.h (+3, -0) (Diff)
/source/blender/blenkernel/intern/fcurve.c (+131, -12) (Diff)
/source/blender/blenlib/CMakeLists.txt (+1, -0) (Diff)
/source/blender/blenloader/intern/readfile.c (+1, -0) (Diff)
/source/blender/editors/animation/drivers.c (+1, -4) (Diff)
/source/blender/editors/interface/interface_anim.c (+2, -2) (Diff)
/source/blender/editors/space_graph/graph_buttons.c (+10, -5) (Diff)
/source/blender/makesdna/DNA_anim_types.h (+2, -0) (Diff)
/source/blender/makesrna/intern/rna_fcurve.c (+13, -3) (Diff)
/tests/gtests/blenlib/CMakeLists.txt (+1, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021