diff options
Diffstat (limited to 'source/blender/blenkernel/intern')
26 files changed, 132 insertions, 130 deletions
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/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index c972e18fc12..d01ccd96f2f 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -5404,6 +5404,9 @@ void CustomData_blend_read(BlendDataReader *reader, CustomData *data, const int else if (layer->type == CD_GRID_PAINT_MASK) { blend_read_paint_mask(reader, count, static_cast<GridPaintMask *>(layer->data)); } + else if (layer->type == CD_MDEFORMVERT) { + BKE_defvert_blend_read(reader, count, static_cast<MDeformVert *>(layer->data)); + } i++; } } diff --git a/source/blender/blenkernel/intern/fcurve_test.cc b/source/blender/blenkernel/intern/fcurve_test.cc index 1912e3a9d8d..285c6a0af4d 100644 --- a/source/blender/blenkernel/intern/fcurve_test.cc +++ b/source/blender/blenkernel/intern/fcurve_test.cc @@ -7,7 +7,6 @@ #include "BKE_fcurve.h" #include "ED_keyframing.h" -#include "ED_types.h" /* For SELECT. */ #include "DNA_anim_types.h" 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 707518c0c34..b7063395052 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -249,7 +249,6 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address else { Set<std::string> names_to_skip; if (!BLO_write_is_undo(writer)) { - BKE_mesh_legacy_convert_hide_layers_to_flags(mesh); BKE_mesh_legacy_convert_material_indices_to_mpoly(mesh); BKE_mesh_legacy_bevel_weight_from_layers(mesh); @@ -261,6 +260,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address mesh->medge = const_cast<MEdge *>(mesh->edges().data()); mesh->mpoly = const_cast<MPoly *>(mesh->polys().data()); mesh->mloop = const_cast<MLoop *>(mesh->loops().data()); + mesh->dvert = const_cast<MDeformVert *>(mesh->deform_verts().data()); } CustomData_blend_write_prepare(mesh->vdata, vert_layers, names_to_skip); @@ -315,9 +315,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id) BLO_read_data_address(reader, &mesh->adt); BKE_animdata_blend_read_data(reader, mesh->adt); - /* Normally BKE_defvert_blend_read should be called in CustomData_blend_read, - * but for backwards compatibility in do_versions to work we do it here. */ - BKE_defvert_blend_read(reader, mesh->totvert, mesh->dvert); BLO_read_list(reader, &mesh->vertex_group_names); CustomData_blend_read(reader, &mesh->vdata, mesh->totvert); @@ -325,6 +322,11 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id) CustomData_blend_read(reader, &mesh->fdata, mesh->totface); CustomData_blend_read(reader, &mesh->ldata, mesh->totloop); CustomData_blend_read(reader, &mesh->pdata, mesh->totpoly); + if (mesh->deform_verts().is_empty()) { + /* Vertex group data was also an owning pointer in old Blender versions. + * Don't read them again if they were read as part of #CustomData. */ + BKE_defvert_blend_read(reader, mesh->totvert, mesh->dvert); + } mesh->texflag &= ~ME_AUTOSPACE_EVALUATED; mesh->edit_mesh = nullptr; @@ -1343,7 +1345,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 +1370,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 +1384,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 +1413,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 +1765,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 479b635341a..7a04e45fe00 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -414,7 +414,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)) { @@ -607,7 +607,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh, get_poly2d_cos(orig_me, orig_mp, cos_2d, mim.to_target_transform[orig_me_index], axis_mat); } CustomData *target_cd = &dest_mesh->ldata; - const Span<MVert> dst_vertices = dest_mesh->verts(); + const Span<MVert> dst_verts = dest_mesh->verts(); const Span<MLoop> dst_loops = dest_mesh->loops(); for (int i = 0; i < mp->totloop; ++i) { int loop_index = mp->loopstart + i; @@ -618,7 +618,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh, * The coordinate needs to be projected into 2d, just like the interpolating polygon's * coordinates were. The `dest_mesh` coordinates are already in object 0 local space. */ float co[2]; - mul_v2_m3v3(co, axis_mat, dst_vertices[dst_loops[loop_index].v].co); + mul_v2_m3v3(co, axis_mat, dst_verts[dst_loops[loop_index].v].co); interp_weights_poly_v2(weights.data(), cos_2d, orig_mp->totloop, co); } for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) { @@ -721,10 +721,10 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim) merge_vertex_loop_poly_customdata_layers(result, mim); /* Set the vertex coordinate values and other data. */ - MutableSpan<MVert> vertices = result->verts_for_write(); + MutableSpan<MVert> verts = result->verts_for_write(); for (int vi : im->vert_index_range()) { const Vert *v = im->vert(vi); - MVert *mv = &vertices[vi]; + MVert *mv = &verts[vi]; copy_v3fl_v3db(mv->co, v->co); if (v->orig != NO_INDEX) { const Mesh *orig_me; @@ -737,8 +737,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 e816dff7b4c..6422d4fa1df 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 f2fe2e0b141..938d7e42aa3 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.cc +++ b/source/blender/blenkernel/intern/mesh_evaluate.cc @@ -717,7 +717,7 @@ void BKE_mesh_polygon_flip(const MPoly *mpoly, MLoop *mloop, CustomData *ldata) BKE_mesh_polygon_flip_ex(mpoly, mloop, ldata, nullptr, mdisp, true); } -void BKE_mesh_polygons_flip(const MPoly *mpoly, MLoop *mloop, CustomData *ldata, int totpoly) +void BKE_mesh_polys_flip(const MPoly *mpoly, MLoop *mloop, CustomData *ldata, int totpoly) { MDisps *mdisp = (MDisps *)CustomData_get_layer(ldata, CD_MDISPS); const MPoly *mp; @@ -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_fair.cc b/source/blender/blenkernel/intern/mesh_fair.cc index fe5add864ea..41dcb3501cc 100644 --- a/source/blender/blenkernel/intern/mesh_fair.cc +++ b/source/blender/blenkernel/intern/mesh_fair.cc @@ -76,13 +76,13 @@ class FairingContext { virtual ~FairingContext() = default; - void fair_vertices(bool *affected, - const eMeshFairingDepth depth, - VertexWeight *vertex_weight, - LoopWeight *loop_weight) + void fair_verts(bool *affected, + const eMeshFairingDepth depth, + VertexWeight *vertex_weight, + LoopWeight *loop_weight) { - fair_vertices_ex(affected, (int)depth, vertex_weight, loop_weight); + fair_verts_ex(affected, (int)depth, vertex_weight, loop_weight); } protected: @@ -143,28 +143,28 @@ class FairingContext { loop_weight); } - void fair_vertices_ex(const bool *affected, - const int order, - VertexWeight *vertex_weight, - LoopWeight *loop_weight) + void fair_verts_ex(const bool *affected, + const int order, + VertexWeight *vertex_weight, + LoopWeight *loop_weight) { Map<int, int> vert_col_map; - int num_affected_vertices = 0; + int affected_verts_num = 0; for (int i = 0; i < totvert_; i++) { if (!affected[i]) { continue; } - vert_col_map.add(i, num_affected_vertices); - num_affected_vertices++; + vert_col_map.add(i, affected_verts_num); + affected_verts_num++; } /* Early return, nothing to do. */ - if (ELEM(num_affected_vertices, 0, totvert_)) { + if (ELEM(affected_verts_num, 0, totvert_)) { return; } /* Setup fairing matrices */ - LinearSolver *solver = EIG_linear_solver_new(num_affected_vertices, num_affected_vertices, 3); + LinearSolver *solver = EIG_linear_solver_new(affected_verts_num, affected_verts_num, 3); for (auto item : vert_col_map.items()) { const int v = item.key; const int col = item.value; @@ -450,42 +450,40 @@ class UniformLoopWeight : public LoopWeight { } }; -static void prefair_and_fair_vertices(FairingContext *fairing_context, - bool *affected_vertices, - const eMeshFairingDepth depth) +static void prefair_and_fair_verts(FairingContext *fairing_context, + bool *affected_verts, + const eMeshFairingDepth depth) { /* Prefair. */ UniformVertexWeight *uniform_vertex_weights = new UniformVertexWeight(fairing_context); UniformLoopWeight *uniform_loop_weights = new UniformLoopWeight(); - fairing_context->fair_vertices( - affected_vertices, depth, uniform_vertex_weights, uniform_loop_weights); + fairing_context->fair_verts(affected_verts, depth, uniform_vertex_weights, uniform_loop_weights); delete uniform_vertex_weights; /* Fair. */ VoronoiVertexWeight *voronoi_vertex_weights = new VoronoiVertexWeight(fairing_context); /* TODO: Implement cotangent loop weights. */ - fairing_context->fair_vertices( - affected_vertices, depth, voronoi_vertex_weights, uniform_loop_weights); + fairing_context->fair_verts(affected_verts, depth, voronoi_vertex_weights, uniform_loop_weights); delete uniform_loop_weights; delete voronoi_vertex_weights; } -void BKE_mesh_prefair_and_fair_vertices(struct Mesh *mesh, - struct MVert *deform_mverts, - bool *affect_vertices, - const eMeshFairingDepth depth) +void BKE_mesh_prefair_and_fair_verts(struct Mesh *mesh, + struct MVert *deform_mverts, + bool *affect_verts, + const eMeshFairingDepth depth) { MeshFairingContext *fairing_context = new MeshFairingContext(mesh, deform_mverts); - prefair_and_fair_vertices(fairing_context, affect_vertices, depth); + prefair_and_fair_verts(fairing_context, affect_verts, depth); delete fairing_context; } -void BKE_bmesh_prefair_and_fair_vertices(struct BMesh *bm, - bool *affect_vertices, - const eMeshFairingDepth depth) +void BKE_bmesh_prefair_and_fair_verts(struct BMesh *bm, + bool *affect_verts, + const eMeshFairingDepth depth) { BMeshFairingContext *fairing_context = new BMeshFairingContext(bm); - prefair_and_fair_vertices(fairing_context, affect_vertices, depth); + prefair_and_fair_verts(fairing_context, affect_verts, depth); delete fairing_context; } diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 31ae8478257..10fc8ff3195 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -986,7 +986,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>( @@ -1020,7 +1020,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( @@ -1071,7 +1071,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); @@ -1086,7 +1086,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_merge.c b/source/blender/blenkernel/intern/mesh_merge.c index dc1ebf4c6e0..9c0e3c1bf59 100644 --- a/source/blender/blenkernel/intern/mesh_merge.c +++ b/source/blender/blenkernel/intern/mesh_merge.c @@ -354,11 +354,11 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, ml = src_loops + mp->loopstart; /* check faces with all vertices merged */ - bool all_vertices_merged = true; + bool all_verts_merged = true; for (j = 0; j < mp->totloop; j++, ml++) { if (vtargetmap[ml->v] == -1) { - all_vertices_merged = false; + all_verts_merged = false; /* This will be used to check for poly using several time the same vert. */ BLI_BITMAP_DISABLE(vert_tag, ml->v); } @@ -368,7 +368,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, } } - if (UNLIKELY(all_vertices_merged)) { + if (UNLIKELY(all_verts_merged)) { if (merge_mode == MESH_MERGE_VERTS_DUMP_IF_MAPPED) { /* In this mode, all vertices merged is enough to dump face */ continue; diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index a88ff4e9d90..21dd39586ec 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -2021,18 +2021,18 @@ void BKE_mesh_normals_loop_custom_set(const MVert *mverts, false); } -void BKE_mesh_normals_loop_custom_from_vertices_set(const MVert *mverts, - const float (*vert_normals)[3], - float (*r_custom_vertnors)[3], - const int numVerts, - MEdge *medges, - const int numEdges, - const MLoop *mloops, - const int numLoops, - const MPoly *mpolys, - const float (*polynors)[3], - const int numPolys, - short (*r_clnors_data)[2]) +void BKE_mesh_normals_loop_custom_from_verts_set(const MVert *mverts, + const float (*vert_normals)[3], + float (*r_custom_vertnors)[3], + const int numVerts, + MEdge *medges, + const int numEdges, + const MLoop *mloops, + const int numLoops, + const MPoly *mpolys, + const float (*polynors)[3], + const int numPolys, + short (*r_clnors_data)[2]) { mesh_normals_loop_custom_set(mverts, vert_normals, @@ -2087,7 +2087,7 @@ void BKE_mesh_set_custom_normals(Mesh *mesh, float (*r_custom_loopnors)[3]) mesh_set_custom_normals(mesh, r_custom_loopnors, false); } -void BKE_mesh_set_custom_normals_from_vertices(Mesh *mesh, float (*r_custom_vertnors)[3]) +void BKE_mesh_set_custom_normals_from_verts(Mesh *mesh, float (*r_custom_vertnors)[3]) { mesh_set_custom_normals(mesh, r_custom_vertnors, true); } 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/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c index 97c85ae526c..e887f543dc5 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.c +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c @@ -354,10 +354,9 @@ static GridCoord *vertex_grid_coord_with_grid_index(const Vertex *vertex, const /* Get grid coordinates which correspond to corners of the given face. * All the grid coordinates will be from the same grid index. */ -static void grid_coords_from_face_vertices( - const MultiresReshapeSmoothContext *reshape_smooth_context, - const Face *face, - const GridCoord *grid_coords[]) +static void grid_coords_from_face_verts(const MultiresReshapeSmoothContext *reshape_smooth_context, + const Face *face, + const GridCoord *grid_coords[]) { BLI_assert(face->num_corners == 4); @@ -417,7 +416,7 @@ static void foreach_toplevel_grid_coord_task(void *__restrict userdata_v, const Face *face = &reshape_smooth_context->geometry.faces[face_index]; const GridCoord *face_grid_coords[4]; - grid_coords_from_face_vertices(reshape_smooth_context, face, face_grid_coords); + grid_coords_from_face_verts(reshape_smooth_context, face, face_grid_coords); for (int y = 0; y < inner_grid_size; ++y) { const float ptex_v = (float)y * inner_grid_size_1_inv; diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c index 7884d6718af..9a0f7aa2126 100644 --- a/source/blender/blenkernel/intern/multires_unsubdivide.c +++ b/source/blender/blenkernel/intern/multires_unsubdivide.c @@ -161,7 +161,7 @@ static bool is_vertex_diagonal(BMVert *from_v, BMVert *to_v) */ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex) { - bool *visited_vertices = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices"); + bool *visited_verts = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices"); GSQueue *queue; queue = BLI_gsqueue_new(sizeof(BMVert *)); @@ -177,7 +177,7 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex int neighbor_vertex_index = BM_elem_index_get(neighbor_v); if (neighbor_v != initial_vertex && is_vertex_diagonal(neighbor_v, initial_vertex)) { BLI_gsqueue_push(queue, &neighbor_v); - visited_vertices[neighbor_vertex_index] = true; + visited_verts[neighbor_vertex_index] = true; BM_elem_flag_set(neighbor_v, BM_ELEM_TAG, true); } } @@ -211,10 +211,10 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex BM_ITER_ELEM (f, &iter, diagonal_v, BM_FACES_OF_VERT) { BM_ITER_ELEM (neighbor_v, &iter_a, f, BM_VERTS_OF_FACE) { int neighbor_vertex_index = BM_elem_index_get(neighbor_v); - if (!visited_vertices[neighbor_vertex_index] && neighbor_v != diagonal_v && + if (!visited_verts[neighbor_vertex_index] && neighbor_v != diagonal_v && is_vertex_diagonal(neighbor_v, diagonal_v)) { BLI_gsqueue_push(queue, &neighbor_v); - visited_vertices[neighbor_vertex_index] = true; + visited_verts[neighbor_vertex_index] = true; BM_elem_flag_set(neighbor_v, BM_ELEM_TAG, true); } } @@ -224,7 +224,7 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex } BLI_gsqueue_free(queue); - MEM_freeN(visited_vertices); + MEM_freeN(visited_verts); } /** @@ -352,14 +352,14 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i */ static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id) { - bool *visited_vertices = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices"); + bool *visited_verts = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices"); int current_id = 0; for (int i = 0; i < bm->totvert; i++) { - if (!visited_vertices[i]) { + if (!visited_verts[i]) { GSQueue *queue; queue = BLI_gsqueue_new(sizeof(BMVert *)); - visited_vertices[i] = true; + visited_verts[i] = true; elem_id[i] = current_id; BMVert *iv = BM_vert_at_index(bm, i); BLI_gsqueue_push(queue, &iv); @@ -372,8 +372,8 @@ static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id) BM_ITER_ELEM (ed, &iter, current_v, BM_EDGES_OF_VERT) { neighbor_v = BM_edge_other_vert(ed, current_v); const int neighbor_index = BM_elem_index_get(neighbor_v); - if (!visited_vertices[neighbor_index]) { - visited_vertices[neighbor_index] = true; + if (!visited_verts[neighbor_index]) { + visited_verts[neighbor_index] = true; elem_id[neighbor_index] = current_id; BLI_gsqueue_push(queue, &neighbor_v); } @@ -383,7 +383,7 @@ static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id) BLI_gsqueue_free(queue); } } - MEM_freeN(visited_vertices); + MEM_freeN(visited_verts); return current_id; } diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 73db00e7306..d9ce9f0e490 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1511,7 +1511,7 @@ void BKE_sculptsession_free(Object *ob) } if (ss->boundary_preview) { - MEM_SAFE_FREE(ss->boundary_preview->vertices); + MEM_SAFE_FREE(ss->boundary_preview->verts); MEM_SAFE_FREE(ss->boundary_preview->edges); MEM_SAFE_FREE(ss->boundary_preview->distance); MEM_SAFE_FREE(ss->boundary_preview->edit_info); @@ -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/particle.c b/source/blender/blenkernel/intern/particle.c index ea058ba1dc5..7f4cded559c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2120,8 +2120,8 @@ void psys_particle_on_dm(Mesh *mesh_final, const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(mesh_final); if (from == PART_FROM_VERT) { - const MVert *vertices = BKE_mesh_verts(mesh_final); - copy_v3_v3(vec, vertices[mapindex].co); + const MVert *verts = BKE_mesh_verts(mesh_final); + copy_v3_v3(vec, verts[mapindex].co); if (nor) { copy_v3_v3(nor, vert_normals[mapindex]); diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 1c6274ef35e..6d761f56f13 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1831,7 +1831,7 @@ BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh) return pbvh->grid_hidden; } -int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh) +int BKE_pbvh_get_grid_num_verts(const PBVH *pbvh) { BLI_assert(pbvh->header.type == PBVH_GRIDS); return pbvh->totgrid * pbvh->gridkey.grid_area; 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/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 6ca598a3688..d1451353feb 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -2632,7 +2632,7 @@ static void springs_from_mesh(Object *ob) BodyPoint *bp; int a; float scale = 1.0f; - const MVert *vertices = BKE_mesh_verts(me); + const MVert *verts = BKE_mesh_verts(me); sb = ob->soft; if (me && sb) { @@ -2643,7 +2643,7 @@ static void springs_from_mesh(Object *ob) if (me->totvert) { bp = ob->soft->bpoint; for (a = 0; a < me->totvert; a++, bp++) { - copy_v3_v3(bp->origS, vertices[a].co); + copy_v3_v3(bp->origS, verts[a].co); mul_m4_v3(ob->obmat, bp->origS); } } @@ -2755,15 +2755,15 @@ static void mesh_faces_to_scratch(Object *ob) MLoopTri *looptri, *lt; BodyFace *bodyface; int a; - const MVert *vertices = BKE_mesh_verts(me); - const MPoly *polygons = BKE_mesh_polys(me); + const MVert *verts = BKE_mesh_verts(me); + const MPoly *polys = BKE_mesh_polys(me); const MLoop *loops = BKE_mesh_loops(me); /* Allocate and copy faces. */ sb->scratch->totface = poly_to_tri_count(me->totpoly, me->totloop); looptri = lt = MEM_mallocN(sizeof(*looptri) * sb->scratch->totface, __func__); - BKE_mesh_recalc_looptri(loops, polygons, vertices, me->totloop, me->totpoly, looptri); + BKE_mesh_recalc_looptri(loops, polys, verts, me->totloop, me->totpoly, looptri); bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace) * sb->scratch->totface, "SB_body_Faces"); |