[Bf-blender-cvs] [13d984cfaad] temp-nodes-group-declarations: Add "Custom" socket declaration
Hans Goudey
noreply at git.blender.org
Thu Dec 22 21:18:13 CET 2022
Commit: 13d984cfaad26e506579350ad97ba0dc04d8e5d3
Author: Hans Goudey
Date: Thu Dec 22 15:18:07 2022 -0500
Branches: temp-nodes-group-declarations
https://developer.blender.org/rB13d984cfaad26e506579350ad97ba0dc04d8e5d3
Add "Custom" socket declaration
I didn't test this yet
===================================================================
M source/blender/nodes/NOD_socket_declarations.hh
M source/blender/nodes/intern/node_common.cc
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 83bf2e5b9bc..131aed32afa 100644
--- a/source/blender/nodes/NOD_socket_declarations.hh
+++ b/source/blender/nodes/NOD_socket_declarations.hh
@@ -248,6 +248,16 @@ class Extend : public SocketDeclaration {
class ExtendBuilder : public SocketDeclarationBuilder<Extend> {
};
+class Custom : public SocketDeclaration {
+ public:
+ const char *idname_;
+
+ bNodeSocket &build(bNodeTree &ntree, bNode &node) const override;
+ bool matches(const bNodeSocket &socket) const override;
+ bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override;
+ bool can_connect(const bNodeSocket &socket) const override;
+};
+
/* -------------------------------------------------------------------- */
/** \name #FloatBuilder Inline Methods
* \{ */
diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc
index a81f5d463b7..1258867e9bd 100644
--- a/source/blender/nodes/intern/node_common.cc
+++ b/source/blender/nodes/intern/node_common.cc
@@ -200,7 +200,10 @@ static SocketDeclarationPtr declataion_for_interface_socket(const bNodeSocket &i
case SOCK_MATERIAL:
dst = std::make_unique<decl::Material>();
break;
- default:
+ case SOCK_CUSTOM:
+ std::unique_ptr<decl::Custom> decl = std::make_unique<decl::Custom>();
+ decl->idname_ = io_socket.idname;
+ dst = std::move(decl);
break;
}
dst->name_ = io_socket.name;
diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc
index 321e3a1c499..64773f66dbd 100644
--- a/source/blender/nodes/intern/node_socket_declarations.cc
+++ b/source/blender/nodes/intern/node_socket_declarations.cc
@@ -537,4 +537,40 @@ bNodeSocket &Extend::update_or_build(bNodeTree & /*ntree*/,
/** \} */
+/* -------------------------------------------------------------------- */
+/** \name #Custom
+ * \{ */
+
+bNodeSocket &Custom::build(bNodeTree &ntree, bNode &node) const
+{
+ bNodeSocket &socket = *nodeAddSocket(
+ &ntree, &node, in_out_, idname_, identifier_.c_str(), name_.c_str());
+ return socket;
+}
+
+bool Custom::matches(const bNodeSocket &socket) const
+{
+ if (!this->matches_common_data(socket)) {
+ return false;
+ }
+ if (socket.type != SOCK_CUSTOM) {
+ return false;
+ }
+ return true;
+}
+
+bool Custom::can_connect(const bNodeSocket &socket) const
+{
+ return sockets_can_connect(*this, socket) && STREQ(socket.idname, idname_);
+}
+
+bNodeSocket &Custom::update_or_build(bNodeTree & /*ntree*/,
+ bNode & /*node*/,
+ bNodeSocket &socket) const
+{
+ return socket;
+}
+
+/** \} */
+
} // namespace blender::nodes::decl
More information about the Bf-blender-cvs
mailing list