Paint brush no long SCULPT_undo_push_node per dab (except for first

stroke) for dyntopo.  Instead it updates the original vertex color
customdata layer.

Calling into the undo system destroys threading with dyntopo, as its
undo code is single-threaded.
This commit is contained in:
Joseph Eagar 2020-10-30 19:37:22 -07:00
parent 43ccbe353f
commit 0f0d1f8e2a
3 changed files with 34 additions and 1 deletions

View File

@ -229,6 +229,7 @@ void BKE_pbvh_free(PBVH *pbvh);
/** update original data, only data whose r_** parameters are passed in will be updated*/
void BKE_pbvh_bmesh_update_origvert(
PBVH *pbvh, struct BMVert *v, float **r_co, float **r_no, float **r_color);
void BKE_pbvh_update_origcolor_bmesh(PBVH *pbvh, PBVHNode *node);
/* Hierarchical Search in the BVH, two methods:
* - for each hit calling a callback

View File

@ -1424,6 +1424,30 @@ static int pbvh_flush_bb(PBVH *pbvh, PBVHNode *node, int flag)
return update;
}
void BKE_pbvh_update_origcolor_bmesh(PBVH *pbvh, PBVHNode *node)
{
PBVHVertexIter vd;
if (!pbvh->bm || !pbvh->cd_origvcol_offset) {
return;
}
int cd_vcol_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PROP_COLOR);
if (cd_vcol_offset == -1) {
return;
}
BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_ALL)
{
float *c1 = BM_ELEM_CD_GET_VOID_P(vd.bm_vert, pbvh->cd_origvcol_offset);
float *c2 = BM_ELEM_CD_GET_VOID_P(vd.bm_vert, cd_vcol_offset);
copy_v4_v4(c1, c2);
}
BKE_pbvh_vertex_iter_end;
}
void BKE_pbvh_update_bounds(PBVH *pbvh, int flag)
{
if (!pbvh->nodes) {

View File

@ -5768,7 +5768,15 @@ static void do_brush_action_task_cb(void *__restrict userdata,
BKE_pbvh_node_mark_update_mask(data->nodes[n]);
}
else if (ELEM(data->brush->sculpt_tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR)) {
SCULPT_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COLOR);
//make sure we have at least one undo_color node
if (!ss->bm || SCULPT_stroke_is_first_brush_step(ss->cache)) {
SCULPT_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COLOR);
}
if (ss->bm) {
BKE_pbvh_update_origcolor_bmesh(ss->pbvh, data->nodes[n]);
}
BKE_pbvh_node_mark_update_color(data->nodes[n]);
}
else {