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.
This commit is contained in:
parent
23b068ce8a
commit
89025958af
Notes:
blender-bot
2023-02-14 09:03:49 +01:00
Referenced by issue #44921, Cycles node editor, nodes position not maintained after Material panel changes
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue