diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-04-01 02:03:20 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-04-01 02:07:47 +0300 |
commit | da3cb514e52de922148534c660a0b04ee5c43eeb (patch) | |
tree | 82d81dd0be84454a05984fdda9caa79c3b1c2262 /source/blender/editors/sculpt_paint/sculpt_undo.c | |
parent | 0062813c731ff2a0866d86a2b0558c67b8091f37 (diff) |
Multires: Initial Face Sets support
This implements the Sculpt Mode API functions needed for Face Sets and
visibility management for PBVH_GRIDS. No major changes were needed in
the operators and the sculpt mode code. This implementation stores the
face sets in the base mesh, so faces created in higher subdivision
levels can't be modified individually. Also, we are not checking for
multiple face sets per vertex (that can be added in the future), so
relax tools don't work yet. The rest of the features (paint, undo,
visibility operators..) work as expected.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D7168
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index af404c64fb0..5233ce8d257 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -48,6 +48,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_multires.h" +#include "BKE_object.h" #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subdiv_ccg.h" @@ -335,8 +336,11 @@ static bool sculpt_undo_restore_face_sets(bContext *C, SculptUndoNode *unode) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - SculptSession *ss = ob->sculpt; - memcpy(ss->face_sets, unode->face_sets, ss->totpoly * sizeof(int)); + Mesh *me = BKE_object_get_original_mesh(ob); + int *face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); + for (int i = 0; i < me->totpoly; i++) { + face_sets[i] = unode->face_sets[i]; + } return false; } @@ -542,7 +546,6 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase return; } else if (unode->type == SCULPT_UNDO_FACE_SETS) { - sculpt_undo_restore_face_sets(C, unode); rebuild = true; @@ -551,14 +554,15 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase BKE_sculpt_update_object_for_edit(depsgraph, ob, true, need_mask); SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { BKE_mesh_flush_hidden_from_verts(ob->data); } + DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { - DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } @@ -983,8 +987,6 @@ static SculptUndoNode *sculpt_undo_geometry_push(Object *ob, SculptUndoType type static SculptUndoNode *sculpt_undo_face_sets_push(Object *ob, SculptUndoType type) { UndoSculpt *usculpt = sculpt_undo_get_nodes(); - SculptSession *ss = ob->sculpt; - SculptUndoNode *unode = usculpt->nodes.first; unode = MEM_callocN(sizeof(*unode), __func__); @@ -993,8 +995,14 @@ static SculptUndoNode *sculpt_undo_face_sets_push(Object *ob, SculptUndoType typ unode->type = type; unode->applied = true; - unode->face_sets = MEM_callocN(ss->totpoly * sizeof(int), "sculpt face sets"); - memcpy(unode->face_sets, ss->face_sets, ss->totpoly * sizeof(int)); + Mesh *me = BKE_object_get_original_mesh(ob); + + unode->face_sets = MEM_callocN(me->totpoly * sizeof(int), "sculpt face sets"); + + int *face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); + for (int i = 0; i < me->totpoly; i++) { + unode->face_sets[i] = face_sets[i]; + } BLI_addtail(&usculpt->nodes, unode); |