[Bf-blender-cvs] [2bc444763b9] temp-lineart-contained: Fix T82532: Sculpt fails to redo the first sculpt session stroke

Campbell Barton noreply at git.blender.org
Sat Mar 13 02:01:01 CET 2021


Commit: 2bc444763b9a8643f6c07fc78ea806a1c34a7343
Author: Campbell Barton
Date:   Sat Mar 13 01:25:34 2021 +1100
Branches: temp-lineart-contained
https://developer.blender.org/rB2bc444763b9a8643f6c07fc78ea806a1c34a7343

Fix T82532: Sculpt fails to redo the first sculpt session stroke

Sculpt undo relied on having a mode-changing undo step to properly
apply changes.

However this isn't the case with startup files or when mixing
global undo steps with sculpt (see T82851, also fixed).

Undo stepping logic follows image_undosys_step_decode_undo.

===================================================================

M	source/blender/editors/sculpt_paint/sculpt_undo.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index ec103bd2b98..b1e71a27dfc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1492,7 +1492,8 @@ static void sculpt_undosys_step_decode_redo_impl(struct bContext *C,
 
 static void sculpt_undosys_step_decode_undo(struct bContext *C,
                                             Depsgraph *depsgraph,
-                                            SculptUndoStep *us)
+                                            SculptUndoStep *us,
+                                            const bool is_final)
 {
   SculptUndoStep *us_iter = us;
   while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) {
@@ -1501,8 +1502,12 @@ static void sculpt_undosys_step_decode_undo(struct bContext *C,
     }
     us_iter = (SculptUndoStep *)us_iter->step.next;
   }
-  while (us_iter != us) {
+
+  while ((us_iter != us) || (!is_final && us_iter == us)) {
     sculpt_undosys_step_decode_undo_impl(C, depsgraph, us_iter);
+    if (us_iter == us) {
+      break;
+    }
     us_iter = (SculptUndoStep *)us_iter->step.prev;
   }
 }
@@ -1527,11 +1532,8 @@ 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 UNUSED(is_final))
+static void sculpt_undosys_step_decode(
+    struct bContext *C, struct Main *bmain, UndoStep *us_p, const eUndoStepDir dir, bool is_final)
 {
   BLI_assert(dir != STEP_INVALID);
 
@@ -1574,7 +1576,7 @@ static void sculpt_undosys_step_decode(struct bContext *C,
 
   SculptUndoStep *us = (SculptUndoStep *)us_p;
   if (dir == STEP_UNDO) {
-    sculpt_undosys_step_decode_undo(C, depsgraph, us);
+    sculpt_undosys_step_decode_undo(C, depsgraph, us, is_final);
   }
   else if (dir == STEP_REDO) {
     sculpt_undosys_step_decode_redo(C, depsgraph, us);



More information about the Bf-blender-cvs mailing list