From fc1f5bded46afbb9b16fffe9e4c7f7c212566255 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 19 Jan 2020 12:44:34 +0300 Subject: Depsgraph: fix false positive time dependencies for simple drivers. The dependency graph has to know whether a driver must be re-evaluated every frame due to a dependency on the current frame number. For python drivers it was using a heuristic based on searching for certain sub- strings in the expression, notably including '('. When the expression is actually evaluated using Python, this can't be easily improved; however if the Simple Expression evaluator is used, this check can be done precisely by accessing the parsed data. Differential Revision: https://developer.blender.org/D6624 --- tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc b/tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc index 32e33e2e118..449577401d7 100644 --- a/tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc +++ b/tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc @@ -282,6 +282,19 @@ TEST(expr_pylike, MultipleArgs) BLI_expr_pylike_free(expr); } +TEST(expr_pylike, UsingParam) +{ + const char *names[3] = {"x", "y", "z"}; + + ExprPyLike_Parsed *expr = BLI_expr_pylike_parse("x + z", names, ARRAY_SIZE(names)); + + EXPECT_TRUE(BLI_expr_pylike_is_using_param(expr, 0)); + EXPECT_FALSE(BLI_expr_pylike_is_using_param(expr, 1)); + EXPECT_TRUE(BLI_expr_pylike_is_using_param(expr, 2)); + + BLI_expr_pylike_free(expr); +} + #define TEST_ERROR(name, str, x, code) \ TEST(expr_pylike, Error_##name) \ { \ -- cgit v1.2.3