Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Carlisle <Blendify>2021-12-06 01:46:45 +0300
committerAaron Carlisle <carlisle.b3d@gmail.com>2021-12-06 01:47:33 +0300
commit3f7014ecc9d523997062eadd62888af5fc70a2b6 (patch)
treed084b014e9b116d2ab579f54c332dd49c311828c /source/blender/nodes/shader/nodes/node_shader_normal_map.cc
parent0a8a22fc04d3475d2c5f41f2e022c8e28d099520 (diff)
Shader Nodes: Declare nodes in their own namespace
Follow up on rB1df8abff257030ba79bc23dc321f35494f4d91c5 This puts all static functions in geometry node files into a new namespace. This allows using unity build which can improve compile times significantly - The namespace name is derived from the file name. That makes it possible to write some tooling that checks the names later on. The filename extension (cc) is added to the namespace name as well. This also possibly simplifies tooling but also makes it more obvious that this namespace is specific to a file. - In the register function of every node, I added a namespace alias namespace `file_ns = blender::nodes::node_shader_*_cc`;. This avoids some duplication of the file name and may also simplify tooling, because this line is easy to detect. The name `file_ns` stands for "file namespace" and also indicates that this namespace corresponds to the current file. In the future some nodes will be split up to separate files and given their own namespace This will allow function names to be simplified similar to rBfab39440e94 Reviewed By: HooglyBoogly Differential Revision: https://developer.blender.org/D13480
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_normal_map.cc')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc
index 09ff6d716ab..ec77fcfeefe 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc
@@ -21,6 +21,8 @@
/* **************** OUTPUT ******************** */
+namespace blender::nodes::node_shader_normal_map_cc {
+
static bNodeSocketTemplate sh_node_normal_map_in[] = {
{SOCK_FLOAT, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
{SOCK_RGBA, N_("Color"), 0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f},
@@ -115,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()
{
+ 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, nullptr, nullptr, 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);
}