[Bf-blender-cvs] [b72d4e1d98b] simulation-tree: new operator socket
Jacques Lucke
noreply at git.blender.org
Tue Feb 25 18:02:02 CET 2020
Commit: b72d4e1d98bab097e71f00058a2995c55865ffcb
Author: Jacques Lucke
Date: Tue Feb 25 14:46:24 2020 +0100
Branches: simulation-tree
https://developer.blender.org/rBb72d4e1d98bab097e71f00058a2995c55865ffcb
new operator socket
===================================================================
M source/blender/simulations/nodes/my_test_node.cc
===================================================================
diff --git a/source/blender/simulations/nodes/my_test_node.cc b/source/blender/simulations/nodes/my_test_node.cc
index 044a6712f28..9dfcc3b4d17 100644
--- a/source/blender/simulations/nodes/my_test_node.cc
+++ b/source/blender/simulations/nodes/my_test_node.cc
@@ -181,6 +181,47 @@ class FixedTypeSocketDecl : public SocketDecl {
}
};
+class OperatorSocketDecl : public SocketDecl {
+ eNodeSocketInOut m_in_out;
+ StringRefNull m_ui_name;
+ StringRefNull m_identifier;
+
+ public:
+ OperatorSocketDecl(bNodeTree &ntree,
+ bNode &node,
+ eNodeSocketInOut in_out,
+ StringRefNull ui_name,
+ StringRefNull identifier)
+ : SocketDecl(ntree, node, 1), m_in_out(in_out), m_ui_name(ui_name), m_identifier(identifier)
+ {
+ }
+
+ bool sockets_are_correct(ArrayRef<bNodeSocket *> sockets) const override
+ {
+ if (sockets.size() != 1) {
+ return false;
+ }
+
+ bNodeSocket *socket = sockets[0];
+ if (!STREQ(socket->idname, "OperatorSocket")) {
+ return false;
+ }
+ if (socket->name != m_ui_name) {
+ return false;
+ }
+ if (socket->identifier != m_identifier) {
+ return false;
+ }
+ return true;
+ }
+
+ void build() const override
+ {
+ nodeAddSocket(
+ &m_ntree, &m_node, m_in_out, "OperatorSocket", m_identifier.data(), m_ui_name.data());
+ }
+};
+
class NodeDecl {
public:
bNodeTree &m_ntree;
@@ -284,6 +325,17 @@ class NodeBuilder {
m_node_decl.m_outputs.append(decl);
}
+ void operator_input(StringRef identifier, StringRef ui_name)
+ {
+ OperatorSocketDecl *decl = m_allocator.construct<OperatorSocketDecl>(
+ m_node_decl.m_ntree,
+ m_node_decl.m_node,
+ SOCK_IN,
+ m_allocator.copy_string(ui_name),
+ m_allocator.copy_string(identifier));
+ m_node_decl.m_inputs.append(decl);
+ }
+
void float_input(StringRef identifier, StringRef ui_name)
{
this->fixed_input(identifier, ui_name, *data_socket_float);
@@ -815,6 +867,7 @@ void register_node_type_my_test_node()
LISTBASE_FOREACH (VariadicNodeSocketIdentifier *, value, &storage->inputs_info) {
node_builder.float_input(value->identifier, "Value");
}
+ node_builder.operator_input("New Input", "New");
node_builder.float_output("result", "Result");
});
ntype.add_draw_fn([](uiLayout *layout, struct bContext *UNUSED(C), struct PointerRNA *ptr) {
@@ -873,6 +926,11 @@ void init_socket_data_types()
stype.set_color({0.06, 0.52, 0.15, 1.0});
stype.register_type();
}
+ {
+ static SocketDefinition stype("OperatorSocket");
+ stype.set_color({0.0, 0.0, 0.0, 0.0});
+ stype.register_type();
+ }
{
static SocketDefinition stype("MyFloatSocket");
stype.set_color({1, 1, 1, 1});
More information about the Bf-blender-cvs
mailing list