Commit: 52181a26c68782878ff27c62d16acb871c66614a
Author: Sergey Sharybin
Date:   Thu Sep 15 12:12:59 2016 +0200
Branches: master
https://developer.blender.org/rB52181a26c68782878ff27c62d16acb871c66614a

Depsgraph: Avoid some false-positive time dependencies of scripted drivers

This was quite weak to consider all scripted expression to be time-dependent.
Current solution is somewhat better but still crappy. Not sure how can we make
it really nice.

===================================================================

M       source/blender/depsgraph/intern/builder/deg_builder_relations.cc

===================================================================

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 2148a35..09c7d9a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -115,6 +115,32 @@ namespace DEG {
 /* ***************** */
 /* Relations Builder */
 
+/* TODO(sergey): This is somewhat weak, but we don't want neither 
false-positive
+ * time dependencies nor special exceptions in the depsgraph evaluation.
+ */
+static bool python_driver_depends_on_time(ChannelDriver *driver)
+{
+       if (driver->expression[0] == '\0') {
+               /* Empty expression depends on nothing. */
+               return false;
+       }
+       if (strchr(driver->expression, '(') != NULL) {
+               /* Function calls are considered dependent on a time. */
+               return true;
+       }
+       if (strstr(driver->expression, "time") != NULL) {
+               /* Variable `time` depends on time. */
+               /* TODO(sergey): This is a bit weak, but not sure about better 
way of
+                * handling this.
+                */
+               return true;
+       }
+       /* Possible indirect time relation s should be handled via variable
+        * targets.
+        */
+       return false;
+}
+
 /* **** General purpose functions ****  */
 
 RNAPathKey::RNAPathKey(ID *id, const char *path) :
@@ -1016,7 +1042,9 @@ void DepsgraphRelationBuilder::build_driver(ID *id, 
FCurve *fcu)
         * so for now we'll be quite conservative here about optimization and 
consider
         * all python drivers to be depending on time.
         */
-       if (driver->type == DRIVER_TYPE_PYTHON) {
+       if ((driver->type == DRIVER_TYPE_PYTHON) &&
+           python_driver_depends_on_time(driver))
+       {
                TimeSourceKey time_src_key;
                add_relation(time_src_key, driver_key, DEPSREL_TYPE_TIME, 
"[TimeSrc -> Driver]");
        }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to