[Bf-blender-cvs] [67e4b1d3e9f] master: Fix missing node tree updates when unconnected node affects output via driver

Sergey Sharybin noreply at git.blender.org
Tue Jan 16 12:07:09 CET 2018


Commit: 67e4b1d3e9fdb70b5007aeb00dd31482b649ee19
Author: Sergey Sharybin
Date:   Tue Jan 16 12:06:22 2018 +0100
Branches: master
https://developer.blender.org/rB67e4b1d3e9fdb70b5007aeb00dd31482b649ee19

Fix missing node tree updates when unconnected node affects output via driver

Fixes T53794: Can't control color ramp node color values with drivers

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

M	source/blender/editors/space_node/node_relationships.c

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

diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 64c019d12a3..70f7553cf41 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -31,12 +31,14 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_anim_types.h"
 #include "DNA_node_types.h"
 
 #include "BLI_math.h"
 #include "BLI_blenlib.h"
 #include "BLI_easing.h"
 
+#include "BKE_animsys.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
@@ -63,6 +65,15 @@
 
 /* ****************** Relations helpers *********************** */
 
+static bool ntree_has_drivers(bNodeTree *ntree)
+{
+	AnimData *adt = BKE_animdata_from_id(&ntree->id);
+	if (adt == NULL) {
+		return false;
+	}
+	return !BLI_listbase_is_empty(&adt->drivers);
+}
+
 static bool ntree_check_nodes_connected_dfs(bNodeTree *ntree,
                                             bNode *from,
                                             bNode *to)
@@ -134,6 +145,14 @@ static bool node_group_has_output(bNode *node)
 
 bool node_connected_to_output(bNodeTree *ntree, bNode *node)
 {
+	/* Special case for drivers: if node tree has any drivers we assume it is
+	 * always to be tagged for update when node changes. Otherwise we will be
+	 * doomed to do some deep and nasty deep search of indirect dependencies,
+	 * which will be too complicated without real benefit.
+	 */
+	if (ntree_has_drivers(ntree)) {
+		return true;
+	}
 	for (bNode *current_node = ntree->nodes.first;
 	     current_node != NULL;
 	     current_node = current_node->next)
@@ -144,11 +163,17 @@ bool node_connected_to_output(bNodeTree *ntree, bNode *node)
 		 * We could make check more grained here by taking which socket the node
 		 * is connected to and so eventually.
 		 */
-		if (current_node->type == NODE_GROUP &&
-		    ntree_check_nodes_connected(ntree, node, current_node) &&
-		    node_group_has_output(current_node))
-		{
-			return true;
+		if (current_node->type == NODE_GROUP) {
+			if (current_node->id != NULL &&
+			    ntree_has_drivers((bNodeTree *)current_node->id))
+			{
+				return true;
+			}
+			if (ntree_check_nodes_connected(ntree, node, current_node) &&
+			    node_group_has_output(current_node))
+			{
+				return true;
+			}
 		}
 		if (current_node->flag & NODE_DO_OUTPUT) {
 			if (ntree_check_nodes_connected(ntree, node, current_node)) {



More information about the Bf-blender-cvs mailing list