Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/function/nodes/node_fn_compare.cc
| Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | static void node_compare_gather_link_searches(GatherLinkSearchOpParams ¶ms) | ||||
| const NodeDeclaration &declaration = *params.node_type().fixed_declaration; | const NodeDeclaration &declaration = *params.node_type().fixed_declaration; | ||||
| if (params.in_out() == SOCK_OUT) { | if (params.in_out() == SOCK_OUT) { | ||||
| search_link_ops_for_declarations(params, declaration.outputs()); | search_link_ops_for_declarations(params, declaration.outputs()); | ||||
| return; | return; | ||||
| } | } | ||||
| const eNodeSocketDatatype type = static_cast<eNodeSocketDatatype>(params.other_socket().type); | const eNodeSocketDatatype type = static_cast<eNodeSocketDatatype>(params.other_socket().type); | ||||
| if (ELEM(type, SOCK_FLOAT, SOCK_BOOLEAN, SOCK_RGBA, SOCK_VECTOR, SOCK_INT)) { | if (ELEM(type, SOCK_BOOLEAN, SOCK_FLOAT, SOCK_RGBA, SOCK_VECTOR, SOCK_INT, SOCK_STRING)) { | ||||
| params.add_item(IFACE_("A"), SocketSearchOp{"A", type, NODE_COMPARE_GREATER_THAN}); | const eNodeSocketDatatype mode_type = (type == SOCK_BOOLEAN) ? SOCK_FLOAT : type; | ||||
| params.add_item(IFACE_("B"), SocketSearchOp{"B", type, NODE_COMPARE_GREATER_THAN}); | const bool string_type = (type == SOCK_STRING); | ||||
| params.add_item( | /* Add socket A compare operations. */ | ||||
| IFACE_("C"), | for (const EnumPropertyItem *item = rna_enum_node_compare_operation_items; | ||||
| SocketSearchOp{ | item->identifier != nullptr; | ||||
| "C", SOCK_VECTOR, NODE_COMPARE_GREATER_THAN, NODE_COMPARE_MODE_DOT_PRODUCT}); | 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}); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Add Angle socket. */ | |||||
| if (!string_type) { | |||||
| params.add_item( | params.add_item( | ||||
| IFACE_("Angle"), | IFACE_("Angle"), | ||||
| SocketSearchOp{ | SocketSearchOp{ | ||||
| "Angle", SOCK_VECTOR, NODE_COMPARE_GREATER_THAN, NODE_COMPARE_MODE_DIRECTION}); | "Angle", SOCK_VECTOR, NODE_COMPARE_GREATER_THAN, NODE_COMPARE_MODE_DIRECTION}); | ||||
| } | } | ||||
| else if (type == SOCK_STRING) { | |||||
| params.add_item(IFACE_("A"), SocketSearchOp{"A", type, NODE_COMPARE_EQUAL}); | |||||
| params.add_item(IFACE_("B"), SocketSearchOp{"B", type, NODE_COMPARE_EQUAL}); | |||||
| } | } | ||||
| } | } | ||||
| static void node_compare_label(const bNodeTree *UNUSED(ntree), | static void node_compare_label(const bNodeTree *UNUSED(ntree), | ||||
| const bNode *node, | const bNode *node, | ||||
| char *label, | char *label, | ||||
| int maxlen) | int maxlen) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | |||||
| } // namespace blender::nodes::node_fn_compare_cc | } // namespace blender::nodes::node_fn_compare_cc | ||||
| void register_node_type_fn_compare() | void register_node_type_fn_compare() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_fn_compare_cc; | namespace file_ns = blender::nodes::node_fn_compare_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| fn_node_type_base(&ntype, FN_NODE_COMPARE, "Compare", NODE_CLASS_CONVERTER, 0); | fn_node_type_base(&ntype, FN_NODE_COMPARE, "Compare", NODE_CLASS_CONVERTER); | ||||
| ntype.declare = file_ns::fn_node_compare_declare; | ntype.declare = file_ns::fn_node_compare_declare; | ||||
| ntype.labelfunc = file_ns::node_compare_label; | ntype.labelfunc = file_ns::node_compare_label; | ||||
| node_type_update(&ntype, file_ns::node_compare_update); | node_type_update(&ntype, file_ns::node_compare_update); | ||||
| node_type_init(&ntype, file_ns::node_compare_init); | node_type_init(&ntype, file_ns::node_compare_init); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeFunctionCompare", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeFunctionCompare", node_free_standard_storage, node_copy_standard_storage); | ||||
| ntype.build_multi_function = file_ns::fn_node_compare_build_multi_function; | ntype.build_multi_function = file_ns::fn_node_compare_build_multi_function; | ||||
| ntype.draw_buttons = file_ns::geo_node_compare_layout; | ntype.draw_buttons = file_ns::geo_node_compare_layout; | ||||
| ntype.gather_link_search_ops = file_ns::node_compare_gather_link_searches; | ntype.gather_link_search_ops = file_ns::node_compare_gather_link_searches; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||