Fix T90221: geometry viewer node links to other socket types

The viewer node in geometry node trees only supports geometry nodes.
This patch ensures that when ctrl shift clicking on a node, it will only
link to geometry sockets.

Differential Revision: https://developer.blender.org/D12055
This commit is contained in:
Wannes Malfait 2021-07-28 15:48:31 +02:00 committed by Jacques Lucke
parent 3db37075f6
commit b304616f2a
Notes: blender-bot 2023-05-03 10:14:48 +02:00
Referenced by issue #90221, Geometry Nodes Bug: "Viewer" node doesn't connect to geometry socket in the "Object Info" node
1 changed files with 41 additions and 10 deletions

View File

@ -664,9 +664,19 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
nodeRemLink(snode->edittree, link);
/* find a socket after the previously connected socket */
for (sock = sock->next; sock; sock = sock->next) {
if (!nodeSocketIsHidden(sock)) {
break;
if (ED_node_is_geometry(snode)) {
/* Geometry nodes viewer only supports geometry sockets for now. */
for (sock = sock->next; sock; sock = sock->next) {
if (sock->type == SOCK_GEOMETRY && !nodeSocketIsHidden(sock)) {
break;
}
}
}
else {
for (sock = sock->next; sock; sock = sock->next) {
if (!nodeSocketIsHidden(sock)) {
break;
}
}
}
}
@ -674,19 +684,40 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
if (tonode) {
/* Find a selected socket that overrides the socket to connect to */
LISTBASE_FOREACH (bNodeSocket *, sock2, &tonode->outputs) {
if (!nodeSocketIsHidden(sock2) && sock2->flag & SELECT) {
sock = sock2;
break;
if (ED_node_is_geometry(snode)) {
/* Geometry nodes viewer only supports geometry sockets for now. */
LISTBASE_FOREACH (bNodeSocket *, sock2, &tonode->outputs) {
if (sock2->type == SOCK_GEOMETRY && !nodeSocketIsHidden(sock2) && sock2->flag & SELECT) {
sock = sock2;
break;
}
}
}
else {
LISTBASE_FOREACH (bNodeSocket *, sock2, &tonode->outputs) {
if (!nodeSocketIsHidden(sock2) && sock2->flag & SELECT) {
sock = sock2;
break;
}
}
}
}
/* find a socket starting from the first socket */
if (!sock) {
for (sock = (bNodeSocket *)tonode->outputs.first; sock; sock = sock->next) {
if (!nodeSocketIsHidden(sock)) {
break;
if (ED_node_is_geometry(snode)) {
/* Geometry nodes viewer only supports geometry sockets for now. */
for (sock = (bNodeSocket *)tonode->outputs.first; sock; sock = sock->next) {
if (sock->type == SOCK_GEOMETRY && !nodeSocketIsHidden(sock)) {
break;
}
}
}
else {
for (sock = (bNodeSocket *)tonode->outputs.first; sock; sock = sock->next) {
if (!nodeSocketIsHidden(sock)) {
break;
}
}
}
}