Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-01-25 18:51:20 +0300
committerHans Goudey <h.goudey@me.com>2022-01-25 18:51:20 +0300
commita18bd403bf3edb495ee0531600bbf3cf23d45e1c (patch)
treedb920edc41550f3d86cb34f8b80ce06f021623ac
parent96667e33913e37e257ae444009c5f7bea57b0d72 (diff)
Nodes: Improve link-drag search support for boolean math node
List the operations in the search instead of the "Boolean" socket names.
-rw-r--r--source/blender/makesdna/DNA_node_types.h4
-rw-r--r--source/blender/nodes/function/nodes/node_fn_boolean_math.cc25
2 files changed, 27 insertions, 2 deletions
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 34252715545..b154576df76 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1927,7 +1927,7 @@ typedef enum NodeVectorMathOperation {
} NodeVectorMathOperation;
/** Boolean math node operations. */
-enum {
+typedef enum NodeBooleanMathOperation {
NODE_BOOLEAN_MATH_AND = 0,
NODE_BOOLEAN_MATH_OR = 1,
NODE_BOOLEAN_MATH_NOT = 2,
@@ -1939,7 +1939,7 @@ enum {
NODE_BOOLEAN_MATH_IMPLY = 7,
NODE_BOOLEAN_MATH_NIMPLY = 8,
-};
+} NodeBooleanMathOperation;
/** Float compare node operations. */
typedef enum NodeCompareMode {
diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
index 15b0bab22b7..8c75a1c538d 100644
--- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
+++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
@@ -22,6 +22,8 @@
#include "UI_interface.h"
#include "UI_resources.h"
+#include "NOD_socket_search_link.hh"
+
#include "node_function_util.hh"
namespace blender::nodes::node_fn_boolean_math_cc {
@@ -59,6 +61,28 @@ static void node_boolean_math_label(const bNodeTree *UNUSED(ntree),
BLI_strncpy(label, IFACE_(name), maxlen);
}
+static void node_gather_link_searches(GatherLinkSearchOpParams &params)
+{
+ const eNodeSocketDatatype type = static_cast<eNodeSocketDatatype>(params.other_socket().type);
+ if (!params.node_tree().typeinfo->validate_link(
+ static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_BOOLEAN)) {
+ return;
+ }
+
+ for (const EnumPropertyItem *item = rna_enum_node_boolean_math_items;
+ item->identifier != nullptr;
+ item++) {
+ if (item->name != nullptr && item->identifier[0] != '\0') {
+ NodeBooleanMathOperation operation = static_cast<NodeBooleanMathOperation>(item->value);
+ params.add_item(IFACE_(item->name), [operation](LinkSearchOpParams &params) {
+ bNode &node = params.add_node("FunctionNodeBooleanMath");
+ node.custom1 = operation;
+ params.update_and_connect_available_socket(node, "Boolean");
+ });
+ }
+ }
+}
+
static const fn::MultiFunction *get_multi_function(bNode &bnode)
{
static fn::CustomMF_SI_SI_SO<bool, bool, bool> and_fn{"And",
@@ -124,5 +148,6 @@ void register_node_type_fn_boolean_math()
node_type_update(&ntype, file_ns::node_boolean_math_update);
ntype.build_multi_function = file_ns::fn_node_boolean_math_build_multi_function;
ntype.draw_buttons = file_ns::fn_node_boolean_math_layout;
+ ntype.gather_link_search_ops = file_ns::node_gather_link_searches;
nodeRegisterType(&ntype);
}