diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-07 05:22:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-07 05:29:59 +0300 |
commit | d6c0f3796a3dd6d9fb6996e1e7d12633f982e560 (patch) | |
tree | 29c8ab95d46433be39d308f3740abbf365a1477e /source/blender/editors/sculpt_paint | |
parent | a5869c367e660b52f0b90f89b2405944db434156 (diff) |
Fix T61049: Undo dynamic topology sculpt asserts
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index d8a85c33e55..1b8e6da6ee3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -48,6 +48,7 @@ #include "BKE_key.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" +#include "BKE_scene.h" #include "BKE_subsurf.h" #include "BKE_subdiv_ccg.h" #include "BKE_undo_system.h" @@ -1098,11 +1099,35 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep * } } -static void sculpt_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int dir) +static void sculpt_undosys_step_decode(struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir) { - /* TODO(campbell): undo_system: use low-level API to set mode. */ - ED_object_mode_set(C, OB_MODE_SCULPT); - BLI_assert(sculpt_undosys_poll(C)); + /* Ensure sculpt mode. */ + { + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + /* Sculpt needs evaluated state. */ + BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); + Object *ob = OBACT(view_layer); + if (ob && (ob->type == OB_MESH)) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); + if (ob->mode & OB_MODE_SCULPT) { + /* pass */ + } + else { + ED_object_mode_generic_exit(bmain, depsgraph, scene, ob); + Mesh *me = ob->data; + /* Don't add sculpt topology undo steps when reading back undo state. + * The undo steps must enter/exit for us. */ + me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; + ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, NULL); + } + BLI_assert(sculpt_undosys_poll(C)); + } + else { + BLI_assert(0); + return; + } + } SculptUndoStep *us = (SculptUndoStep *)us_p; if (dir < 0) { |