Fix sculpt undo steps not enabling dyntopo
authorCampbell Barton <ideasman42@gmail.com>
Thu, 7 Feb 2019 06:54:53 +0000 (17:54 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 7 Feb 2019 09:28:33 +0000 (20:28 +1100)
Logic to disable dyntopo when entering sculpt mode was applied on undo.

source/blender/editors/include/ED_object.h
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sculpt_paint/sculpt_undo.c
source/blender/editors/util/ed_util.c

index 8c6b8a97b792d1d6370db257797eeb0551919af8..612adec18603c4cf362164d40c85e9f465f683ec 100644 (file)
@@ -151,7 +151,7 @@ void ED_object_wpaintmode_exit(struct bContext *C);
 
 void ED_object_sculptmode_enter_ex(
         struct Main *bmain, struct Depsgraph *depsgraph,
-        struct Scene *scene, struct Object *ob,
+        struct Scene *scene, struct Object *ob, const bool force_dyntopo,
         struct ReportList *reports);
 void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports);
 void ED_object_sculptmode_exit_ex(
index 6512e279a15ac1b261f3190369f7569cdaac1b18..b994a688f8696053dd2250919541207f2ac6693b 100644 (file)
@@ -5845,7 +5845,7 @@ static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, Object *ob, Mult
 
 void ED_object_sculptmode_enter_ex(
         Main *bmain, Depsgraph *depsgraph,
-        Scene *scene, Object *ob,
+        Scene *scene, Object *ob, const bool force_dyntopo,
         ReportList *reports)
 {
        const int mode_flag = OB_MODE_SCULPT;
@@ -5926,7 +5926,7 @@ void ED_object_sculptmode_enter_ex(
                        }
                }
 
-               if (message_unsupported == NULL) {
+               if ((message_unsupported == NULL) || force_dyntopo) {
                        /* Needed because we may be entering this mode before the undo system loads. */
                        wmWindowManager *wm = bmain->wm.first;
                        bool has_undo = wm->undo_stack != NULL;
@@ -5959,7 +5959,7 @@ void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports)
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Object *ob = OBACT(view_layer);
        Depsgraph *depsgraph = CTX_data_depsgraph(C);
-       ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, reports);
+       ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, false, reports);
 }
 
 void ED_object_sculptmode_exit_ex(
@@ -6041,7 +6041,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
                ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
        }
        else {
-               ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, op->reports);
+               ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, false, op->reports);
                BKE_paint_toolslots_brush_validate(bmain, &ts->sculpt->paint);
        }
 
index 1b8e6da6ee3ef4173be44d1e51328c0a052da949..67b815ee7d64d4fc4a57e998fa2270ad125fe93c 100644 (file)
@@ -1119,7 +1119,7 @@ static void sculpt_undosys_step_decode(struct bContext *C, struct Main *bmain, U
                                /* 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);
+                               ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, true, NULL);
                        }
                        BLI_assert(sculpt_undosys_poll(C));
                }
index 0e3158c6d4420f33a3318f377fbd6a4bea06fc16..16b85f532701dbb22ae2a777d6948723a29f085e 100644 (file)
@@ -146,7 +146,7 @@ void ED_editors_init(bContext *C)
                                else if (mode & OB_MODE_ALL_SCULPT) {
                                        if (obact == ob) {
                                                if (mode == OB_MODE_SCULPT) {
-                                                       ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, reports);
+                                                       ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, true, reports);
                                                }
                                                else if (mode == OB_MODE_VERTEX_PAINT) {
                                                        ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);