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 | |
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
79 files changed, 236 insertions, 251 deletions
diff --git a/source/blender/blenkernel/BKE_attribute.hh b/source/blender/blenkernel/BKE_attribute.hh index 83e1a3208ae..4aa6c133e9e 100644 --- a/source/blender/blenkernel/BKE_attribute.hh +++ b/source/blender/blenkernel/BKE_attribute.hh @@ -755,12 +755,6 @@ class CustomDataAttributes { bool foreach_attribute(const AttributeForeachCallback callback, eAttrDomain domain) const; }; -AttributeAccessor mesh_attributes(const Mesh &mesh); -MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh); - -AttributeAccessor pointcloud_attributes(const PointCloud &pointcloud); -MutableAttributeAccessor pointcloud_attributes_for_write(PointCloud &pointcloud); - /* -------------------------------------------------------------------- */ /** \name #AttributeIDRef Inline Methods * \{ */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index c282305af5b..0036ed1cf61 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -826,7 +826,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, mesh_final = BKE_mesh_copy_for_eval(mesh_input, true); ASSERT_IS_VALID_MESH(mesh_final); } - MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh_final); + MutableAttributeAccessor attributes = mesh_final->attributes_for_write(); SpanAttributeWriter<float3> rest_positions = attributes.lookup_or_add_for_write_only_span<float3>("rest_position", ATTR_DOMAIN_POINT); if (rest_positions) { diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 941003d6c96..f66a1f9ee93 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -103,11 +103,11 @@ static std::optional<blender::bke::MutableAttributeAccessor> get_attribute_acces Mesh &mesh = reinterpret_cast<Mesh &>(id); /* The attribute API isn't implemented for BMesh, so edit mode meshes are not supported. */ BLI_assert(mesh.edit_mesh == nullptr); - return mesh_attributes_for_write(mesh); + return mesh.attributes_for_write(); } case ID_PT: { PointCloud &pointcloud = reinterpret_cast<PointCloud &>(id); - return pointcloud_attributes_for_write(pointcloud); + return pointcloud.attributes_for_write(); } case ID_CV: { Curves &curves_id = reinterpret_cast<Curves &>(id); diff --git a/source/blender/blenkernel/intern/bvhutils.cc b/source/blender/blenkernel/intern/bvhutils.cc index 1d8b53a28ba..9bea8a0d6d3 100644 --- a/source/blender/blenkernel/intern/bvhutils.cc +++ b/source/blender/blenkernel/intern/bvhutils.cc @@ -1294,7 +1294,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, break; case BVHTREE_FROM_LOOPTRI_NO_HIDDEN: { - blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*mesh); + blender::bke::AttributeAccessor attributes = mesh->attributes(); mask = looptri_no_hidden_map_get( mesh->polys().data(), attributes.lookup_or_default(".hide_poly", ATTR_DOMAIN_FACE, false), @@ -1454,7 +1454,7 @@ BVHTree *BKE_bvhtree_from_pointcloud_get(BVHTreeFromPointCloud *data, return nullptr; } - blender::bke::AttributeAccessor attributes = blender::bke::pointcloud_attributes(*pointcloud); + blender::bke::AttributeAccessor attributes = pointcloud->attributes(); blender::VArraySpan<blender::float3> positions = attributes.lookup_or_default<blender::float3>( "position", ATTR_DOMAIN_POINT, blender::float3(0)); diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc index 8be7cec1b04..b9fea2a27b8 100644 --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@ -711,7 +711,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main, Set<AttributeIDRef> main_attributes_set; - MutableAttributeAccessor mesh_attributes = bke::mesh_attributes_for_write(*mesh); + MutableAttributeAccessor mesh_attributes = mesh->attributes_for_write(); main_attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) { if (!should_add_attribute_to_mesh(main_attributes, mesh_attributes, id)) { diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index 1a994266df7..715c7d6c743 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -149,7 +149,7 @@ VArray<float3> mesh_normals_varray(const Mesh &mesh, * array and copy the face normal for each of its corners. In this case using the mesh * component's generic domain interpolation is fine, the data will still be normalized, * since the face normal is just copied to every corner. */ - return mesh_attributes(mesh).adapt_domain( + return mesh.attributes().adapt_domain( VArray<float3>::ForSpan({(float3 *)BKE_mesh_poly_normals_ensure(&mesh), mesh.totpoly}), ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER); @@ -1324,18 +1324,19 @@ static const AttributeAccessorFunctions &get_mesh_accessor_functions_ref() return fn; } -AttributeAccessor mesh_attributes(const Mesh &mesh) +} // namespace blender::bke + +blender::bke::AttributeAccessor Mesh::attributes() const { - return AttributeAccessor(&mesh, get_mesh_accessor_functions_ref()); + return blender::bke::AttributeAccessor(this, blender::bke::get_mesh_accessor_functions_ref()); } -MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh) +blender::bke::MutableAttributeAccessor Mesh::attributes_for_write() { - return MutableAttributeAccessor(&mesh, get_mesh_accessor_functions_ref()); + return blender::bke::MutableAttributeAccessor(this, + blender::bke::get_mesh_accessor_functions_ref()); } -} // namespace blender::bke - std::optional<blender::bke::AttributeAccessor> MeshComponent::attributes() const { return blender::bke::AttributeAccessor(mesh_, blender::bke::get_mesh_accessor_functions_ref()); diff --git a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc index 238854c987e..6980b561bc3 100644 --- a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc +++ b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc @@ -201,18 +201,20 @@ static const AttributeAccessorFunctions &get_pointcloud_accessor_functions_ref() return fn; } -AttributeAccessor pointcloud_attributes(const PointCloud &pointcloud) +} // namespace blender::bke + +blender::bke::AttributeAccessor PointCloud::attributes() const { - return AttributeAccessor(&pointcloud, get_pointcloud_accessor_functions_ref()); + return blender::bke::AttributeAccessor(this, + blender::bke::get_pointcloud_accessor_functions_ref()); } -MutableAttributeAccessor pointcloud_attributes_for_write(PointCloud &pointcloud) +blender::bke::MutableAttributeAccessor PointCloud::attributes_for_write() { - return MutableAttributeAccessor(&pointcloud, get_pointcloud_accessor_functions_ref()); + return blender::bke::MutableAttributeAccessor( + this, blender::bke::get_pointcloud_accessor_functions_ref()); } -} // namespace blender::bke - std::optional<blender::bke::AttributeAccessor> PointCloudComponent::attributes() const { return blender::bke::AttributeAccessor(pointcloud_, diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc index a52ffb6496b..56e9e9dcdff 100644 --- a/source/blender/blenkernel/intern/geometry_fields.cc +++ b/source/blender/blenkernel/intern/geometry_fields.cc @@ -18,7 +18,7 @@ namespace blender::bke { MeshFieldContext::MeshFieldContext(const Mesh &mesh, const eAttrDomain domain) : mesh_(mesh), domain_(domain) { - BLI_assert(mesh_attributes(mesh).domain_supported(domain_)); + BLI_assert(mesh.attributes().domain_supported(domain_)); } CurvesFieldContext::CurvesFieldContext(const CurvesGeometry &curves, const eAttrDomain domain) @@ -94,13 +94,13 @@ GeometryFieldContext::GeometryFieldContext(const InstancesComponent &instances) std::optional<AttributeAccessor> GeometryFieldContext::attributes() const { if (const Mesh *mesh = this->mesh()) { - return mesh_attributes(*mesh); + return mesh->attributes(); } if (const CurvesGeometry *curves = this->curves()) { return curves->attributes(); } if (const PointCloud *pointcloud = this->pointcloud()) { - return pointcloud_attributes(*pointcloud); + return pointcloud->attributes(); } if (const InstancesComponent *instances = this->instances()) { return instances->attributes(); diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index 02f0a8398b0..4d0db4d5386 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -2715,7 +2715,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain, gpl_fill, scene->r.cfra + frame_offset, GP_GETFRAME_ADD_NEW); int i; - const VArray<int> mesh_material_indices = mesh_attributes(*me_eval).lookup_or_default<int>( + const VArray<int> mesh_material_indices = me_eval->attributes().lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); for (i = 0; i < mpoly_len; i++) { const MPoly *mp = &polys[i]; diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 84fc9005d53..6b99085ea28 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -1343,7 +1343,7 @@ void BKE_mesh_material_index_remove(Mesh *me, short index) { using namespace blender; using namespace blender::bke; - MutableAttributeAccessor attributes = mesh_attributes_for_write(*me); + MutableAttributeAccessor attributes = me->attributes_for_write(); AttributeWriter<int> material_indices = attributes.lookup_for_write<int>("material_index"); if (!material_indices) { return; @@ -1368,7 +1368,7 @@ bool BKE_mesh_material_index_used(Mesh *me, short index) { using namespace blender; using namespace blender::bke; - const AttributeAccessor attributes = mesh_attributes(*me); + const AttributeAccessor attributes = me->attributes(); const VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); if (material_indices.is_single()) { @@ -1382,7 +1382,7 @@ void BKE_mesh_material_index_clear(Mesh *me) { using namespace blender; using namespace blender::bke; - MutableAttributeAccessor attributes = mesh_attributes_for_write(*me); + MutableAttributeAccessor attributes = me->attributes_for_write(); attributes.remove("material_index"); BKE_mesh_tessface_clear(me); @@ -1411,7 +1411,7 @@ void BKE_mesh_material_remap(Mesh *me, const uint *remap, uint remap_len) } } else { - MutableAttributeAccessor attributes = mesh_attributes_for_write(*me); + MutableAttributeAccessor attributes = me->attributes_for_write(); AttributeWriter<int> material_indices = attributes.lookup_for_write<int>("material_index"); if (!material_indices) { return; @@ -1763,7 +1763,7 @@ void BKE_mesh_count_selected_items(const Mesh *mesh, int r_count[3]) void BKE_mesh_vert_coords_get(const Mesh *mesh, float (*vert_coords)[3]) { - blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*mesh); + blender::bke::AttributeAccessor attributes = mesh->attributes(); VArray<float3> positions = attributes.lookup_or_default( "position", ATTR_DOMAIN_POINT, float3(0)); positions.materialize({(float3 *)vert_coords, mesh->totvert}); diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index 4201b03c1f7..4b08e0b2ed5 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -415,7 +415,7 @@ static void copy_poly_attributes(Mesh *dest_mesh, Span<short> material_remap, MutableSpan<int> dst_material_indices) { - const VArray<int> src_material_indices = bke::mesh_attributes(*orig_me).lookup_or_default<int>( + const VArray<int> src_material_indices = orig_me->attributes().lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); const int src_index = src_material_indices[index_in_orig_me]; if (material_remap.size() > 0 && material_remap.index_range().contains(src_index)) { @@ -739,8 +739,8 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim) /* Set the loopstart and totloop for each output poly, * and set the vertices in the appropriate loops. */ bke::SpanAttributeWriter<int> dst_material_indices = - bke::mesh_attributes_for_write(*result).lookup_or_add_for_write_only_span<int>( - "material_index", ATTR_DOMAIN_FACE); + result->attributes_for_write().lookup_or_add_for_write_only_span<int>("material_index", + ATTR_DOMAIN_FACE); int cur_loop_index = 0; MutableSpan<MLoop> dst_loops = result->loops_for_write(); MutableSpan<MPoly> dst_polys = result->polys_for_write(); diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 9f8326454d2..a8ff90c128a 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -193,7 +193,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba MEdge *medge = edges.data(); MPoly *mpoly = polys.data(); MLoop *mloop = loops.data(); - MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>( "material_index", ATTR_DOMAIN_FACE); MLoopUV *mloopuv = static_cast<MLoopUV *>(CustomData_add_layer_named( @@ -639,9 +639,8 @@ void BKE_pointcloud_from_mesh(Mesh *me, PointCloud *pointcloud) /* Copy over all attributes. */ CustomData_merge(&me->vdata, &pointcloud->pdata, CD_MASK_PROP_ALL, CD_DUPLICATE, me->totvert); - bke::AttributeAccessor mesh_attributes = bke::mesh_attributes(*me); - bke::MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write( - *pointcloud); + bke::AttributeAccessor mesh_attributes = me->attributes(); + bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write(); const VArray<float3> mesh_positions = mesh_attributes.lookup_or_default<float3>( "position", ATTR_DOMAIN_POINT, float3(0)); @@ -1085,7 +1084,7 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain, BKE_mesh_nomain_to_mesh(mesh, mesh_in_bmain, nullptr, &CD_MASK_MESH, true); /* Anonymous attributes shouldn't exist on original data. */ - blender::bke::mesh_attributes_for_write(*mesh_in_bmain).remove_anonymous(); + mesh_in_bmain->attributes_for_write().remove_anonymous(); /* User-count is required because so far mesh was in a limbo, where library management does * not perform any user management (i.e. copy of a mesh will not increase users of materials). */ diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc b/source/blender/blenkernel/intern/mesh_evaluate.cc index b1a70d5450c..938d7e42aa3 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.cc +++ b/source/blender/blenkernel/intern/mesh_evaluate.cc @@ -736,7 +736,7 @@ void BKE_mesh_flush_hidden_from_verts(Mesh *me) { using namespace blender; using namespace blender::bke; - MutableAttributeAccessor attributes = mesh_attributes_for_write(*me); + MutableAttributeAccessor attributes = me->attributes_for_write(); const VArray<bool> hide_vert = attributes.lookup_or_default<bool>( ".hide_vert", ATTR_DOMAIN_POINT, false); @@ -776,7 +776,7 @@ void BKE_mesh_flush_hidden_from_polys(Mesh *me) { using namespace blender; using namespace blender::bke; - MutableAttributeAccessor attributes = mesh_attributes_for_write(*me); + MutableAttributeAccessor attributes = me->attributes_for_write(); const VArray<bool> hide_poly = attributes.lookup_or_default<bool>( ".hide_poly", ATTR_DOMAIN_FACE, false); @@ -907,7 +907,7 @@ static void mesh_flush_select_from_verts(const Span<MVert> verts, void BKE_mesh_flush_select_from_verts(Mesh *me) { - const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*me); + const blender::bke::AttributeAccessor attributes = me->attributes(); mesh_flush_select_from_verts( me->verts(), me->loops(), diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 39b1ffb7cf4..2f67e303095 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -925,7 +925,7 @@ void BKE_mesh_legacy_convert_hide_layers_to_flags(Mesh *mesh) { using namespace blender; using namespace blender::bke; - const AttributeAccessor attributes = mesh_attributes(*mesh); + const AttributeAccessor attributes = mesh->attributes(); MutableSpan<MVert> verts = mesh->verts_for_write(); const VArray<bool> hide_vert = attributes.lookup_or_default<bool>( @@ -959,7 +959,7 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh) { using namespace blender; using namespace blender::bke; - MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); const Span<MVert> verts = mesh->verts(); if (std::any_of( @@ -1010,7 +1010,7 @@ void BKE_mesh_legacy_convert_material_indices_to_mpoly(Mesh *mesh) { using namespace blender; using namespace blender::bke; - const AttributeAccessor attributes = mesh_attributes(*mesh); + const AttributeAccessor attributes = mesh->attributes(); MutableSpan<MPoly> polys = mesh->polys_for_write(); const VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); @@ -1025,7 +1025,7 @@ void BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *mesh) { using namespace blender; using namespace blender::bke; - MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); const Span<MPoly> polys = mesh->polys(); if (std::any_of( polys.begin(), polys.end(), [](const MPoly &poly) { return poly.mat_nr != 0; })) { diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 50577969a83..47de7245ccc 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -243,7 +243,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, (void)0 blender::bke::AttributeWriter<int> material_indices = - blender::bke::mesh_attributes_for_write(*mesh).lookup_for_write<int>("material_index"); + mesh->attributes_for_write().lookup_for_write<int>("material_index"); blender::MutableVArraySpan<int> material_indices_span(material_indices.varray); MVert *mv = mverts; @@ -1152,7 +1152,7 @@ bool BKE_mesh_validate_material_indices(Mesh *me) bool is_valid = true; blender::bke::AttributeWriter<int> material_indices = - blender::bke::mesh_attributes_for_write(*me).lookup_for_write<int>("material_index"); + me->attributes_for_write().lookup_for_write<int>("material_index"); blender::MutableVArraySpan<int> material_indices_span(material_indices.varray); for (const int i : material_indices_span.index_range()) { if (material_indices_span[i] < 0 || material_indices_span[i] > mat_nr_max) { diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index cb15dbef69d..d9ce9f0e490 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -2134,7 +2134,7 @@ void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh) return; } - MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_only_span<bool>( ".hide_poly", ATTR_DOMAIN_FACE); if (!hide_poly) { diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index 14ca3f58db9..29248466cdd 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -194,8 +194,7 @@ static void pointcloud_random(PointCloud *pointcloud) RNG *rng = BLI_rng_new(0); - blender::bke::MutableAttributeAccessor attributes = - blender::bke::pointcloud_attributes_for_write(*pointcloud); + blender::bke::MutableAttributeAccessor attributes = pointcloud->attributes_for_write(); blender::bke::SpanAttributeWriter positions = attributes.lookup_or_add_for_write_only_span<float3>(POINTCLOUD_ATTR_POSITION, ATTR_DOMAIN_POINT); @@ -258,7 +257,7 @@ PointCloud *BKE_pointcloud_new_nomain(const int totpoint) static std::optional<blender::bounds::MinMaxResult<float3>> point_cloud_bounds( const PointCloud &pointcloud) { - blender::bke::AttributeAccessor attributes = blender::bke::pointcloud_attributes(pointcloud); + blender::bke::AttributeAccessor attributes = pointcloud.attributes(); blender::VArraySpan<float3> positions = attributes.lookup_or_default<float3>( POINTCLOUD_ATTR_POSITION, ATTR_DOMAIN_POINT, float3(0)); blender::VArray<float> radii = attributes.lookup_or_default<float>( diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index fe9369fd652..ccd82865178 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -965,7 +965,7 @@ static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm, return; } - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); BM_mesh_elem_table_ensure(&bm, BM_VERT | BM_EDGE | BM_FACE); write_fn_to_attribute<bool>( @@ -1154,11 +1154,9 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh if (need_material_index) { BM_mesh_elem_table_ensure(bm, BM_FACE); write_fn_to_attribute<int>( - blender::bke::mesh_attributes_for_write(*me), - "material_index", - ATTR_DOMAIN_FACE, - true, - [&](const int i) { return static_cast<int>(BM_face_at_index(bm, i)->mat_nr); }); + me->attributes_for_write(), "material_index", ATTR_DOMAIN_FACE, true, [&](const int i) { + return static_cast<int>(BM_face_at_index(bm, i)->mat_nr); + }); } /* Patch hook indices and vertex parents. */ @@ -1423,11 +1421,9 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks * if (need_material_index) { BM_mesh_elem_table_ensure(bm, BM_FACE); write_fn_to_attribute<int>( - blender::bke::mesh_attributes_for_write(*me), - "material_index", - ATTR_DOMAIN_FACE, - true, - [&](const int i) { return static_cast<int>(BM_face_at_index(bm, i)->mat_nr); }); + me->attributes_for_write(), "material_index", ATTR_DOMAIN_FACE, true, [&](const int i) { + return static_cast<int>(BM_face_at_index(bm, i)->mat_nr); + }); } convert_bmesh_hide_flags_to_mesh_attributes( diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc index 57efed855f5..a43b23c8969 100644 --- a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc +++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc @@ -141,7 +141,7 @@ static void pointcloud_batch_cache_ensure_pos(const PointCloud &pointcloud, return; } - const bke::AttributeAccessor attributes = bke::pointcloud_attributes(pointcloud); + const bke::AttributeAccessor attributes = pointcloud.attributes(); const VArraySpan<float3> positions = attributes.lookup<float3>("position", ATTR_DOMAIN_POINT); const VArray<float> radii = attributes.lookup<float>("radius", ATTR_DOMAIN_POINT); /* From the opengl wiki: diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 6e317201424..51fbc5a3027 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -1967,9 +1967,8 @@ static void draw_subdiv_cache_ensure_mat_offsets(DRWSubdivCache *cache, return; } - const blender::VArraySpan<int> material_indices = blender::bke::mesh_attributes(*mesh_eval) - .lookup_or_default<int>( - "material_index", ATTR_DOMAIN_FACE, 0); + const blender::VArraySpan<int> material_indices = mesh_eval->attributes().lookup_or_default<int>( + "material_index", ATTR_DOMAIN_FACE, 0); /* Count number of subdivided polygons for each material. */ int *mat_start = static_cast<int *>(MEM_callocN(sizeof(int) * mat_len, "subdiv mat_start")); diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index bf9f5acac04..2386fd1030d 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -548,7 +548,7 @@ static void snap_curves_to_surface_exec_object(Object &curves_ob, BKE_mesh_runtime_looptri_len(&surface_mesh)}; VArraySpan<float2> surface_uv_map; if (curves_id.surface_uv_map != nullptr) { - const bke::AttributeAccessor surface_attributes = bke::mesh_attributes(surface_mesh); + const bke::AttributeAccessor surface_attributes = surface_mesh.attributes(); surface_uv_map = surface_attributes .lookup(curves_id.surface_uv_map, ATTR_DOMAIN_CORNER, CD_PROP_FLOAT2) .typed<float2>(); diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index eafe13f093d..14f2f8c6af5 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -282,7 +282,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op) RNA_enum_get(op->ptr, "mode")); Mesh *mesh = reinterpret_cast<Mesh *>(ob_data); - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); /* General conversion steps are always the same: * 1. Convert old data to right domain and data type. @@ -646,8 +646,7 @@ bool ED_geometry_attribute_convert(Mesh *mesh, return false; } - blender::bke::MutableAttributeAccessor attributes = blender::bke::mesh_attributes_for_write( - *mesh); + blender::bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); GVArray src_varray = attributes.lookup_or_default(name, new_domain, new_type); diff --git a/source/blender/editors/mesh/editface.cc b/source/blender/editors/mesh/editface.cc index 68a30b0cd77..f729db29b8c 100644 --- a/source/blender/editors/mesh/editface.cc +++ b/source/blender/editors/mesh/editface.cc @@ -67,11 +67,11 @@ void paintface_flush_flags(bContext *C, return; } - bke::AttributeAccessor attributes_me = bke::mesh_attributes(*me); + bke::AttributeAccessor attributes_me = me->attributes(); Mesh *me_orig = (Mesh *)ob_eval->runtime.data_orig; - bke::MutableAttributeAccessor attributes_orig = bke::mesh_attributes_for_write(*me_orig); + bke::MutableAttributeAccessor attributes_orig = me_orig->attributes_for_write(); Mesh *me_eval = (Mesh *)ob_eval->runtime.data_eval; - bke::MutableAttributeAccessor attributes_eval = bke::mesh_attributes_for_write(*me_eval); + bke::MutableAttributeAccessor attributes_eval = me_eval->attributes_for_write(); bool updated = false; const Span<MPoly> me_polys = me->polys(); @@ -142,7 +142,7 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected) } MutableSpan<MPoly> polys = me->polys_for_write(); - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me); + bke::MutableAttributeAccessor attributes = me->attributes_for_write(); bke::SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_span<bool>( ".hide_poly", ATTR_DOMAIN_FACE); @@ -175,7 +175,7 @@ void paintface_reveal(bContext *C, Object *ob, const bool select) } MutableSpan<MPoly> polys = me->polys_for_write(); - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me); + bke::MutableAttributeAccessor attributes = me->attributes_for_write(); if (select) { const VArray<bool> hide_poly = attributes.lookup_or_default<bool>( @@ -209,7 +209,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const uint index, const bo const Span<MEdge> edges = me->edges(); MutableSpan<MPoly> polys = me->polys_for_write(); const Span<MLoop> loops = me->loops(); - bke::AttributeAccessor attributes = bke::mesh_attributes(*me); + bke::AttributeAccessor attributes = me->attributes(); const VArray<bool> hide_poly = attributes.lookup_or_default<bool>( ".hide_poly", ATTR_DOMAIN_FACE, false); @@ -306,7 +306,7 @@ bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool fl } MutableSpan<MPoly> polys = me->polys_for_write(); - bke::AttributeAccessor attributes = bke::mesh_attributes(*me); + bke::AttributeAccessor attributes = me->attributes(); const VArray<bool> hide_poly = attributes.lookup_or_default<bool>( ".hide_poly", ATTR_DOMAIN_FACE, false); @@ -372,7 +372,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) const Span<MVert> verts = me->verts(); const Span<MPoly> polys = me->polys(); const Span<MLoop> loops = me->loops(); - bke::AttributeAccessor attributes = bke::mesh_attributes(*me); + bke::AttributeAccessor attributes = me->attributes(); const VArray<bool> hide_poly = attributes.lookup_or_default<bool>( ".hide_poly", ATTR_DOMAIN_FACE, false); @@ -410,7 +410,7 @@ bool paintface_mouse_select(bContext *C, Mesh *me = BKE_mesh_from_object(ob); MutableSpan<MPoly> polys = me->polys_for_write(); - bke::AttributeAccessor attributes = bke::mesh_attributes(*me); + bke::AttributeAccessor attributes = me->attributes(); const VArray<bool> hide_poly = attributes.lookup_or_default<bool>( ".hide_poly", ATTR_DOMAIN_FACE, false); @@ -530,7 +530,7 @@ bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags) } MutableSpan<MVert> verts = me->verts_for_write(); - bke::AttributeAccessor attributes = bke::mesh_attributes(*me); + bke::AttributeAccessor attributes = me->attributes(); const VArray<bool> hide_vert = attributes.lookup_or_default<bool>( ".hide_vert", ATTR_DOMAIN_POINT, false); @@ -607,7 +607,7 @@ void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags) } MutableSpan<MVert> verts = me->verts_for_write(); - bke::AttributeAccessor attributes = bke::mesh_attributes(*me); + bke::AttributeAccessor attributes = me->attributes(); const VArray<bool> hide_vert = attributes.lookup_or_default<bool>( ".hide_vert", ATTR_DOMAIN_POINT, false); @@ -636,7 +636,7 @@ void paintvert_hide(bContext *C, Object *ob, const bool unselected) } MutableSpan<MVert> verts = me->verts_for_write(); - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me); + bke::MutableAttributeAccessor attributes = me->attributes_for_write(); bke::SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_span<bool>( ".hide_vert", ATTR_DOMAIN_POINT); @@ -669,7 +669,7 @@ void paintvert_reveal(bContext *C, Object *ob, const bool select) } MutableSpan<MVert> verts = me->verts_for_write(); - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me); + bke::MutableAttributeAccessor attributes = me->attributes_for_write(); const VArray<bool> hide_vert = attributes.lookup_or_default<bool>( ".hide_vert", ATTR_DOMAIN_POINT, false); diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index ad7f504c87b..d6713724e15 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -254,7 +254,7 @@ static void join_mesh_single(Depsgraph *depsgraph, CustomData_copy_data_named(&me->pdata, pdata, 0, *polyofs, me->totpoly); blender::bke::AttributeWriter<int> material_indices = - blender::bke::mesh_attributes_for_write(*me).lookup_for_write<int>("material_index"); + me->attributes_for_write().lookup_for_write<int>("material_index"); if (material_indices) { blender::MutableVArraySpan<int> material_indices_span(material_indices.varray); for (const int i : material_indices_span.index_range()) { diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 513ead708e3..1068da6816f 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -3158,7 +3158,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) } /* Anonymous attributes shouldn't be available on the applied geometry. */ - blender::bke::mesh_attributes_for_write(*new_mesh).remove_anonymous(); + new_mesh->attributes_for_write().remove_anonymous(); BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */ } diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 8bbceccab28..9bb82cc086c 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -766,7 +766,7 @@ static bool modifier_apply_obdata( BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true); /* Anonymous attributes shouldn't be available on the applied geometry. */ - blender::bke::mesh_attributes_for_write(*me).remove_anonymous(); + me->attributes_for_write().remove_anonymous(); if (md_eval->type == eModifierType_Multires) { multires_customdata_delete(me); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc index d452d94d2f0..b5d739ae08e 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc @@ -167,11 +167,10 @@ struct AddOperationExecutor { /* Find UV map. */ VArraySpan<float2> surface_uv_map; if (curves_id_orig_->surface_uv_map != nullptr) { - surface_uv_map = bke::mesh_attributes(surface_orig) - .lookup<float2>(curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER); - surface_uv_map_eval_ = bke::mesh_attributes(*surface_eval_) - .lookup<float2>(curves_id_orig_->surface_uv_map, - ATTR_DOMAIN_CORNER); + surface_uv_map = surface_orig.attributes().lookup<float2>(curves_id_orig_->surface_uv_map, + ATTR_DOMAIN_CORNER); + surface_uv_map_eval_ = surface_eval_->attributes().lookup<float2>( + curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER); } if (surface_uv_map.is_empty()) { diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc index 2e03e907e34..c33ee5e0727 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc @@ -137,9 +137,9 @@ struct DensityAddOperationExecutor { /* Find UV map. */ VArraySpan<float2> surface_uv_map; if (curves_id_orig_->surface_uv_map != nullptr) { - surface_uv_map = bke::mesh_attributes(*surface_orig_) + surface_uv_map = surface_orig_->attributes() .lookup<float2>(curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER); - surface_uv_map_eval_ = bke::mesh_attributes(*surface_eval_) + surface_uv_map_eval_ = surface_eval_->attributes() .lookup<float2>(curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER); } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc index 833f00ae0d0..1108f5c72a9 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc @@ -180,8 +180,8 @@ struct SlideOperationExecutor { } surface_looptris_orig_ = {BKE_mesh_runtime_looptri_ensure(surface_orig_), BKE_mesh_runtime_looptri_len(surface_orig_)}; - surface_uv_map_orig_ = - bke::mesh_attributes(*surface_orig_).lookup<float2>(uv_map_name, ATTR_DOMAIN_CORNER); + surface_uv_map_orig_ = surface_orig_->attributes().lookup<float2>(uv_map_name, + ATTR_DOMAIN_CORNER); if (surface_uv_map_orig_.is_empty()) { report_missing_uv_map_on_original_surface(stroke_extension.reports); return; @@ -209,8 +209,8 @@ struct SlideOperationExecutor { BKE_mesh_runtime_looptri_len(surface_eval_)}; surface_verts_eval_ = surface_eval_->verts(); surface_loops_eval_ = surface_eval_->loops(); - surface_uv_map_eval_ = - bke::mesh_attributes(*surface_eval_).lookup<float2>(uv_map_name, ATTR_DOMAIN_CORNER); + surface_uv_map_eval_ = surface_eval_->attributes().lookup<float2>(uv_map_name, + ATTR_DOMAIN_CORNER); if (surface_uv_map_eval_.is_empty()) { report_missing_uv_map_on_evaluated_surface(stroke_extension.reports); return; diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc index 8f11774a16b..10ad4c2192f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc @@ -92,7 +92,7 @@ static bool vertex_paint_from_weight(Object *ob) return false; } - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me); + bke::MutableAttributeAccessor attributes = me->attributes_for_write(); bke::GAttributeWriter color_attribute = attributes.lookup_for_write(active_color_layer->name); if (!color_attribute) { @@ -162,7 +162,7 @@ static IndexMask get_selected_indices(const Mesh &mesh, const Span<MVert> verts = mesh.verts(); const Span<MPoly> polys = mesh.polys(); - bke::AttributeAccessor attributes = bke::mesh_attributes(mesh); + bke::AttributeAccessor attributes = mesh.attributes(); if (mesh.editflag & ME_EDIT_PAINT_FACE_SEL) { const VArray<bool> selection = attributes.adapt_domain( @@ -196,7 +196,7 @@ static void face_corner_color_equalize_verts(Mesh &mesh, const IndexMask selecti return; } - bke::AttributeAccessor attributes = bke::mesh_attributes(mesh); + bke::AttributeAccessor attributes = mesh.attributes(); if (attributes.lookup_meta_data(active_color_layer->name)->domain == ATTR_DOMAIN_POINT) { return; @@ -270,7 +270,7 @@ static bool transform_active_color(Mesh &mesh, const TransformFn &transform_fn) return false; } - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh); + bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::GAttributeWriter color_attribute = attributes.lookup_for_write(active_color_layer->name); if (!color_attribute) { diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc index 61782186402..3290c0ddd87 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc @@ -276,7 +276,7 @@ IndexMask GeometryDataSource::apply_selection_filter(Vector<int64_t> &indices) c BLI_assert(object_eval_->mode == OB_MODE_EDIT); Object *object_orig = DEG_get_original_object(object_eval_); const Mesh *mesh_eval = geometry_set_.get_mesh_for_read(); - const bke::AttributeAccessor attributes_eval = bke::mesh_attributes(*mesh_eval); + const bke::AttributeAccessor attributes_eval = mesh_eval->attributes(); Mesh *mesh_orig = (Mesh *)object_orig->data; BMesh *bm = mesh_orig->edit_mesh->bm; BM_mesh_elem_table_ensure(bm, BM_VERT); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index b01c04471ae..c4a633e920e 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -505,9 +505,8 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) FrsMaterial tmpMat; - const blender::VArray<int> material_indices = - blender::bke::mesh_attributes(*me).lookup_or_default<int>( - "material_index", ATTR_DOMAIN_FACE, 0); + const blender::VArray<int> material_indices = me->attributes().lookup_or_default<int>( + "material_index", ATTR_DOMAIN_FACE, 0); // We parse the vlak nodes again and import meshes while applying the clipping // by the near and far view planes. 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(); diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc index 52c11d32933..7d38cd1ec88 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc @@ -391,7 +391,7 @@ void ABCGenericMeshWriter::get_geo_groups(Object *object, struct Mesh *mesh, std::map<std::string, std::vector<int32_t>> &geo_groups) { - const bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh); + const bke::AttributeAccessor attributes = mesh->attributes(); const VArraySpan<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index d0c2063b7e6..65d99e3f057 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -769,7 +769,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, size_t num_polys = new_mesh->totpoly; if (num_polys > 0) { std::map<std::string, int> mat_map; - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*new_mesh); + bke::MutableAttributeAccessor attributes = new_mesh->attributes_for_write(); bke::SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE); assign_facesets_to_material_indices(sample_sel, material_indices.span, mat_map); @@ -830,7 +830,7 @@ void AbcMeshReader::assign_facesets_to_material_indices(const ISampleSelector &s void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const ISampleSelector &sample_sel) { std::map<std::string, int> mat_map; - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE); assign_facesets_to_material_indices(sample_sel, material_indices.span, mat_map); diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 3728bbd34c3..e60900ccdb6 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -288,7 +288,7 @@ static bool collect_vertex_counts_per_poly(Mesh *me, std::vector<unsigned long> &vcount_list) { const Span<MPoly> polys = me->polys(); - const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*me); + const blender::bke::AttributeAccessor attributes = me->attributes(); const blender::VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); bool is_triangulated = true; @@ -399,7 +399,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index, /* performs the actual writing */ prepareToAppendValues(is_triangulated, *primitive_list, vcount_list); - const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*me); + const blender::bke::AttributeAccessor attributes = me->attributes(); const blender::VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 259b52ed435..0b96cd8ce90 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -807,7 +807,7 @@ void USDMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const double mot std::map<pxr::SdfPath, int> mat_map; - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh); + bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE); this->assign_facesets_to_material_indices(motionSampleTime, material_indices.span, &mat_map); @@ -916,7 +916,7 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh, MutableSpan<MPoly> polys = active_mesh->polys_for_write(); if (!polys.is_empty() && import_params_.import_materials) { std::map<pxr::SdfPath, int> mat_map; - bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*active_mesh); + bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write(); bke::SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE); assign_facesets_to_material_indices(motionSampleTime, material_indices.span, &mat_map); diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 9f8e38c4dfd..a39f74c6420 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -256,7 +256,7 @@ static void get_loops_polys(const Mesh *mesh, USDMeshData &usd_mesh_data) { /* Only construct face groups (a.k.a. geometry subsets) when we need them for material * assignments. */ - const bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh); + const bke::AttributeAccessor attributes = mesh->attributes(); const VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); if (!material_indices.is_single() && mesh->totcol > 1) { diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index 902f801ee5b..4d934960010 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -255,7 +255,7 @@ void OBJWriter::write_vertex_coords(FormatHandler &fh, colors_layer = BKE_id_attributes_active_color_get(&mesh->id); } if (write_colors && (colors_layer != nullptr)) { - const bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh); + const bke::AttributeAccessor attributes = mesh->attributes(); const VArray<ColorGeometry4f> attribute = attributes.lookup_or_default<ColorGeometry4f>( colors_layer->name, ATTR_DOMAIN_POINT, {0.0f, 0.0f, 0.0f, 0.0f}); @@ -374,7 +374,7 @@ void OBJWriter::write_poly_elements(FormatHandler &fh, } } - const bke::AttributeAccessor attributes = bke::mesh_attributes(*obj_mesh_data.get_mesh()); + const bke::AttributeAccessor attributes = obj_mesh_data.get_mesh()->attributes(); const VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index 7f421b010b7..10880b016fb 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -203,7 +203,7 @@ void OBJMesh::calc_smooth_groups(const bool use_bitflags) void OBJMesh::calc_poly_order() { - const bke::AttributeAccessor attributes = bke::mesh_attributes(*export_mesh_eval_); + const bke::AttributeAccessor attributes = export_mesh_eval_->attributes(); const VArray<int> material_indices = attributes.lookup_or_default<int>( "material_index", ATTR_DOMAIN_FACE, 0); if (material_indices.is_single() && material_indices.get_internal_single() == 0) { diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index 84f1c6dd6b0..b1a2c7834f4 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -188,8 +188,8 @@ void MeshFromGeometry::create_polys_loops(Mesh *mesh, bool use_vertex_groups) MutableSpan<MPoly> polys = mesh->polys_for_write(); MutableSpan<MLoop> loops = mesh->loops_for_write(); bke::SpanAttributeWriter<int> material_indices = - bke::mesh_attributes_for_write(*mesh).lookup_or_add_for_write_only_span<int>( - "material_index", ATTR_DOMAIN_FACE); + mesh->attributes_for_write().lookup_or_add_for_write_only_span<int>("material_index", + ATTR_DOMAIN_FACE); const int64_t tot_face_elems{mesh->totpoly}; int tot_loop_idx = 0; diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index f14ec52decc..00a9e36612c 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -18,6 +18,10 @@ namespace blender { template<typename T> class Span; template<typename T> class MutableSpan; +namespace bke { +class AttributeAccessor; +class MutableAttributeAccessor; +} // namespace bke } // namespace blender #endif @@ -346,6 +350,9 @@ typedef struct Mesh { /** Write access to loop data. */ blender::MutableSpan<MLoop> loops_for_write(); + blender::bke::AttributeAccessor attributes() const; + blender::bke::MutableAttributeAccessor attributes_for_write(); + /** * Vertex group data, encoded as an array of indices and weights for every vertex. * \warning: May be empty. diff --git a/source/blender/makesdna/DNA_pointcloud_types.h b/source/blender/makesdna/DNA_pointcloud_types.h index ee829ebcf6e..34c5d153165 100644 --- a/source/blender/makesdna/DNA_pointcloud_types.h +++ b/source/blender/makesdna/DNA_pointcloud_types.h @@ -10,6 +10,13 @@ #include "DNA_customdata_types.h" #ifdef __cplusplus +namespace blender::bke { +class AttributeAccessor; +class MutableAttributeAccessor; +} // namespace blender::bke +#endif + +#ifdef __cplusplus extern "C" { #endif @@ -32,6 +39,11 @@ typedef struct PointCloud { short totcol; short _pad3[3]; +#ifdef __cplusplus + blender::bke::AttributeAccessor attributes() const; + blender::bke::MutableAttributeAccessor attributes_for_write(); +#endif + /* Draw Cache */ void *batch_cache; } PointCloud; 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); } |