Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_relationships.c
| Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | static void pick_input_link_by_link_intersect(const bContext *C, | ||||
| const View2D *v2d = ®ion->v2d; | const View2D *v2d = ®ion->v2d; | ||||
| float drag_start[2]; | float drag_start[2]; | ||||
| RNA_float_get_array(op->ptr, "drag_start", drag_start); | RNA_float_get_array(op->ptr, "drag_start", drag_start); | ||||
| bNode *node; | bNode *node; | ||||
| bNodeSocket *socket; | bNodeSocket *socket; | ||||
| node_find_indicated_socket(snode, &node, &socket, drag_start, SOCK_IN); | node_find_indicated_socket(snode, &node, &socket, drag_start, SOCK_IN); | ||||
| const float trigger_drag_distance = 25.0f; | /* Distance to test overlapping of cursor on link. */ | ||||
| const float cursor_link_touch_distance = 25.0f; | const float cursor_link_touch_distance = 12.5f * UI_DPI_FAC; | ||||
| const float socket_height = node_socket_calculate_height(socket); | |||||
| float cursor_to_socket_relative[2]; | |||||
| float socket_position[2] = {socket->locx, socket->locy}; | |||||
| sub_v2_v2v2(cursor_to_socket_relative, cursor, socket_position); | |||||
| float distance_from_socket_v2[2] = { | |||||
| max_ff(0, fabs(cursor_to_socket_relative[0]) - NODE_SOCKSIZE * 0.5), | |||||
| max_ff(0, fabs(cursor_to_socket_relative[1]) - socket_height)}; | |||||
| const float distance_from_socket = len_v2(distance_from_socket_v2); | |||||
| const int resolution = NODE_LINK_RESOL; | const int resolution = NODE_LINK_RESOL; | ||||
| bNodeLink *link_to_pick = NULL; | bNodeLink *link_to_pick = NULL; | ||||
| clear_picking_highlight(&snode->edittree->links); | clear_picking_highlight(&snode->edittree->links); | ||||
| LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) { | LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) { | ||||
| if (link->tosock == socket) { | if (link->tosock == socket) { | ||||
| /* Test if the cursor is near a link. */ | /* Test if the cursor is near a link. */ | ||||
| Show All 28 Lines | if (!link_to_pick) { | ||||
| } | } | ||||
| } | } | ||||
| if (link_to_pick) { | if (link_to_pick) { | ||||
| /* Highlight is set here and cleared in the next iteration or if the operation finishes. */ | /* Highlight is set here and cleared in the next iteration or if the operation finishes. */ | ||||
| link_to_pick->flag |= NODE_LINK_TEMP_HIGHLIGHT; | link_to_pick->flag |= NODE_LINK_TEMP_HIGHLIGHT; | ||||
| ED_area_tag_redraw(CTX_wm_area(C)); | ED_area_tag_redraw(CTX_wm_area(C)); | ||||
| if (distance_from_socket > trigger_drag_distance) { | if (!node_find_indicated_socket(snode, &node, &socket, cursor, SOCK_IN)) { | ||||
| pick_link(C, op, nldrag, snode, node, link_to_pick); | pick_link(C, op, nldrag, snode, node, link_to_pick); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static int sort_nodes_locx(const void *a, const void *b) | static int sort_nodes_locx(const void *a, const void *b) | ||||
| { | { | ||||
| const bNodeListItem *nli1 = a; | const bNodeListItem *nli1 = a; | ||||
| ▲ Show 20 Lines • Show All 1,976 Lines • Show Last 20 Lines | |||||