diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index 318f7eda225..2a0fee6fdb9 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -439,6 +439,7 @@ void BKE_pbvh_bmesh_after_stroke(PBVH *pbvh); /* Update Bounding Box/Redraw and clear flags. */ void BKE_pbvh_update_bounds(PBVH *pbvh, int flags); +void BKE_pbvh_update_mask(PBVH *pbvh); void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flags); void BKE_pbvh_update_visibility(PBVH *pbvh); void BKE_pbvh_update_normals(PBVH *pbvh, SubdivCCG *subdiv_ccg); diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index a9d89d8be94..67634b086e5 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -1546,17 +1546,12 @@ void BKE_pbvh_update_bounds(PBVH *pbvh, int flag) } } -void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flag) +void BKE_pbvh_update_mask(PBVH *pbvh) { using namespace blender; - if (pbvh->nodes.is_empty()) { - return; - } - Vector nodes = blender::bke::pbvh::search_gather( - pbvh, [&](PBVHNode &node) { return update_search(&node, flag); }); + pbvh, [&](PBVHNode &node) { return update_search(&node, PBVH_UpdateMask); }); - if (flag & (PBVH_UpdateMask)) { threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { for (PBVHNode *node : nodes.as_span().slice(range)) { node_update_mask_redraw(*pbvh, *node); @@ -1564,6 +1559,12 @@ void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flag) }); } +void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flag) +{ + using namespace blender; + Vector nodes = blender::bke::pbvh::search_gather( + pbvh, [&](PBVHNode &node) { return update_search(&node, flag); }); + if (flag & (PBVH_UpdateColor)) { for (PBVHNode *node : nodes) { node->flag |= PBVH_UpdateRedraw | PBVH_UpdateDrawBuffers | PBVH_UpdateColor; diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index 8b5107a778e..cec9d7fc1ae 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -141,7 +141,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED); } - BKE_pbvh_update_vertex_data(pbvh, PBVH_UpdateMask); + BKE_pbvh_update_mask(pbvh); SCULPT_undo_push_end(ob); @@ -837,7 +837,7 @@ static void sculpt_gesture_mask_end(bContext *C, SculptGestureContext *sgcontext if (BKE_pbvh_type(sgcontext->ss->pbvh) == PBVH_GRIDS) { multires_mark_as_modified(depsgraph, sgcontext->vc.obact, MULTIRES_COORDS_MODIFIED); } - BKE_pbvh_update_vertex_data(sgcontext->ss->pbvh, PBVH_UpdateMask); + BKE_pbvh_update_mask(sgcontext->ss->pbvh); } static void sculpt_gesture_init_mask_properties(bContext *C, diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 09d21dac15e..e944cac7579 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -5546,7 +5546,7 @@ void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType up } if (update_flags & SCULPT_UPDATE_MASK) { - BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateMask); + BKE_pbvh_update_mask(ss->pbvh); } if (update_flags & SCULPT_UPDATE_COLOR) { diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc index bbebd4eabf3..132038362e5 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc +++ b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc @@ -143,7 +143,7 @@ static int sculpt_mask_init_exec(bContext *C, wmOperator *op) SCULPT_undo_push_end(ob); - BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateMask); + BKE_pbvh_update_mask(ss->pbvh); SCULPT_tag_update_overlays(C); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index 7012c5c3ced..10adeb6611e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -943,7 +943,7 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven sculpt_mask_by_color_full_mesh(ob, active_vertex, threshold, invert, preserve_mask); } - BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateMask); + BKE_pbvh_update_mask(ss->pbvh); SCULPT_undo_push_end(ob); SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); @@ -1145,7 +1145,7 @@ static int sculpt_bake_cavity_exec(bContext *C, wmOperator *op) SCULPT_automasking_cache_free(automasking); - BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateMask); + BKE_pbvh_update_mask(ss->pbvh); SCULPT_undo_push_end(ob); SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index 01d00628a02..cd0988701bc 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -1041,7 +1041,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw); if (update_mask) { - BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateMask); + BKE_pbvh_update_mask(ss->pbvh); } if (update_face_sets) { DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);