[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55442] trunk/blender/source/blender/ editors/space_node/node_group.c: When making a node group always add one input and one output node, regardless of whether there are any exposed sockets.

Lukas Toenne lukas.toenne at googlemail.com
Wed Mar 20 14:58:04 CET 2013


Revision: 55442
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55442
Author:   lukastoenne
Date:     2013-03-20 13:58:03 +0000 (Wed, 20 Mar 2013)
Log Message:
-----------
When making a node group always add one input and one output node, regardless of whether there are any exposed sockets. The standard common case is that some sockets will eventually have to be exposed anyway, and it's easier to just delete the unused node instead of having to look it up in the menu.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_node/node_group.c

Modified: trunk/blender/source/blender/editors/space_node/node_group.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_group.c	2013-03-20 13:30:20 UTC (rev 55441)
+++ trunk/blender/source/blender/editors/space_node/node_group.c	2013-03-20 13:58:03 UTC (rev 55442)
@@ -730,7 +730,7 @@
 	float min[2], max[2], center[2];
 	int totselect;
 	int expose_all = FALSE;
-	bNode *input_node = NULL, *output_node = NULL;	/* lazy initialized, in case there are no external links */
+	bNode *input_node, *output_node;
 	
 	/* XXX rough guess, not nice but we don't have access to UI constants here ... */
 	static const float offsetx = 200;
@@ -797,6 +797,16 @@
 	/* node groups don't use internal cached data */
 	ntreeFreeCache(ngroup);
 	
+	/* create input node */
+	input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
+	input_node->locx = min[0] - center[0] - offsetx;
+	input_node->locy = -offsety;
+	
+	/* create output node */
+	output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
+	output_node->locx = max[0] - center[0] + offsetx;
+	output_node->locy = -offsety;
+	
 	/* relink external sockets */
 	for (link = ntree->links.first; link; link = linkn) {
 		int fromselect = node_group_make_use_node(link->fromnode, gnode);
@@ -818,13 +828,6 @@
 			bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock);
 			bNodeSocket *input_sock;
 			
-			/* lazy init */
-			if (!input_node) {
-				input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
-				
-				input_node->locx = min[0] - center[0] - offsetx;
-				input_node->locy = -offsety;
-			}
 			/* update the group node and interface node sockets,
 			 * so the new interface socket can be linked.
 			 */
@@ -843,13 +846,6 @@
 			bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->fromnode, link->fromsock);
 			bNodeSocket *output_sock;
 			
-			/* lazy init */
-			if (!output_node) {
-				output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
-				
-				output_node->locx = max[0] - center[0] + offsetx;
-				output_node->locy = -offsety;
-			}
 			/* update the group node and interface node sockets,
 			 * so the new interface socket can be linked.
 			 */
@@ -892,13 +888,6 @@
 					
 					iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
 					
-					/* lazy init */
-					if (!input_node) {
-						input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
-						
-						input_node->locx = min[0] - center[0] - offsetx;
-						input_node->locy = -offsety;
-					}
 					node_group_input_verify(ngroup, input_node, (ID *)ngroup);
 					
 					/* create new internal link */
@@ -917,14 +906,6 @@
 					
 					iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
 					
-					/* lazy init */
-					if (!output_node) {
-						output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
-						
-						output_node->locx = max[0] - center[0] + offsetx;
-						output_node->locy = -offsety;
-					}
-					
 					node_group_output_verify(ngroup, output_node, (ID *)ngroup);
 					
 					/* create new internal link */




More information about the Bf-blender-cvs mailing list