diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-23 16:19:40 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-23 16:19:40 +0300 |
commit | 060a5341419412fd7996cf99a56db1f581a4c30c (patch) | |
tree | 59413121aaf62bedc794822ea8d1c4d2c55e9088 /source/blender/blenkernel/intern/paint.cc | |
parent | 35375380d73b93999b879164fd59266ee044472c (diff) |
Mesh: Move sculpt face sets to a generic attribute
Similar to the other refactors from T95965, this commit moves sculpt
face sets to use a generic integer attribute named `".sculpt_face_set"`.
This makes face sets accessible in the Python API.
The attribute is not visible in the attributes list or the spreadsheet
because it is meant for internal use, though that could be an option
in the future along with other similar attributes. Currently the change
is small, but in the future this could simplify code by allowing use
of more generic attribute APIs.
Differential Revision: https://developer.blender.org/D16045
Diffstat (limited to 'source/blender/blenkernel/intern/paint.cc')
-rw-r--r-- | source/blender/blenkernel/intern/paint.cc | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 0181c6e7eac..7475d2b5144 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1739,7 +1739,8 @@ static void sculpt_update_object( /* Sculpt Face Sets. */ if (use_face_sets) { - ss->face_sets = static_cast<int *>(CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS)); + ss->face_sets = static_cast<int *>( + CustomData_get_layer_named(&me->pdata, CD_PROP_INT32, ".sculpt_face_set")); } else { ss->face_sets = nullptr; @@ -1966,22 +1967,17 @@ int *BKE_sculpt_face_sets_ensure(Mesh *mesh) { using namespace blender; using namespace blender::bke; - if (CustomData_has_layer(&mesh->pdata, CD_SCULPT_FACE_SETS)) { - return static_cast<int *>(CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS)); + MutableAttributeAccessor attributes = mesh->attributes_for_write(); + if (!attributes.contains(".sculpt_face_set")) { + SpanAttributeWriter<int> face_sets = attributes.lookup_or_add_for_write_only_span<int>( + ".sculpt_face_set", ATTR_DOMAIN_FACE); + face_sets.span.fill(1); + mesh->face_sets_color_default = 1; + face_sets.finish(); } - const AttributeAccessor attributes = mesh->attributes_for_write(); - const VArray<bool> hide_poly = attributes.lookup_or_default<bool>( - ".hide_poly", ATTR_DOMAIN_FACE, false); - - MutableSpan<int> face_sets = { - static_cast<int *>(CustomData_add_layer( - &mesh->pdata, CD_SCULPT_FACE_SETS, CD_CONSTRUCT, nullptr, mesh->totpoly)), - mesh->totpoly}; - - face_sets.fill(1); - mesh->face_sets_color_default = 1; - return face_sets.data(); + return static_cast<int *>( + CustomData_get_layer_named(&mesh->pdata, CD_PROP_INT32, ".sculpt_face_set")); } bool *BKE_sculpt_hide_poly_ensure(Mesh *mesh) |