[Bf-blender-cvs] [b304616f2ad] master: Fix T90221: geometry viewer node links to other socket types

Wannes Malfait noreply at git.blender.org
Wed Jul 28 15:55:17 CEST 2021


Commit: b304616f2addbba19d1863ea2af73194946df501
Author: Wannes Malfait
Date:   Wed Jul 28 15:48:31 2021 +0200
Branches: master
https://developer.blender.org/rBb304616f2addbba19d1863ea2af73194946df501

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

===================================================================

M	source/blender/editors/space_node/node_relationships.cc

===================================================================

diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc
index 61a874b2b2d..c6c3ca27d6e 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -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;
+        }
       }
     }
   }



More information about the Bf-blender-cvs mailing list