Fix: CustomData layers become unsorted in versioning
n versioning, when converting CD_SCULPT_FACE_SETS to CD_PROP_INT32 the layers were not kept properly ordered by type. This was discovered while investigating T104053 Differential Revision: D17165
This commit is contained in:
@@ -1228,12 +1228,18 @@ void BKE_mesh_legacy_face_set_from_generic(Mesh *mesh,
|
|||||||
blender::MutableSpan<CustomDataLayer> poly_layers)
|
blender::MutableSpan<CustomDataLayer> poly_layers)
|
||||||
{
|
{
|
||||||
using namespace blender;
|
using namespace blender;
|
||||||
|
void *faceset_data = nullptr;
|
||||||
for (CustomDataLayer &layer : poly_layers) {
|
for (CustomDataLayer &layer : poly_layers) {
|
||||||
if (StringRef(layer.name) == ".sculpt_face_set") {
|
if (StringRef(layer.name) == ".sculpt_face_set") {
|
||||||
layer.type = CD_SCULPT_FACE_SETS;
|
faceset_data = layer.data;
|
||||||
|
layer.data = nullptr;
|
||||||
|
CustomData_free_layer_named(&mesh->pdata, ".sculpt_face_set", mesh->totpoly);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CustomData_update_typemap(&mesh->pdata);
|
if (faceset_data != nullptr) {
|
||||||
|
CustomData_add_layer(&mesh->pdata, CD_SCULPT_FACE_SETS, CD_ASSIGN, faceset_data, mesh->totpoly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
|
void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
|
||||||
@@ -1242,13 +1248,18 @@ void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
|
|||||||
if (mesh->attributes().contains(".sculpt_face_set")) {
|
if (mesh->attributes().contains(".sculpt_face_set")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (CustomDataLayer &layer : MutableSpan(mesh->pdata.layers, mesh->pdata.totlayer)) {
|
void *faceset_data = nullptr;
|
||||||
if (layer.type == CD_SCULPT_FACE_SETS) {
|
for (const int i : IndexRange(mesh->totpoly)) {
|
||||||
BLI_strncpy(layer.name, ".sculpt_face_set", sizeof(layer.name));
|
if (mesh->pdata.layers[i].type == CD_SCULPT_FACE_SETS) {
|
||||||
layer.type = CD_PROP_INT32;
|
faceset_data = mesh->pdata.layers[i].data;
|
||||||
|
mesh->pdata.layers[i].data = nullptr;
|
||||||
|
CustomData_free_layer(&mesh->pdata, CD_SCULPT_FACE_SETS, mesh->totpoly, i);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CustomData_update_typemap(&mesh->pdata);
|
if (faceset_data != nullptr) {
|
||||||
|
CustomData_add_layer_named(&mesh->pdata, CD_PROP_INT32, CD_ASSIGN, faceset_data, mesh->totpoly, ".sculpt_face_set");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|||||||
Reference in New Issue
Block a user