Commit: 333dc7b5c4ee44986294c6b5683fa4813454279b
Author: Aaron Carlisle
Date:   Tue Dec 7 21:05:13 2021 -0500
Branches: master
https://developer.blender.org/rB333dc7b5c4ee44986294c6b5683fa4813454279b

Nodes: Add Shader Socket to new decleration API

This commit adds the shader socket type to the new socket builder api.

Re commits part of rB0bd3cad04edf4bf9b9d3b1353f955534aa5e6740

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

M       source/blender/nodes/NOD_socket_declarations.hh
M       source/blender/nodes/intern/node_socket_declarations.cc

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

diff --git a/source/blender/nodes/NOD_socket_declarations.hh 
b/source/blender/nodes/NOD_socket_declarations.hh
index 89bc198f97e..98c8fa68876 100644
--- a/source/blender/nodes/NOD_socket_declarations.hh
+++ b/source/blender/nodes/NOD_socket_declarations.hh
@@ -213,6 +213,21 @@ class Image : public IDSocketDeclaration {
   Image();
 };
 
+class ShaderBuilder;
+
+class Shader : public SocketDeclaration {
+ private:
+  friend ShaderBuilder;
+
+ public:
+  using Builder = ShaderBuilder;
+
+  bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) 
const override;
+  bool matches(const bNodeSocket &socket) const override;
+};
+
+class ShaderBuilder : public SocketDeclarationBuilder<Shader> {};
+
 /* -------------------------------------------------------------------- */
 /** \name #FloatBuilder Inline Methods
  * \{ */
diff --git a/source/blender/nodes/intern/node_socket_declarations.cc 
b/source/blender/nodes/intern/node_socket_declarations.cc
index ed5691ebf7f..1795cc339e7 100644
--- a/source/blender/nodes/intern/node_socket_declarations.cc
+++ b/source/blender/nodes/intern/node_socket_declarations.cc
@@ -376,4 +376,29 @@ GeometryBuilder &GeometryBuilder::only_instances(bool 
value)
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name #Shader
+ * \{ */
+
+bNodeSocket &Shader::build(bNodeTree &ntree, bNode &node, eNodeSocketInOut 
in_out) const
+{
+  bNodeSocket &socket = *nodeAddSocket(
+      &ntree, &node, in_out, "NodeSocketShader", identifier_.c_str(), 
name_.c_str());
+  this->set_common_flags(socket);
+  return socket;
+}
+
+bool Shader::matches(const bNodeSocket &socket) const
+{
+  if (!this->matches_common_data(socket)) {
+    return false;
+  }
+  if (socket.type != SOCK_SHADER) {
+    return false;
+  }
+  return true;
+}
+
+/** \} */
+
 }  // namespace blender::nodes::decl

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to