diff options
author | Hans Goudey <h.goudey@me.com> | 2022-01-25 18:51:20 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-01-25 18:51:20 +0300 |
commit | a18bd403bf3edb495ee0531600bbf3cf23d45e1c (patch) | |
tree | db920edc41550f3d86cb34f8b80ce06f021623ac /source/blender/nodes | |
parent | 96667e33913e37e257ae444009c5f7bea57b0d72 (diff) |
Nodes: Improve link-drag search support for boolean math node
List the operations in the search instead of the "Boolean" socket names.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/function/nodes/node_fn_boolean_math.cc | 25 |
1 files changed, 25 insertions, 0 deletions
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 ¶ms) +{ + 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 ¶ms) { + 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); } |