diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-10-01 01:35:11 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-10-01 01:35:11 +0300 |
commit | 81f15a51aa7891c16579d004eac446ec4e7866be (patch) | |
tree | 90b8d8b6422f9b91b13b448720586379f863dce4 /source/blender/editors/sculpt_paint | |
parent | 991a35b844bc3b9366551ec23d3a38ee614c1048 (diff) |
Sculpt: Fix sculpt face set undo creating duplicate face set layers
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 04c60933c73..ee9ae6a898b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -486,8 +486,13 @@ static bool sculpt_undo_restore_face_sets(bContext *C, SculptUndoNode *unode) BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); Mesh *me = BKE_object_get_original_mesh(ob); - int *face_sets = CustomData_add_layer_named( - &me->pdata, CD_PROP_INT32, CD_CONSTRUCT, NULL, me->totpoly, ".sculpt_face_set"); + + int *face_sets = CustomData_get_layer_named(&me->pdata, CD_PROP_INT32, ".sculpt_face_set"); + if (!face_sets) { + face_sets = CustomData_add_layer_named( + &me->pdata, CD_PROP_INT32, CD_CONSTRUCT, NULL, me->totpoly, ".sculpt_face_set"); + } + for (int i = 0; i < me->totpoly; i++) { SWAP(int, face_sets[i], unode->face_sets[i]); } |