Commit: 1df8abff257030ba79bc23dc321f35494f4d91c5 Author: Jacques Lucke Date: Tue Nov 23 14:56:01 2021 +0100 Branches: master https://developer.blender.org/rB1df8abff257030ba79bc23dc321f35494f4d91c5
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 =================================================================== M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_clamp.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_color_ramp.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_combine_xyz.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_convert.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_curve_map.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_fill.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_map_range.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_math.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_mix.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_proximity.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_randomize.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_sample_texture.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_separate_xyz.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_vector_math.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_vector_rotate.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_endpoints.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_reverse.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_select_by_handle_type.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_set_handles.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_spline_type.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_subdivide.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_to_points.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_delete_geometry.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_edge_split.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_material_assign.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_mesh_to_curve.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_instance.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_rotate.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_scale.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_separate.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_translate.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_points_to_volume.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_raycast.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_select_by_material.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_subdivision_surface.cc M source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_volume_to_mesh.cc M source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc M source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc M source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc M source/blender/nodes/geometry/nodes/node_geo_boolean.cc M source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc M source/blender/nodes/geometry/nodes/node_geo_collection_info.cc M source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc M source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc M source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc M source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc M source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc M source/blender/nodes/geometry/nodes/node_geo_curve_length.cc M source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc M source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc M source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc M source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc M source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc M source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc M source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc M source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc M source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc M source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc M source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc M source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc M source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc M source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc M source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc M source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc M source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc M source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc M source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc M source/blender/nodes/geometry/nodes/node_geo_edge_split.cc M source/blender/nodes/geometry/nodes/node_geo_image_texture.cc M source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc M source/blender/nodes/geometry/nodes/node_geo_input_curve_tilt.cc M source/blender/nodes/geometry/nodes/node_geo_input_id.cc M source/blender/nodes/geometry/nodes/node_geo_input_index.cc M source/blender/nodes/geometry/nodes/node_geo_input_material.cc M source/blender/nodes/geometry/nodes/node_geo_input_material_index.cc M source/blender/nodes/geometry/nodes/node_geo_input_normal.cc M source/blender/nodes/geometry/nodes/node_geo_input_position.cc M source/blender/nodes/geometry/nodes/node_geo_input_radius.cc M source/blender/nodes/geometry/nodes/node_geo_input_shade_smooth.cc M source/blender/nodes/geometry/nodes/node_geo_input_spline_cyclic.cc M source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc M source/blender/nodes/geometry/nodes/node_geo_input_spline_resolution.cc M source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc M source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc M source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc M source/blender/nodes/geometry/nodes/node_geo_is_viewport.cc M source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc M source/blender/nodes/geometry/nodes/node_geo_material_replace.cc M source/blender/nodes/geometry/nodes/node_geo_material_selection.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc M source/blender/nodes/geometry/nodes/node_geo_object_info.cc M source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc M source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc M source/blender/nodes/geometry/nodes/node_geo_proximity.cc M source/blender/nodes/geometry/nodes/node_geo_raycast.cc M source/blender/nodes/geometry/nodes/node_geo_realize_instances.cc M source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc M source/blender/nodes/geometry/nodes/node_geo_scale_instances.cc M source/blender/nodes/geometry/nodes/node_geo_separate_components.cc M source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc M source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc M source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc M source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc M source/blender/nodes/geometry/nodes/node_geo_set_id.cc M source/blender/nodes/geometry/nodes/node_geo_set_material.cc M source/blender/nodes/geometry/nodes/node_geo_set_material_index.cc M source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc M source/blender/nodes/geometry/nodes/node_geo_set_position.cc M source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc M source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc M source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc M source/blender/nodes/geometry/nodes/node_geo_string_join.cc M source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc M source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc M source/blender/nodes/geometry/nodes/node_geo_switch.cc M source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc M source/blender/nodes/geometry/nodes/node_geo_transform.cc M source/blender/nodes/geometry/nodes/node_geo_translate_instances.cc M source/blender/nodes/geometry/nodes/node_geo_triangulate.cc M source/blender/nodes/geometry/nodes/node_geo_viewer.cc M source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc =================================================================== diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc index dc7c251d034..c99db5b1f3f 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc @@ -22,7 +22,7 @@ #include "node_geometry_util.hh" -namespace blender::nodes { +namespace blender::nodes::node_geo_legacy_align_rotation_to_vector_cc { static void geo_node_align_rotation_to_vector_declare(NodeDeclarationBuilder &b) { @@ -219,10 +219,12 @@ static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params) params.set_output("Geometry", geometry_set); } -} // namespace blender::nodes +} // namespace blender::nodes::node_geo_legacy_align_rotation_to_vector_cc void register_node_type_geo_align_rotation_to_vector() { + namespace file_ns = blender::nodes::node_geo_legacy_align_rotation_to_vector_cc; + static bNodeType ntype; geo_node_type_base(&ntype, @@ -230,14 +232,14 @@ void register_node_type_geo_align_rotation_to_vector() "Align Rotation to Vector", NODE_CLASS_GEOMETRY, 0); - node_type_init(&ntype, blender::nodes::geo_node_align_rotation_to_vector_init); - node_type_update(&ntype, blender::nodes::geo_node_align_rotation_to_vector_update); + node_type_init(&ntype, file_ns::geo_node_align_rotation_to_vector_init); + node_type_update(&ntype, file_ns::geo_node_align_rotation_to_vector_update); node_type_storage(&ntype, "NodeGeometryAlignRotationToVector", node_free_standard_storage, node_copy_standard_storage); - ntype.declare = blender::nodes::geo_node_align_rotation_to_vector_declare; - ntype.geometry_node_execute = blender::nodes::geo_node_align_rotation_to_vector_exec; - ntype.draw_buttons = blender::nodes::geo_node_align_rotation_to_vector_layout; + ntype.declare = file_ns::geo_node_align_rotation_to_vector_declare; + ntype.geometry_node_execute = file_ns::geo_node_align_rotation_to_vector_exec; + ntype.draw_buttons = file_ns::geo_node_align_rotation_to_vector_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_clamp.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_clamp.cc index a11a1bd3825..96ca3b6739e 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_clamp.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_clamp.cc @@ -20,7 +20,7 @@ #include "node_geometry_util.hh" -namespace blender::nodes { +namespace blender::nodes::node_geo_legacy_attribute_clamp_cc { static void geo_node_attribute_clamp_declare(NodeDeclarationBuilder &b) { @@ -262,19 +262,21 @@ static void geo_node_attribute_clamp_exec(GeoNodeExecParams params) params.set_output("Geometry", geometry_set); } -} // namespace blender::nodes +} // namespace blender::nodes::node_geo_legacy_attribute_clamp_cc void register_node_type_geo_attribute_clamp() { + namespace file_ns = blender::nodes::node_geo_legacy_attribute_clamp_cc; + static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_LEGACY_ATTRIBUTE_CLAMP, "Attribute Clamp", NODE_CLASS_ATTRIBUTE, 0); - node_type_init(&ntype, blender::nodes::geo_node_attribute_clamp_init); - node_type_update(&ntype, blender::nodes::geo_node_attribute_clamp_update); - ntype.declare = blender::nodes::geo_node_attribute_clamp_declare; - ntype.geometry_node_execute = blender::nodes::geo_node_attribute_clamp_exec; - ntype.draw_buttons = blender::nodes::geo_node_attribute_clamp_layout; + node_type_init(&ntype, file_ns::geo_node_attribute_clamp_init); + node_type_update(&ntype, file_ns::geo_node_attribute_clamp_update); + ntype.declare = file_ns::geo_node_attribute_clamp_declare; + ntype.geometry_node_execute = file_ns::geo_node_attribute_clamp_exec; + ntype.draw_buttons = file_ns::geo_node_attribute_clamp_layout; node_type_storage( &ntype, "NodeAttributeClamp", node_free_standard_storage, node_copy_standard_storage); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_color_ramp.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_color_ramp.cc index 061f5f3d7ee..a1ce2f6b005 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_color_ramp.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_color_ramp.cc @@ -23,7 +23,7 @@ #include "node_geometry_util.hh" -namespace blender::nodes { +namespace blender::nodes::node_geo_legacy_attributes_color_ramp_cc { static void geo_node_attribute_color_ramp_declare(NodeDeclarationBuilder &b) { @@ -119,10 +119,12 @@ static void geo_node_attribute_color_ramp_exec(GeoNodeExecParams params) params.set_output("Geometry", std::move(geometry_set)); } -} // namespace blender::nodes +} // namespace blender::nodes::node_geo_legacy_attributes_color_ramp_cc void register_node_type_geo_attribute_color_ramp() { + namespace file_ns = blender::nodes::node_geo_legacy_attributes_color_ramp_cc; + static bNodeType ntype; geo_node_type_base(&ntype, @@ -132,10 +134,10 @@ void register_node_type_geo_attribute_color_ramp() 0); node_type_storage( &ntype, "NodeAttributeColorRamp", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, blender::nodes::geo_node_attribute_color_ramp_init); + node_type_init(&ntype, file_ns::geo_node_attribute_color_ramp_init); node_type_size_preset(&ntype, NODE_SIZE_LARGE); - ntype.declare = blender::nodes::geo_node_attribute_color_ramp_declare; - ntype.geometry_node_execute = blender::nodes::geo_node_attribute_color_ramp_exec; - ntype.draw_buttons = blender::nodes::geo_node_attribute_color_ramp_layout; + ntype.declare = file_ns::geo_node_attribute_color_ramp_declare; + ntype.geometry_node_execute = file_ns::geo_node_attribute_color_ramp_exec; + ntype.draw_buttons = file_ns::geo_node_attribute_color_ramp_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_combine_xyz.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_combine_xyz.cc index a610356955b..31721bf7c6a 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_combine_xyz.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_combine_xyz.cc @@ -19,7 +19,7 @@ #include "node_geometry_util.hh" -namespace blender::nodes { +namespace blender::nodes::node_geo_legacy_attribute_combine_xyz_cc { static void geo_node_attribute_combine_xyz_declare(NodeDeclarationBuilder &b) { @@ -130,10 +130,12 @@ static void geo_node_attribute_combine_xyz_exec(GeoNodeExecParams params) params.set_output("Geometry", geometry_set); } -} // namespace blender::nodes +} // namespace blender::nodes::node_geo_legacy_attribute_combine_xyz_cc void register_node_type_geo_attribute_combine_xyz() { + namespace file_ns = blender::nodes::node_geo_legacy_attribute_combine_xyz_cc; + static bNodeType ntype; geo_node_type_base(&ntype, @@ -141,13 +143,13 @@ void register_node_type_geo_attribute_combine_xyz() "Attribute Combine XYZ", NODE_CLASS_ATTRIBUTE, 0); - node_type_init(&ntype, blender::nodes::geo_node_attribute_combine_xyz_init); - node_type_update(&ntype, blender::nodes::geo_node_attribute_combine_xyz_update); + node_type_init(&ntype, file_ns::geo_node_attribute_combine_xyz_init); + node_type_update(&ntype, file_ns::geo_node_attribute_combine_xyz_update); node_type_storage( &ntype, "NodeAttributeCombineXYZ", node_free_standard_storage, node_copy_standard_storage); - ntype.declare = blender::nodes::geo_node_attribute_combine_xyz_declare; - ntype.geometry_node_execute = blender::nodes::geo_node_attribute_combine_xyz_exec; - ntype.draw_buttons = blender::nodes::geo_node_attribute_combine_xyz_layout; + ntype.declare = file_ns::geo_node_attribute_combine_xyz_declare; + ntype.geometry_node_execute = file_ns::geo_node_attribute_combine_xyz_exec; + ntype.draw_buttons = file_ns::geo_node_attribute_combine_xyz_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc index a4ffe884999..94c0652819b 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_compare.cc @@ -21,7 +21,7 @@ #include "node_geometry_util.hh" -namespace blender::nodes { +namespace blender::nodes::node_geo_legacy_attribute_compare_cc { static void geo_node_attribute_compare_declare(NodeDeclarationBuilder &b) { @@ -341,20 +341,22 @@ static void geo_node_attribute_compare_exec(GeoNodeExecParams params) params.set_output("Geometry", geometry_set); } -} // namespace blender::nodes +} // namespace blender::nodes::node_geo_legacy_attribute_compare_cc void register_node_type_geo_attribute_compare() { + namespace file_ns = blender::nodes::node_geo_legacy_attribute_compare_cc; + static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_LEGACY_ATTRIBUTE_COMPARE, "Attribute Compare", NODE_CLASS_ATTRIBUTE, 0); - ntype.declare = blender::nodes::geo_node_attribute_compare_declare; - ntype.geometry_node_execute = blender::nodes::geo_node_attribute_compare_exec; - ntype.draw_buttons = blender::nodes::geo_node_attribute_compare_layout; - node_type_update(&ntype, blender::nodes::geo_node_attribute_compare_update); + ntype.declare = file_ns::geo_node_attribute_compare_declare; + ntype.geometry_node_execute = file_ns::geo_node_attribute_compare_exec; + ntype.draw_buttons = file_ns::geo_node_attribute_compare_layout; + node_type_update(&ntype, file_ns::geo_node @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
