Nodes: Improve link-drag search support for boolean math node
List the operations in the search instead of the "Boolean" socket names.
This commit is contained in:
@@ -1927,7 +1927,7 @@ typedef enum NodeVectorMathOperation {
|
|||||||
} NodeVectorMathOperation;
|
} NodeVectorMathOperation;
|
||||||
|
|
||||||
/** Boolean math node operations. */
|
/** Boolean math node operations. */
|
||||||
enum {
|
typedef enum NodeBooleanMathOperation {
|
||||||
NODE_BOOLEAN_MATH_AND = 0,
|
NODE_BOOLEAN_MATH_AND = 0,
|
||||||
NODE_BOOLEAN_MATH_OR = 1,
|
NODE_BOOLEAN_MATH_OR = 1,
|
||||||
NODE_BOOLEAN_MATH_NOT = 2,
|
NODE_BOOLEAN_MATH_NOT = 2,
|
||||||
@@ -1939,7 +1939,7 @@ enum {
|
|||||||
|
|
||||||
NODE_BOOLEAN_MATH_IMPLY = 7,
|
NODE_BOOLEAN_MATH_IMPLY = 7,
|
||||||
NODE_BOOLEAN_MATH_NIMPLY = 8,
|
NODE_BOOLEAN_MATH_NIMPLY = 8,
|
||||||
};
|
} NodeBooleanMathOperation;
|
||||||
|
|
||||||
/** Float compare node operations. */
|
/** Float compare node operations. */
|
||||||
typedef enum NodeCompareMode {
|
typedef enum NodeCompareMode {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
|
|
||||||
|
#include "NOD_socket_search_link.hh"
|
||||||
|
|
||||||
#include "node_function_util.hh"
|
#include "node_function_util.hh"
|
||||||
|
|
||||||
namespace blender::nodes::node_fn_boolean_math_cc {
|
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);
|
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 const fn::MultiFunction *get_multi_function(bNode &bnode)
|
||||||
{
|
{
|
||||||
static fn::CustomMF_SI_SI_SO<bool, bool, bool> and_fn{"And",
|
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);
|
node_type_update(&ntype, file_ns::node_boolean_math_update);
|
||||||
ntype.build_multi_function = file_ns::fn_node_boolean_math_build_multi_function;
|
ntype.build_multi_function = file_ns::fn_node_boolean_math_build_multi_function;
|
||||||
ntype.draw_buttons = file_ns::fn_node_boolean_math_layout;
|
ntype.draw_buttons = file_ns::fn_node_boolean_math_layout;
|
||||||
|
ntype.gather_link_search_ops = file_ns::node_gather_link_searches;
|
||||||
nodeRegisterType(&ntype);
|
nodeRegisterType(&ntype);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user