diff options
author | Hans Goudey <h.goudey@me.com> | 2022-01-14 23:38:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-01-14 23:38:49 +0300 |
commit | 9fe704800ef1288ef7258e9dda6a538dc92ddddd (patch) | |
tree | afec1675431fbf42c70ff6bacd4b6eacc240eec1 /source/blender | |
parent | b7a27efd781b909536ad6f6ade6b7a9d5f746eb9 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/nodes/function/nodes/node_fn_compare.cc | 61 |
1 files changed, 31 insertions, 30 deletions
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 ¶ms) { - 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}); } } |