Nodes: Add Compare node operations to link drag search menu
Exposes compare operations via rna emums. This uses the rna enum to build the search list using named operations linked to socket A. This also weights the Math Node comparison operations lower for geometry node trees. Differential Revision: https://developer.blender.org/D13695
This commit is contained in:
@@ -71,14 +71,21 @@ static void sh_node_math_gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
||||
if (params.node_tree().typeinfo->validate_link(
|
||||
static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
|
||||
|
||||
const bool is_geometry_node_tree = params.node_tree().type == NTREE_GEOMETRY;
|
||||
const int weight = ELEM(params.other_socket().type, SOCK_FLOAT, SOCK_BOOLEAN, SOCK_INT) ? 0 :
|
||||
-1;
|
||||
|
||||
for (const EnumPropertyItem *item = rna_enum_node_math_items; item->identifier != nullptr;
|
||||
item++) {
|
||||
if (item->name != nullptr && item->identifier[0] != '\0') {
|
||||
params.add_item(
|
||||
IFACE_(item->name), SocketSearchOp{"Value", (NodeMathOperation)item->value}, weight);
|
||||
const int gn_weight =
|
||||
(is_geometry_node_tree &&
|
||||
ELEM(item->value, NODE_MATH_COMPARE, NODE_MATH_GREATER_THAN, NODE_MATH_LESS_THAN)) ?
|
||||
-1 :
|
||||
weight;
|
||||
params.add_item(IFACE_(item->name),
|
||||
SocketSearchOp{"Value", (NodeMathOperation)item->value},
|
||||
gn_weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user