From f868d51bdd3ed56cbf4ec74846b54caa8fe1fa1d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Mar 2020 16:42:24 +0100 Subject: Sculpt Undo: Allow Geometry undo step to be non-exclusive Before this change it was not possible to have base geometry and grid coordinates to be stored in the same undo step. Differential Revision: https://developer.blender.org/D7298 --- source/blender/editors/sculpt_paint/sculpt_undo.c | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index cccc5e29ba7..f6ed4fa21e0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -622,12 +622,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase if (lb->first) { unode = lb->first; - if (unode->type == SCULPT_UNDO_GEOMETRY) { - sculpt_undo_geometry_restore(unode, ob); - BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); - return; - } - else if (unode->type == SCULPT_UNDO_FACE_SETS) { + if (unode->type == SCULPT_UNDO_FACE_SETS) { sculpt_undo_restore_face_sets(C, unode); rebuild = true; @@ -653,10 +648,18 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } } - BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); + if (lb->first != NULL) { + /* Only do early object update for edits if first node needs this. + * Undo steps like geometry does not need object to be updated before they run and will + * ensure object is updated after the node is handled. */ + const SculptUndoNode *first_unode = (const SculptUndoNode *)lb->first; + if (first_unode->type != SCULPT_UNDO_GEOMETRY) { + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); + } - if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) { - return; + if (sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) { + return; + } } char *undo_modified_grids = NULL; @@ -705,13 +708,16 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase case SCULPT_UNDO_FACE_SETS: break; + case SCULPT_UNDO_GEOMETRY: + sculpt_undo_geometry_restore(unode, ob); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); + break; + case SCULPT_UNDO_DYNTOPO_BEGIN: case SCULPT_UNDO_DYNTOPO_END: case SCULPT_UNDO_DYNTOPO_SYMMETRIZE: BLI_assert(!"Dynamic topology should've already been handled"); break; - case SCULPT_UNDO_GEOMETRY: - break; } } -- cgit v1.2.3