Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 17 Jan 2018 17:03:08 +0000 (18:03 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 17 Jan 2018 17:03:08 +0000 (18:03 +0100)
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
source/blender/depsgraph/intern/depsgraph.cc

index dde8555ab9ee4c44eff745e3bc362a604a004496..077bdd94f562f5d73815d5241663dbc67d813848 100644 (file)
@@ -1201,7 +1201,8 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
                                        continue;
                                }
                                if (is_same_bone_dependency(variable_key, self_key) ||
-                                   is_nodetree_node_dependency(variable_key, self_key))
+                                   is_same_nodetree_node_dependency(variable_key, self_key) ||
+                                   is_same_shapekey_dependency(variable_key, self_key))
                                {
                                        continue;
                                }
index 920f115a1750ae11905838aad0ebd7269989bb33..30b3219f9890fb1286bc485f01e922357157a9e9 100644 (file)
@@ -297,6 +297,8 @@ protected:
        DepsNodeHandle create_node_handle(const KeyType& key,
                                          const char *default_name = "");
 
+       /* TODO(sergey): All those is_same* functions are to be generalized. */
+
        /* Check whether two keys correponds to the same bone from same armature.
         *
         * This is used by drivers relations builder to avoid possible fake
@@ -310,7 +312,14 @@ protected:
         * the same node tree as a driver variable.
         */
        template <typename KeyFrom, typename KeyTo>
-       bool is_nodetree_node_dependency(const KeyFrom& key_from,
+       bool is_same_nodetree_node_dependency(const KeyFrom& key_from,
+                                             const KeyTo& key_to);
+
+       /* Similar to above, but used to check whether driver is using key from
+        * the same key datablock as a driver variable.
+        */
+       template <typename KeyFrom, typename KeyTo>
+       bool is_same_shapekey_dependency(const KeyFrom& key_from,
                                         const KeyTo& key_to);
 
 private:
index 7853bb9ca70b01dca18ba48f5409bba73716391e..d55f00ae7e4f4d90879f89b07c363fbf9115aaac 100644 (file)
@@ -164,7 +164,7 @@ bool DepsgraphRelationBuilder::is_same_bone_dependency(const KeyFrom& key_from,
 }
 
 template <typename KeyFrom, typename KeyTo>
-bool DepsgraphRelationBuilder::is_nodetree_node_dependency(
+bool DepsgraphRelationBuilder::is_same_nodetree_node_dependency(
         const KeyFrom& key_from,
         const KeyTo& key_to)
 {
@@ -196,4 +196,31 @@ bool DepsgraphRelationBuilder::is_nodetree_node_dependency(
        return true;
 }
 
+template <typename KeyFrom, typename KeyTo>
+bool DepsgraphRelationBuilder::is_same_shapekey_dependency(
+        const KeyFrom& key_from,
+        const KeyTo& key_to)
+{
+       /* Get operations for requested keys. */
+       DepsNode *node_from = get_node(key_from);
+       DepsNode *node_to = get_node(key_to);
+       if (node_from == NULL || node_to == NULL) {
+               return false;
+       }
+       OperationDepsNode *op_from = node_from->get_exit_operation();
+       OperationDepsNode *op_to = node_to->get_entry_operation();
+       if (op_from == NULL || op_to == NULL) {
+               return false;
+       }
+       /* Check if this is actually a shape key datablock. */
+       if (GS(op_from->owner->owner->id->name) != ID_KE) {
+               return false;
+       }
+       /* Different key data blocks. */
+       if (op_from->owner->owner != op_to->owner->owner) {
+               return false;
+       }
+       return true;
+}
+
 }  // namespace DEG
index 827bb4d10adc8d9fbdfd72c7e90783be665906fb..8fc4c0bcec14de9de3d5c9e6e754088b1452a5bf 100644 (file)
@@ -467,6 +467,7 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx,
                deg_debug_fprintf(ctx, "[");
                /* Note: without label an id seem necessary to avoid bugs in graphviz/dot */
                deg_debug_fprintf(ctx, "id=\"%s\"", rel->name);
+               deg_debug_fprintf(ctx, "label=\"%s\"", rel->name);
                deg_debug_fprintf(ctx, ",color="); deg_debug_graphviz_relation_color(ctx, rel);
                deg_debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
                /* NOTE: edge from node to own cluster is not possible and gives graphviz
index 45013bb1bcde9ffd8d5443874ed4aa8591333c3e..128dfd0e556935c751cf8c211741755fa80b5805 100644 (file)
@@ -204,11 +204,7 @@ static bool pointer_to_component_node_criteria(
                }
        }
        else if (ptr->type == &RNA_ShapeKey) {
-               Key *key = (Key *)ptr->id.data;
-               /* ShapeKeys are currently handled as geometry on the geometry that
-                * owns it.
-                */
-               *id = key->from;
+               *id = (ID *)ptr->id.data;
                *type = DEG_NODE_TYPE_GEOMETRY;
                return true;
        }