diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-08 05:41:39 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-08 05:41:39 +0300 |
commit | d5934974219135102f364f57c45a8b1465e2b8d9 (patch) | |
tree | 415beea6d138085505b74d52301ff913781203dd /source/blender/io | |
parent | 17bc29253070f1707acd40c75e4a0e5c53704b24 (diff) |
Cleanup: Use C++ methods to retrieve attribute accessors
Replace `mesh_attributes`, `mesh_attributes_for_write` and the point
cloud versions with methods on the `Mesh` and `PointCloud` types.
This makes them friendlier to use and improves readability.
Differential Revision: https://developer.blender.org/D15907
Diffstat (limited to 'source/blender/io')
8 files changed, 13 insertions, 13 deletions
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; |