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/nodes | |
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/nodes')
33 files changed, 100 insertions, 119 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc index 69938f3e447..a6af74645b6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc @@ -154,7 +154,7 @@ static void node_geo_exec(GeoNodeExecParams params) /* Store intersecting edges in attribute. */ if (attribute_outputs.intersecting_edges_id) { - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*result); + MutableAttributeAccessor attributes = result->attributes_for_write(); SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_only_span<bool>( attribute_outputs.intersecting_edges_id.get(), ATTR_DOMAIN_EDGE); diff --git a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc index e8dbfbde401..3f6155460ed 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc @@ -270,8 +270,8 @@ static void node_geo_exec(GeoNodeExecParams params) BKE_mesh_wrapper_ensure_mdata(surface_mesh_eval); - const AttributeAccessor mesh_attributes_eval = bke::mesh_attributes(*surface_mesh_eval); - const AttributeAccessor mesh_attributes_orig = bke::mesh_attributes(*surface_mesh_orig); + const AttributeAccessor mesh_attributes_eval = surface_mesh_eval->attributes(); + const AttributeAccessor mesh_attributes_orig = surface_mesh_orig->attributes(); Curves &curves_id = *curves_geometry.get_curves_for_write(); CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 82a6504cf4e..851ca622d6b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -382,8 +382,8 @@ static void separate_point_cloud_selection(GeometrySet &geometry_set, {GEO_COMPONENT_TYPE_POINT_CLOUD}, GEO_COMPONENT_TYPE_POINT_CLOUD, false, attributes); copy_attributes_based_on_mask(attributes, - bke::pointcloud_attributes(src_pointcloud), - bke::pointcloud_attributes_for_write(*pointcloud), + src_pointcloud.attributes(), + pointcloud->attributes_for_write(), ATTR_DOMAIN_POINT, selection); geometry_set.replace_pointcloud(pointcloud); @@ -921,23 +921,23 @@ static void do_mesh_separation(GeometrySet &geometry_set, /* Copy attributes. */ copy_attributes_based_on_map(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), ATTR_DOMAIN_POINT, vertex_map); copy_attributes_based_on_map(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), ATTR_DOMAIN_EDGE, edge_map); copy_attributes_based_on_mask(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), ATTR_DOMAIN_FACE, IndexMask(Vector<int64_t>(selected_poly_indices.as_span()))); copy_face_corner_attributes(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), selected_loops_num, selected_poly_indices, mesh_in); @@ -997,23 +997,21 @@ static void do_mesh_separation(GeometrySet &geometry_set, mesh_in, *mesh_out, edge_map, selected_poly_indices, new_loop_starts); /* Copy attributes. */ - copy_attributes(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), - {ATTR_DOMAIN_POINT}); + copy_attributes( + attributes, mesh_in.attributes(), mesh_out->attributes_for_write(), {ATTR_DOMAIN_POINT}); copy_attributes_based_on_map(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), ATTR_DOMAIN_EDGE, edge_map); copy_attributes_based_on_mask(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), ATTR_DOMAIN_FACE, IndexMask(Vector<int64_t>(selected_poly_indices.as_span()))); copy_face_corner_attributes(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), selected_loops_num, selected_poly_indices, mesh_in); @@ -1060,17 +1058,17 @@ static void do_mesh_separation(GeometrySet &geometry_set, /* Copy attributes. */ copy_attributes(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), {ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE}); copy_attributes_based_on_mask(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), ATTR_DOMAIN_FACE, IndexMask(Vector<int64_t>(selected_poly_indices.as_span()))); copy_face_corner_attributes(attributes, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out), + mesh_in.attributes(), + mesh_out->attributes_for_write(), selected_loops_num, selected_poly_indices, mesh_in); @@ -1089,8 +1087,7 @@ static void separate_mesh_selection(GeometrySet &geometry_set, { const Mesh &src_mesh = *geometry_set.get_mesh_for_read(); bke::MeshFieldContext field_context{src_mesh, selection_domain}; - fn::FieldEvaluator evaluator{field_context, - bke::mesh_attributes(src_mesh).domain_size(selection_domain)}; + fn::FieldEvaluator evaluator{field_context, src_mesh.attributes().domain_size(selection_domain)}; evaluator.add(selection_field); evaluator.evaluate(); const VArray<bool> selection = evaluator.get_evaluated<bool>(0); diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc index aaab259fc51..b84ee33e26f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc @@ -291,8 +291,8 @@ BLI_NOINLINE static void propagate_existing_attributes( const Span<float3> bary_coords, const Span<int> looptri_indices) { - const AttributeAccessor mesh_attributes = bke::mesh_attributes(mesh); - MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write(points); + const AttributeAccessor mesh_attributes = mesh.attributes(); + MutableAttributeAccessor point_attributes = points.attributes_for_write(); for (Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) { const AttributeIDRef attribute_id = entry.key; @@ -333,7 +333,7 @@ BLI_NOINLINE static void compute_attribute_outputs(const Mesh &mesh, const Span<int> looptri_indices, const AttributeOutputs &attribute_outputs) { - MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write(points); + MutableAttributeAccessor point_attributes = points.attributes_for_write(); SpanAttributeWriter<int> ids = point_attributes.lookup_or_add_for_write_only_span<int>( "id", ATTR_DOMAIN_POINT); @@ -396,7 +396,7 @@ static Array<float> calc_full_density_factors_with_selection(const Mesh &mesh, const Field<bool> &selection_field) { const eAttrDomain domain = ATTR_DOMAIN_CORNER; - const int domain_size = bke::mesh_attributes(mesh).domain_size(domain); + const int domain_size = mesh.attributes().domain_size(domain); Array<float> densities(domain_size, 0.0f); bke::MeshFieldContext field_context{mesh, domain}; @@ -491,8 +491,7 @@ static void point_distribution_calculate(GeometrySet &geometry_set, } PointCloud *pointcloud = BKE_pointcloud_new_nomain(positions.size()); - bke::MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write( - *pointcloud); + bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write(); bke::SpanAttributeWriter<float3> point_positions = point_attributes.lookup_or_add_for_write_only_span<float3>("position", ATTR_DOMAIN_POINT); bke::SpanAttributeWriter<float> point_radii = diff --git a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc index 861711e06cc..84e63845b84 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc @@ -918,8 +918,8 @@ static void calc_dual_mesh(GeometrySet &geometry_set, new_to_old_edges_map, new_to_old_face_corners_map, boundary_vertex_to_relevant_face_map, - bke::mesh_attributes(mesh_in), - bke::mesh_attributes_for_write(*mesh_out)); + mesh_in.attributes(), + mesh_out->attributes_for_write()); MutableSpan<MVert> dst_verts = mesh_out->verts_for_write(); MutableSpan<MEdge> dst_edges = mesh_out->edges_for_write(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index f0018e91478..d2a3c339301 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -593,22 +593,15 @@ static void duplicate_faces(GeometrySet &geometry_set, loop_mapping, offsets, selection, - bke::mesh_attributes(mesh), - bke::mesh_attributes_for_write(*new_mesh)); + mesh.attributes(), + new_mesh->attributes_for_write()); - copy_stable_id_faces(mesh, - selection, - offsets, - vert_mapping, - bke::mesh_attributes(mesh), - bke::mesh_attributes_for_write(*new_mesh)); + copy_stable_id_faces( + mesh, selection, offsets, vert_mapping, mesh.attributes(), new_mesh->attributes_for_write()); if (attribute_outputs.duplicate_index) { - create_duplicate_index_attribute(bke::mesh_attributes_for_write(*new_mesh), - ATTR_DOMAIN_FACE, - selection, - attribute_outputs, - offsets); + create_duplicate_index_attribute( + new_mesh->attributes_for_write(), ATTR_DOMAIN_FACE, selection, attribute_outputs, offsets); } geometry_set.replace_mesh(new_mesh); @@ -769,17 +762,14 @@ static void duplicate_edges(GeometrySet &geometry_set, vert_orig_indices, edge_offsets, selection, - bke::mesh_attributes(mesh), - bke::mesh_attributes_for_write(*new_mesh)); + mesh.attributes(), + new_mesh->attributes_for_write()); - copy_stable_id_edges(mesh, - selection, - edge_offsets, - bke::mesh_attributes(mesh), - bke::mesh_attributes_for_write(*new_mesh)); + copy_stable_id_edges( + mesh, selection, edge_offsets, mesh.attributes(), new_mesh->attributes_for_write()); if (attribute_outputs.duplicate_index) { - create_duplicate_index_attribute(bke::mesh_attributes_for_write(*new_mesh), + create_duplicate_index_attribute(new_mesh->attributes_for_write(), ATTR_DOMAIN_EDGE, selection, attribute_outputs, @@ -926,14 +916,13 @@ static void duplicate_points_mesh(GeometrySet &geometry_set, ATTR_DOMAIN_POINT, offsets, selection, - bke::mesh_attributes(mesh), - bke::mesh_attributes_for_write(*new_mesh)); + mesh.attributes(), + new_mesh->attributes_for_write()); - copy_stable_id_point( - offsets, bke::mesh_attributes(mesh), bke::mesh_attributes_for_write(*new_mesh)); + copy_stable_id_point(offsets, mesh.attributes(), new_mesh->attributes_for_write()); if (attribute_outputs.duplicate_index) { - create_duplicate_index_attribute(bke::mesh_attributes_for_write(*new_mesh), + create_duplicate_index_attribute(new_mesh->attributes_for_write(), ATTR_DOMAIN_POINT, selection, attribute_outputs, @@ -973,15 +962,13 @@ static void duplicate_points_pointcloud(GeometrySet &geometry_set, ATTR_DOMAIN_POINT, offsets, selection, - bke::pointcloud_attributes(src_points), - bke::pointcloud_attributes_for_write(*pointcloud)); + src_points.attributes(), + pointcloud->attributes_for_write()); - copy_stable_id_point(offsets, - bke::pointcloud_attributes(src_points), - bke::pointcloud_attributes_for_write(*pointcloud)); + copy_stable_id_point(offsets, src_points.attributes(), pointcloud->attributes_for_write()); if (attribute_outputs.duplicate_index) { - create_duplicate_index_attribute(bke::pointcloud_attributes_for_write(*pointcloud), + create_duplicate_index_attribute(pointcloud->attributes_for_write(), ATTR_DOMAIN_POINT, selection, attribute_outputs, diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc index 483a535dfa7..9ef9ee8ad6e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc @@ -88,7 +88,7 @@ class PathToEdgeSelectionFieldInput final : public bke::MeshFieldInput { edge_paths_to_selection(mesh, start_verts, next_vert, selection_span); - return bke::mesh_attributes(mesh).adapt_domain<bool>( + return mesh.attributes().adapt_domain<bool>( VArray<bool>::ForContainer(std::move(selection)), ATTR_DOMAIN_EDGE, domain); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index d335a162776..9224e9d55f3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -66,7 +66,7 @@ static void save_selection_as_attribute(Mesh &mesh, const eAttrDomain domain, const IndexMask selection) { - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); BLI_assert(!attributes.contains(id)); SpanAttributeWriter<bool> attribute = attributes.lookup_or_add_for_write_span<bool>(id, domain); @@ -138,7 +138,7 @@ static CustomData &get_customdata(Mesh &mesh, const eAttrDomain domain) static MutableSpan<int> get_orig_index_layer(Mesh &mesh, const eAttrDomain domain) { - const bke::AttributeAccessor attributes = bke::mesh_attributes(mesh); + const bke::AttributeAccessor attributes = mesh.attributes(); CustomData &custom_data = get_customdata(mesh, domain); if (int *orig_indices = static_cast<int *>(CustomData_get_layer(&custom_data, CD_ORIGINDEX))) { return {orig_indices, attributes.domain_size(domain)}; @@ -252,7 +252,7 @@ static void extrude_mesh_vertices(Mesh &mesh, new_edges[i_selection] = new_loose_edge(selection[i_selection], new_vert_range[i_selection]); } - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) { if (!ELEM(meta_data.domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE)) { @@ -498,7 +498,7 @@ static void extrude_mesh_edges(Mesh &mesh, const Array<Vector<int>> new_vert_to_duplicate_edge_map = create_vert_to_edge_map( new_vert_range.size(), duplicate_edges, orig_vert_size); - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) { GSpanAttributeWriter attribute = attributes.lookup_or_add_for_write_span( @@ -878,7 +878,7 @@ static void extrude_mesh_face_regions(Mesh &mesh, const Array<Vector<int>> new_vert_to_duplicate_edge_map = create_vert_to_edge_map( new_vert_range.size(), boundary_edges, orig_vert_size); - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) { GSpanAttributeWriter attribute = attributes.lookup_or_add_for_write_span( @@ -1132,7 +1132,7 @@ static void extrude_individual_mesh_faces(Mesh &mesh, } }); - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) { GSpanAttributeWriter attribute = attributes.lookup_or_add_for_write_span( diff --git a/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc index fc9c9870c5c..613425716d4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc @@ -44,7 +44,7 @@ static void mesh_flip_faces(Mesh &mesh, const Field<bool> &selection_field) } } - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.for_all( [&](const bke::AttributeIDRef &attribute_id, const AttributeMetaData &meta_data) { if (meta_data.domain == ATTR_DOMAIN_CORNER) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc index f2304849cbc..f2e7379b3a2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc @@ -82,8 +82,7 @@ class AngleFieldInput final : public bke::MeshFieldInput { }; VArray<float> angles = VArray<float>::ForFunc(mesh.totedge, angle_fn); - return bke::mesh_attributes(mesh).adapt_domain<float>( - std::move(angles), ATTR_DOMAIN_EDGE, domain); + return mesh.attributes().adapt_domain<float>(std::move(angles), ATTR_DOMAIN_EDGE, domain); } uint64_t hash() const override @@ -150,8 +149,7 @@ class SignedAngleFieldInput final : public bke::MeshFieldInput { }; VArray<float> angles = VArray<float>::ForFunc(mesh.totedge, angle_fn); - return bke::mesh_attributes(mesh).adapt_domain<float>( - std::move(angles), ATTR_DOMAIN_EDGE, domain); + return mesh.attributes().adapt_domain<float>(std::move(angles), ATTR_DOMAIN_EDGE, domain); } uint64_t hash() const override diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc index 716cbf589d9..bfe8753c039 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc @@ -34,7 +34,7 @@ class EdgeNeighborCountFieldInput final : public bke::MeshFieldInput { face_count[loop.e]++; } - return bke::mesh_attributes(mesh).adapt_domain<int>( + return mesh.attributes().adapt_domain<int>( VArray<int>::ForContainer(std::move(face_count)), ATTR_DOMAIN_EDGE, domain); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc index 597400c1751..c8ceae239a4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc @@ -83,13 +83,13 @@ static VArray<float3> construct_edge_positions_gvarray(const Mesh &mesh, const Span<MEdge> edges = mesh.edges(); if (vertex == VERTEX_ONE) { - return bke::mesh_attributes(mesh).adapt_domain<float3>( + return mesh.attributes().adapt_domain<float3>( VArray<float3>::ForFunc(edges.size(), [verts, edges](const int i) { return verts[edges[i].v1].co; }), ATTR_DOMAIN_EDGE, domain); } - return bke::mesh_attributes(mesh).adapt_domain<float3>( + return mesh.attributes().adapt_domain<float3>( VArray<float3>::ForFunc(edges.size(), [verts, edges](const int i) { return verts[edges[i].v2].co; }), ATTR_DOMAIN_EDGE, diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc index c4d792c6c9a..be921c1f1c5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc @@ -27,7 +27,7 @@ static VArray<float> construct_face_area_varray(const Mesh &mesh, const eAttrDom return BKE_mesh_calc_poly_area(&poly, &loops[poly.loopstart], verts.data()); }; - return bke::mesh_attributes(mesh).adapt_domain<float>( + return mesh.attributes().adapt_domain<float>( VArray<float>::ForFunc(polys.size(), area_fn), ATTR_DOMAIN_FACE, domain); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc index 040b243a868..72c45de7b0f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc @@ -72,7 +72,7 @@ class PlanarFieldInput final : public bke::MeshFieldInput { return max - min < thresholds[i] / 2.0f; }; - return bke::mesh_attributes(mesh).adapt_domain<bool>( + return mesh.attributes().adapt_domain<bool>( VArray<bool>::ForFunc(polys.size(), planar_fn), ATTR_DOMAIN_FACE, domain); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc index cd58a0ad428..9e85eae3a31 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc @@ -37,7 +37,7 @@ static VArray<int> construct_neighbor_count_varray(const Mesh &mesh, const eAttr } } - return bke::mesh_attributes(mesh).adapt_domain<int>( + return mesh.attributes().adapt_domain<int>( VArray<int>::ForContainer(std::move(poly_count)), ATTR_DOMAIN_FACE, domain); } @@ -71,7 +71,7 @@ class FaceNeighborCountFieldInput final : public bke::MeshFieldInput { static VArray<int> construct_vertex_count_varray(const Mesh &mesh, const eAttrDomain domain) { const Span<MPoly> polys = mesh.polys(); - return bke::mesh_attributes(mesh).adapt_domain<int>( + return mesh.attributes().adapt_domain<int>( VArray<int>::ForFunc(polys.size(), [polys](const int i) -> float { return polys[i].totloop; }), ATTR_DOMAIN_FACE, diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc index 53cb3d0a19f..9d7735e707d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc @@ -47,7 +47,7 @@ class IslandFieldInput final : public bke::MeshFieldInput { output[i] = ordered_roots.index_of_or_add(root); } - return bke::mesh_attributes(mesh).adapt_domain<int>( + return mesh.attributes().adapt_domain<int>( VArray<int>::ForContainer(std::move(output)), ATTR_DOMAIN_POINT, domain); } @@ -87,8 +87,7 @@ class IslandCountFieldInput final : public bke::MeshFieldInput { island_list.add(root); } - return VArray<int>::ForSingle(island_list.size(), - bke::mesh_attributes(mesh).domain_size(domain)); + return VArray<int>::ForSingle(island_list.size(), mesh.attributes().domain_size(domain)); } uint64_t hash() const override diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc index e13edc8f979..a54daabde3b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc @@ -125,7 +125,7 @@ class ShortestEdgePathsNextVertFieldInput final : public bke::MeshFieldInput { } } }); - return bke::mesh_attributes(mesh).adapt_domain<int>( + return mesh.attributes().adapt_domain<int>( VArray<int>::ForContainer(std::move(next_index)), ATTR_DOMAIN_POINT, domain); } @@ -189,7 +189,7 @@ class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { } } }); - return bke::mesh_attributes(mesh).adapt_domain<float>( + return mesh.attributes().adapt_domain<float>( VArray<float>::ForContainer(std::move(cost)), ATTR_DOMAIN_POINT, domain); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc index 2a80d7d855a..ec2f1b00e6c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc @@ -45,8 +45,7 @@ static void convert_instances_to_points(GeometrySet &geometry_set, PointCloud *pointcloud = BKE_pointcloud_new_nomain(selection.size()); geometry_set.replace_pointcloud(pointcloud); - bke::MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write( - *pointcloud); + bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write(); bke::SpanAttributeWriter<float3> point_positions = point_attributes.lookup_or_add_for_write_only_span<float3>("position", ATTR_DOMAIN_POINT); diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc index 9822e0ea0d6..628688f3b47 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc @@ -32,7 +32,7 @@ static void select_mesh_by_material(const Mesh &mesh, slots.append(i); } } - const AttributeAccessor attributes = bke::mesh_attributes(mesh); + const AttributeAccessor attributes = mesh.attributes(); const VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); if (material != nullptr && material_indices.is_single() && @@ -81,7 +81,7 @@ class MaterialSelectionFieldInput final : public bke::GeometryFieldInput { Array<bool> selection(mesh->totpoly); select_mesh_by_material(*mesh, material_, IndexMask(mesh->totpoly), selection); - return bke::mesh_attributes(*mesh).adapt_domain<bool>( + return mesh->attributes().adapt_domain<bool>( VArray<bool>::ForContainer(std::move(selection)), ATTR_DOMAIN_FACE, domain); return nullptr; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index 20e805ab4e1..edf14f664c5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -480,7 +480,7 @@ static void calculate_selection_outputs(Mesh *mesh, const ConeConfig &config, ConeAttributeOutputs &attribute_outputs) { - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); /* Populate "Top" selection output. */ if (attribute_outputs.top_id) { @@ -536,7 +536,7 @@ static void calculate_selection_outputs(Mesh *mesh, */ static void calculate_cone_uvs(Mesh *mesh, const ConeConfig &config) { - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); SpanAttributeWriter<float2> uv_attribute = attributes.lookup_or_add_for_write_only_span<float2>( "uv_map", ATTR_DOMAIN_CORNER); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc index d8a4db43b27..6f0b8283b72 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc @@ -18,7 +18,7 @@ namespace blender::nodes { static void calculate_uvs( Mesh *mesh, Span<MVert> verts, Span<MLoop> loops, const float size_x, const float size_y) { - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); SpanAttributeWriter<float2> uv_attribute = attributes.lookup_or_add_for_write_only_span<float2>( "uv_map", ATTR_DOMAIN_CORNER); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index 017132b1a43..d39e72b7f0a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -254,7 +254,7 @@ BLI_NOINLINE static void calculate_sphere_corners(MutableSpan<MLoop> loops, BLI_NOINLINE static void calculate_sphere_uvs(Mesh *mesh, const float segments, const float rings) { - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); SpanAttributeWriter<float2> uv_attribute = attributes.lookup_or_add_for_write_only_span<float2>( "uv_map", ATTR_DOMAIN_CORNER); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc index d5c7fec4ce7..a1d6695b33b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc @@ -2,6 +2,7 @@ #include "BLI_task.hh" +#include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" #include "BKE_attribute_math.hh" @@ -65,7 +66,7 @@ static void geometry_set_mesh_to_points(GeometrySet &geometry_set, geometry_set.remove_geometry_during_modify(); return; } - const int domain_size = bke::mesh_attributes(*mesh).domain_size(domain); + const int domain_size = mesh->attributes().domain_size(domain); if (domain_size == 0) { geometry_set.remove_geometry_during_modify(); return; @@ -83,7 +84,7 @@ static void geometry_set_mesh_to_points(GeometrySet &geometry_set, PointCloud *pointcloud = BKE_pointcloud_new_nomain(selection.size()); geometry_set.replace_pointcloud(pointcloud); - MutableAttributeAccessor dst_attributes = bke::pointcloud_attributes_for_write(*pointcloud); + MutableAttributeAccessor dst_attributes = pointcloud->attributes_for_write(); GSpanAttributeWriter position = dst_attributes.lookup_or_add_for_write_only_span( "position", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); @@ -102,7 +103,7 @@ static void geometry_set_mesh_to_points(GeometrySet &geometry_set, {GEO_COMPONENT_TYPE_MESH}, GEO_COMPONENT_TYPE_POINT_CLOUD, false, attributes); attributes.remove("position"); - const AttributeAccessor src_attributes = bke::mesh_attributes(*mesh); + const AttributeAccessor src_attributes = mesh->attributes(); for (Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) { const AttributeIDRef attribute_id = entry.key; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points.cc b/source/blender/nodes/geometry/nodes/node_geo_points.cc index e0ba1f1c810..4a294076834 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points.cc @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ #include "BKE_pointcloud.h" +#include "DNA_pointcloud_types.h" #include "BLI_task.hh" @@ -70,7 +71,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field<float> radius_field = params.extract_input<Field<float>>("Radius"); PointCloud *points = BKE_pointcloud_new_nomain(count); - MutableAttributeAccessor attributes = bke::pointcloud_attributes_for_write(*points); + MutableAttributeAccessor attributes = points->attributes_for_write(); AttributeWriter<float3> output_position = attributes.lookup_or_add_for_write<float3>( "position", ATTR_DOMAIN_POINT); AttributeWriter<float> output_radii = attributes.lookup_or_add_for_write<float>( diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc index 1f6ffca0303..4ac3bf712f7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc @@ -47,8 +47,8 @@ static void geometry_set_points_to_vertices(GeometrySet &geometry_set, Mesh *mesh = BKE_mesh_new_nomain(selection.size(), 0, 0, 0, 0); geometry_set.replace_mesh(mesh); - const AttributeAccessor src_attributes = bke::pointcloud_attributes(*points); - MutableAttributeAccessor dst_attributes = bke::mesh_attributes_for_write(*mesh); + const AttributeAccessor src_attributes = points->attributes(); + MutableAttributeAccessor dst_attributes = mesh->attributes_for_write(); for (Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) { const AttributeIDRef attribute_id = entry.key; diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index 5c2ec74b59e..f657b128c51 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -312,7 +312,7 @@ class RaycastFunction : public fn::MultiFunction { } const Mesh &mesh = *target_.get_mesh_for_read(); target_context_.emplace(bke::MeshFieldContext{mesh, domain_}); - const int domain_size = bke::mesh_attributes(mesh).domain_size(domain_); + const int domain_size = mesh.attributes().domain_size(domain_); target_evaluator_ = std::make_unique<FieldEvaluator>(*target_context_, domain_size); target_evaluator_->add(std::move(src_field)); target_evaluator_->evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc index 3aee25b0693..8d00d82664b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc @@ -50,7 +50,7 @@ static void assign_material_to_faces(Mesh &mesh, const IndexMask selection, Mate BKE_id_material_eval_assign(&mesh.id, new_material_index + 1, material); } - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_span<int>( "material_index", ATTR_DOMAIN_FACE); material_indices.span.fill_indices(selection, new_material_index); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc b/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc index f1ac6e7f14c..28d07b31218 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc @@ -25,7 +25,7 @@ static void set_radius_in_component(PointCloud &pointcloud, if (pointcloud.totpoint == 0) { return; } - MutableAttributeAccessor attributes = bke::pointcloud_attributes_for_write(pointcloud); + MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); AttributeWriter<float> radii = attributes.lookup_or_add_for_write<float>("radius", ATTR_DOMAIN_POINT); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc b/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc index fa4d3eb6ac9..0df51e49827 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc @@ -22,7 +22,7 @@ static void set_smooth(Mesh &mesh, return; } - MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + MutableAttributeAccessor attributes = mesh.attributes_for_write(); AttributeWriter<bool> smooth = attributes.lookup_or_add_for_write<bool>("shade_smooth", ATTR_DOMAIN_FACE); diff --git a/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc index 76ffb3cbb52..afc492c40e4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc @@ -438,7 +438,7 @@ class NearestInterpolatedTransferFunction : public fn::MultiFunction { { const Mesh &mesh = *source_.get_mesh_for_read(); source_context_.emplace(bke::MeshFieldContext{mesh, domain_}); - const int domain_size = bke::mesh_attributes(mesh).domain_size(domain_); + const int domain_size = mesh.attributes().domain_size(domain_); source_evaluator_ = std::make_unique<FieldEvaluator>(*source_context_, domain_size); source_evaluator_->add(src_field_); source_evaluator_->evaluate(); @@ -583,7 +583,7 @@ class NearestTransferFunction : public fn::MultiFunction { { if (use_mesh_) { const Mesh &mesh = *source_.get_mesh_for_read(); - const int domain_size = bke::mesh_attributes(mesh).domain_size(domain_); + const int domain_size = mesh.attributes().domain_size(domain_); mesh_context_.emplace(bke::MeshFieldContext(mesh, domain_)); mesh_evaluator_ = std::make_unique<FieldEvaluator>(*mesh_context_, domain_size); mesh_evaluator_->add(src_field_); diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform.cc b/source/blender/nodes/geometry/nodes/node_geo_transform.cc index 0a36f58ba09..4130cad3bda 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform.cc @@ -47,7 +47,7 @@ static void transform_mesh(Mesh &mesh, const float4x4 &transform) static void translate_pointcloud(PointCloud &pointcloud, const float3 translation) { - MutableAttributeAccessor attributes = bke::pointcloud_attributes_for_write(pointcloud); + MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); SpanAttributeWriter position = attributes.lookup_or_add_for_write_span<float3>( "position", ATTR_DOMAIN_POINT); for (const int i : position.span.index_range()) { @@ -58,7 +58,7 @@ static void translate_pointcloud(PointCloud &pointcloud, const float3 translatio static void transform_pointcloud(PointCloud &pointcloud, const float4x4 &transform) { - MutableAttributeAccessor attributes = bke::pointcloud_attributes_for_write(pointcloud); + MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); SpanAttributeWriter position = attributes.lookup_or_add_for_write_span<float3>( "position", ATTR_DOMAIN_POINT); for (const int i : position.span.index_range()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc index 4953a0aa8d0..ccb489f6e29 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc @@ -87,7 +87,7 @@ static VArray<float3> construct_uv_gvarray(const Mesh &mesh, GEO_uv_parametrizer_flush(handle); GEO_uv_parametrizer_delete(handle); - return bke::mesh_attributes(mesh).adapt_domain<float3>( + return mesh.attributes().adapt_domain<float3>( VArray<float3>::ForContainer(std::move(uv)), ATTR_DOMAIN_CORNER, domain); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc index 513b9534c55..801bc3f4642 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc @@ -126,7 +126,7 @@ static VArray<float3> construct_uv_gvarray(const Mesh &mesh, GEO_uv_parametrizer_flush(handle); GEO_uv_parametrizer_delete(handle); - return bke::mesh_attributes(mesh).adapt_domain<float3>( + return mesh.attributes().adapt_domain<float3>( VArray<float3>::ForContainer(std::move(uv)), ATTR_DOMAIN_CORNER, domain); } |