From 1df8abff257030ba79bc23dc321f35494f4d91c5 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 23 Nov 2021 14:56:01 +0100 Subject: Geometry Nodes: add namespace for every file This puts all static functions in geometry node files into a new namespace. This allows using unity build which can improve compile times significantly (P2578). * The name space name is derived from the file name. That makes it possible to write some tooling that checks the names later on. The file name 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_geo_*_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 beginning I used `node_ns` but `file_ns` is more generic which may make it more suitable when we want to use unity builds outside of the nodes modules in the future. * Some node files contain code that is actually shared between different nodes. For now I left that code in the `blender::nodes` namespace and moved it to the top of the file (couldn't move it to the bottom in all cases, so I just moved it to the top everywhere). As a separate cleanup step, this shared code should actually be moved to a separate file. Differential Revision: https://developer.blender.org/D13330 --- source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc') diff --git a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc index e7c9715934a..6a40fe5c25c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc @@ -16,7 +16,7 @@ #include "node_geometry_util.hh" -namespace blender::nodes { +namespace blender::nodes::node_geo_bounding_box_cc { static void geo_node_bounding_box_declare(NodeDeclarationBuilder &b) { @@ -78,14 +78,16 @@ static void geo_node_bounding_box_exec(GeoNodeExecParams params) } } -} // namespace blender::nodes +} // namespace blender::nodes::node_geo_bounding_box_cc void register_node_type_geo_bounding_box() { + namespace file_ns = blender::nodes::node_geo_bounding_box_cc; + static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_BOUNDING_BOX, "Bounding Box", NODE_CLASS_GEOMETRY, 0); - ntype.declare = blender::nodes::geo_node_bounding_box_declare; - ntype.geometry_node_execute = blender::nodes::geo_node_bounding_box_exec; + ntype.declare = file_ns::geo_node_bounding_box_declare; + ntype.geometry_node_execute = file_ns::geo_node_bounding_box_exec; nodeRegisterType(&ntype); } -- cgit v1.2.3 From fab39440e94d94b0a6ea8ef7771312adbab98e66 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 23 Nov 2021 10:55:51 -0500 Subject: Cleanup: Simplify geometry node function names With this commit, we no longer use the prefixes for every node type function like `geo_node_translate_instances_`. They just added more places to change when adding a new node, for no real benefit. Differential Revision: https://developer.blender.org/D13337 --- source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc') diff --git a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc index 6a40fe5c25c..da1f9a00c69 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc @@ -18,7 +18,7 @@ namespace blender::nodes::node_geo_bounding_box_cc { -static void geo_node_bounding_box_declare(NodeDeclarationBuilder &b) +static void node_declare(NodeDeclarationBuilder &b) { b.add_input(N_("Geometry")); b.add_output(N_("Bounding Box")); @@ -26,7 +26,7 @@ static void geo_node_bounding_box_declare(NodeDeclarationBuilder &b) b.add_output(N_("Max")); } -static void geo_node_bounding_box_exec(GeoNodeExecParams params) +static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); @@ -87,7 +87,7 @@ void register_node_type_geo_bounding_box() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_BOUNDING_BOX, "Bounding Box", NODE_CLASS_GEOMETRY, 0); - ntype.declare = file_ns::geo_node_bounding_box_declare; - ntype.geometry_node_execute = file_ns::geo_node_bounding_box_exec; + ntype.declare = file_ns::node_declare; + ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); } -- cgit v1.2.3