[Bf-blender-cvs] [8902595] master: Fix T44921: Node editor, nodes position not maintained after Material panel changes

Sergey Sharybin noreply at git.blender.org
Tue Jun 2 09:35:47 CEST 2015


Commit: 89025958af5fc23fd2119557856446e8d527bcf6
Author: Sergey Sharybin
Date:   Tue Jun 2 12:32:43 2015 +0500
Branches: master
https://developer.blender.org/rB89025958af5fc23fd2119557856446e8d527bcf6

Fix T44921: Node editor, nodes position not maintained after Material panel changes

Also improved a bit behavior of adding new nodes, now they will not overlap that
badly. Still not ideal, but further improvements better not to happen at bcon4.

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

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

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

diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 8b68ac0..ea91a73 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -214,8 +214,22 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *
 	}
 	else if (!node_from) {
 		node_from = nodeAddStaticNode(C, ntree, type);
-		node_from->locx = node_to->locx - (node_from->typeinfo->width + 50);
-		node_from->locy = node_to->locy;
+		if (node_prev != NULL) {
+			/* If we're replacing existing node, use it's location. */
+			node_from->locx = node_prev->locx;
+			node_from->locy = node_prev->locy;
+			node_from->offsetx = node_prev->offsetx;
+			node_from->offsety = node_prev->offsety;
+		}
+		else {
+			/* Avoid exact intersection of nodes.
+			 * TODO(sergey): Still not ideal, but better than nothing.
+			 */
+			int index = BLI_findindex(&node_to->inputs, sock_to);
+			BLI_assert(index != -1);
+			node_from->locx = node_to->locx - (node_from->typeinfo->width + 50);
+			node_from->locy = node_to->locy - (node_from->typeinfo->height * index);
+		}
 		
 		node_link_item_apply(node_from, item);
 	}




More information about the Bf-blender-cvs mailing list