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:
authorJacques Lucke <jacques@blender.org>2021-11-23 16:56:01 +0300
committerJacques Lucke <jacques@blender.org>2021-11-23 16:56:01 +0300
commit1df8abff257030ba79bc23dc321f35494f4d91c5 (patch)
tree64f10b5d525e819fa4f52a6d7e3edc83cf42079a /source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
parent47276b84701727c2f187c77f1ec502b4ca4963bd (diff)
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
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc62
1 files changed, 34 insertions, 28 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
index b5903f7b71e..1079cc48040 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
@@ -24,31 +24,6 @@
namespace blender::nodes {
-static void geo_node_mesh_primitive_cube_declare(NodeDeclarationBuilder &b)
-{
- b.add_input<decl::Vector>(N_("Size"))
- .default_value(float3(1))
- .min(0.0f)
- .subtype(PROP_TRANSLATION)
- .description(N_("Side length along each axis"));
- b.add_input<decl::Int>(N_("Vertices X"))
- .default_value(2)
- .min(2)
- .max(1000)
- .description(N_("Number of vertices for the X side of the shape"));
- b.add_input<decl::Int>(N_("Vertices Y"))
- .default_value(2)
- .min(2)
- .max(1000)
- .description(N_("Number of vertices for the Y side of the shape"));
- b.add_input<decl::Int>(N_("Vertices Z"))
- .default_value(2)
- .min(2)
- .max(1000)
- .description(N_("Number of vertices for the Z side of the shape"));
- b.add_output<decl::Geometry>(N_("Mesh"));
-}
-
struct CuboidConfig {
float3 size;
int verts_x;
@@ -439,6 +414,35 @@ Mesh *create_cuboid_mesh(const float3 size,
return mesh;
}
+} // namespace blender::nodes
+
+namespace blender::nodes::node_geo_mesh_primitive_cube_cc {
+
+static void geo_node_mesh_primitive_cube_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Vector>(N_("Size"))
+ .default_value(float3(1))
+ .min(0.0f)
+ .subtype(PROP_TRANSLATION)
+ .description(N_("Side length along each axis"));
+ b.add_input<decl::Int>(N_("Vertices X"))
+ .default_value(2)
+ .min(2)
+ .max(1000)
+ .description(N_("Number of vertices for the X side of the shape"));
+ b.add_input<decl::Int>(N_("Vertices Y"))
+ .default_value(2)
+ .min(2)
+ .max(1000)
+ .description(N_("Number of vertices for the Y side of the shape"));
+ b.add_input<decl::Int>(N_("Vertices Z"))
+ .default_value(2)
+ .min(2)
+ .max(1000)
+ .description(N_("Number of vertices for the Z side of the shape"));
+ b.add_output<decl::Geometry>(N_("Mesh"));
+}
+
static Mesh *create_cube_mesh(const float3 size,
const int verts_x,
const int verts_y,
@@ -501,14 +505,16 @@ static void geo_node_mesh_primitive_cube_exec(GeoNodeExecParams params)
params.set_output("Mesh", GeometrySet::create_with_mesh(mesh));
}
-} // namespace blender::nodes
+} // namespace blender::nodes::node_geo_mesh_primitive_cube_cc
void register_node_type_geo_mesh_primitive_cube()
{
+ namespace file_ns = blender::nodes::node_geo_mesh_primitive_cube_cc;
+
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_CUBE, "Cube", NODE_CLASS_GEOMETRY, 0);
- ntype.declare = blender::nodes::geo_node_mesh_primitive_cube_declare;
- ntype.geometry_node_execute = blender::nodes::geo_node_mesh_primitive_cube_exec;
+ ntype.declare = file_ns::geo_node_mesh_primitive_cube_declare;
+ ntype.geometry_node_execute = file_ns::geo_node_mesh_primitive_cube_exec;
nodeRegisterType(&ntype);
}