Fix T87356 & T87358: Small multi-input socket issues

T87356 occured because last_node_hovered_while_dragging_a_link was not
set on node_link_init.
The assert in T87358 failed because the sorting operation was called even
if the drag link contained a link to another socket.
A little one frame jump was caused because frame was refreshed after
picking a link and before sorting happened.

Reviewer: Hans Goudey

Differential Revision: https://developer.blender.org/D10940
This commit is contained in:
Fabian Schempp 2021-04-15 10:00:25 +02:00
parent 5ec39fc2e4
commit 2c3a9caffe
Notes: blender-bot 2023-02-14 07:47:59 +01:00
Referenced by issue #87356, Bad offset for node link in multi-input socket after disconnecting
Referenced by issue #87358, Assert for boolean node multi-input socket
2 changed files with 13 additions and 2 deletions

View File

@ -58,9 +58,11 @@ typedef struct bNodeLinkDrag {
bool from_multi_input_socket;
int in_out;
/** Temporarily stores the last picked link from multi input socket operator. */
/** Temporarily stores the last picked link from multi-input socket operator. */
struct bNodeLink *last_picked_multi_input_socket_link;
/** Temporarily stores the last hovered socket for multi-input socket operator.
* Store it to recalculate sorting after it is no longer hovered. */
struct bNode *last_node_hovered_while_dragging_a_link;
} bNodeLinkDrag;

View File

@ -224,6 +224,12 @@ static void pick_link(const bContext *C,
BLI_addtail(&nldrag->links, linkdata);
nodeRemLink(snode->edittree, link_to_pick);
BLI_assert(nldrag->last_node_hovered_while_dragging_a_link != NULL);
sort_multi_input_socket_links(
snode, nldrag->last_node_hovered_while_dragging_a_link, NULL,NULL);
/* Send changed event to original link->tonode. */
if (node) {
snode_update(snode, node);
@ -895,7 +901,9 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
existing_link_connected_to_fromsock->multi_input_socket_index;
continue;
}
sort_multi_input_socket_links(snode, tnode, link, cursor);
if(link->tosock && link->tosock->flag & SOCK_MULTI_INPUT){
sort_multi_input_socket_links(snode, tnode, link, cursor);
}
}
}
else {
@ -1038,6 +1046,7 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
/* or an input? */
else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) {
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
nldrag->last_node_hovered_while_dragging_a_link = node;
const int num_links = nodeCountSocketLinks(snode->edittree, sock);
if (num_links > 0) {