[Bf-blender-cvs] [a55b58476ee] sculpt-dev: Sculpt: Fix topology rake performance regression

Joseph Eagar noreply at git.blender.org
Mon Oct 18 01:28:46 CEST 2021


Commit: a55b58476ee56159007fa78f283ab390629d6844
Author: Joseph Eagar
Date:   Sun Oct 17 16:27:55 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBa55b58476ee56159007fa78f283ab390629d6844

Sculpt: Fix topology rake performance regression

* Don't use quite so many iterations
* Defer normals update

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

M	source/blender/editors/sculpt_paint/sculpt_brushes.c
M	source/blender/editors/sculpt_paint/sculpt_ops.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt_brushes.c b/source/blender/editors/sculpt_paint/sculpt_brushes.c
index 0374209094f..0375f09f38b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_brushes.c
+++ b/source/blender/editors/sculpt_paint/sculpt_brushes.c
@@ -3746,7 +3746,9 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
     return;
   }
 
-  const float bstrength = clamp_f(data->strength, 0.0f, 1.0f);
+  /*take square root of strength to get stronger behavior at
+    lower values, to match previous behavior*/
+  const float bstrength = sqrtf(clamp_f(data->strength, 0.0f, 1.0f));
 
   SculptBrushTest test;
   SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
@@ -3928,7 +3930,7 @@ void SCULPT_bmesh_topology_rake(Sculpt *sd,
       this seems desirably though?*/
   }
   /* Iterations increase both strength and quality. */
-  const int iterations = 3 + ((int)bstrength) * 2;
+  const int iterations = 1 + bstrength * 1.5f;
 
   int iteration;
   const int count = iterations * strength + 1;
@@ -3951,7 +3953,13 @@ void SCULPT_bmesh_topology_rake(Sculpt *sd,
     BKE_pbvh_parallel_range_settings(&settings, true, totnode);
 
     BLI_task_parallel_range(0, totnode, &data, do_topology_rake_bmesh_task_cb_ex, &settings);
-    BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg);
+
+    /* don't update normals just yet */
+    // BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg);
+  }
+
+  for (int i = 0; i < totnode; i++) {
+    BKE_pbvh_node_mark_update_tri_area(nodes[i]);
   }
 }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c
index c3104c75c8f..3e1307c5f2e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -123,7 +123,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-
 /* Reset the copy of the mesh that is being sculpted on (currently just for the layer brush). */
 
 static int sculpt_set_persistent_base_exec(bContext *C, wmOperator *UNUSED(op))
@@ -378,7 +377,6 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot)
                 1.0f);
 }
 
-
 static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
 {
   struct wmMsgBus *mbus = CTX_wm_message_bus(C);
@@ -444,7 +442,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-
 static int vertex_to_loop_colors_exec(bContext *C, wmOperator *UNUSED(op))
 {
   Object *ob = CTX_data_active_object(C);
@@ -760,8 +757,6 @@ static void SCULPT_OT_sample_color(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER;
 }
 
-
-
 /**
  * #sculpt_mask_by_color_delta_get returns values in the (0,1) range that are used to generate the
  * mask based on the difference between two colors (the active color and the color of any other
@@ -1154,7 +1149,6 @@ static void SCULPT_OT_set_limit_surface(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-
 typedef struct BMLinkItem {
   struct BMLinkItem *next, *prev;
   BMVert *item;
@@ -1501,4 +1495,3 @@ void ED_operatortypes_sculpt(void)
   WM_operatortype_append(SCULPT_OT_expand);
   WM_operatortype_append(SCULPT_OT_regularize_rake_directions);
 }
-



More information about the Bf-blender-cvs mailing list