Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_relationships.c
| Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | static void pick_link(const bContext *C, | ||||
| RNA_boolean_set(op->ptr, "has_link_picked", true); | RNA_boolean_set(op->ptr, "has_link_picked", true); | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| LinkData *linkdata = create_drag_link( | LinkData *linkdata = create_drag_link( | ||||
| bmain, snode, link_to_pick->fromnode, link_to_pick->fromsock); | bmain, snode, link_to_pick->fromnode, link_to_pick->fromsock); | ||||
| BLI_addtail(&nldrag->links, linkdata); | BLI_addtail(&nldrag->links, linkdata); | ||||
| nodeRemLink(snode->edittree, link_to_pick); | nodeRemLink(snode->edittree, link_to_pick); | ||||
| BLI_assert(nldrag->last_node_hovered_while_dragging_a_link != NULL); | |||||
HooglyBoogly: Is this going to run needlessly in the non-multi-input-socket case? I'm not sure.
Obviously… | |||||
| sort_multi_input_socket_links( | |||||
| snode, nldrag->last_node_hovered_while_dragging_a_link, NULL,NULL); | |||||
| /* Send changed event to original link->tonode. */ | /* Send changed event to original link->tonode. */ | ||||
| if (node) { | if (node) { | ||||
| snode_update(snode, node); | snode_update(snode, node); | ||||
| } | } | ||||
| } | } | ||||
| static void pick_input_link_by_link_intersect(const bContext *C, | static void pick_input_link_by_link_intersect(const bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| ▲ Show 20 Lines • Show All 655 Lines • ▼ Show 20 Lines | if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) { | ||||
| link->tonode = tnode; | link->tonode = tnode; | ||||
| link->tosock = tsock; | link->tosock = tsock; | ||||
| nldrag->last_node_hovered_while_dragging_a_link = tnode; | nldrag->last_node_hovered_while_dragging_a_link = tnode; | ||||
| if (existing_link_connected_to_fromsock) { | if (existing_link_connected_to_fromsock) { | ||||
| link->multi_input_socket_index = | link->multi_input_socket_index = | ||||
| existing_link_connected_to_fromsock->multi_input_socket_index; | existing_link_connected_to_fromsock->multi_input_socket_index; | ||||
| continue; | continue; | ||||
| } | } | ||||
| if(link->tosock && link->tosock->flag & SOCK_MULTI_INPUT){ | |||||
| sort_multi_input_socket_links(snode, tnode, link, cursor); | sort_multi_input_socket_links(snode, tnode, link, cursor); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| else { | else { | ||||
| LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) { | LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) { | ||||
| bNodeLink *link = linkdata->data; | bNodeLink *link = linkdata->data; | ||||
| if (nldrag->last_node_hovered_while_dragging_a_link) { | if (nldrag->last_node_hovered_while_dragging_a_link) { | ||||
| sort_multi_input_socket_links( | sort_multi_input_socket_links( | ||||
| snode, nldrag->last_node_hovered_while_dragging_a_link, NULL, cursor); | snode, nldrag->last_node_hovered_while_dragging_a_link, NULL, cursor); | ||||
| } | } | ||||
| link->tonode = NULL; | link->tonode = NULL; | ||||
| ▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | else { | ||||
| LinkData *linkdata = create_drag_link(bmain, snode, node, sock); | LinkData *linkdata = create_drag_link(bmain, snode, node, sock); | ||||
| BLI_addtail(&nldrag->links, linkdata); | BLI_addtail(&nldrag->links, linkdata); | ||||
| } | } | ||||
| } | } | ||||
| /* or an input? */ | /* or an input? */ | ||||
| else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) { | else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) { | ||||
| nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); | 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); | const int num_links = nodeCountSocketLinks(snode->edittree, sock); | ||||
| if (num_links > 0) { | if (num_links > 0) { | ||||
| /* dragged links are fixed on output side */ | /* dragged links are fixed on output side */ | ||||
| nldrag->in_out = SOCK_OUT; | nldrag->in_out = SOCK_OUT; | ||||
| /* detach current links and store them in the operator data */ | /* detach current links and store them in the operator data */ | ||||
| bNodeLink *link_to_pick; | bNodeLink *link_to_pick; | ||||
| LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) { | LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) { | ||||
| ▲ Show 20 Lines • Show All 1,227 Lines • Show Last 20 Lines | |||||
Is this going to run needlessly in the non-multi-input-socket case? I'm not sure.
Obviously it's not a big problem if it did, but if the check to avoid that was simple I don't see why we wouldn't include it. Only if it's simple though.