diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-08 05:41:39 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-08 05:41:39 +0300 |
commit | d5934974219135102f364f57c45a8b1465e2b8d9 (patch) | |
tree | 415beea6d138085505b74d52301ff913781203dd /source/blender/geometry | |
parent | 17bc29253070f1707acd40c75e4a0e5c53704b24 (diff) |
Cleanup: Use C++ methods to retrieve attribute accessors
Replace `mesh_attributes`, `mesh_attributes_for_write` and the point
cloud versions with methods on the `Mesh` and `PointCloud` types.
This makes them friendlier to use and improves readability.
Differential Revision: https://developer.blender.org/D15907
Diffstat (limited to 'source/blender/geometry')
4 files changed, 8 insertions, 10 deletions
diff --git a/source/blender/geometry/intern/mesh_primitive_cuboid.cc b/source/blender/geometry/intern/mesh_primitive_cuboid.cc index ad41cbd259d..39571f2931e 100644 --- a/source/blender/geometry/intern/mesh_primitive_cuboid.cc +++ b/source/blender/geometry/intern/mesh_primitive_cuboid.cc @@ -321,7 +321,7 @@ static void calculate_polys(const CuboidConfig &config, static void calculate_uvs(const CuboidConfig &config, Mesh *mesh, const bke::AttributeIDRef &uv_id) { - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter<float2> uv_attribute = attributes.lookup_or_add_for_write_only_span<float2>(uv_id, ATTR_DOMAIN_CORNER); MutableSpan<float2> uvs = uv_attribute.span; diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc index dab373f475b..22961504015 100644 --- a/source/blender/geometry/intern/mesh_to_curve_convert.cc +++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc @@ -44,7 +44,7 @@ bke::CurvesGeometry create_curve_from_vert_indices(const Mesh &mesh, curves.cyclic_for_write().fill(false); curves.cyclic_for_write().slice(cyclic_curves).fill(true); - const bke::AttributeAccessor mesh_attributes = bke::mesh_attributes(mesh); + const bke::AttributeAccessor mesh_attributes = mesh.attributes(); bke::MutableAttributeAccessor curves_attributes = curves.attributes_for_write(); Set<bke::AttributeIDRef> source_attribute_ids = mesh_attributes.all_ids(); diff --git a/source/blender/geometry/intern/point_merge_by_distance.cc b/source/blender/geometry/intern/point_merge_by_distance.cc index 42fac849667..81f57f785a3 100644 --- a/source/blender/geometry/intern/point_merge_by_distance.cc +++ b/source/blender/geometry/intern/point_merge_by_distance.cc @@ -17,7 +17,7 @@ PointCloud *point_merge_by_distance(const PointCloud &src_points, const float merge_distance, const IndexMask selection) { - const bke::AttributeAccessor src_attributes = bke::pointcloud_attributes(src_points); + const bke::AttributeAccessor src_attributes = src_points.attributes(); VArraySpan<float3> positions = src_attributes.lookup_or_default<float3>( "position", ATTR_DOMAIN_POINT, float3(0)); const int src_size = positions.size(); @@ -41,8 +41,7 @@ PointCloud *point_merge_by_distance(const PointCloud &src_points, /* Create the new point cloud and add it to a temporary component for the attribute API. */ const int dst_size = src_size - duplicate_count; PointCloud *dst_pointcloud = BKE_pointcloud_new_nomain(dst_size); - bke::MutableAttributeAccessor dst_attributes = bke::pointcloud_attributes_for_write( - *dst_pointcloud); + bke::MutableAttributeAccessor dst_attributes = dst_pointcloud->attributes_for_write(); /* By default, every point is just "merged" with itself. Then fill in the results of the merge * finding, converting from indices into the selection to indices into the full input point diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index b230b938ee9..29a9f51c0a7 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -668,7 +668,7 @@ static AllPointCloudsInfo preprocess_pointclouds(const GeometrySet &geometry_set pointcloud_info.pointcloud = pointcloud; /* Access attributes. */ - bke::AttributeAccessor attributes = bke::pointcloud_attributes(*pointcloud); + bke::AttributeAccessor attributes = pointcloud->attributes(); pointcloud_info.attributes.reinitialize(info.attributes.size()); for (const int attribute_index : info.attributes.index_range()) { const AttributeIDRef &attribute_id = info.attributes.ids[attribute_index]; @@ -744,8 +744,7 @@ static void execute_realize_pointcloud_tasks(const RealizeInstancesOptions &opti PointCloudComponent &dst_component = r_realized_geometry.get_component_for_write<PointCloudComponent>(); dst_component.replace(dst_pointcloud); - bke::MutableAttributeAccessor dst_attributes = bke::pointcloud_attributes_for_write( - *dst_pointcloud); + bke::MutableAttributeAccessor dst_attributes = dst_pointcloud->attributes_for_write(); SpanAttributeWriter<float3> positions = dst_attributes.lookup_or_add_for_write_only_span<float3>( "position", ATTR_DOMAIN_POINT); @@ -883,7 +882,7 @@ static AllMeshesInfo preprocess_meshes(const GeometrySet &geometry_set, } /* Access attributes. */ - bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh); + bke::AttributeAccessor attributes = mesh->attributes(); mesh_info.attributes.reinitialize(info.attributes.size()); for (const int attribute_index : info.attributes.index_range()) { const AttributeIDRef &attribute_id = info.attributes.ids[attribute_index]; @@ -1045,7 +1044,7 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options, Mesh *dst_mesh = BKE_mesh_new_nomain(tot_vertices, tot_edges, 0, tot_loops, tot_poly); MeshComponent &dst_component = r_realized_geometry.get_component_for_write<MeshComponent>(); dst_component.replace(dst_mesh); - bke::MutableAttributeAccessor dst_attributes = bke::mesh_attributes_for_write(*dst_mesh); + bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write(); MutableSpan<MVert> dst_verts = dst_mesh->verts_for_write(); MutableSpan<MEdge> dst_edges = dst_mesh->edges_for_write(); MutableSpan<MPoly> dst_polys = dst_mesh->polys_for_write(); |