diff --git a/source/blender/nodes/composite/nodes/node_composite_math.cc b/source/blender/nodes/composite/nodes/node_composite_math.cc index 1f9b22db66c..508ee4d3000 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.cc +++ b/source/blender/nodes/composite/nodes/node_composite_math.cc @@ -11,6 +11,9 @@ #include "COM_shader_node.hh" #include "NOD_math_functions.hh" +#include "NOD_socket_search_link.hh" + +#include "RNA_enum_types.h" #include "node_composite_util.hh" @@ -38,6 +41,32 @@ static void cmp_node_math_declare(NodeDeclarationBuilder &b) b.add_output("Value"); } +class SocketSearchOp { + public: + std::string socket_name; + NodeMathOperation mode = NODE_MATH_ADD; + void operator()(LinkSearchOpParams ¶ms) + { + bNode &node = params.add_node("CompositorNodeMath"); + node.custom1 = mode; + params.update_and_connect_available_socket(node, socket_name); + } +}; + +static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) +{ + const int weight = ELEM(params.other_socket().type, SOCK_FLOAT) ? 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(CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, item->name), + SocketSearchOp{"Value", (NodeMathOperation)item->value}, + weight); + } + } +} + using namespace blender::realtime_compositor; class MathShaderNode : public ShaderNode { @@ -99,6 +128,7 @@ void register_node_type_cmp_math() ntype.labelfunc = node_math_label; ntype.updatefunc = node_math_update; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; + ntype.gather_link_search_ops = file_ns::node_gather_link_searches; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.cc b/source/blender/nodes/composite/nodes/node_composite_mixrgb.cc index 9067637b6e9..b66f4690ba7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.cc +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.cc @@ -14,6 +14,10 @@ #include "COM_shader_node.hh" +#include "NOD_socket_search_link.hh" + +#include "RNA_enum_types.h" + #include "node_composite_util.hh" /* **************** MIX RGB ******************** */ @@ -37,6 +41,32 @@ static void cmp_node_mixrgb_declare(NodeDeclarationBuilder &b) b.add_output("Image"); } +class SocketSearchOp { + public: + std::string socket_name; + int mode = MA_RAMP_BLEND; + void operator()(LinkSearchOpParams ¶ms) + { + bNode &node = params.add_node("CompositorNodeMixRGB"); + node.custom1 = mode; + params.update_and_connect_available_socket(node, socket_name); + } +}; + +static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) +{ + const int weight = ELEM(params.other_socket().type, SOCK_RGBA) ? 0 : -1; + + for (const EnumPropertyItem *item = rna_enum_ramp_blend_items; item->identifier != nullptr; + item++) { + if (item->name != nullptr && item->identifier[0] != '\0') { + params.add_item(CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, item->name), + SocketSearchOp{"Image", item->value}, + weight); + } + } +} + using namespace blender::realtime_compositor; class MixRGBShaderNode : public ShaderNode { @@ -153,6 +183,7 @@ void register_node_type_cmp_mix_rgb() ntype.declare = file_ns::cmp_node_mixrgb_declare; ntype.labelfunc = node_blend_label; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; + ntype.gather_link_search_ops = file_ns::node_gather_link_searches; nodeRegisterType(&ntype); }