Fix sculpt undo steps not enabling dyntopo
[blender.git] / source / blender / editors / sculpt_paint / sculpt.c
index 29e1950efc981a9b0181184a8f523c943401a6fa..b994a688f8696053dd2250919541207f2ac6693b 100644 (file)
@@ -18,8 +18,7 @@
  * Implements the Sculpt Mode tools
  */
 
  * Implements the Sculpt Mode tools
  */
 
-/** \file blender/editors/sculpt_paint/sculpt.c
- *  \ingroup edsculpt
+/** \file \ingroup edsculpt
  */
 
 
  */
 
 
@@ -4566,7 +4565,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
        StrokeCache *cache = ss->cache;
        const float mouse[2] = {
                cache->mouse[0],
        StrokeCache *cache = ss->cache;
        const float mouse[2] = {
                cache->mouse[0],
-               cache->mouse[1]
+               cache->mouse[1],
        };
        int tool = brush->sculpt_tool;
 
        };
        int tool = brush->sculpt_tool;
 
@@ -5846,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,
 
 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;
         ReportList *reports)
 {
        const int mode_flag = OB_MODE_SCULPT;
@@ -5927,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;
                        /* 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;
@@ -5960,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);
        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(
 }
 
 void ED_object_sculptmode_exit_ex(
@@ -6042,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_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);
        }
 
                BKE_paint_toolslots_brush_validate(bmain, &ts->sculpt->paint);
        }