diff options
-rw-r--r-- | source/blender/nodes/shader/CMakeLists.txt | 40 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_hair_info.cc (renamed from source/blender/nodes/shader/nodes/node_shader_hair_info.c) | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_holdout.cc (renamed from source/blender/nodes/shader/nodes/node_shader_holdout.c) | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc (renamed from source/blender/nodes/shader/nodes/node_shader_hueSatVal.c) | 14 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_invert.cc (renamed from source/blender/nodes/shader/nodes/node_shader_invert.c) | 14 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_layer_weight.cc (renamed from source/blender/nodes/shader/nodes/node_shader_layer_weight.c) | 15 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_light_falloff.cc (renamed from source/blender/nodes/shader/nodes/node_shader_light_falloff.c) | 13 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_light_path.cc (renamed from source/blender/nodes/shader/nodes/node_shader_light_path.c) | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_mapping.cc (renamed from source/blender/nodes/shader/nodes/node_shader_mapping.c) | 16 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_normal.cc (renamed from source/blender/nodes/shader/nodes/node_shader_normal.c) | 14 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_normal_map.cc (renamed from source/blender/nodes/shader/nodes/node_shader_normal_map.c) | 30 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_object_info.cc (renamed from source/blender/nodes/shader/nodes/node_shader_object_info.c) | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_output_aov.cc (renamed from source/blender/nodes/shader/nodes/node_shader_output_aov.c) | 16 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_output_light.cc (renamed from source/blender/nodes/shader/nodes/node_shader_output_light.c) | 10 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc (renamed from source/blender/nodes/shader/nodes/node_shader_output_linestyle.c) | 10 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_output_material.cc (renamed from source/blender/nodes/shader/nodes/node_shader_output_material.c) | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_output_world.cc (renamed from source/blender/nodes/shader/nodes/node_shader_output_world.c) | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_particle_info.cc (renamed from source/blender/nodes/shader/nodes/node_shader_particle_info.c) | 15 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_rgb.cc (renamed from source/blender/nodes/shader/nodes/node_shader_rgb.c) | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_script.cc (renamed from source/blender/nodes/shader/nodes/node_shader_script.c) | 23 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc (renamed from source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.c) | 28 |
21 files changed, 237 insertions, 105 deletions
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 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 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 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 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 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 index 0a6a82c36f4..9d4334662c9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc @@ -19,6 +19,8 @@ #include "../node_shader_util.h" +namespace blender::nodes::node_shader_light_falloff_cc { + /* **************** INPUT ********************* */ static bNodeSocketTemplate sh_node_light_falloff_in[] = { @@ -45,15 +47,20 @@ static int node_shader_gpu_light_falloff(GPUMaterial *mat, return GPU_stack_link(mat, node, "node_light_falloff", in, out); } +} // namespace blender::nodes::node_shader_light_falloff_cc + /* node type definition */ -void register_node_type_sh_light_falloff(void) +void register_node_type_sh_light_falloff() { + namespace file_ns = blender::nodes::node_shader_light_falloff_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR, 0); - node_type_socket_templates(&ntype, sh_node_light_falloff_in, sh_node_light_falloff_out); + node_type_socket_templates( + &ntype, file_ns::sh_node_light_falloff_in, file_ns::sh_node_light_falloff_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_gpu(&ntype, node_shader_gpu_light_falloff); + node_type_gpu(&ntype, file_ns::node_shader_gpu_light_falloff); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.c b/source/blender/nodes/shader/nodes/node_shader_light_path.cc index fb34e3a4475..2643dbc9e0e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_path.c +++ b/source/blender/nodes/shader/nodes/node_shader_light_path.cc @@ -19,6 +19,8 @@ #include "../node_shader_util.h" +namespace blender::nodes::node_shader_light_path_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_light_path_out[] = { @@ -47,14 +49,18 @@ static int node_shader_gpu_light_path(GPUMaterial *mat, return GPU_stack_link(mat, node, "node_light_path", in, out); } +} // namespace blender::nodes::node_shader_light_path_cc + /* node type definition */ -void register_node_type_sh_light_path(void) +void register_node_type_sh_light_path() { + namespace file_ns = blender::nodes::node_shader_light_path_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LIGHT_PATH, "Light Path", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, NULL, sh_node_light_path_out); - node_type_gpu(&ntype, node_shader_gpu_light_path); + node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_light_path_out); + node_type_gpu(&ntype, file_ns::node_shader_gpu_light_path); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.cc index 7f192058307..d5cf2bb69ee 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.cc @@ -23,6 +23,8 @@ #include "node_shader_util.h" +namespace blender::nodes::node_shader_mapping_cc { + /* **************** MAPPING ******************** */ static bNodeSocketTemplate sh_node_mapping_in[] = { {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_NONE}, @@ -49,7 +51,7 @@ static const char *gpu_shader_get_name(int mode) case NODE_MAPPING_TYPE_NORMAL: return "mapping_normal"; } - return NULL; + return nullptr; } static int gpu_shader_mapping(GPUMaterial *mat, @@ -72,14 +74,18 @@ static void node_shader_update_mapping(bNodeTree *ntree, bNode *node) ntree, sock, ELEM(node->custom1, NODE_MAPPING_TYPE_POINT, NODE_MAPPING_TYPE_TEXTURE)); } -void register_node_type_sh_mapping(void) +} // namespace blender::nodes::node_shader_mapping_cc + +void register_node_type_sh_mapping() { + namespace file_ns = blender::nodes::node_shader_mapping_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, 0); - node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out); - node_type_gpu(&ntype, gpu_shader_mapping); - node_type_update(&ntype, node_shader_update_mapping); + node_type_socket_templates(&ntype, file_ns::sh_node_mapping_in, file_ns::sh_node_mapping_out); + node_type_gpu(&ntype, file_ns::gpu_shader_mapping); + node_type_update(&ntype, file_ns::node_shader_update_mapping); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.cc index 83d5abcba67..d448ca79501 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.cc @@ -23,6 +23,8 @@ #include "node_shader_util.h" +namespace blender::nodes::node_shader_normal_cc { + /* **************** NORMAL ******************** */ static bNodeSocketTemplate sh_node_normal_in[] = { {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION}, @@ -64,14 +66,18 @@ static int gpu_shader_normal(GPUMaterial *mat, return GPU_stack_link(mat, node, "normal_new_shading", in, out, vec); } -void register_node_type_sh_normal(void) +} // namespace blender::nodes::node_shader_normal_cc + +void register_node_type_sh_normal() { + namespace file_ns = blender::nodes::node_shader_normal_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0); - node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal); - node_type_gpu(&ntype, gpu_shader_normal); + node_type_socket_templates(&ntype, file_ns::sh_node_normal_in, file_ns::sh_node_normal_out); + node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_normal); + node_type_gpu(&ntype, file_ns::gpu_shader_normal); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc index 493acb06963..0899d08f4e1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc @@ -19,6 +19,8 @@ #include "../node_shader_util.h" +namespace blender::nodes::node_shader_normal_map_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_normal_map_in[] = { @@ -34,7 +36,7 @@ static bNodeSocketTemplate sh_node_normal_map_out[] = { static void node_shader_init_normal_map(bNodeTree *UNUSED(ntree), bNode *node) { - NodeShaderNormalMap *attr = MEM_callocN(sizeof(NodeShaderNormalMap), "NodeShaderNormalMap"); + NodeShaderNormalMap *attr = MEM_cnew<NodeShaderNormalMap>("NodeShaderNormalMap"); node->storage = attr; } @@ -53,15 +55,16 @@ static int gpu_shader_normal_map(GPUMaterial *mat, GPUNodeStack *in, GPUNodeStack *out) { - NodeShaderNormalMap *nm = node->storage; + NodeShaderNormalMap *nm = static_cast<NodeShaderNormalMap *>(node->storage); GPUNodeLink *strength; if (in[0].link) { strength = in[0].link; } else if (node->original) { - bNodeSocket *socket = BLI_findlink(&node->original->inputs, 0); - bNodeSocketValueFloat *socket_data = socket->default_value; + bNodeSocket *socket = static_cast<bNodeSocket *>(BLI_findlink(&node->original->inputs, 0)); + bNodeSocketValueFloat *socket_data = static_cast<bNodeSocketValueFloat *>( + socket->default_value); strength = GPU_uniform(&socket_data->value); } else { @@ -73,8 +76,8 @@ static int gpu_shader_normal_map(GPUMaterial *mat, newnormal = in[1].link; } else if (node->original) { - bNodeSocket *socket = BLI_findlink(&node->original->inputs, 1); - bNodeSocketValueRGBA *socket_data = socket->default_value; + bNodeSocket *socket = static_cast<bNodeSocket *>(BLI_findlink(&node->original->inputs, 1)); + bNodeSocketValueRGBA *socket_data = static_cast<bNodeSocketValueRGBA *>(socket->default_value); newnormal = GPU_uniform(socket_data->value); } else { @@ -114,19 +117,24 @@ static int gpu_shader_normal_map(GPUMaterial *mat, return true; } +} // namespace blender::nodes::node_shader_normal_map_cc + /* node type definition */ -void register_node_type_sh_normal_map(void) +void register_node_type_sh_normal_map() { + namespace file_ns = blender::nodes::node_shader_normal_map_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR, 0); - node_type_socket_templates(&ntype, sh_node_normal_map_in, sh_node_normal_map_out); + node_type_socket_templates( + &ntype, file_ns::sh_node_normal_map_in, file_ns::sh_node_normal_map_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, node_shader_init_normal_map); + node_type_init(&ntype, file_ns::node_shader_init_normal_map); node_type_storage( &ntype, "NodeShaderNormalMap", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, gpu_shader_normal_map); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal_map); + node_type_gpu(&ntype, file_ns::gpu_shader_normal_map); + node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_normal_map); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.cc index 47040954c9e..a95a955789c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_object_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_object_info.cc @@ -19,6 +19,8 @@ #include "../node_shader_util.h" +namespace blender::nodes::node_shader_object_info_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_object_info_out[] = { @@ -49,13 +51,17 @@ static int node_shader_gpu_object_info(GPUMaterial *mat, GPU_constant(&index)); } -void register_node_type_sh_object_info(void) +} // namespace blender::nodes::node_shader_object_info_cc + +void register_node_type_sh_object_info() { + namespace file_ns = blender::nodes::node_shader_object_info_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OBJECT_INFO, "Object Info", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, NULL, sh_node_object_info_out); - node_type_gpu(&ntype, node_shader_gpu_object_info); + node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_object_info_out); + node_type_gpu(&ntype, file_ns::node_shader_gpu_object_info); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_aov.c b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc index 32765b459ca..3b551401b49 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_aov.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc @@ -21,6 +21,8 @@ #include "BLI_hash.h" +namespace blender::nodes::node_shader_output_aov_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_output_aov_in[] = { @@ -31,7 +33,7 @@ static bNodeSocketTemplate sh_node_output_aov_in[] = { static void node_shader_init_output_aov(bNodeTree *UNUSED(ntree), bNode *node) { - NodeShaderOutputAOV *aov = MEM_callocN(sizeof(NodeShaderOutputAOV), "NodeShaderOutputAOV"); + NodeShaderOutputAOV *aov = MEM_cnew<NodeShaderOutputAOV>("NodeShaderOutputAOV"); node->storage = aov; } @@ -52,17 +54,21 @@ static int node_shader_gpu_output_aov(GPUMaterial *mat, return true; } +} // namespace blender::nodes::node_shader_output_aov_cc + /* node type definition */ -void register_node_type_sh_output_aov(void) +void register_node_type_sh_output_aov() { + namespace file_ns = blender::nodes::node_shader_output_aov_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_AOV, "AOV Output", NODE_CLASS_OUTPUT, 0); - node_type_socket_templates(&ntype, sh_node_output_aov_in, NULL); - node_type_init(&ntype, node_shader_init_output_aov); + node_type_socket_templates(&ntype, file_ns::sh_node_output_aov_in, nullptr); + node_type_init(&ntype, file_ns::node_shader_init_output_aov); node_type_storage( &ntype, "NodeShaderOutputAOV", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, node_shader_gpu_output_aov); + node_type_gpu(&ntype, file_ns::node_shader_gpu_output_aov); ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_output_light.c b/source/blender/nodes/shader/nodes/node_shader_output_light.cc index a78e02678ea..07ed21a8404 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_light.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_light.cc @@ -19,6 +19,8 @@ #include "../node_shader_util.h" +namespace blender::nodes::node_shader_output_light_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_output_light_in[] = { @@ -26,13 +28,17 @@ static bNodeSocketTemplate sh_node_output_light_in[] = { {-1, ""}, }; +} // namespace blender::nodes::node_shader_output_light_cc + /* node type definition */ -void register_node_type_sh_output_light(void) +void register_node_type_sh_output_light() { + namespace file_ns = blender::nodes::node_shader_output_light_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_LIGHT, "Light Output", NODE_CLASS_OUTPUT, 0); - node_type_socket_templates(&ntype, sh_node_output_light_in, NULL); + node_type_socket_templates(&ntype, file_ns::sh_node_output_light_in, nullptr); ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc index a970b13baba..2051bb6ded0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc @@ -19,6 +19,8 @@ #include "../node_shader_util.h" +namespace blender::nodes::node_shader_output_linestyle_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_output_linestyle_in[] = { @@ -29,13 +31,17 @@ static bNodeSocketTemplate sh_node_output_linestyle_in[] = { {-1, ""}, }; +} // namespace blender::nodes::node_shader_output_linestyle_cc + /* node type definition */ -void register_node_type_sh_output_linestyle(void) +void register_node_type_sh_output_linestyle() { + namespace file_ns = blender::nodes::node_shader_output_linestyle_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_LINESTYLE, "Line Style Output", NODE_CLASS_OUTPUT, 0); - node_type_socket_templates(&ntype, sh_node_output_linestyle_in, NULL); + node_type_socket_templates(&ntype, file_ns::sh_node_output_linestyle_in, nullptr); ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.cc index 129f53f99d3..308435576c1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.cc @@ -21,6 +21,8 @@ #include "BKE_scene.h" +namespace blender::nodes::node_shader_output_material_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_output_material_in[] = { @@ -73,14 +75,18 @@ static int node_shader_gpu_output_material(GPUMaterial *mat, return true; } +} // namespace blender::nodes::node_shader_output_material_cc + /* node type definition */ -void register_node_type_sh_output_material(void) +void register_node_type_sh_output_material() { + namespace file_ns = blender::nodes::node_shader_output_material_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_MATERIAL, "Material Output", NODE_CLASS_OUTPUT, 0); - node_type_socket_templates(&ntype, sh_node_output_material_in, NULL); - node_type_gpu(&ntype, node_shader_gpu_output_material); + node_type_socket_templates(&ntype, file_ns::sh_node_output_material_in, nullptr); + node_type_gpu(&ntype, file_ns::node_shader_gpu_output_material); ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.cc index 4d62ec5ec87..add277c2650 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_world.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_world.cc @@ -19,6 +19,8 @@ #include "../node_shader_util.h" +namespace blender::nodes::node_shader_output_world_cc { + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_output_world_in[] = { @@ -41,14 +43,18 @@ static int node_shader_gpu_output_world(GPUMaterial *mat, return true; } +} // namespace blender::nodes::node_shader_output_world_cc + /* node type definition */ -void register_node_type_sh_output_world(void) +void register_node_type_sh_output_world() { + namespace file_ns = blender::nodes::node_shader_output_world_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_WORLD, "World Output", NODE_CLASS_OUTPUT, 0); - node_type_socket_templates(&ntype, sh_node_output_world_in, NULL); - node_type_gpu(&ntype, node_shader_gpu_output_world); + node_type_socket_templates(&ntype, file_ns::sh_node_output_world_in, nullptr); + node_type_gpu(&ntype, file_ns::node_shader_gpu_output_world); ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc index c6eabc3b2cb..8a054b19c71 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc @@ -18,8 +18,11 @@ */ #include "../node_shader_util.h" + #include "RE_texture.h" +namespace blender::nodes::node_shader_particle_info_cc { + static bNodeSocketTemplate outputs[] = { {SOCK_FLOAT, "Index"}, {SOCK_FLOAT, "Random"}, @@ -61,15 +64,19 @@ static int gpu_shader_particle_info(GPUMaterial *mat, GPU_builtin(GPU_PARTICLE_ANG_VELOCITY)); } +} // namespace blender::nodes::node_shader_particle_info_cc + /* node type definition */ -void register_node_type_sh_particle_info(void) +void register_node_type_sh_particle_info() { + namespace file_ns = blender::nodes::node_shader_particle_info_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, NULL, outputs); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_particle_info); - node_type_gpu(&ntype, gpu_shader_particle_info); + node_type_socket_templates(&ntype, nullptr, file_ns::outputs); + node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_particle_info); + node_type_gpu(&ntype, file_ns::gpu_shader_particle_info); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.cc index 0bdef9a2a17..e07b8dd4f1d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_rgb.cc @@ -23,6 +23,8 @@ #include "node_shader_util.h" +namespace blender::nodes::node_shader_rgb_cc { + /* **************** RGB ******************** */ static bNodeSocketTemplate sh_node_rgb_out[] = { {SOCK_RGBA, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f}, @@ -39,13 +41,17 @@ static int gpu_shader_rgb(GPUMaterial *mat, return GPU_stack_link(mat, node, "set_rgba", in, out, link); } -void register_node_type_sh_rgb(void) +} // namespace blender::nodes::node_shader_rgb_cc + +void register_node_type_sh_rgb() { + namespace file_ns = blender::nodes::node_shader_rgb_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_RGB, "RGB", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, NULL, sh_node_rgb_out); - node_type_gpu(&ntype, gpu_shader_rgb); + node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_rgb_out); + node_type_gpu(&ntype, file_ns::gpu_shader_rgb); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.cc index 42ab272de0e..52e855b5fe5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_script.c +++ b/source/blender/nodes/shader/nodes/node_shader_script.cc @@ -23,17 +23,19 @@ #include "node_shader_util.h" +namespace blender::nodes::node_shader_script_cc { + /* **************** Script ******************** */ static void init(bNodeTree *UNUSED(ntree), bNode *node) { - NodeShaderScript *nss = MEM_callocN(sizeof(NodeShaderScript), "shader script node"); + NodeShaderScript *nss = MEM_cnew<NodeShaderScript>("shader script node"); node->storage = nss; } static void node_free_script(bNode *node) { - NodeShaderScript *nss = node->storage; + NodeShaderScript *nss = static_cast<NodeShaderScript *>(node->storage); if (nss) { if (nss->bytecode) { @@ -48,23 +50,28 @@ static void node_copy_script(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node) { - NodeShaderScript *src_nss = src_node->storage; - NodeShaderScript *dest_nss = MEM_dupallocN(src_nss); + NodeShaderScript *src_nss = static_cast<NodeShaderScript *>(src_node->storage); + NodeShaderScript *dest_nss = static_cast<NodeShaderScript *>(MEM_dupallocN(src_nss)); if (src_nss->bytecode) { - dest_nss->bytecode = MEM_dupallocN(src_nss->bytecode); + dest_nss->bytecode = static_cast<char *>(MEM_dupallocN(src_nss->bytecode)); } dest_node->storage = dest_nss; } -void register_node_type_sh_script(void) +} // namespace blender::nodes::node_shader_script_cc + +void register_node_type_sh_script() { + namespace file_ns = blender::nodes::node_shader_script_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SCRIPT, "Script", NODE_CLASS_SCRIPT, 0); - node_type_init(&ntype, init); - node_type_storage(&ntype, "NodeShaderScript", node_free_script, node_copy_script); + node_type_init(&ntype, file_ns::init); + node_type_storage( + &ntype, "NodeShaderScript", file_ns::node_free_script, file_ns::node_copy_script); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.c b/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc index dfecb830b35..485c2ede9fe 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc @@ -23,6 +23,8 @@ #include "node_shader_util.h" +namespace blender::nodes::node_shader_sepcomb_hsv_cc { + /* **************** SEPARATE HSV ******************** */ static bNodeSocketTemplate sh_node_sephsv_in[] = { {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f}, @@ -57,18 +59,24 @@ static int gpu_shader_sephsv(GPUMaterial *mat, return GPU_stack_link(mat, node, "separate_hsv", in, out); } -void register_node_type_sh_sephsv(void) +} // namespace blender::nodes::node_shader_sepcomb_hsv_cc + +void register_node_type_sh_sephsv() { + namespace file_ns = blender::nodes::node_shader_sepcomb_hsv_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTER, 0); - node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv); - node_type_gpu(&ntype, gpu_shader_sephsv); + node_type_socket_templates(&ntype, file_ns::sh_node_sephsv_in, file_ns::sh_node_sephsv_out); + node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_sephsv); + node_type_gpu(&ntype, file_ns::gpu_shader_sephsv); nodeRegisterType(&ntype); } +namespace blender::nodes::node_shader_sepcomb_hsv_cc { + /* **************** COMBINE HSV ******************** */ static bNodeSocketTemplate sh_node_combhsv_in[] = { {SOCK_FLOAT, N_("H"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, @@ -105,14 +113,18 @@ static int gpu_shader_combhsv(GPUMaterial *mat, return GPU_stack_link(mat, node, "combine_hsv", in, out); } -void register_node_type_sh_combhsv(void) +} // namespace blender::nodes::node_shader_sepcomb_hsv_cc + +void register_node_type_sh_combhsv() { + namespace file_ns = blender::nodes::node_shader_sepcomb_hsv_cc; + static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTER, 0); - node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv); - node_type_gpu(&ntype, gpu_shader_combhsv); + node_type_socket_templates(&ntype, file_ns::sh_node_combhsv_in, file_ns::sh_node_combhsv_out); + node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_combhsv); + node_type_gpu(&ntype, file_ns::gpu_shader_combhsv); nodeRegisterType(&ntype); } |