[Bf-blender-cvs] [367fc69dc1c] master: Nodes: Convert several shader nodes to c++

Aaron Carlisle noreply at git.blender.org
Mon Jan 3 05:45:15 CET 2022


Commit: 367fc69dc1c5ebb6e30ef74488a041502ea8a370
Author: Aaron Carlisle
Date:   Sun Jan 2 23:34:56 2022 -0500
Branches: master
https://developer.blender.org/rB367fc69dc1c5ebb6e30ef74488a041502ea8a370

Nodes: Convert several shader nodes to c++

Also add file namespace

This is needed to use new node APIs

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

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

M	source/blender/nodes/shader/CMakeLists.txt
R086	source/blender/nodes/shader/nodes/node_shader_hair_info.c	source/blender/nodes/shader/nodes/node_shader_hair_info.cc
R081	source/blender/nodes/shader/nodes/node_shader_holdout.c	source/blender/nodes/shader/nodes/node_shader_holdout.cc
R088	source/blender/nodes/shader/nodes/node_shader_hueSatVal.c	source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc
R084	source/blender/nodes/shader/nodes/node_shader_invert.c	source/blender/nodes/shader/nodes/node_shader_invert.cc
R083	source/blender/nodes/shader/nodes/node_shader_layer_weight.c	source/blender/nodes/shader/nodes/node_shader_layer_weight.cc
R083	source/blender/nodes/shader/nodes/node_shader_light_falloff.c	source/blender/nodes/shader/nodes/node_shader_light_falloff.cc
R087	source/blender/nodes/shader/nodes/node_shader_light_path.c	source/blender/nodes/shader/nodes/node_shader_light_path.cc
R085	source/blender/nodes/shader/nodes/node_shader_mapping.c	source/blender/nodes/shader/nodes/node_shader_mapping.cc
R084	source/blender/nodes/shader/nodes/node_shader_normal.c	source/blender/nodes/shader/nodes/node_shader_normal.cc
R077	source/blender/nodes/shader/nodes/node_shader_normal_map.c	source/blender/nodes/shader/nodes/node_shader_normal_map.cc
R085	source/blender/nodes/shader/nodes/node_shader_object_info.c	source/blender/nodes/shader/nodes/node_shader_object_info.cc
R081	source/blender/nodes/shader/nodes/node_shader_output_aov.c	source/blender/nodes/shader/nodes/node_shader_output_aov.cc
R080	source/blender/nodes/shader/nodes/node_shader_output_light.c	source/blender/nodes/shader/nodes/node_shader_output_light.cc
R081	source/blender/nodes/shader/nodes/node_shader_output_linestyle.c	source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc
R087	source/blender/nodes/shader/nodes/node_shader_output_material.c	source/blender/nodes/shader/nodes/node_shader_output_material.cc
R082	source/blender/nodes/shader/nodes/node_shader_output_world.c	source/blender/nodes/shader/nodes/node_shader_output_world.cc
R085	source/blender/nodes/shader/nodes/node_shader_particle_info.c	source/blender/nodes/shader/nodes/node_shader_particle_info.cc
R083	source/blender/nodes/shader/nodes/node_shader_rgb.c	source/blender/nodes/shader/nodes/node_shader_rgb.cc
R067	source/blender/nodes/shader/nodes/node_shader_script.c	source/blender/nodes/shader/nodes/node_shader_script.cc
R080	source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.c	source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc

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

diff --git a/source/blender/nodes/shader/CMakeLists.txt b/source/blender/nodes/shader/CMakeLists.txt
index 3e514b8635c..6e2ad57865b 100644
--- a/source/blender/nodes/shader/CMakeLists.txt
+++ b/source/blender/nodes/shader/CMakeLists.txt
@@ -71,32 +71,32 @@ set(SRC
   nodes/node_shader_fresnel.cc
   nodes/node_shader_gamma.cc
   nodes/node_shader_geometry.cc
-  nodes/node_shader_hair_info.c
-  nodes/node_shader_holdout.c
-  nodes/node_shader_hueSatVal.c
+  nodes/node_shader_hair_info.cc
+  nodes/node_shader_holdout.cc
+  nodes/node_shader_hueSatVal.cc
   nodes/node_shader_ies_light.cc
-  nodes/node_shader_invert.c
-  nodes/node_shader_layer_weight.c
-  nodes/node_shader_light_falloff.c
-  nodes/node_shader_light_path.c
+  nodes/node_shader_invert.cc
+  nodes/node_shader_layer_weight.cc
+  nodes/node_shader_light_falloff.cc
+  nodes/node_shader_light_path.cc
   nodes/node_shader_map_range.cc
-  nodes/node_shader_mapping.c
+  nodes/node_shader_mapping.cc
   nodes/node_shader_math.cc
   nodes/node_shader_mix_rgb.cc
   nodes/node_shader_mix_shader.cc
-  nodes/node_shader_normal.c
-  nodes/node_shader_normal_map.c
-  nodes/node_shader_object_info.c
-  nodes/node_shader_output_aov.c
-  nodes/node_shader_output_light.c
-  nodes/node_shader_output_linestyle.c
-  nodes/node_shader_output_material.c
-  nodes/node_shader_output_world.c
-  nodes/node_shader_particle_info.c
+  nodes/node_shader_normal.cc
+  nodes/node_shader_normal_map.cc
+  nodes/node_shader_object_info.cc
+  nodes/node_shader_output_aov.cc
+  nodes/node_shader_output_light.cc
+  nodes/node_shader_output_linestyle.cc
+  nodes/node_shader_output_material.cc
+  nodes/node_shader_output_world.cc
+  nodes/node_shader_particle_info.cc
   nodes/node_shader_rgb_to_bw.cc
-  nodes/node_shader_rgb.c
-  nodes/node_shader_script.c
-  nodes/node_shader_sepcomb_hsv.c
+  nodes/node_shader_rgb.cc
+  nodes/node_shader_script.cc
+  nodes/node_shader_sepcomb_hsv.cc
   nodes/node_shader_sepcomb_rgb.cc
   nodes/node_shader_sepcomb_xyz.cc
   nodes/node_shader_shader_to_rgb.cc
diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.c b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc
similarity index 86%
rename from source/blender/nodes/shader/nodes/node_shader_hair_info.c
rename to source/blender/nodes/shader/nodes/node_shader_hair_info.cc
index 784f9da9d0d..0ea1d09c683 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hair_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc
@@ -19,6 +19,8 @@
 
 #include "../node_shader_util.h"
 
+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},
@@ -43,14 +45,18 @@ static int node_shader_gpu_hair_info(GPUMaterial *mat,
   return GPU_stack_link(mat, node, "node_hair_info", in, out, length_link);
 }
 
+}  // namespace blender::nodes::node_shader_hair_info_cc
+
 /* node type definition */
-void register_node_type_sh_hair_info(void)
+void register_node_type_sh_hair_info()
 {
+  namespace file_ns = blender::nodes::node_shader_hair_info_cc;
+
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_HAIR_INFO, "Hair Info", NODE_CLASS_INPUT, 0);
-  node_type_socket_templates(&ntype, NULL, outputs);
-  node_type_gpu(&ntype, node_shader_gpu_hair_info);
+  node_type_socket_templates(&ntype, nullptr, file_ns::outputs);
+  node_type_gpu(&ntype, file_ns::node_shader_gpu_hair_info);
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.c b/source/blender/nodes/shader/nodes/node_shader_holdout.cc
similarity index 81%
rename from source/blender/nodes/shader/nodes/node_shader_holdout.c
rename to source/blender/nodes/shader/nodes/node_shader_holdout.cc
index 1d94219ea8b..048a6e8749a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_holdout.c
+++ b/source/blender/nodes/shader/nodes/node_shader_holdout.cc
@@ -19,6 +19,8 @@
 
 #include "../node_shader_util.h"
 
+namespace blender::nodes::node_shader_holdout_cc {
+
 /* **************** OUTPUT ******************** */
 
 static bNodeSocketTemplate sh_node_holdout_in[] = {
@@ -39,14 +41,18 @@ static int gpu_shader_rgb(GPUMaterial *mat,
   return GPU_stack_link(mat, node, "node_holdout", in, out);
 }
 
+}  // namespace blender::nodes::node_shader_holdout_cc
+
 /* node type definition */
-void register_node_type_sh_holdout(void)
+void register_node_type_sh_holdout()
 {
+  namespace file_ns = blender::nodes::node_shader_holdout_cc;
+
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_HOLDOUT, "Holdout", NODE_CLASS_SHADER, 0);
-  node_type_socket_templates(&ntype, sh_node_holdout_in, sh_node_holdout_out);
-  node_type_gpu(&ntype, gpu_shader_rgb);
+  node_type_socket_templates(&ntype, file_ns::sh_node_holdout_in, file_ns::sh_node_holdout_out);
+  node_type_gpu(&ntype, file_ns::gpu_shader_rgb);
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc
similarity index 88%
rename from source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
rename to source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc
index 50eb5bf32c9..26a7511b29b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc
@@ -23,6 +23,8 @@
 
 #include "node_shader_util.h"
 
+namespace blender::nodes::node_shader_hueSatVal_cc {
+
 /* **************** Hue Saturation ******************** */
 static bNodeSocketTemplate sh_node_hue_sat_in[] = {
     {SOCK_FLOAT, N_("Hue"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
@@ -85,15 +87,19 @@ static int gpu_shader_hue_sat(GPUMaterial *mat,
   return GPU_stack_link(mat, node, "hue_sat", in, out);
 }
 
-void register_node_type_sh_hue_sat(void)
+}  // namespace blender::nodes::node_shader_hueSatVal_cc
+
+void register_node_type_sh_hue_sat()
 {
+  namespace file_ns = blender::nodes::node_shader_hueSatVal_cc;
+
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
-  node_type_socket_templates(&ntype, sh_node_hue_sat_in, sh_node_hue_sat_out);
+  node_type_socket_templates(&ntype, file_ns::sh_node_hue_sat_in, file_ns::sh_node_hue_sat_out);
   node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
-  node_type_exec(&ntype, NULL, NULL, node_shader_exec_hue_sat);
-  node_type_gpu(&ntype, gpu_shader_hue_sat);
+  node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_hue_sat);
+  node_type_gpu(&ntype, file_ns::gpu_shader_hue_sat);
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.cc
similarity index 84%
rename from source/blender/nodes/shader/nodes/node_shader_invert.c
rename to source/blender/nodes/shader/nodes/node_shader_invert.cc
index 0d6709a1968..34862ad2246 100644
--- a/source/blender/nodes/shader/nodes/node_shader_invert.c
+++ b/source/blender/nodes/shader/nodes/node_shader_invert.cc
@@ -23,6 +23,8 @@
 
 #include "node_shader_util.h"
 
+namespace blender::nodes::node_shader_invert_cc {
+
 /* **************** INVERT ******************** */
 static bNodeSocketTemplate sh_node_invert_in[] = {
     {SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
@@ -65,14 +67,18 @@ static int gpu_shader_invert(GPUMaterial *mat,
   return GPU_stack_link(mat, node, "invert", in, out);
 }
 
-void register_node_type_sh_invert(void)
+}  // namespace blender::nodes::node_shader_invert_cc
+
+void register_node_type_sh_invert()
 {
+  namespace file_ns = blender::nodes::node_shader_invert_cc;
+
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
-  node_type_socket_templates(&ntype, sh_node_invert_in, sh_node_invert_out);
-  node_type_exec(&ntype, NULL, NULL, node_shader_exec_invert);
-  node_type_gpu(&ntype, gpu_shader_invert);
+  node_type_socket_templates(&ntype, file_ns::sh_node_invert_in, file_ns::sh_node_invert_out);
+  node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_invert);
+  node_type_gpu(&ntype, file_ns::gpu_shader_invert);
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc
similarity index 83%
rename from source/blender/nodes/shader/nodes/node_shader_layer_weight.c
rename to source/blender/nodes/shader/nodes/node_shader_layer_weight.cc
index d21a98452ce..5e684cb08ac 100644
--- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
+++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc
@@ -19,6 +19,8 @@
 
 #include "../node_shader_util.h"
 
+namespace blender::nodes::node_shader_layer_weight_cc {
+
 /* **************** Layer Weight ******************** */
 
 static bNodeSocketTemplate sh_node_layer_weight_in[] = {
@@ -59,15 +61,20 @@ static void node_shader_exec_layer_weight(void *UNUSED(data),
 {
 }
 
+}  // namespace blender::nodes::node_shader_layer_weight_cc
+
 /* node type definition */
-void register_node_type_sh_layer_weight(void)
+void register_node_type_sh_layer_weight()
 {
+  namespace file_ns = blender::nodes::node_shader_layer_weight_cc;
+
   static bNodeType ntype;
 
   sh_node_type_base(&ntype, SH_NODE_LAYER_WEIGHT, "Layer Weight", NODE_CLASS_INPUT, 0);
-  node_type_socket_templates(&ntype, sh_node_layer_weight_in, sh_node_layer_weight_out);
-  node_type_gpu(&ntype, node_shader_gpu_layer_weight);
-  node_type_exec(&ntype, NULL, NULL, node_shader_exec_layer_weight);
+  node_type_socket_templates(
+      &ntype, file_ns::sh_node_layer_weight_in, file_ns::sh_node_layer_weight_out);
+  node_type_gpu(&ntype, file_ns::node_shader_gpu_layer_weight);
+  node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_layer_weight);
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc
similarity index 83%
rename from sour

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list