[Bf-blender-cvs] [73c590e1eb4] temp_bmesh_multires: Added detail_size to local dyntopo brush settings

Joseph Eagar noreply at git.blender.org
Tue Apr 20 15:34:52 CEST 2021


Commit: 73c590e1eb41f75b1d4b757ac546e372dd5ac3dd
Author: Joseph Eagar
Date:   Tue Apr 20 06:34:35 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB73c590e1eb41f75b1d4b757ac546e372dd5ac3dd

Added detail_size to local dyntopo brush settings

===================================================================

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/brush.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_pose.c
M	source/blender/makesdna/DNA_brush_defaults.h
M	source/blender/makesdna/DNA_brush_enums.h
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 8de62e27bee..6433277f40f 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -814,6 +814,7 @@ class VIEW3D_PT_sculpt_dyntopo_advanced(Panel, View3DPaintPanel):
         do_prop("collapse")
         do_prop("cleanup")
         do_prop("spacing")
+        do_prop("detail_size")
         do_prop("detail_range")
         do_prop("detail_percent")
         do_prop("constant_detail")
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 8388ac191b7..94e703bf9c5 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1953,7 +1953,9 @@ void BKE_brush_sculpt_reset(Brush *br)
       break;
 
     case SCULPT_TOOL_SIMPLIFY:
-      br->dyntopo.inherit = DYNTOPO_INHERIT_BITMASK &
+      //don't use DYNTOPO_INHERIT_BITMASK, we want to include
+      //future bits
+      br->dyntopo.inherit = 0x7FFFFFFF &
                             ~(DYNTOPO_INHERIT_ALL | DYNTOPO_SUBDIVIDE | DYNTOPO_COLLAPSE);
       br->dyntopo.flag |= DYNTOPO_COLLAPSE | DYNTOPO_SUBDIVIDE;
       br->autosmooth_factor = 0.02;
@@ -2615,12 +2617,15 @@ void BKE_brush_get_dyntopo(Brush *brush, Sculpt *sd, DynTopoSettings *out)
     brush->dyntopo = *out = brush2.dyntopo;
 
     brush_free_data((ID *)&brush2);
+  } else if (!out->detail_size) {
+    brush->dyntopo.inherit |= DYNTOPO_INHERIT_DETAIL_SIZE;
+    brush->dyntopo.detail_size = 12.0;
   }
 
   int inherit = out->inherit;
 
   if (inherit & DYNTOPO_INHERIT_ALL) {
-    inherit = 0x7FFFFFF;
+    inherit = 0x7FFFFFFF;
   }
 
   if (inherit & DYNTOPO_INHERIT_MODE) {
@@ -2638,6 +2643,10 @@ void BKE_brush_get_dyntopo(Brush *brush, Sculpt *sd, DynTopoSettings *out)
     }
   }
 
+  if (inherit & DYNTOPO_INHERIT_DETAIL_SIZE) {
+    out->detail_size = sd->detail_size;
+  }
+
   if (inherit & DYNTOPO_INHERIT_DETAIL_RANGE) {
     out->detail_range = sd->detail_range;
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 87e326fbf18..b5bc5fabab3 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -8590,7 +8590,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
   else {
     BKE_pbvh_bmesh_detail_size_set(ss->pbvh,
                                    (ss->cache->radius / ss->cache->dyntopo_pixel_radius) *
-                                       (sd->detail_size * U.pixelsize) / 0.4f,
+                                       (brush->cached_dyntopo.detail_size * U.pixelsize) / 0.4f,
                                    brush->cached_dyntopo.detail_range);
   }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c
index 3639709d4de..fdd1da824be 100644
--- a/source/blender/editors/sculpt_paint/sculpt_pose.c
+++ b/source/blender/editors/sculpt_paint/sculpt_pose.c
@@ -157,7 +157,7 @@ static void pose_solve_scale_chain(SculptPoseIKChain *ik_chain, const float scal
   }
 }
 
-static void do_pose_brush_task_cb_ex(void *__restrict userdata,
+ATTR_NO_OPT static void do_pose_brush_task_cb_ex(void *__restrict userdata,
                                      const int n,
                                      const TaskParallelTLS *__restrict UNUSED(tls))
 {
@@ -222,7 +222,7 @@ typedef struct PoseGrowFactorTLSData {
   int pos_count;
 } PoseGrowFactorTLSData;
 
-static void pose_brush_grow_factor_task_cb_ex(void *__restrict userdata,
+ATTR_NO_OPT static void pose_brush_grow_factor_task_cb_ex(void *__restrict userdata,
                                               const int n,
                                               const TaskParallelTLS *__restrict tls)
 {
@@ -255,7 +255,7 @@ static void pose_brush_grow_factor_task_cb_ex(void *__restrict userdata,
   BKE_pbvh_vertex_iter_end;
 }
 
-static void pose_brush_grow_factor_reduce(const void *__restrict UNUSED(userdata),
+ATTR_NO_OPT static void pose_brush_grow_factor_reduce(const void *__restrict UNUSED(userdata),
                                           void *__restrict chunk_join,
                                           void *__restrict chunk)
 {
@@ -267,7 +267,7 @@ static void pose_brush_grow_factor_reduce(const void *__restrict UNUSED(userdata
 
 /* Grow the factor until its boundary is near to the offset pose origin or outside the target
  * distance. */
-static void sculpt_pose_grow_pose_factor(Sculpt *sd,
+ATTR_NO_OPT static void sculpt_pose_grow_pose_factor(Sculpt *sd,
                                          Object *ob,
                                          SculptSession *ss,
                                          float pose_origin[3],
@@ -549,7 +549,7 @@ static bool pose_face_sets_floodfill_cb(
  * \param r_pose_origin: Must be a valid pointer.
  * \param r_pose_factor: Optional, when set to NULL it won't be calculated.
  */
-void SCULPT_pose_calc_pose_data(Sculpt *sd,
+ATTR_NO_OPT void SCULPT_pose_calc_pose_data(Sculpt *sd,
                                 Object *ob,
                                 SculptSession *ss,
                                 float initial_location[3],
@@ -635,7 +635,7 @@ static SculptPoseIKChain *pose_ik_chain_new(const int totsegments, const int tot
 }
 
 /* Init the origin/head pairs of all the segments from the calculated origins. */
-static void pose_ik_chain_origin_heads_init(SculptPoseIKChain *ik_chain,
+ATTR_NO_OPT static void pose_ik_chain_origin_heads_init(SculptPoseIKChain *ik_chain,
                                             const float initial_location[3])
 {
   float origin[3];
@@ -671,7 +671,7 @@ static int pose_brush_num_effective_segments(const Brush *brush)
   return brush->pose_ik_segments;
 }
 
-static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
+ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
                                                       Object *ob,
                                                       SculptSession *ss,
                                                       Brush *br,
@@ -753,7 +753,7 @@ static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
   return ik_chain;
 }
 
-static SculptPoseIKChain *pose_ik_chain_init_face_sets(
+ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_face_sets(
     Sculpt *sd, Object *ob, SculptSession *ss, Brush *br, const float radius)
 {
 
@@ -862,7 +862,7 @@ static bool pose_face_sets_fk_find_masked_floodfill_cb(
   return SCULPT_vertex_has_face_set(ss, to_vr, data->initial_face_set);
 }
 
-static bool pose_face_sets_fk_set_weights_floodfill_cb(
+ATTR_NO_OPT static bool pose_face_sets_fk_set_weights_floodfill_cb(
     SculptSession *ss, SculptVertRef UNUSED(from_v), SculptVertRef to_v, bool UNUSED(is_duplicate), void *userdata)
 {
   PoseFloodFillData *data = userdata;
@@ -870,7 +870,7 @@ static bool pose_face_sets_fk_set_weights_floodfill_cb(
   return !SCULPT_vertex_has_face_set(ss, to_v, data->masked_face_set);
 }
 
-static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
+ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
     Sculpt *sd, Object *ob, SculptSession *ss, const float radius, const float *initial_location)
 {
   const int totvert = SCULPT_vertex_count_get(ss);
diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h
index bb986cba79d..a99dc3f7e8e 100644
--- a/source/blender/makesdna/DNA_brush_defaults.h
+++ b/source/blender/makesdna/DNA_brush_defaults.h
@@ -111,7 +111,7 @@
  \
     .mtex = _DNA_DEFAULT_MTex, \
     .mask_mtex = _DNA_DEFAULT_MTex, \
-    .dyntopo = {0.4f, 25.0f, 3.0f, DYNTOPO_COLLAPSE|DYNTOPO_SUBDIVIDE, DYNTOPO_DETAIL_RELATIVE, DYNTOPO_INHERIT_ALL, 25},\
+    .dyntopo = {0.4f, 25.0f, 12.0f, 3.0f, DYNTOPO_COLLAPSE|DYNTOPO_SUBDIVIDE, DYNTOPO_DETAIL_RELATIVE, DYNTOPO_INHERIT_ALL, 25},\
     .concave_mask_factor = 0.75f\
   }
 
diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h
index 2df757dbf2d..4031f42d2ea 100644
--- a/source/blender/makesdna/DNA_brush_enums.h
+++ b/source/blender/makesdna/DNA_brush_enums.h
@@ -631,12 +631,13 @@ enum {
   DYNTOPO_INHERIT_DETAIL_PERCENT = 1<<12,
   DYNTOPO_INHERIT_MODE = 1<<13,
   DYNTOPO_INHERIT_CONSTANT_DETAIL = 1<<14,
-  DYNTOPO_INHERIT_SPACING = 1<<15
+  DYNTOPO_INHERIT_SPACING = 1<<15,
+  DYNTOPO_INHERIT_DETAIL_SIZE = 1<<16
   //make sure to update DYNTOPO_INHERIT_BITMASK when adding flags here
 };
 
 //represents all possible inherit flags
-#define DYNTOPO_INHERIT_BITMASK ((1<<16)-1)
+#define DYNTOPO_INHERIT_BITMASK ((1<<17)-1)
 
 //dyntopo mode
 enum {
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 2ec827cc2ba..2993ec9a4f8 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -153,10 +153,12 @@ typedef struct BrushGpencilSettings {
 typedef struct DynTopoSettings {
   float detail_range;
   float detail_percent;
+  float detail_size;
   float constant_detail;
   short flag, mode;
   int inherit;
   int spacing;
+  int _pad[1];
 } DynTopoSettings;
 
 typedef struct Brush {
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 367c74c3964..53557f28c48 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -369,6 +369,7 @@ static EnumPropertyItem rna_enum_brush_dyntopo_inherit[] = {
     {DYNTOPO_INHERIT_CONSTANT_DETAIL, "CONSTANT_DETAIL", ICON_NONE, "Constant Detail", ""},
     {DYNTOPO_INHERIT_SPACING, "SPACING", ICON_NONE, "Spacing", ""},
     {DYNTOPO_CLEANUP, "CLEANUP", ICON_NONE, "Cleanup", ""},
+    {DYNTOPO_INHERIT_DETAIL_SIZE, "DETAIL_SIZE", ICON_NONE, "Detail Size", ""},
     {0, NULL, 0, NULL, NULL},
 };
 
@@ -1190,6 +1191,14 @@ static void rna_def_dyntopo_settings(BlenderRNA *brna) {
       prop, "Detail Percent", "");
   RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+  prop = RNA_def_property(sr

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list