From 2c3a9caffee61d52cc50a70ff9b2ec3984ee0fc5 Mon Sep 17 00:00:00 2001 From: Fabian Schempp Date: Thu, 15 Apr 2021 10:00:25 +0200 Subject: 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 --- source/blender/editors/space_node/node_relationships.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_node/node_relationships.c') diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 80601747f2e..4fa0c8c3c5a 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -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) { -- cgit v1.2.3