[Bf-blender-cvs] [2d98802905c] temp_bmesh_multires: * Added a "projection" option to smooth/autosmooth. It works by projection neighboring vertices onto the current smooth vert's normal plane, multiplied by a "projection" factor. This is extremely similar to what the surface laplacian produces, but is much simpler, uses no temporary state and thus can be used in more places.

Joseph Eagar noreply at git.blender.org
Sun May 2 19:57:40 CEST 2021


Commit: 2d98802905c762e06ff986e9bb0f160de70b221f
Author: Joseph Eagar
Date:   Sun May 2 10:54:12 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB2d98802905c762e06ff986e9bb0f160de70b221f

* Added a "projection" option to smooth/autosmooth.  It works by
  projection neighboring vertices onto the current smooth vert's normal
  plane, multiplied by a "projection" factor.  This is extremely similar
  to what the surface laplacian produces, but is much simpler, uses
  no temporary state and thus can be used in more places.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/editors/sculpt_paint/sculpt.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_smooth.c
M	source/blender/makesdna/DNA_brush_defaults.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/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 748533bb710..5b2bd5619dc 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -564,7 +564,22 @@ def brush_settings(layout, context, brush, popover=False):
                 pressure_name="use_inverse_smooth_pressure",
                 slider=True,
             )
-
+            UnifiedPaintPanel.prop_unified(
+                layout,
+                context,
+                brush,
+                "auto_smooth_projection",
+                slider=True,
+            )
+        elif brush.sculpt_tool == "SMOOTH":
+            UnifiedPaintPanel.prop_unified(
+                layout,
+                context,
+                brush,
+                "auto_smooth_projection",
+                slider=True,
+            )
+        
 
         if capabilities.has_vcol_boundary_smooth:
             layout.prop(brush, "vcol_boundary_factor", slider=True)
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 94e703bf9c5..8bd1e3a7ed9 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -447,6 +447,7 @@ static void brush_defaults(Brush *brush)
   FROM_DEFAULT(alpha);
   FROM_DEFAULT(hardness);
   FROM_DEFAULT(autosmooth_factor);
+  FROM_DEFAULT(autosmooth_projection);
   FROM_DEFAULT(topology_rake_factor);
   FROM_DEFAULT(crease_pinch_factor);
   FROM_DEFAULT(normal_radius_factor);
@@ -1651,6 +1652,7 @@ void BKE_brush_debug_print_state(Brush *br)
   BR_TEST(plane_offset, f);
 
   BR_TEST(autosmooth_factor, f);
+  BR_TEST(autosmooth_projection, f);
 
   BR_TEST(topology_rake_factor, f);
 
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 36f920fb2ba..d32ade625c0 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -19,22 +19,23 @@
  */
 
 /*
+
 TODO:
 
 Convergence improvements:
 1. DONE: Limit number of edges processed per run.
-2. Scale split steps by ratio of long to short edges to
+2. DONE: Scale split steps by ratio of long to short edges to
    prevent runaway tesselation.
-3. Detect and dissolve three and four valence vertices that are surrounded by
+3. DONE: Detect and dissolve three and four valence vertices that are surrounded by
    all tris.
-4. Use different (coarser) brush spacing for applying dyntopo
+4. DONE: Use different (coarser) brush spacing for applying dyntopo
 
 Drawing improvements:
-4. Build and cache vertex index buffers, to reduce GPU bandwidth
+4. PARTIAL DONE: Build and cache vertex index buffers, to reduce GPU bandwidth
 
 Topology rake:
-5. Enable new curvature topology rake code and add to UI.
-6. Add code to cache curvature data per vertex in a CD layer.
+5. DONE: Enable new curvature topology rake code and add to UI.
+6. DONE: Add code to cache curvature data per vertex in a CD layer.
 
 */
 
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 0f119b33529..1f561419e07 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3493,7 +3493,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
       do_mask_brush_draw(sd, ob, nodes, totnode);
       break;
     case BRUSH_MASK_SMOOTH:
-      SCULPT_smooth(sd, ob, nodes, totnode, ss->cache->bstrength, true);
+      SCULPT_smooth(sd, ob, nodes, totnode, ss->cache->bstrength, true, 0.0f);
       break;
   }
 }
@@ -6614,7 +6614,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
       break;
     case SCULPT_TOOL_SMOOTH:
       if (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_LAPLACIAN) {
-        SCULPT_do_smooth_brush(sd, ob, nodes, totnode);
+        SCULPT_do_smooth_brush(sd, ob, nodes, totnode, brush->autosmooth_projection);
       }
       else if (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_SURFACE) {
         SCULPT_do_surface_smooth_brush(sd, ob, nodes, totnode);
@@ -6726,10 +6726,10 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
       brush->autosmooth_factor > 0) {
     if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) {
       SCULPT_smooth(
-          sd, ob, nodes, totnode, brush->autosmooth_factor * (1.0f - ss->cache->pressure), false);
+          sd, ob, nodes, totnode, brush->autosmooth_factor * (1.0f - ss->cache->pressure), false, brush->autosmooth_projection);
     }
     else {
-      SCULPT_smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, false);
+      SCULPT_smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, false, brush->autosmooth_projection);
     }
   }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index d129e7a5631..c117a3a41f3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -334,7 +334,7 @@ static void mesh_filter_task_cb(void *__restrict userdata,
     switch (filter_type) {
       case MESH_FILTER_SMOOTH:
         fade = clamp_f(fade, -1.0f, 1.0f);
-        SCULPT_neighbor_coords_average_interior(ss, avg, vd.vertex);
+        SCULPT_neighbor_coords_average_interior(ss, avg, vd.vertex, 0.0f);
         sub_v3_v3v3(val, avg, orig_co);
         madd_v3_v3v3fl(val, orig_co, val, fade);
         sub_v3_v3v3(disp, val, orig_co);
@@ -399,7 +399,7 @@ static void mesh_filter_task_cb(void *__restrict userdata,
                                              ss->filter_cache->surface_smooth_laplacian_disp,
                                              vd.vertex,
                                              orig_data.co,
-                                             ss->filter_cache->surface_smooth_shape_preservation);
+                                             ss->filter_cache->surface_smooth_shape_preservation, 0.0f);
         break;
       }
       case MESH_FILTER_SHARPEN: {
@@ -424,7 +424,7 @@ static void mesh_filter_task_cb(void *__restrict userdata,
 
         float disp_avg[3];
         float avg_co[3];
-        SCULPT_neighbor_coords_average(ss, avg_co, vd.vertex);
+        SCULPT_neighbor_coords_average(ss, avg_co, vd.vertex, 0.0f);
         sub_v3_v3v3(disp_avg, avg_co, vd.co);
         mul_v3_v3fl(
             disp_avg, disp_avg, smooth_ratio * pow2f(ss->filter_cache->sharpen_factor[vd.index]));
@@ -489,7 +489,7 @@ static void mesh_filter_enhance_details_init_directions(SculptSession *ss)
     SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
 
     float avg[3];
-    SCULPT_neighbor_coords_average(ss, avg, vertex);
+    SCULPT_neighbor_coords_average(ss, avg, vertex, 0.0f);
     sub_v3_v3v3(filter_cache->detail_directions[i], avg, SCULPT_vertex_co_get(ss, vertex));
   }
 }
@@ -540,7 +540,7 @@ static void mesh_filter_sharpen_init(SculptSession *ss,
     float avg[3];
     SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
 
-    SCULPT_neighbor_coords_average(ss, avg, vertex);
+    SCULPT_neighbor_coords_average(ss, avg, vertex, 0.0f);
     sub_v3_v3v3(filter_cache->detail_directions[i], avg, SCULPT_vertex_co_get(ss, vertex));
     filter_cache->sharpen_factor[i] = len_v3(filter_cache->detail_directions[i]);
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index cb96d926161..eeeea403362 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -571,14 +571,18 @@ void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
 /* Smooth Brush. */
 void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], struct BMVert *v);
 
-void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], SculptVertRef index);
+void SCULPT_neighbor_coords_average(SculptSession *ss,
+                                    float result[3],
+                                    SculptVertRef index,
+                                    float projection);
 float SCULPT_neighbor_mask_average(SculptSession *ss, SculptVertRef index);
 void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], SculptVertRef index);
 
 /* Mask the mesh boundaries smoothing only the mesh surface without using automasking. */
 void SCULPT_neighbor_coords_average_interior(SculptSession *ss,
                                              float result[3],
-                                             SculptVertRef index);
+                                             SculptVertRef index,
+                                             float projection);
 
 void SCULPT_smooth_vcol_boundary(
     Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, float bstrength);
@@ -588,8 +592,10 @@ void SCULPT_smooth(Sculpt *sd,
                    PBVHNode **nodes,
                    const int totnode,
                    float bstrength,
-                   const bool smooth_mask);
-void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
+                   const bool smooth_mask,
+                   float projection);
+
+void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float projection);
 
 /* Surface Smooth Brush. */
 
@@ -599,7 +605,9 @@ void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
                                           float (*laplacian_disp)[3],
                                           const SculptVertRef v_index,
                                           const float origco[3],
-                                          const float alpha);
+                                          const float alpha,
+                                          const float projection);
+
 void SCULPT_surface_smooth_displace_step(SculptSession *ss,
                                          float *co,
                                          float (*laplacian_disp)[3],
@@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list