[Bf-blender-cvs] [684500837d2] master: Cleanup: convert function nodes socket list to use new API

Rajesh Advani noreply at git.blender.org
Fri Sep 3 10:47:47 CEST 2021


Commit: 684500837d2994a2da840456cbff8c04b4371e00
Author: Rajesh Advani
Date:   Fri Sep 3 10:45:48 2021 +0200
Branches: master
https://developer.blender.org/rB684500837d2994a2da840456cbff8c04b4371e00

Cleanup: convert function nodes socket list to use new API

The new API was introduced in rB1e69a25043120cc8dddc3f58622eb50e1443def1.

Differential Revision: https://developer.blender.org/D12380

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

M	source/blender/nodes/function/node_function_util.hh
M	source/blender/nodes/function/nodes/node_fn_boolean_math.cc
M	source/blender/nodes/function/nodes/node_fn_float_compare.cc
M	source/blender/nodes/function/nodes/node_fn_float_to_int.cc
M	source/blender/nodes/function/nodes/node_fn_input_string.cc
M	source/blender/nodes/function/nodes/node_fn_input_vector.cc
M	source/blender/nodes/function/nodes/node_fn_random_float.cc

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

diff --git a/source/blender/nodes/function/node_function_util.hh b/source/blender/nodes/function/node_function_util.hh
index 96a8f29c3e9..46b485298e3 100644
--- a/source/blender/nodes/function/node_function_util.hh
+++ b/source/blender/nodes/function/node_function_util.hh
@@ -31,6 +31,7 @@
 
 #include "NOD_function.h"
 #include "NOD_multi_function.hh"
+#include "NOD_socket_declarations.hh"
 
 #include "node_util.h"
 
diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
index 58e7d82beea..b71ee092de6 100644
--- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
+++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
@@ -24,17 +24,17 @@
 
 #include "node_function_util.hh"
 
-static bNodeSocketTemplate fn_node_boolean_math_in[] = {
-    {SOCK_BOOLEAN, N_("Boolean")},
-    {SOCK_BOOLEAN, N_("Boolean")},
-    {-1, ""},
-};
+namespace blender::nodes {
 
-static bNodeSocketTemplate fn_node_boolean_math_out[] = {
-    {SOCK_BOOLEAN, N_("Boolean")},
-    {-1, ""},
+static void fn_node_boolean_math_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Bool>("Boolean", "Boolean");
+  b.add_input<decl::Bool>("Boolean", "Boolean_001");
+  b.add_output<decl::Bool>("Boolean");
 };
 
+}  // namespace blender::nodes
+
 static void fn_node_boolean_math_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
   uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
@@ -91,7 +91,7 @@ void register_node_type_fn_boolean_math()
   static bNodeType ntype;
 
   fn_node_type_base(&ntype, FN_NODE_BOOLEAN_MATH, "Boolean Math", NODE_CLASS_CONVERTER, 0);
-  node_type_socket_templates(&ntype, fn_node_boolean_math_in, fn_node_boolean_math_out);
+  ntype.declare = blender::nodes::fn_node_boolean_math_declare;
   node_type_label(&ntype, node_boolean_math_label);
   node_type_update(&ntype, node_boolean_math_update);
   ntype.build_multi_function = fn_node_boolean_math_build_multi_function;
diff --git a/source/blender/nodes/function/nodes/node_fn_float_compare.cc b/source/blender/nodes/function/nodes/node_fn_float_compare.cc
index 918dd24e520..4f4830afabc 100644
--- a/source/blender/nodes/function/nodes/node_fn_float_compare.cc
+++ b/source/blender/nodes/function/nodes/node_fn_float_compare.cc
@@ -26,18 +26,18 @@
 
 #include "node_function_util.hh"
 
-static bNodeSocketTemplate fn_node_float_compare_in[] = {
-    {SOCK_FLOAT, N_("A"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
-    {SOCK_FLOAT, N_("B"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
-    {SOCK_FLOAT, N_("Epsilon"), 0.001f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
-    {-1, ""},
-};
+namespace blender::nodes {
 
-static bNodeSocketTemplate fn_node_float_compare_out[] = {
-    {SOCK_BOOLEAN, N_("Result")},
-    {-1, ""},
+static void fn_node_float_compare_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Float>("A").min(-10000.0f).max(10000.0f);
+  b.add_input<decl::Float>("B").min(-10000.0f).max(10000.0f);
+  b.add_input<decl::Float>("Epsilon").default_value(0.001f).min(-10000.0f).max(10000.0f);
+  b.add_output<decl::Bool>("Result");
 };
 
+}  // namespace blender::nodes
+
 static void geo_node_float_compare_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
   uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
@@ -110,7 +110,7 @@ void register_node_type_fn_float_compare()
   static bNodeType ntype;
 
   fn_node_type_base(&ntype, FN_NODE_FLOAT_COMPARE, "Float Compare", NODE_CLASS_CONVERTER, 0);
-  node_type_socket_templates(&ntype, fn_node_float_compare_in, fn_node_float_compare_out);
+  ntype.declare = blender::nodes::fn_node_float_compare_declare;
   node_type_label(&ntype, node_float_compare_label);
   node_type_update(&ntype, node_float_compare_update);
   ntype.build_multi_function = fn_node_float_compare_build_multi_function;
diff --git a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc
index 40b8f27f895..e59c78d2c04 100644
--- a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc
+++ b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc
@@ -25,16 +25,16 @@
 
 #include "node_function_util.hh"
 
-static bNodeSocketTemplate fn_node_float_to_int_in[] = {
-    {SOCK_FLOAT, N_("Float"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
-    {-1, ""},
-};
+namespace blender::nodes {
 
-static bNodeSocketTemplate fn_node_float_to_int_out[] = {
-    {SOCK_INT, N_("Integer")},
-    {-1, ""},
+static void fn_node_float_to_int_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Float>("Float");
+  b.add_output<decl::Int>("Integer");
 };
 
+}  // namespace blender::nodes
+
 static void fn_node_float_to_int_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
   uiItemR(layout, ptr, "rounding_mode", 0, "", ICON_NONE);
@@ -88,7 +88,7 @@ void register_node_type_fn_float_to_int()
   static bNodeType ntype;
 
   fn_node_type_base(&ntype, FN_NODE_FLOAT_TO_INT, "Float to Integer", NODE_CLASS_CONVERTER, 0);
-  node_type_socket_templates(&ntype, fn_node_float_to_int_in, fn_node_float_to_int_out);
+  ntype.declare = blender::nodes::fn_node_float_to_int_declare;
   node_type_label(&ntype, node_float_to_int_label);
   ntype.build_multi_function = fn_node_float_to_int_build_multi_function;
   ntype.draw_buttons = fn_node_float_to_int_layout;
diff --git a/source/blender/nodes/function/nodes/node_fn_input_string.cc b/source/blender/nodes/function/nodes/node_fn_input_string.cc
index 560ace57aba..4a8e898fb9b 100644
--- a/source/blender/nodes/function/nodes/node_fn_input_string.cc
+++ b/source/blender/nodes/function/nodes/node_fn_input_string.cc
@@ -19,11 +19,15 @@
 #include "UI_interface.h"
 #include "UI_resources.h"
 
-static bNodeSocketTemplate fn_node_input_string_out[] = {
-    {SOCK_STRING, N_("String")},
-    {-1, ""},
+namespace blender::nodes {
+
+static void fn_node_input_string_declare(NodeDeclarationBuilder &b)
+{
+  b.add_output<decl::String>("String");
 };
 
+}  // namespace blender::nodes
+
 static void fn_node_input_string_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
   uiItemR(layout, ptr, "string", 0, "", ICON_NONE);
@@ -75,7 +79,7 @@ void register_node_type_fn_input_string()
   static bNodeType ntype;
 
   fn_node_type_base(&ntype, FN_NODE_INPUT_STRING, "String", NODE_CLASS_INPUT, 0);
-  node_type_socket_templates(&ntype, nullptr, fn_node_input_string_out);
+  ntype.declare = blender::nodes::fn_node_input_string_declare;
   node_type_init(&ntype, fn_node_input_string_init);
   node_type_storage(&ntype, "NodeInputString", fn_node_input_string_free, fn_node_string_copy);
   ntype.build_multi_function = fn_node_input_string_build_multi_function;
diff --git a/source/blender/nodes/function/nodes/node_fn_input_vector.cc b/source/blender/nodes/function/nodes/node_fn_input_vector.cc
index 244c045de9a..9548df7b423 100644
--- a/source/blender/nodes/function/nodes/node_fn_input_vector.cc
+++ b/source/blender/nodes/function/nodes/node_fn_input_vector.cc
@@ -21,11 +21,15 @@
 #include "UI_interface.h"
 #include "UI_resources.h"
 
-static bNodeSocketTemplate fn_node_input_vector_out[] = {
-    {SOCK_VECTOR, N_("Vector")},
-    {-1, ""},
+namespace blender::nodes {
+
+static void fn_node_input_vector_declare(NodeDeclarationBuilder &b)
+{
+  b.add_output<decl::Vector>("Vector");
 };
 
+}  // namespace blender::nodes
+
 static void fn_node_input_vector_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
   uiLayout *col = uiLayoutColumn(layout, true);
@@ -52,7 +56,7 @@ void register_node_type_fn_input_vector()
   static bNodeType ntype;
 
   fn_node_type_base(&ntype, FN_NODE_INPUT_VECTOR, "Vector", 0, 0);
-  node_type_socket_templates(&ntype, nullptr, fn_node_input_vector_out);
+  ntype.declare = blender::nodes::fn_node_input_vector_declare;
   node_type_init(&ntype, fn_node_input_vector_init);
   node_type_storage(
       &ntype, "NodeInputVector", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/function/nodes/node_fn_random_float.cc b/source/blender/nodes/function/nodes/node_fn_random_float.cc
index 47ec9adf6bd..1bd39aacdca 100644
--- a/source/blender/nodes/function/nodes/node_fn_random_float.cc
+++ b/source/blender/nodes/function/nodes/node_fn_random_float.cc
@@ -18,18 +18,18 @@
 
 #include "BLI_hash.h"
 
-static bNodeSocketTemplate fn_node_random_float_in[] = {
-    {SOCK_FLOAT, N_("Min"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
-    {SOCK_FLOAT, N_("Max"), 1.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
-    {SOCK_INT, N_("Seed"), 0, 0, 0, 0, -10000, 10000},
-    {-1, ""},
-};
+namespace blender::nodes {
 
-static bNodeSocketTemplate fn_node_random_float_out[] = {
-    {SOCK_FLOAT, N_("Value")},
-    {-1, ""},
+static void fn_node_random_float_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Float>("Min").min(-10000.0f).max(10000.0f);
+  b.add_input<decl::Float>("Max").default_value(1.0f).min(-10000.0f).max(10000.0f);
+  b.add_input<decl::Int>("Seed").min(-10000).max(10000);
+  b.add_output<decl::Float>("Value");
 };
 
+}  // namespace blender::nodes
+
 class RandomFloatFunction : public blender::fn::MultiFunction {
  public:
   RandomFloatFunction()
@@ -79,7 +79,7 @@ void register_node_type_fn_random_float()
   static bNodeType ntype;
 
   fn_node_type_base(&ntype, FN_NODE_RANDOM_FLOAT, "Random Float", 0, 0);
-  node_type_socket_templates(&ntype, fn_node_random_float_in, fn_node_random_float_out);
+  ntype.declare = blender::nodes::fn_node_random_float_declare;
   ntype.build_multi_function = fn_node_random_float_build_multi_function;
   nodeRegisterType(&ntype);
 }



More information about the Bf-blender-cvs mailing list