Bevel mod: cleanup flags and extra data.
[blender.git] / source / blender / editors / sculpt_paint / sculpt.c
index 29e1950efc981a9b0181184a8f523c943401a6fa..f3b0b32c8d5e0fd1c575ca435873e0e610fe9d0c 100644 (file)
@@ -18,8 +18,8 @@
  * Implements the Sculpt Mode tools
  */
 
-/** \file blender/editors/sculpt_paint/sculpt.c
- *  \ingroup edsculpt
+/** \file
+ * \ingroup edsculpt
  */
 
 
@@ -4095,7 +4095,7 @@ void sculpt_cache_calc_brushdata_symm(
        /* XXX This reduces the length of the grab delta if it approaches the line of symmetry
         * XXX However, a different approach appears to be needed */
 #if 0
-       if (sd->paint.symmetry_flags & SCULPT_SYMMETRY_FEATHER) {
+       if (sd->paint.symmetry_flags & PAINT_SYMMETRY_FEATHER) {
                float frac = 1.0f / max_overlap_count(sd);
                float reduce = (feather - frac) / (1 - frac);
 
@@ -4412,12 +4412,12 @@ static void sculpt_update_cache_invariants(
        else {
                max_scale = 0.0f;
                for (i = 0; i < 3; i ++) {
-                       max_scale = max_ff(max_scale, fabsf(ob->size[i]));
+                       max_scale = max_ff(max_scale, fabsf(ob->scale[i]));
                }
        }
-       cache->scale[0] = max_scale / ob->size[0];
-       cache->scale[1] = max_scale / ob->size[1];
-       cache->scale[2] = max_scale / ob->size[2];
+       cache->scale[0] = max_scale / ob->scale[0];
+       cache->scale[1] = max_scale / ob->scale[1];
+       cache->scale[2] = max_scale / ob->scale[2];
 
        cache->plane_trim_squared = brush->plane_trim * brush->plane_trim;
 
@@ -4566,7 +4566,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
        StrokeCache *cache = ss->cache;
        const float mouse[2] = {
                cache->mouse[0],
-               cache->mouse[1]
+               cache->mouse[1],
        };
        int tool = brush->sculpt_tool;
 
@@ -5046,11 +5046,11 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
 /* Copy the PBVH bounding box into the object's bounding box */
 void sculpt_update_object_bounding_box(Object *ob)
 {
-       if (ob->bb) {
+       if (ob->runtime.bb) {
                float bb_min[3], bb_max[3];
 
                BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max);
-               BKE_boundbox_init_from_minmax(ob->bb, bb_min, bb_max);
+               BKE_boundbox_init_from_minmax(ob->runtime.bb, bb_min, bb_max);
        }
 }
 
@@ -5157,7 +5157,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
        sculpt_restore_mesh(sd, ob);
 
        if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) {
-               float object_space_constant_detail = mat4_to_scale(ob->obmat) / sd->constant_detail;
+               float object_space_constant_detail = 1.0f / (sd->constant_detail * mat4_to_scale(ob->obmat));
                BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
        }
        else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
@@ -5846,7 +5846,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;
@@ -5881,7 +5881,7 @@ void ED_object_sculptmode_enter_ex(
                BKE_sculpt_mask_layers_ensure(ob, mmd);
        }
 
-       if (!(fabsf(ob->size[0] - ob->size[1]) < 1e-4f && fabsf(ob->size[1] - ob->size[2]) < 1e-4f)) {
+       if (!(fabsf(ob->scale[0] - ob->scale[1]) < 1e-4f && fabsf(ob->scale[1] - ob->scale[2]) < 1e-4f)) {
                BKE_report(reports, RPT_WARNING,
                           "Object has non-uniform scale, sculpting may be unpredictable");
        }
@@ -5927,7 +5927,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;
@@ -5960,7 +5960,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(
@@ -6042,7 +6042,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);
        }
 
@@ -6104,7 +6104,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
        size = max_fff(dim[0], dim[1], dim[2]);
 
        /* update topology size */
-       float object_space_constant_detail = mat4_to_scale(ob->obmat) / sd->constant_detail;
+       float object_space_constant_detail = 1.0f / (sd->constant_detail * mat4_to_scale(ob->obmat));
        BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
 
        sculpt_undo_push_begin("Dynamic topology flood fill");