[Bf-blender-cvs] [46204f843b5] master: Depsgraph: Fix for fake dependency cycle being created for shape key drivers

Sergey Sharybin noreply at git.blender.org
Wed Jan 17 18:02:54 CET 2018


Commit: 46204f843b5710dabb99e194aee5e3202b9688e4
Author: Sergey Sharybin
Date:   Wed Jan 17 18:00:54 2018 +0100
Branches: master
https://developer.blender.org/rB46204f843b5710dabb99e194aee5e3202b9688e4

Depsgraph: Fix for fake dependency cycle being created for shape key drivers

One thing i'm not fully happy with is all this is_same_* functions. Need to
get rid of this by probably adding explicit entry/init/whatever nodes and
maybe making node criteria aware of whether key will be used as "from" or
as "to" node.

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

M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
M	source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph.cc

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 38e58043e5b..3e352539035 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1178,7 +1178,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;
 				}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 1a761f76744..de13ee19122 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -276,6 +276,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
@@ -289,7 +291,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:
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
index 5b1f7be8e45..b7dd05517cf 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
@@ -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
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index ca7e9c5c40c..270202f9f34 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -468,6 +468,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
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index c4841d6789e..757af7cc3fc 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -192,11 +192,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;
 	}



More information about the Bf-blender-cvs mailing list