[Bf-blender-cvs] [9fe704800ef] master: Nodes: Support link-drag search with compare node outputs

Hans Goudey noreply at git.blender.org
Fri Jan 14 21:38:56 CET 2022


Commit: 9fe704800ef1288ef7258e9dda6a538dc92ddddd
Author: Hans Goudey
Date:   Fri Jan 14 14:38:49 2022 -0600
Branches: master
https://developer.blender.org/rB9fe704800ef1288ef7258e9dda6a538dc92ddddd

Nodes: Support link-drag search with compare node outputs

The search list only displayed the "Result" output socket in this
case, which is unexpected since dragging from an input gives the
operations in the list as well. Also use integer mode when
connecting to boolean sockets.

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

M	source/blender/nodes/function/nodes/node_fn_compare.cc

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

diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc
index 7c09bace756..13a7ff86624 100644
--- a/source/blender/nodes/function/nodes/node_fn_compare.cc
+++ b/source/blender/nodes/function/nodes/node_fn_compare.cc
@@ -122,41 +122,42 @@ class SocketSearchOp {
 
 static void node_compare_gather_link_searches(GatherLinkSearchOpParams &params)
 {
-  const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
-  if (params.in_out() == SOCK_OUT) {
-    search_link_ops_for_declarations(params, declaration.outputs());
+  const eNodeSocketDatatype type = static_cast<eNodeSocketDatatype>(params.other_socket().type);
+  if (!ELEM(type, SOCK_BOOLEAN, SOCK_FLOAT, SOCK_RGBA, SOCK_VECTOR, SOCK_INT, SOCK_STRING)) {
     return;
   }
 
-  const eNodeSocketDatatype type = static_cast<eNodeSocketDatatype>(params.other_socket().type);
-
-  if (ELEM(type, SOCK_BOOLEAN, SOCK_FLOAT, SOCK_RGBA, SOCK_VECTOR, SOCK_INT, SOCK_STRING)) {
-    const eNodeSocketDatatype mode_type = (type == SOCK_BOOLEAN) ? SOCK_FLOAT : type;
-    const bool string_type = (type == SOCK_STRING);
-    /* Add socket A compare operations. */
-    for (const EnumPropertyItem *item = rna_enum_node_compare_operation_items;
-         item->identifier != nullptr;
-         item++) {
-      if (item->name != nullptr && item->identifier[0] != '\0') {
-        if (!string_type &&
-            ELEM(item->value, NODE_COMPARE_COLOR_BRIGHTER, NODE_COMPARE_COLOR_DARKER)) {
-          params.add_item(IFACE_(item->name),
-                          SocketSearchOp{"A", SOCK_RGBA, (NodeCompareOperation)item->value});
-        }
-        else if ((!string_type) ||
-                 (string_type && ELEM(item->value, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL))) {
-          params.add_item(IFACE_(item->name),
-                          SocketSearchOp{"A", mode_type, (NodeCompareOperation)item->value});
-        }
+  const eNodeSocketDatatype mode_type = (type == SOCK_BOOLEAN) ? SOCK_INT : type;
+  const bool string_type = (type == SOCK_STRING);
+
+  const std::string socket_name = params.in_out() == SOCK_IN ? "A" : "Result";
+
+  for (const EnumPropertyItem *item = rna_enum_node_compare_operation_items;
+       item->identifier != nullptr;
+       item++) {
+    if (item->name != nullptr && item->identifier[0] != '\0') {
+      if (!string_type &&
+          ELEM(item->value, NODE_COMPARE_COLOR_BRIGHTER, NODE_COMPARE_COLOR_DARKER)) {
+        params.add_item(IFACE_(item->name),
+                        SocketSearchOp{socket_name,
+                                       SOCK_RGBA,
+                                       static_cast<NodeCompareOperation>(item->value)});
+      }
+      else if ((!string_type) ||
+               (string_type && ELEM(item->value, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL))) {
+        params.add_item(IFACE_(item->name),
+                        SocketSearchOp{socket_name,
+                                       mode_type,
+                                       static_cast<NodeCompareOperation>(item->value)});
       }
     }
-    /* Add Angle socket. */
-    if (!string_type) {
-      params.add_item(
-          IFACE_("Angle"),
-          SocketSearchOp{
-              "Angle", SOCK_VECTOR, NODE_COMPARE_GREATER_THAN, NODE_COMPARE_MODE_DIRECTION});
-    }
+  }
+  /* Add Angle socket. */
+  if (!string_type && params.in_out() == SOCK_IN) {
+    params.add_item(
+        IFACE_("Angle"),
+        SocketSearchOp{
+            "Angle", SOCK_VECTOR, NODE_COMPARE_GREATER_THAN, NODE_COMPARE_MODE_DIRECTION});
   }
 }



More information about the Bf-blender-cvs mailing list