Sculpt: Fix topology rake performance regression

* Don't use quite so many iterations
* Defer normals update
This commit is contained in:
Joseph Eagar 2021-10-17 16:27:55 -07:00
parent 934abc9280
commit a55b58476e
2 changed files with 11 additions and 10 deletions

View File

@ -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]);
}
}

View File

@ -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);
}