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
This commit is contained in:
Aaron Carlisle 2021-12-07 21:05:13 -05:00
parent 0d8c479225
commit 333dc7b5c4
2 changed files with 40 additions and 0 deletions

View File

@ -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
* \{ */

View File

@ -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