Nodes: match Multi-input socket activation distance

Activation distance for multi input sockets had different length
dependend of dpi factor. That caused jumping when activation distance
became shorter than snapping distance.

Fixed by removing activation distance and using same function
which is used to evaluate snapping.

Reviewer: Dalai Felinto

Differential Revision: https://developer.blender.org/D10809
This commit is contained in:
Fabian Schempp 2021-03-26 17:29:10 +01:00
parent f560bc90c7
commit 1e855149b2
Notes: blender-bot 2023-02-14 02:08:37 +01:00
Referenced by issue #86885, Multi-input node socket activation distance is larger than regular input socket
3 changed files with 14 additions and 19 deletions

View File

@ -1128,10 +1128,15 @@ static bool cursor_isect_multi_input_socket(const float cursor[2], const bNodeSo
{
const float node_socket_height = node_socket_calculate_height(socket);
const rctf multi_socket_rect = {
.xmin = socket->locx - NODE_SOCKSIZE * 4,
.xmax = socket->locx + NODE_SOCKSIZE,
.ymin = socket->locy - node_socket_height * 0.5 - NODE_SOCKSIZE * 2.0f,
.ymax = socket->locy + node_socket_height * 0.5 + NODE_SOCKSIZE * 2.0f,
.xmin = socket->locx - NODE_SOCKSIZE * 4.0f,
.xmax = socket->locx + NODE_SOCKSIZE * 2.0f,
/*.xmax = socket->locx + NODE_SOCKSIZE * 5.5f
* would be the same behavior as for regular sockets.
* But keep it smaller because for multi-input socket you
* sometimes want to drag the link to the other side, if you may
* accidentally pick the wrong link otherwise. */
.ymin = socket->locy - node_socket_height * 0.5 - NODE_SOCKSIZE,
.ymax = socket->locy + node_socket_height * 0.5 + NODE_SOCKSIZE,
};
if (BLI_rctf_isect_pt(&multi_socket_rect, cursor[0], cursor[1])) {
return true;
@ -1141,7 +1146,7 @@ static bool cursor_isect_multi_input_socket(const float cursor[2], const bNodeSo
/* type is SOCK_IN and/or SOCK_OUT */
int node_find_indicated_socket(
SpaceNode *snode, bNode **nodep, bNodeSocket **sockp, float cursor[2], int in_out)
SpaceNode *snode, bNode **nodep, bNodeSocket **sockp, const float cursor[2], int in_out)
{
rctf rect;

View File

@ -260,7 +260,7 @@ int node_render_changed_exec(bContext *, struct wmOperator *);
int node_find_indicated_socket(struct SpaceNode *snode,
struct bNode **nodep,
struct bNodeSocket **sockp,
float cursor[2],
const float cursor[2],
int in_out);
void NODE_OT_duplicate(struct wmOperatorType *ot);

View File

@ -245,18 +245,8 @@ static void pick_input_link_by_link_intersect(const bContext *C,
bNodeSocket *socket;
node_find_indicated_socket(snode, &node, &socket, drag_start, SOCK_IN);
const float trigger_drag_distance = 25.0f;
const float cursor_link_touch_distance = 25.0f;
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);
/* Distance to test overlapping of cursor on link. */
const float cursor_link_touch_distance = 12.5f * UI_DPI_FAC;
const int resolution = NODE_LINK_RESOL;
@ -301,7 +291,7 @@ static void pick_input_link_by_link_intersect(const bContext *C,
link_to_pick->flag |= NODE_LINK_TEMP_HIGHLIGHT;
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);
}
}