[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56857] trunk/blender/source/blender: Fix #35388, grouped nodes not editable in properties ui.

Lukas Toenne lukas.toenne at googlemail.com
Thu May 16 17:06:18 CEST 2013


Revision: 56857
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56857
Author:   lukastoenne
Date:     2013-05-16 15:06:18 +0000 (Thu, 16 May 2013)
Log Message:
-----------
Fix #35388, grouped nodes not editable in properties ui.

The issue here was that the "active" material node depends on the editor context. Previously (< 2.67) there was only 1 edited node group possible globally throughout Blender, so the active material in the context could be resolved more easily. The solution now involves the active_viewer_key variable (first introduced for compositor viewer nodes in r56271, naming is a bit awkward but hard to change in DNA). This key defines the "last modified" node tree to resolve ambiguity of active context items. For single editors the result is the same as in 2.66, if multiple editors are used with different node groups the last modified tree is used.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56271

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2013-05-16 13:58:21 UTC (rev 56856)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2013-05-16 15:06:18 UTC (rev 56857)
@@ -2278,30 +2278,41 @@
 	return node;
 }
 
-/* two active flags, ID nodes have special flag for buttons display */
-bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
+static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key, bNodeInstanceKey parent_key, bNodeTree *ntree, short idtype)
 {
-	bNode *node, *tnode;
-	
-	if (ntree == NULL) return NULL;
-
-	for (node = ntree->nodes.first; node; node = node->next)
-		if (node->id && GS(node->id->name) == idtype)
-			if (node->flag & NODE_ACTIVE_ID)
-				return node;
-	
-	/* no node with active ID in this tree, look inside groups */
-	for (node = ntree->nodes.first; node; node = node->next) {
-		if (node->type == NODE_GROUP) {
-			tnode = nodeGetActiveID((bNodeTree *)node->id, idtype);
-			if (tnode)
-				return tnode;
+	if (parent_key.value == active_key.value) {
+		bNode *node;
+		for (node = ntree->nodes.first; node; node = node->next)
+			if (node->id && GS(node->id->name) == idtype)
+				if (node->flag & NODE_ACTIVE_ID)
+					return node;
+	}
+	else {
+		bNode *node, *tnode;
+		/* no node with active ID in this tree, look inside groups */
+		for (node = ntree->nodes.first; node; node = node->next) {
+			if (node->type == NODE_GROUP) {
+				bNodeTree *group = (bNodeTree *)node->id;
+				bNodeInstanceKey group_key = BKE_node_instance_key(parent_key, ntree, node);
+				tnode = node_get_active_id_recursive(active_key, group_key, group, idtype);
+				if (tnode)
+					return tnode;
+			}
 		}
 	}
 	
 	return NULL;
 }
 
+/* two active flags, ID nodes have special flag for buttons display */
+bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
+{
+	if (ntree)
+		return node_get_active_id_recursive(ntree->active_viewer_key, NODE_INSTANCE_KEY_BASE, ntree, idtype);
+	else
+		return NULL;
+}
+
 bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
 {
 	bNode *node;

Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_node_types.h	2013-05-16 13:58:21 UTC (rev 56856)
+++ trunk/blender/source/blender/makesdna/DNA_node_types.h	2013-05-16 15:06:18 UTC (rev 56857)
@@ -370,10 +370,8 @@
 	 * Only available in base node trees (e.g. scene->node_tree)
 	 */
 	struct bNodeInstanceHash *previews;
-	/* XXX workaround for ambiguous viewer output:
-	 * Viewer nodes all write to the same image buffer.
-	 * This determines the tree instance containing the "active" output.
-	 * Only used in local scene->nodetree.
+	/* Defines the node tree instance to use for the "active" context,
+	 * in case multiple different editors are used and make context ambiguous.
 	 */
 	bNodeInstanceKey active_viewer_key;
 	int pad;




More information about the Bf-blender-cvs mailing list