diff options
author | Bastien Montagne <bastien@blender.org> | 2021-02-05 00:03:39 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-02-05 00:03:39 +0300 |
commit | 94cf74afbb1329a9ff099e2ebd7f43ed8313f9ec (patch) | |
tree | 6859715425521345f93993ecdcf7182b060ac236 /source/blender/editors/sculpt_paint | |
parent | 7d5640ee101e6b9ddbd9f534539ae939f68bfd9b (diff) |
Cleanup/refactor: Undosys: Get rid of the magic values for undo direction.
Move `eUndoStepDir` to `BKE_undo_system.h` and use its values
everywhere.
Note that this also introduce the `STEP_INVALID` value in that enum.
Finally, kept the matching struct members in some lower-level readfile
code as an `int` to avoid having to include `BKE_undo_system.h` in a lot
of unrelated files.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_curve_undo.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.c b/source/blender/editors/sculpt_paint/paint_curve_undo.c index a8e22f66734..dbe522bf304 100644 --- a/source/blender/editors/sculpt_paint/paint_curve_undo.c +++ b/source/blender/editors/sculpt_paint/paint_curve_undo.c @@ -126,7 +126,7 @@ static bool paintcurve_undosys_step_encode(struct bContext *C, static void paintcurve_undosys_step_decode(struct bContext *UNUSED(C), struct Main *UNUSED(bmain), UndoStep *us_p, - int UNUSED(dir), + const eUndoStepDir UNUSED(dir), bool UNUSED(is_final)) { PaintCurveUndoStep *us = (PaintCurveUndoStep *)us_p; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 938080b392d..ec103bd2b98 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -1527,9 +1527,14 @@ 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, int dir, bool UNUSED(is_final)) +static void sculpt_undosys_step_decode(struct bContext *C, + struct Main *bmain, + UndoStep *us_p, + const eUndoStepDir dir, + bool UNUSED(is_final)) { + BLI_assert(dir != STEP_INVALID); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* Ensure sculpt mode. */ @@ -1568,10 +1573,10 @@ static void sculpt_undosys_step_decode( } SculptUndoStep *us = (SculptUndoStep *)us_p; - if (dir < 0) { + if (dir == STEP_UNDO) { sculpt_undosys_step_decode_undo(C, depsgraph, us); } - else { + else if (dir == STEP_REDO) { sculpt_undosys_step_decode_redo(C, depsgraph, us); } } |