Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-06-02 10:32:43 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-06-02 10:32:43 +0300
commit89025958af5fc23fd2119557856446e8d527bcf6 (patch)
treee3e96de953454ebf62d35dd410691957fec26774
parent23b068ce8aa57130d48e24d98ccea518ee7584aa (diff)
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.
-rw-r--r--source/blender/editors/space_node/node_templates.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 8b68ac013c2..ea91a735bbe 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);
}