diff options
author | Charlie Jolly <charlie> | 2022-10-10 16:25:12 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2022-10-10 16:36:44 +0300 |
commit | f5e1a2119d2584cd823154d0ace5e4bf95cde5a1 (patch) | |
tree | b2676a95967a3dd91e5b4a6819093283b54a7906 /source/blender/nodes | |
parent | 25b745ae85ea47675508adb0aa46ccb3cb738e21 (diff) |
Node: Add blend modes to Mix node link drag search
Allows searching for Mix blend modes
e.g. Overlay when using link drag search
Requested by @simonthommes in GN chat
Reviewed By: HooglyBoogly
Differential Revision: https://developer.blender.org/D16209
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_mix.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_mix.cc b/source/blender/nodes/shader/nodes/node_shader_mix.cc index 2efd57155b9..eba283e8be8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix.cc @@ -123,6 +123,19 @@ static void sh_node_mix_update(bNodeTree *ntree, bNode *node) nodeSetSocketAvailability(ntree, sock_factor_vec, use_vector_factor); } +class SocketSearchOp { + public: + std::string socket_name; + int type = MA_RAMP_BLEND; + void operator()(LinkSearchOpParams ¶ms) + { + bNode &node = params.add_node("ShaderNodeMix"); + node_storage(node).data_type = SOCK_RGBA; + node_storage(node).blend_type = type; + params.update_and_connect_available_socket(node, socket_name); + } +}; + static void node_mix_gather_link_searches(GatherLinkSearchOpParams ¶ms) { const eNodeSocketDatatype sock_type = static_cast<eNodeSocketDatatype>( @@ -132,6 +145,15 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams ¶ms) const eNodeSocketDatatype type = ELEM(sock_type, SOCK_BOOLEAN, SOCK_INT) ? SOCK_FLOAT : sock_type; + const std::string socket_name = params.in_out() == SOCK_IN ? "A" : "Result"; + 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{socket_name, item->value}); + } + } + if (params.in_out() == SOCK_OUT) { params.add_item(IFACE_("Result"), [type](LinkSearchOpParams ¶ms) { bNode &node = params.add_node("ShaderNodeMix"); |