[Bf-blender-cvs] [e4b6180c4ea] sculpt-dev: Sculpt-dev: fix elastic deform brush

Joseph Eagar noreply at git.blender.org
Fri Dec 3 01:40:05 CET 2021


Commit: e4b6180c4eaedabb3e0e5d84a26b21f40b770d7e
Author: Joseph Eagar
Date:   Thu Dec 2 16:37:31 2021 -0800
Branches: sculpt-dev
https://developer.blender.org/rBe4b6180c4eaedabb3e0e5d84a26b21f40b770d7e

Sculpt-dev: fix elastic deform brush

* Volume preservation had wrong bounds in
  elastic deform brush leading to wrong
  behavior.
* Fixed unprojected_radius channel not
  being shown in header when scene radius
  unit is on.
* Draw face sets now only fully rebuild draw buffers
  in indexed draw modes that require it.

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/brush_channel_define.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/editors/sculpt_paint/sculpt_face_set.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 76b634939c4..eb0acf4f199 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -261,19 +261,26 @@ class _draw_tool_settings_context_mode:
             "accumulate" : ["Accu..", 2.5] #needs an icon
         }
         
+        scene_radius = UnifiedPaintPanel.get_channel_value(context, brush, "radius_unit") == "SCENE"
+        
         for ch in brush.channels:
+            show_in_header = ch.show_in_header
+            
+            if ch.idname == "radius" and scene_radius:
+              ch = brush.channels["unprojected_radius"]
+            
             final_ch = ch
-
+            
             if ch.inherit:
                 sculpt.channels.ensure(ch)
                 final_ch = sculpt.channels[ch.idname]
 
-            row = row1.row(align=False).row(align=True)
-            row.use_property_split = False
-            row.use_property_decorate = False
-            layoutuse_property_split = False
+            if show_in_header:
+                row = row1.row(align=False).row(align=True)
+                row.use_property_split = False
+                row.use_property_decorate = False
+                layoutuse_property_split = False
 
-            if ch.show_in_header:
                 text = ch.name if ch.type in ["BOOL", "FLOAT", "INT"] else ""
 
                 if final_ch.type in ["VEC3", "VEC4"]:
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 24de34d21f2..6c9c5c7943c 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -528,6 +528,10 @@ void BKE_pbvh_bmesh_update_all_valence(PBVH *pbvh);
 void BKE_pbvh_bmesh_flag_all_disk_sort(PBVH *pbvh);
 bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, SculptVertRef vertex);
 
+/* if pbvh uses a split index buffer, will call BKE_pbvh_node_mark_update_triangulation;
+   otherwise does nothing.  returns true if BKE_pbvh_node_mark_update_triangulation was
+   called.*/
+bool BKE_pbvh_node_mark_update_index_buffer(PBVH *pbvh, PBVHNode *node);
 void BKE_pbvh_node_mark_update_triangulation(PBVHNode *node);
 void BKE_pbvh_node_mark_original_update(PBVHNode *node);
 void BKE_pbvh_node_mark_update_tri_area(PBVHNode *node);
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 1be82fa8336..2eacd302ab4 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -508,7 +508,7 @@ MAKE_ENUM(blend,"Blending Mode","Brush blending mode",IMB_BLEND_MIX,{\
     "Smooth iterations applied after calculating the pose factor of each vertex",4,0.0f,100.0f)
   MAKE_INT(pose_ik_segments,"Pose IK Segments",
     "Number of segments of the inverse kinematics chain that will deform the mesh",1,1,20)
-  MAKE_FLOAT(surface_smooth_shape_preservation,"Shape Preservation","How much of the original shape is preserved when smoothing",0.5f,0.0f,1.0f)
+  MAKE_FLOAT(surface_smooth_shape_preservation,"Shape Preservation","How much of the original shape is preserved when smoothing", 0.5f,0.0f,1.0f)
   MAKE_FLOAT(surface_smooth_current_vertex,"Per Vertex Displacement",
     "How much the position of each individual vertex influences the final result",0.5f,0.0f,1.0f)
   MAKE_INT(surface_smooth_iterations,"Iterations","Number of smoothing iterations per brush step",4,1,10)
@@ -591,7 +591,7 @@ MAKE_ENUM(blend,"Blending Mode","Brush blending mode",IMB_BLEND_MIX,{\
     })
   MAKE_FLOAT(elastic_deform_volume_preservation,"Volume Preservation",
     "Poisson ratio for elastic deformation. Higher values preserve volume "
-    "more, but also lead to more bulging",0.0f,0.9f,false)
+    "more, but also lead to more bulging", 0.0f, 0.0f, 0.9f)
 
   MAKE_BOOL(use_ctrl_invert,"Use Ctrl Invert","Take brush addition or subtraction mode into account",true)
 
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 03ff3a6d833..95ab239ca37 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -2010,7 +2010,7 @@ void BKE_sculpt_update_object_before_eval(Object *ob)
       /* In vertex/weight paint, force maps to be rebuilt. */
       BKE_sculptsession_free_vwpaint_data(ob->sculpt);
     }
-    else {
+    else if (ss->pbvh) {
       PBVHNode **nodes;
       int n, totnode;
 
@@ -2020,7 +2020,7 @@ void BKE_sculpt_update_object_before_eval(Object *ob)
         BKE_pbvh_node_mark_update(nodes[n]);
       }
 
-      MEM_freeN(nodes);
+      MEM_SAFE_FREE(nodes);
     }
   }
 }
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 86961354764..ba4300244cb 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -4238,6 +4238,17 @@ PBVHNode *BKE_pbvh_get_node(PBVH *pbvh, int node)
   return pbvh->nodes + node;
 }
 
+bool BKE_pbvh_node_mark_update_index_buffer(PBVH *pbvh, PBVHNode *node)
+{
+  bool split_indexed = pbvh->bm && (pbvh->flags & (PBVH_DYNTOPO_SMOOTH_SHADING | PBVH_FAST_DRAW));
+
+  if (split_indexed) {
+    BKE_pbvh_node_mark_update_triangulation(node);
+  }
+
+  return split_indexed;
+}
+
 void BKE_pbvh_node_mark_update_triangulation(PBVHNode *node)
 {
   node->flag |= PBVH_UpdateTris;
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index b5b6e2e7180..fefa1cb4eab 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -633,7 +633,7 @@ void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
   BKE_pbvh_vertex_iter_end;
 
   if (modified) {
-    BKE_pbvh_node_mark_update_triangulation(data->nodes[n]);
+    BKE_pbvh_node_mark_update_index_buffer(ss->pbvh, data->nodes[n]);
   }
 
   // restore automasking flag



More information about the Bf-blender-cvs mailing list