diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index 078c93532d9..fb2e80fccf2 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -207,7 +207,24 @@ static void undosys_step_decode( } UNDO_NESTED_CHECK_BEGIN; - us->type->step_decode(C, bmain, us, dir, is_final); + if (dir < 0) { + if (us->type == BKE_UNDOSYS_TYPE_SCULPT) { + if (us->next && us->next->type == BKE_UNDOSYS_TYPE_SCULPT) { + us->next->type->step_decode(C, bmain, us->next, dir, is_final); + } + } + else if (us->type != BKE_UNDOSYS_TYPE_SCULPT && us->next && + us->next->type == BKE_UNDOSYS_TYPE_SCULPT) { + us->next->type->step_decode(C, bmain, us->next, dir, is_final); + us->type->step_decode(C, bmain, us, dir, is_final); + } + else { + us->type->step_decode(C, bmain, us, dir, is_final); + } + } + else { + us->type->step_decode(C, bmain, us, dir, is_final); + } UNDO_NESTED_CHECK_END; #ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER @@ -696,8 +713,8 @@ bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack, /* Handle accumulate steps. */ if (ustack->step_active) { - UndoStep *us_iter = ustack->step_active; - while (us_iter != us) { + UndoStep *us_iter = ustack->step_active->prev; + while (us_iter && us_iter != us) { /* TODO: * - skip successive steps that store the same data, eg: memfile steps. * - or steps that include another steps data, eg: a memfile step includes text undo data. diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 9677152cf7e..d837e7c5c5d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -1467,6 +1467,8 @@ static void sculpt_undosys_step_decode_undo(struct bContext *C, SculptUndoStep *us) { SculptUndoStep *us_iter = us; + sculpt_undosys_step_decode_undo_impl(C, depsgraph, us_iter); + return; while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { if (us_iter->step.next->is_applied == false) { break;