From d38b7286e95eb64a2eb620ef14ab62717123a5ff Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 4 Sep 2024 13:03:49 +0200 Subject: [PATCH] Cleanup: use StringRef instead of std::string in a few places --- source/blender/geometry/GEO_mesh_primitive_cuboid.hh | 3 ++- .../geometry/GEO_mesh_primitive_cylinder_cone.hh | 3 ++- source/blender/geometry/GEO_mesh_primitive_grid.hh | 8 +++----- .../blender/geometry/GEO_mesh_primitive_uv_sphere.hh | 7 ++----- .../blender/geometry/intern/mesh_primitive_cuboid.cc | 4 ++-- source/blender/geometry/intern/mesh_primitive_grid.cc | 2 +- .../geometry/intern/mesh_primitive_uv_sphere.cc | 2 +- .../nodes/geometry/nodes/node_geo_curve_to_points.cc | 10 +++++----- .../geometry/nodes/node_geo_interpolate_curves.cc | 8 ++++---- .../geometry/nodes/node_geo_mesh_primitive_cube.cc | 2 +- 10 files changed, 23 insertions(+), 26 deletions(-) diff --git a/source/blender/geometry/GEO_mesh_primitive_cuboid.hh b/source/blender/geometry/GEO_mesh_primitive_cuboid.hh index 688760dbc70..e37f8e963df 100644 --- a/source/blender/geometry/GEO_mesh_primitive_cuboid.hh +++ b/source/blender/geometry/GEO_mesh_primitive_cuboid.hh @@ -8,6 +8,7 @@ #include #include "BLI_math_vector_types.hh" +#include "BLI_string_ref.hh" struct Mesh; namespace blender { @@ -22,7 +23,7 @@ Mesh *create_cuboid_mesh(const float3 &size, int verts_x, int verts_y, int verts_z, - const std::optional &uv_id); + const std::optional &uv_id); Mesh *create_cuboid_mesh(const float3 &size, int verts_x, int verts_y, int verts_z); diff --git a/source/blender/geometry/GEO_mesh_primitive_cylinder_cone.hh b/source/blender/geometry/GEO_mesh_primitive_cylinder_cone.hh index 0a1d8bc5e2b..216bbabf6c7 100644 --- a/source/blender/geometry/GEO_mesh_primitive_cylinder_cone.hh +++ b/source/blender/geometry/GEO_mesh_primitive_cylinder_cone.hh @@ -4,7 +4,8 @@ #pragma once -#include "BKE_anonymous_attribute_id.hh" +#include +#include struct Mesh; diff --git a/source/blender/geometry/GEO_mesh_primitive_grid.hh b/source/blender/geometry/GEO_mesh_primitive_grid.hh index bf402ce2b6d..102f36e89d1 100644 --- a/source/blender/geometry/GEO_mesh_primitive_grid.hh +++ b/source/blender/geometry/GEO_mesh_primitive_grid.hh @@ -5,12 +5,10 @@ #pragma once #include -#include + +#include "BLI_string_ref.hh" struct Mesh; -namespace blender::bke { -class AttributeIDRef; -} // namespace blender::bke namespace blender::geometry { @@ -18,6 +16,6 @@ Mesh *create_grid_mesh(int verts_x, int verts_y, float size_x, float size_y, - const std::optional &uv_map_id); + const std::optional &uv_map_id); } // namespace blender::geometry diff --git a/source/blender/geometry/GEO_mesh_primitive_uv_sphere.hh b/source/blender/geometry/GEO_mesh_primitive_uv_sphere.hh index 492f60fb0e5..7431dd9efb0 100644 --- a/source/blender/geometry/GEO_mesh_primitive_uv_sphere.hh +++ b/source/blender/geometry/GEO_mesh_primitive_uv_sphere.hh @@ -5,15 +5,12 @@ #pragma once #include -#include #include "BLI_bounds_types.hh" #include "BLI_math_vector_types.hh" +#include "BLI_string_ref.hh" struct Mesh; -namespace blender::bke { -class AttributeIDRef; -} // namespace blender::bke namespace blender::geometry { @@ -29,6 +26,6 @@ Bounds calculate_bounds_radial_primitive(float radius_top, Mesh *create_uv_sphere_mesh(float radius, int segments, int rings, - const std::optional &uv_map_id); + const std::optional &uv_map_id); } // namespace blender::geometry diff --git a/source/blender/geometry/intern/mesh_primitive_cuboid.cc b/source/blender/geometry/intern/mesh_primitive_cuboid.cc index 81de447af51..82c98375759 100644 --- a/source/blender/geometry/intern/mesh_primitive_cuboid.cc +++ b/source/blender/geometry/intern/mesh_primitive_cuboid.cc @@ -289,7 +289,7 @@ static void calculate_corner_verts(const CuboidConfig &config, MutableSpan } } -static void calculate_uvs(const CuboidConfig &config, Mesh *mesh, const std::string &uv_id) +static void calculate_uvs(const CuboidConfig &config, Mesh *mesh, const StringRef uv_id) { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter uv_attribute = attributes.lookup_or_add_for_write_only_span( @@ -369,7 +369,7 @@ Mesh *create_cuboid_mesh(const float3 &size, const int verts_x, const int verts_y, const int verts_z, - const std::optional &uv_id) + const std::optional &uv_id) { const CuboidConfig config(size, verts_x, verts_y, verts_z); diff --git a/source/blender/geometry/intern/mesh_primitive_grid.cc b/source/blender/geometry/intern/mesh_primitive_grid.cc index 1112eb7d4a7..7a45b80c669 100644 --- a/source/blender/geometry/intern/mesh_primitive_grid.cc +++ b/source/blender/geometry/intern/mesh_primitive_grid.cc @@ -41,7 +41,7 @@ Mesh *create_grid_mesh(const int verts_x, const int verts_y, const float size_x, const float size_y, - const std::optional &uv_map_id) + const std::optional &uv_map_id) { BLI_assert(verts_x > 0 && verts_y > 0); const int edges_x = verts_x - 1; diff --git a/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc b/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc index 3eb5dc393a0..5583d0a0065 100644 --- a/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc +++ b/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc @@ -294,7 +294,7 @@ static Bounds calculate_bounds_uv_sphere(const float radius, Mesh *create_uv_sphere_mesh(const float radius, const int segments, const int rings, - const std::optional &uv_map_id) + const std::optional &uv_map_id) { Mesh *mesh = BKE_mesh_new_nomain(sphere_vert_total(segments, rings), sphere_edge_total(segments, rings), diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index fa3cbf7cc28..7788ad9ab8d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -110,9 +110,9 @@ static void copy_curve_domain_attributes(const AttributeAccessor curve_attribute } static PointCloud *pointcloud_from_curves(bke::CurvesGeometry curves, - const std::optional &tangent_id, - const std::optional &normal_id, - const std::optional &rotation_id) + const std::optional &tangent_id, + const std::optional &normal_id, + const std::optional &rotation_id) { PointCloud *pointcloud = BKE_pointcloud_new_nomain(0); pointcloud->totpoint = curves.points_num(); @@ -142,7 +142,7 @@ static void curve_to_points(GeometrySet &geometry_set, GeoNodeExecParams params, const GeometryNodeCurveResampleMode mode, geometry::ResampleCurvesOutputAttributeIDs resample_attributes, - std::optional rotation_anonymous_id) + const std::optional &rotation_anonymous_id) { switch (mode) { case GEO_NODE_CURVE_RESAMPLE_COUNT: { @@ -213,7 +213,7 @@ static void grease_pencil_to_points(GeometrySet &geometry_set, GeoNodeExecParams params, const GeometryNodeCurveResampleMode mode, geometry::ResampleCurvesOutputAttributeIDs resample_attributes, - std::optional rotation_anonymous_id, + const std::optional &rotation_anonymous_id, const AnonymousAttributePropagationInfo &propagation_info) { Field count; diff --git a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc index a6057f9e951..bae4cfd133f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc @@ -624,8 +624,8 @@ static void interpolate_curve_attributes(bke::CurvesGeometry &child_curves, } static void store_output_attributes(bke::CurvesGeometry &child_curves, - const std::optional weight_attribute_id, - const std::optional index_attribute_id, + const std::optional &weight_attribute_id, + const std::optional &index_attribute_id, const int max_neighbors, const Span all_neighbor_counts, const Span all_neighbor_indices, @@ -689,8 +689,8 @@ static GeometrySet generate_interpolated_curves( const VArray &point_group_ids, const int max_neighbors, const AnonymousAttributePropagationInfo &propagation_info, - const std::optional &index_attribute_id, - const std::optional &weight_attribute_id) + const std::optional &index_attribute_id, + const std::optional &weight_attribute_id) { const bke::CurvesGeometry &guide_curves = guide_curves_id.geometry.wrap(); 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 ca825327004..2159a5ed859 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 @@ -46,7 +46,7 @@ static Mesh *create_cube_mesh(const float3 size, const int verts_x, const int verts_y, const int verts_z, - const std::optional &uv_map_id) + const std::optional &uv_map_id) { const int dimensions = (verts_x - 1 > 0) + (verts_y - 1 > 0) + (verts_z - 1 > 0); if (dimensions == 0) {