Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Carlisle <carlisle.b3d@gmail.com>2021-12-08 05:05:13 +0300
committerAaron Carlisle <carlisle.b3d@gmail.com>2021-12-08 05:05:13 +0300
commit333dc7b5c4ee44986294c6b5683fa4813454279b (patch)
treee2341a03b9310207833517a7e970d9e94d37bac4
parent0d8c479225d754ba376e442d56ffa935956427cf (diff)
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
-rw-r--r--source/blender/nodes/NOD_socket_declarations.hh15
-rw-r--r--source/blender/nodes/intern/node_socket_declarations.cc25
2 files changed, 40 insertions, 0 deletions
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