Fix invalid versioning code for meshes

The issue was introduced in d92edca8622: one shall not use
polygon index to index polygon custom data layer.
This commit is contained in:
Sergey Sharybin 2023-02-02 13:02:41 +01:00
parent 644d54a193
commit d77b87eb93
Notes: blender-bot 2023-02-14 11:28:39 +01:00
Referenced by issue #104299, Crash when opening file (customData)
1 changed files with 5 additions and 3 deletions

View File

@ -1238,7 +1238,8 @@ void BKE_mesh_legacy_face_set_from_generic(Mesh *mesh,
}
}
if (faceset_data != nullptr) {
CustomData_add_layer(&mesh->pdata, CD_SCULPT_FACE_SETS, CD_ASSIGN, faceset_data, mesh->totpoly);
CustomData_add_layer(
&mesh->pdata, CD_SCULPT_FACE_SETS, CD_ASSIGN, faceset_data, mesh->totpoly);
}
}
@ -1249,7 +1250,7 @@ void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
return;
}
void *faceset_data = nullptr;
for (const int i : IndexRange(mesh->totpoly)) {
for (const int i : IndexRange(mesh->pdata.totlayer)) {
if (mesh->pdata.layers[i].type == CD_SCULPT_FACE_SETS) {
faceset_data = mesh->pdata.layers[i].data;
mesh->pdata.layers[i].data = nullptr;
@ -1258,7 +1259,8 @@ void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
}
}
if (faceset_data != nullptr) {
CustomData_add_layer_named(&mesh->pdata, CD_PROP_INT32, CD_ASSIGN, faceset_data, mesh->totpoly, ".sculpt_face_set");
CustomData_add_layer_named(
&mesh->pdata, CD_PROP_INT32, CD_ASSIGN, faceset_data, mesh->totpoly, ".sculpt_face_set");
}
}