[Bf-blender-cvs] [937aa8e1142] master: Cleanup: Use new socket builder API

Aaron Carlisle noreply at git.blender.org
Sat Jan 8 05:54:05 CET 2022


Commit: 937aa8e1142300e0ba82f6f9b9ddb9908be54b9c
Author: Aaron Carlisle
Date:   Fri Jan 7 23:52:19 2022 -0500
Branches: master
https://developer.blender.org/rB937aa8e1142300e0ba82f6f9b9ddb9908be54b9c

Cleanup: Use new socket builder API

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

M	source/blender/nodes/shader/nodes/node_shader_attribute.cc
M	source/blender/nodes/shader/nodes/node_shader_background.cc
M	source/blender/nodes/shader/nodes/node_shader_bevel.cc
M	source/blender/nodes/shader/nodes/node_shader_brightness.cc
M	source/blender/nodes/shader/nodes/node_shader_fresnel.cc
M	source/blender/nodes/shader/nodes/node_shader_hair_info.cc
M	source/blender/nodes/shader/nodes/node_shader_light_path.cc
M	source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc
M	source/blender/nodes/shader/nodes/node_shader_squeeze.cc
M	source/blender/nodes/shader/nodes/node_shader_vector_transform.cc

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

diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.cc b/source/blender/nodes/shader/nodes/node_shader_attribute.cc
index 3e9c57df7cf..8cf48306641 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.cc
@@ -21,15 +21,13 @@
 
 namespace blender::nodes::node_shader_attribute_cc {
 
-/* **************** OUTPUT ******************** */
-
-static bNodeSocketTemplate sh_node_attribute_out[] = {
-    {SOCK_RGBA, N_("Color")},
-    {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    {SOCK_FLOAT, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR},
-    {SOCK_FLOAT, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR},
-    {-1, ""},
-};
+static void node_declare(NodeDeclarationBuilder &b)
+{
+  b.add_output<decl::Color>(N_("Color"));
+  b.add_output<decl::Vector>(N_("Vector"));
+  b.add_output<decl::Float>(N_("Fac"));
+  b.add_output<decl::Float>(N_("Alpha"));
+}
 
 static void node_shader_init_attribute(bNodeTree *UNUSED(ntree), bNode *node)
 {
@@ -75,7 +73,6 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
 
   GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr);
 
-  /* for each output. */
   int i;
   LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->outputs, i) {
     node_shader_gpu_bump_tex_coord(mat, node, &out[i].link);
@@ -94,7 +91,7 @@ void register_node_type_sh_attribute()
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_ATTRIBUTE, "Attribute", NODE_CLASS_INPUT);
-  node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_attribute_out);
+  ntype.declare = file_ns::node_declare;
   node_type_init(&ntype, file_ns::node_shader_init_attribute);
   node_type_storage(
       &ntype, "NodeShaderAttribute", node_free_standard_storage, node_copy_standard_storage);
diff --git a/source/blender/nodes/shader/nodes/node_shader_background.cc b/source/blender/nodes/shader/nodes/node_shader_background.cc
index 39858e36fd1..3b9e71cf842 100644
--- a/source/blender/nodes/shader/nodes/node_shader_background.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_background.cc
@@ -21,18 +21,12 @@
 
 namespace blender::nodes::node_shader_background_cc {
 
-/* **************** OUTPUT ******************** */
-
-static bNodeSocketTemplate sh_node_background_in[] = {
-    {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
-    {SOCK_FLOAT, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate sh_node_background_out[] = {
-    {SOCK_SHADER, N_("Background")},
-    {-1, ""},
-};
+static void node_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f});
+  b.add_input<decl::Float>(N_("Strength")).default_value(1.0f).min(0.0f).max(1000000.0f);
+  b.add_output<decl::Shader>(N_("Background"));
+}
 
 static int node_shader_gpu_background(GPUMaterial *mat,
                                       bNode *node,
@@ -53,8 +47,7 @@ void register_node_type_sh_background()
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_BACKGROUND, "Background", NODE_CLASS_SHADER);
-  node_type_socket_templates(
-      &ntype, file_ns::sh_node_background_in, file_ns::sh_node_background_out);
+  ntype.declare = file_ns::node_declare;
   node_type_gpu(&ntype, file_ns::node_shader_gpu_background);
 
   nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bevel.cc b/source/blender/nodes/shader/nodes/node_shader_bevel.cc
index a3063358556..aa38eea273c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bevel.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_bevel.cc
@@ -21,18 +21,12 @@
 
 namespace blender::nodes::node_shader_bevel_cc {
 
-/* **************** OUTPUT ******************** */
-
-static bNodeSocketTemplate sh_node_bevel_in[] = {
-    {SOCK_FLOAT, N_("Radius"), 0.05f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
-    {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate sh_node_bevel_out[] = {
-    {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    {-1, ""},
-};
+static void node_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Float>(N_("Radius")).default_value(0.05f).min(0.0f).max(1000.0f);
+  b.add_input<decl::Vector>(N_("Normal")).hide_value();
+  b.add_output<decl::Vector>(N_("Normal"));
+}
 
 static void node_shader_init_bevel(bNodeTree *UNUSED(ntree), bNode *node)
 {
@@ -66,7 +60,7 @@ void register_node_type_sh_bevel()
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_BEVEL, "Bevel", NODE_CLASS_INPUT);
-  node_type_socket_templates(&ntype, file_ns::sh_node_bevel_in, file_ns::sh_node_bevel_out);
+  ntype.declare = file_ns::node_declare;
   node_type_init(&ntype, file_ns::node_shader_init_bevel);
   node_type_gpu(&ntype, file_ns::gpu_shader_bevel);
 
diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.cc b/source/blender/nodes/shader/nodes/node_shader_brightness.cc
index e6328c4972a..66bfaba2785 100644
--- a/source/blender/nodes/shader/nodes/node_shader_brightness.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_brightness.cc
@@ -21,19 +21,13 @@
 
 namespace blender::nodes::node_shader_brightness_cc {
 
-/* **************** Bright and contrast  ******************** */
-
-static bNodeSocketTemplate sh_node_brightcontrast_in[] = {
-    {SOCK_RGBA, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f},
-    {SOCK_FLOAT, N_("Bright"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
-    {SOCK_FLOAT, N_("Contrast"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate sh_node_brightcontrast_out[] = {
-    {SOCK_RGBA, N_("Color")},
-    {-1, ""},
-};
+static void node_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Color>(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f});
+  b.add_input<decl::Float>(N_("Bright")).default_value(0.0f).min(-100.0f).max(100.0f);
+  b.add_input<decl::Float>(N_("Contrast")).default_value(0.0f).min(-100.0f).max(100.0f);
+  b.add_output<decl::Color>(N_("Color"));
+}
 
 static int gpu_shader_brightcontrast(GPUMaterial *mat,
                                      bNode *node,
@@ -53,8 +47,7 @@ void register_node_type_sh_brightcontrast()
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR);
-  node_type_socket_templates(
-      &ntype, file_ns::sh_node_brightcontrast_in, file_ns::sh_node_brightcontrast_out);
+  ntype.declare = file_ns::node_declare;
   node_type_gpu(&ntype, file_ns::gpu_shader_brightcontrast);
 
   nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.cc b/source/blender/nodes/shader/nodes/node_shader_fresnel.cc
index 2abfb57a364..5dba42fcc30 100644
--- a/source/blender/nodes/shader/nodes/node_shader_fresnel.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.cc
@@ -21,17 +21,12 @@
 
 namespace blender::nodes::node_shader_fresnel_cc {
 
-/* **************** Fresnel ******************** */
-static bNodeSocketTemplate sh_node_fresnel_in[] = {
-    {SOCK_FLOAT, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
-    {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate sh_node_fresnel_out[] = {
-    {SOCK_FLOAT, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
-    {-1, ""},
-};
+static void node_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Float>(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f);
+  b.add_input<decl::Vector>(N_("Normal")).hide_value();
+  b.add_output<decl::Float>(N_("Fac"));
+}
 
 static int node_shader_gpu_fresnel(GPUMaterial *mat,
                                    bNode *node,
@@ -60,7 +55,7 @@ void register_node_type_sh_fresnel()
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_FRESNEL, "Fresnel", NODE_CLASS_INPUT);
-  node_type_socket_templates(&ntype, file_ns::sh_node_fresnel_in, file_ns::sh_node_fresnel_out);
+  ntype.declare = file_ns::node_declare;
   node_type_gpu(&ntype, file_ns::node_shader_gpu_fresnel);
 
   nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.cc b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc
index c5af7e16201..e22a825c066 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hair_info.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc
@@ -21,16 +21,16 @@
 
 namespace blender::nodes::node_shader_hair_info_cc {
 
-static bNodeSocketTemplate outputs[] = {
-    {SOCK_FLOAT, N_("Is Strand"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    {SOCK_FLOAT, N_("Intercept"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    {SOCK_FLOAT, N_("Length"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    {SOCK_FLOAT, N_("Thickness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    {SOCK_VECTOR, N_("Tangent Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    // { SOCK_FLOAT,  0, N_("Fade"),             0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-    {SOCK_FLOAT, N_("Random")},
-    {-1, ""},
-};
+static void node_declare(NodeDeclarationBuilder &b)
+{
+  b.add_output<decl::Float>(N_("Is Strand"));
+  b.add_output<decl::Float>(N_("Intercept"));
+  b.add_output<decl::Float>(N_("Length"));
+  b.add_output<decl::Float>(N_("Thickness"));
+  b.add_output<decl::Vector>(N_("Tangent Normal"));
+  // b.add_output<decl::Float>(N_("Fade"));
+  b.add_output<decl::Float>(N_("Random"));
+}
 
 static int node_shader_gpu_hair_info(GPUMaterial *mat,
                                      bNode *node,
@@ -55,7 +55,7 @@ void register_node_type_sh_hair_info()
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_HAIR_INFO, "Hair Info", NODE_CLASS_INPUT);
-  node_type_socket_templates(&ntype, nullptr, file_ns::outputs);
+  ntype.declare = file_ns::node_declare;
   node_type_gpu(&ntype, file_ns::node_shader_gpu_hair_info);
 
   nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.cc b/source/blender/nodes/shader/nodes/node_shader_light_p

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list