Comments: notes on sculpt/image undo looping logic

This commit is contained in:
Campbell Barton 2021-03-15 23:29:33 +11:00
parent 14863b3d4d
commit ab6e67767e
Notes: blender-bot 2023-02-14 02:27:51 +01:00
Referenced by issue #83806, Undo - Current Status and Important Fixes Needed
2 changed files with 8 additions and 1 deletions

View File

@ -1490,6 +1490,8 @@ static void sculpt_undosys_step_decode_undo(struct bContext *C,
SculptUndoStep *us,
const bool is_final)
{
/* Walk forward over any applied steps of same type,
* then walk back in the next loop, un-applying them. */
SculptUndoStep *us_iter = us;
while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) {
if (us_iter->step.next->is_applied == false) {
@ -1499,6 +1501,7 @@ static void sculpt_undosys_step_decode_undo(struct bContext *C,
}
while ((us_iter != us) || (!is_final && us_iter == us)) {
BLI_assert(us_iter->step.type == us->step.type); /* Previous loop ensures this. */
sculpt_undosys_step_decode_undo_impl(C, depsgraph, us_iter);
if (us_iter == us) {
break;
@ -1530,6 +1533,7 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C,
static void sculpt_undosys_step_decode(
struct bContext *C, struct Main *bmain, UndoStep *us_p, const eUndoStepDir dir, bool is_final)
{
/* NOTE: behavior for undo/redo closely matches image undo. */
BLI_assert(dir != STEP_INVALID);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);

View File

@ -911,6 +911,8 @@ static void image_undosys_step_decode_redo_impl(ImageUndoStep *us)
static void image_undosys_step_decode_undo(ImageUndoStep *us, bool is_final)
{
/* Walk forward over any applied steps of same type,
* then walk back in the next loop, un-applying them. */
ImageUndoStep *us_iter = us;
while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) {
if (us_iter->step.next->is_applied == false) {
@ -919,7 +921,7 @@ static void image_undosys_step_decode_undo(ImageUndoStep *us, bool is_final)
us_iter = (ImageUndoStep *)us_iter->step.next;
}
while (us_iter != us || (!is_final && us_iter == us)) {
BLI_assert(us_iter->step.type == us->step.type); /* Previous loop ensures this. */
image_undosys_step_decode_undo_impl(us_iter, is_final);
if (us_iter == us) {
break;
@ -949,6 +951,7 @@ static void image_undosys_step_decode_redo(ImageUndoStep *us)
static void image_undosys_step_decode(
struct bContext *C, struct Main *bmain, UndoStep *us_p, const eUndoStepDir dir, bool is_final)
{
/* NOTE: behavior for undo/redo closely matches sculpt undo. */
BLI_assert(dir != STEP_INVALID);
ImageUndoStep *us = (ImageUndoStep *)us_p;