Cleanup: Move sculpt mask update to a separate function
There's no reason to use a general "update vertex data" function, that just confuses things.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<PBVHNode *> 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<PBVHNode *> 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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user