diff options
author | Bastien Montagne <bastien@blender.org> | 2020-11-12 12:41:33 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-11-12 12:47:50 +0300 |
commit | bc090387ace9cf041455fa01e68d61551c47e18f (patch) | |
tree | 20aa9a855f24aefd1d2a43bff476e15669a0d4c8 /source/blender/editors/sculpt_paint/sculpt_undo.c | |
parent | fb4113defb46cf7ae0409336a714eb1a79cd6817 (diff) |
Fix T82388: Sculpt mode: Unexpected undo behavior.
Issue exposed by rB4c7b1766a7f1.
Main idea is that non-memfile first undo step should check into previous
memfile and tag the ID it is editing as `future_changed`.
That way, when we go back and undo to the memfile, said IDs are properly
detected as changed and re-read from the memfile.
Otherwise, undo system sees them as unchanged, and just re-use the
current data instead.
Note that currently only Sculpt mode seems affected (probably because it
is storing the mode switch itself as a Sculpt undo step instead of a
memfile one), but similar action might be needed in some other cases
too.
Maniphest Tasks: T82388
Differential Revision: https://developer.blender.org/D9510
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index f4f30c903aa..af2aad14008 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -1334,10 +1334,17 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType return unode; } -void SCULPT_undo_push_begin(const char *name) +void SCULPT_undo_push_begin(Object *ob, const char *name) { UndoStack *ustack = ED_undo_stack_get(); + if (ob != NULL) { + /* If possible, we need to tag the object and its geometry data as 'changed in the future' in + * the previous undo step if it's a memfile one. */ + ED_undosys_stack_memfile_id_changed_tag(ustack, &ob->id); + ED_undosys_stack_memfile_id_changed_tag(ustack, ob->data); + } + /* Special case, we never read from this. */ bContext *C = NULL; @@ -1525,7 +1532,7 @@ static void sculpt_undosys_step_free(UndoStep *us_p) void ED_sculpt_undo_geometry_begin(struct Object *ob, const char *name) { - SCULPT_undo_push_begin(name); + SCULPT_undo_push_begin(ob, name); SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_GEOMETRY); } @@ -1638,7 +1645,7 @@ void ED_sculpt_undo_push_multires_mesh_begin(bContext *C, const char *str) Object *object = CTX_data_active_object(C); - SCULPT_undo_push_begin(str); + SCULPT_undo_push_begin(object, str); SculptUndoNode *geometry_unode = SCULPT_undo_push_node(object, NULL, SCULPT_UNDO_GEOMETRY); geometry_unode->geometry_clear_pbvh = false; |