[Bf-blender-cvs] [200e3c8d559] temp-sculpt-cavity-mask: temp-sculpt-cavity-mask: Make requested changes

Joseph Eagar noreply at git.blender.org
Sat Sep 24 00:01:36 CEST 2022


Commit: 200e3c8d559b6dded6229db62c43cdb7e28f01cd
Author: Joseph Eagar
Date:   Fri Sep 23 15:01:15 2022 -0700
Branches: temp-sculpt-cavity-mask
https://developer.blender.org/rB200e3c8d559b6dded6229db62c43cdb7e28f01cd

temp-sculpt-cavity-mask: Make requested changes

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

M	release/scripts/addons
M	release/scripts/startup/bl_ui/space_view3d.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_automasking.cc
M	source/blender/editors/sculpt_paint/sculpt_expand.c
M	source/blender/editors/sculpt_paint/sculpt_filter_color.c
M	source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_ops.c
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/addons b/release/scripts/addons
index 3908254f093..67f1fbca148 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 3908254f0938a3c4c29189a455c8e356771e6ce1
+Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 2311532535c..6a09dc11aa5 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5490,22 +5490,12 @@ class VIEW3D_MT_sculpt_automasking_pie(Menu):
         tool_settings = context.tool_settings
         sculpt = tool_settings.sculpt
 
-        def doprop(key, text):
-            if sculpt.brush and getattr(sculpt.brush, key):
-                pie.prop(sculpt, key, text=text + "(overridden by brush)")
-            else:
-                pie.prop(sculpt, key, text=text)
-
-        doprop("use_automasking_topology", "Topology")
-        doprop("use_automasking_topology", "Topology")
-        doprop("use_automasking_face_sets", "Face Sets")
-        doprop("use_automasking_boundary_edges", "Mesh Boundary")
-        doprop("use_automasking_boundary_face_sets", "Face Sets Boundary")
-
-        if sculpt.brush and (sculpt.brush.use_automasking_cavity or sculpt.brush.use_automasking_cavity_inverted):
-            pie.prop(sculpt, "use_automasking_cavity", text="Cavity (overridden by brush)")
-        else:
-            pie.prop(sculpt, "use_automasking_cavity", text="Cavity")
+        pie.prop(sculpt, "use_automasking_topology", text="Topology")
+        pie.prop(sculpt, "use_automasking_face_sets", text="Face Sets")
+        pie.prop(sculpt, "use_automasking_boundary_edges", text="Mesh Boundary")
+        pie.prop(sculpt, "use_automasking_boundary_face_sets", text="Face Sets Boundary")
+        pie.prop(sculpt, "use_automasking_cavity", text="Cavity")
+        pie.prop(sculpt, "use_automasking_cavity_inverted", text="Cavity (Inverted)")
 
 
 class VIEW3D_MT_sculpt_face_sets_edit_pie(Menu):
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 59dbbd80ef5..94cf23a03f3 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -967,33 +967,22 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
 
         col = layout.column(heading="Auto-Masking", align=True)
 
-        def doprop(key, text):
-            col2 = col.column()
-            col2.enabled = not sculpt.brush or not getattr(sculpt.brush, key)
-
-            if not col2.enabled:
-                text += " - overridden by brush"
-            col2.prop(sculpt, key, text=text)
-
-        doprop("use_automasking_topology", "Topology")
-        doprop("use_automasking_face_sets", "Face Sets")
-        doprop("use_automasking_boundary_edges", "Mesh Boundary")
-        doprop("use_automasking_boundary_face_sets", "Face Sets Boundary")
-        doprop("use_automasking_cavity", "Cavity")
-        doprop("use_automasking_cavity_inverted", "Cavity (Inverted)")
+        col.prop(sculpt, "use_automasking_topology", text="Topology")
+        col.prop(sculpt, "use_automasking_face_sets", text="Face Sets")
+        col.prop(sculpt, "use_automasking_boundary_edges", text="Mesh Boundary")
+        col.prop(sculpt, "use_automasking_boundary_face_sets", text="Face Sets Boundary")
+        col.prop(sculpt, "use_automasking_cavity", text="Cavity")
+        col.prop(sculpt, "use_automasking_cavity_inverted", text="Cavity (Inverted)")
 
         col.separator()
 
         if sculpt.use_automasking_cavity or sculpt.use_automasking_cavity_inverted:
-            props = col.operator("sculpt.mask_from_cavity", text="Mask From Cavity")
+            col2 = col.column()
+            props = col2.operator("sculpt.mask_from_cavity", text="Mask From Cavity")
             props.use_automask_settings = True
 
             col2 = col.column()
-            col2.enabled = not (sculpt.brush and sculpt.brush.use_automasking_cavity or sculpt.brush.use_automasking_cavity_inverted)
-
-            if not col2.enabled:
-                col2.label(text="Overridden by brush")
-
+            
             col2.prop(sculpt, "automasking_cavity_factor", text="Cavity Factor")
             col2.prop(sculpt, "automasking_cavity_blur_steps", text="Cavity Blur")
             
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index b2750059f46..2b4bdfdc09e 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -752,9 +752,9 @@ typedef struct SculptSession {
    */
   char *last_paint_canvas_key;
 
-  int stroke_id;
+  uchar stroke_id;
   int last_automasking_settings_hash;
-  int last_cavity_stroke_id;
+  uchar last_cavity_stroke_id;
 } SculptSession;
 
 void BKE_sculptsession_free(struct Object *ob);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 3679f026502..09ea9b05f25 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5412,7 +5412,7 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
       SCULPT_undo_push_begin_ex(ob, sculpt_tool_name(sd));
     }
 
-    ss->stroke_id++;
+    SCULPT_stroke_id_inc(ob);
 
     return true;
   }
@@ -6012,6 +6012,14 @@ void SCULPT_fake_neighbors_free(Object *ob)
   sculpt_pose_fake_neighbors_free(ss);
 }
 
+void SCULPT_stroke_id_inc(Object *ob)
+{
+  /* Manually wrap in int32 space to avoid tripping up undefined behavior
+   * sanitizers.
+   */
+  ob->sculpt->stroke_id = (uchar)(((int)ob->sculpt->stroke_id + 1) & 255);
+}
+
 void SCULPT_stroke_id_ensure(Object *ob)
 {
   SculptSession *ss = ob->sculpt;
@@ -6020,7 +6028,7 @@ void SCULPT_stroke_id_ensure(Object *ob)
     SculptAttributeParams params = {0};
 
     ss->attrs.stroke_id = BKE_sculpt_attribute_ensure(
-        ob, ATTR_DOMAIN_POINT, CD_PROP_INT32, SCULPT_ATTRIBUTE_NAME(stroke_id), &params);
+        ob, ATTR_DOMAIN_POINT, CD_PROP_INT8, SCULPT_ATTRIBUTE_NAME(stroke_id), &params);
   }
 }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 809796f1af3..fdc29bb6ca6 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -354,7 +354,7 @@ static void sculpt_calc_blurred_cavity(SculptSession *ss,
   factor_sum = sculpt_cavity_calc_factor(ss, automasking, factor_sum);
 
   *(float *)SCULPT_vertex_attr_get(vertex, ss->attrs.cavity) = factor_sum;
-  *(int *)SCULPT_vertex_attr_get(vertex, ss->attrs.stroke_id) = automasking->cavity_stroke_id;
+  *(uchar *)SCULPT_vertex_attr_get(vertex, ss->attrs.stroke_id) = automasking->cavity_stroke_id;
 }
 
 int SCULPT_automasking_settings_hash(Object *ob, AutomaskingCache *automasking)
@@ -394,7 +394,7 @@ static float sculpt_automasking_cavity_factor(AutomaskingCache *automasking,
                                               SculptSession *ss,
                                               PBVHVertRef vertex)
 {
-  int stroke_id = *(int *)SCULPT_vertex_attr_get(vertex, ss->attrs.stroke_id);
+  uchar stroke_id = *(uchar *)SCULPT_vertex_attr_get(vertex, ss->attrs.stroke_id);
 
   if (stroke_id != automasking->cavity_stroke_id) {
     sculpt_calc_blurred_cavity(ss, automasking, automasking->settings.cavity_blur_steps, vertex);
diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c
index ef2b0b5959d..7235937bd52 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -2102,7 +2102,7 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
   SculptSession *ss = ob->sculpt;
   Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
 
-  ss->stroke_id++;
+  SCULPT_stroke_id_inc(ob);
 
   /* Create and configure the Expand Cache. */
   ss->expand_cache = MEM_callocN(sizeof(ExpandCache), "expand cache");
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
index aba7e9d10d8..436e1587754 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
@@ -335,7 +335,7 @@ static int sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent
   const bool use_automasking = SCULPT_is_automasking_enabled(sd, ss, NULL);
   if (use_automasking) {
     /* Increment stroke id for automasking system. */
-    ss->stroke_id++;
+    SCULPT_stroke_id_inc(ob);
 
     /* Update the active face set manually as the paint cursor is not enabled when using the Mesh
      * Filter Tool. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index 76086446a66..5e6fa4701a7 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -682,7 +682,7 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
 
   if (use_automasking) {
     /* Increment stroke id for automasking system. */
-    ss->stroke_id++;
+    SCULPT_stroke_id_inc(ob);
 
     /* Update the active face set manually as the paint cursor is not enabled when using the Mesh
      * Filter Tool. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 380b828b851..a88bba16990 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -403,7 +403,7 @@ typedef struct AutomaskingCache {
   AutomaskingSettings settings;
 
   bool can_reuse_cavity;
-  int cavity_stroke_id;
+  uchar cavity_stroke_id;
 } AutomaskingCache;
 
 typedef struct FilterCache {
@@ -1303,7 +1303,7 @@ float *SCULPT_boundary_automasking_init(Object *ob,
 bool SCULPT_automasking_needs_original(const struct Scul

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list