diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index b819fe8e97d..2872ad4fb9c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -58,6 +58,7 @@ #include "BKE_paint.h" #include "BKE_key.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_subsurf.h" #include "BKE_undo_system.h" @@ -144,7 +145,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN SculptSession *ss = ob->sculpt; MVert *mvert; int *index; - + if (unode->maxvert) { /* regular mesh restore */ @@ -157,7 +158,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN if (kb) { ob->shapenr = BLI_findindex(&key->block, kb) + 1; - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, 0, false); + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false); WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob); } else { @@ -197,7 +198,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN /* pbvh uses it's own mvert array, so coords should be */ /* propagated to pbvh here */ - BKE_pbvh_apply_vertCos(ss->pbvh, vertCos); + BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, unode->totvert); MEM_freeN(vertCos); } @@ -261,7 +262,7 @@ static bool sculpt_undo_restore_hidden( if (unode->maxvert) { MVert *mvert = ss->mvert; - + for (i = 0; i < unode->totvert; i++) { MVert *v = &mvert[unode->index[i]]; if ((BLI_BITMAP_TEST(unode->vert_hidden, i) != 0) != ((v->flag & ME_HIDE) != 0)) { @@ -273,12 +274,12 @@ static bool sculpt_undo_restore_hidden( } else if (unode->maxgrid && dm->getGridData) { BLI_bitmap **grid_hidden = dm->getGridHidden(dm); - + for (i = 0; i < unode->totgrid; i++) { SWAP(BLI_bitmap *, unode->grid_hidden[i], grid_hidden[unode->grids[i]]); - + } } @@ -292,7 +293,7 @@ static bool sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNod MVert *mvert; float *vmask; int *index, i, j; - + if (unode->maxvert) { /* regular mesh restore */ @@ -492,7 +493,9 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) } } - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, 0, need_mask); + DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); + + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask); /* call _after_ sculpt_update_mesh_elements() which may update 'ob->derivedFinal' */ dm = mesh_get_derived_final(depsgraph, scene, ob, 0); @@ -671,10 +674,10 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, NULL); - + unode->grid_hidden = MEM_mapallocN(sizeof(*unode->grid_hidden) * totgrid, "unode->grid_hidden"); - + for (i = 0; i < totgrid; i++) { if (grid_hidden[grid_indices[i]]) unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]); @@ -691,7 +694,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( SculptUndoNode *unode; SculptSession *ss = ob->sculpt; int totvert, allvert, totgrid, maxgrid, gridsize, *grids; - + unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode"); BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname)); unode->type = type; @@ -706,7 +709,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( } else maxgrid = 0; - + /* we will use this while sculpting, is mapalloc slow to access then? */ /* general TODO, fix count_alloc */ @@ -722,7 +725,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode); else unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden"); - + break; case SCULPT_UNDO_MASK: unode->mask = MEM_mapallocN(sizeof(float) * allvert, "SculptUndoNode.mask"); @@ -736,7 +739,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( BLI_assert(!"Dynamic topology should've already been handled"); break; } - + BLI_addtail(&usculpt->nodes, unode); if (maxgrid) { @@ -788,7 +791,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) const int *vert_indices; int allvert; int i; - + BKE_pbvh_node_num_verts(pbvh, node, NULL, &allvert); BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); for (i = 0; i < allvert; i++) { @@ -927,7 +930,7 @@ SculptUndoNode *sculpt_undo_push_node( } unode = sculpt_undo_alloc_node(ob, node, type); - + BLI_thread_unlock(LOCK_CUSTOM1); /* copy threaded, hopefully this is the performance critical part */ |