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/mesh_legacy_convert.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/mesh_legacy_convert.cc')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_legacy_convert.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 627c0057a28..efbea35bfcf 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -918,6 +918,33 @@ void BKE_mesh_add_mface_layers(CustomData *fdata, CustomData *ldata, int total) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Face Set Conversion + * \{ */ + +void BKE_mesh_legacy_face_set_from_generic(Mesh *mesh) +{ + using namespace blender; + for (CustomDataLayer &layer : MutableSpan(mesh->pdata.layers, mesh->pdata.totlayer)) { + if (StringRef(layer.name) == ".sculpt_face_set") { + layer.type = CD_SCULPT_FACE_SETS; + } + } +} + +void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh) +{ + using namespace blender; + for (CustomDataLayer &layer : MutableSpan(mesh->pdata.layers, mesh->pdata.totlayer)) { + if (layer.type == CD_SCULPT_FACE_SETS) { + BLI_strncpy(layer.name, ".sculpt_face_set", sizeof(layer.name)); + layer.type = CD_PROP_INT32; + } + } +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Bevel Weight Conversion * \{ */ |