[Bf-blender-cvs] [f5e1a2119d2] master: Node: Add blend modes to Mix node link drag search

Charlie Jolly noreply at git.blender.org
Mon Oct 10 15:37:01 CEST 2022


Commit: f5e1a2119d2584cd823154d0ace5e4bf95cde5a1
Author: Charlie Jolly
Date:   Mon Oct 10 14:25:12 2022 +0100
Branches: master
https://developer.blender.org/rBf5e1a2119d2584cd823154d0ace5e4bf95cde5a1

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

===================================================================

M	source/blender/nodes/shader/nodes/node_shader_mix.cc

===================================================================

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 &params)
+  {
+    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 &params)
 {
   const eNodeSocketDatatype sock_type = static_cast<eNodeSocketDatatype>(
@@ -132,6 +145,15 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams &params)
     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 &params) {
         bNode &node = params.add_node("ShaderNodeMix");



More information about the Bf-blender-cvs mailing list