Fix T74637: Reset face set data when disabling dyntopo

Last time I checked Face Sets were preserved in a more or less
predictable way when modifying the mesh with dyntopo. As it looks that
in some problems this may cause bugs and you can't see or use face sets
when modifying the topology of the mesh whith dyntopo active, it is
probably better to reset them when going from dyntopo to mesh. This way
you know that you are always going to get a predictable face sets state.

Reviewed By: jbakker

Maniphest Tasks: T74637

Differential Revision: https://developer.blender.org/D7099
This commit is contained in:
Pablo Dobarro
2020-03-26 15:56:41 +01:00
parent 0db055338a
commit 7eacda5a2b

View File

@@ -8298,6 +8298,22 @@ static void sculpt_dynamic_topology_disable_ex(
}
else {
BKE_sculptsession_bm_to_me(ob, true);
/* Reset Face Sets as they are no longer valid. */
if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) {
CustomData_add_layer(&me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly);
}
ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS);
for (int i = 0; i < me->totpoly; i++) {
ss->face_sets[i] = 1;
}
me->face_sets_color_default = 1;
/* Sync the visibility to vertices manually as the pmap is still not initialized. */
for (int i = 0; i < me->totvert; i++) {
me->mvert[i].flag &= ~ME_HIDE;
me->mvert[i].flag |= ME_VERT_PBVH_UPDATE;
}
}
/* Clear data. */