Fix T87829, T95331: Issues when nodes too close together
This patch aims to fix the issues presented in T87829 and T95331, namely precision issues while connecting two nodes when being too close together in the node editor editors, in a few cases even resulting in the complete inability to connect nodes. Sockets are found by intersecting a padded rect around the cursor with the nodes' sockets' location. That creates ambiguities, as it's possible for the padded rect to intersect with the wrong node, as the distance between two nodes is smaller than the rect is padded. The fix in this patch is checking against an unpadded rectangle in visible_node(). Differential Revision: https://developer.blender.org/D14122
This commit is contained in:
parent
07fbf3108b
commit
d9d97db018
Notes:
blender-bot
2023-02-14 08:59:10 +01:00
Referenced by commit563404d8ad
, Fix T100430: Restore larger node socket snap hitbox Referenced by commita0c28a8054
, Fix T100430: Restore larger node socket snap hitbox Referenced by issue #100430, Regression: Node socket active/snapping area became smaller Referenced by issue #95331, Node editors: Precision issues, when nodes are close together Referenced by issue #87829, Connector in node editors cannot connect when too close
|
@ -1160,12 +1160,16 @@ bool node_find_indicated_socket(SpaceNode &snode,
|
|||
{
|
||||
rctf rect;
|
||||
|
||||
const float size_sock_padded = NODE_SOCKSIZE + 4;
|
||||
|
||||
*nodep = nullptr;
|
||||
*sockp = nullptr;
|
||||
|
||||
/* check if we click in a socket */
|
||||
LISTBASE_FOREACH (bNode *, node, &snode.edittree->nodes) {
|
||||
BLI_rctf_init_pt_radius(&rect, cursor, NODE_SOCKSIZE + 4);
|
||||
BLI_rctf_init_pt_radius(&rect, cursor, size_sock_padded);
|
||||
rctf node_visible;
|
||||
BLI_rctf_init_pt_radius(&node_visible, cursor, size_sock_padded);
|
||||
|
||||
if (!(node->flag & NODE_HIDDEN)) {
|
||||
/* extra padding inside and out - allow dragging on the text areas too */
|
||||
|
@ -1184,7 +1188,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
|
|||
if (!nodeSocketIsHidden(sock)) {
|
||||
if (sock->flag & SOCK_MULTI_INPUT && !(node->flag & NODE_HIDDEN)) {
|
||||
if (cursor_isect_multi_input_socket(cursor, *sock)) {
|
||||
if (node == visible_node(snode, rect)) {
|
||||
if (node == visible_node(snode, node_visible)) {
|
||||
*nodep = node;
|
||||
*sockp = sock;
|
||||
return true;
|
||||
|
@ -1192,7 +1196,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
|
|||
}
|
||||
}
|
||||
else if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
|
||||
if (node == visible_node(snode, rect)) {
|
||||
if (node == visible_node(snode, node_visible)) {
|
||||
*nodep = node;
|
||||
*sockp = sock;
|
||||
return true;
|
||||
|
@ -1205,7 +1209,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
|
|||
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
|
||||
if (!nodeSocketIsHidden(sock)) {
|
||||
if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
|
||||
if (node == visible_node(snode, rect)) {
|
||||
if (node == visible_node(snode, node_visible)) {
|
||||
*nodep = node;
|
||||
*sockp = sock;
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue