diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-13 19:43:34 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-13 19:43:34 +0300 |
commit | 08a8de739d8c7fa60f257ed171d292879edae013 (patch) | |
tree | 178b714da521826998f56bc15acb4c4019820b2e /source/blender/blenkernel/intern/mesh_legacy_convert.cc | |
parent | eaf416693dcb431ec122fc559788e6c930038c23 (diff) |
Fix: Resolve deprecation warning when copying polygon struct
`MPoly` is used and copied in many places. To avoid the need to use a
special function for copying MPoly, or the need to add a copy
constructor, just rename the `mat_nr` field to include "legacy" in the
name. This keeps the original purpose of notifying developers that
the field shouldn't be used without any further complexity.
Apply the same fix to `bweight`.
Differential Revision: https://developer.blender.org/D15841
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_legacy_convert.cc')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_legacy_convert.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 10fc8ff3195..627c0057a28 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -929,13 +929,13 @@ void BKE_mesh_legacy_bevel_weight_from_layers(Mesh *mesh) CustomData_get_layer(&mesh->vdata, CD_BWEIGHT))) { mesh->cd_flag |= ME_CDFLAG_VERT_BWEIGHT; for (const int i : verts.index_range()) { - verts[i].bweight = std::clamp(weights[i], 0.0f, 1.0f) * 255.0f; + verts[i].bweight_legacy = std::clamp(weights[i], 0.0f, 1.0f) * 255.0f; } } else { mesh->cd_flag &= ~ME_CDFLAG_VERT_BWEIGHT; for (const int i : verts.index_range()) { - verts[i].bweight = 0; + verts[i].bweight_legacy = 0; } } MutableSpan<MEdge> edges = mesh->edges_for_write(); @@ -943,13 +943,13 @@ void BKE_mesh_legacy_bevel_weight_from_layers(Mesh *mesh) CustomData_get_layer(&mesh->edata, CD_BWEIGHT))) { mesh->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT; for (const int i : edges.index_range()) { - edges[i].bweight = std::clamp(weights[i], 0.0f, 1.0f) * 255.0f; + edges[i].bweight_legacy = std::clamp(weights[i], 0.0f, 1.0f) * 255.0f; } } else { mesh->cd_flag &= ~ME_CDFLAG_EDGE_BWEIGHT; for (const int i : edges.index_range()) { - edges[i].bweight = 0; + edges[i].bweight_legacy = 0; } } } @@ -962,7 +962,7 @@ void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh) float *weights = static_cast<float *>( CustomData_add_layer(&mesh->vdata, CD_BWEIGHT, CD_CONSTRUCT, nullptr, verts.size())); for (const int i : verts.index_range()) { - weights[i] = verts[i].bweight / 255.0f; + weights[i] = verts[i].bweight_legacy / 255.0f; } } @@ -971,7 +971,7 @@ void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh) float *weights = static_cast<float *>( CustomData_add_layer(&mesh->edata, CD_BWEIGHT, CD_CONSTRUCT, nullptr, edges.size())); for (const int i : edges.index_range()) { - weights[i] = edges[i].bweight / 255.0f; + weights[i] = edges[i].bweight_legacy / 255.0f; } } } @@ -1077,7 +1077,7 @@ void BKE_mesh_legacy_convert_material_indices_to_mpoly(Mesh *mesh) "material_index", ATTR_DOMAIN_FACE, 0); threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) { for (const int i : range) { - polys[i].mat_nr = material_indices[i]; + polys[i].mat_nr_legacy = material_indices[i]; } }); } @@ -1089,12 +1089,12 @@ void BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *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; })) { + polys.begin(), polys.end(), [](const MPoly &poly) { return poly.mat_nr_legacy != 0; })) { SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>( "material_index", ATTR_DOMAIN_FACE); threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) { for (const int i : range) { - material_indices.span[i] = polys[i].mat_nr; + material_indices.span[i] = polys[i].mat_nr_legacy; } }); material_indices.finish(); |