diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-11-16 01:00:15 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-11-16 01:00:15 +0400 |
commit | e9c9706ce61c66f2451ff94df1ff04786dc7437d (patch) | |
tree | 428b78402f436115ce5607c4ce1c96301ec945d6 /source/blender/editors/sculpt_paint | |
parent | f06c02b8dd5b97de68e4f173a43e4f2eaf41993a (diff) |
Code cleanup: Use different redraw options for sculpt mask operators.
Current redraw options also did an unnecessary normal recalculation on
updated nodes.
Also, for the box and lasso mask only push an undo node if any vertex
has actually been influenced.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_mask.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index c563305a3da..42652cfa578 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -117,7 +117,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) mask_flood_fill_set_elem(vi.mask, mode, value); } BKE_pbvh_vertex_iter_end; - BKE_pbvh_node_mark_update(nodes[i]); + BKE_pbvh_node_mark_redraw(nodes[i]); if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); } @@ -234,17 +234,24 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; + bool any_masked = false; sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { - if (is_effected(clip_planes_final, vi.co)) + if (is_effected(clip_planes_final, vi.co)) { + if (!any_masked) { + any_masked = true; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BKE_pbvh_node_mark_redraw(nodes[i]); + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } mask_flood_fill_set_elem(vi.mask, mode, value); + } } BKE_pbvh_vertex_iter_end; - - BKE_pbvh_node_mark_update(nodes[i]); - if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) - multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); } if (nodes) @@ -359,17 +366,23 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; - - sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + bool any_masked = false; BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { - if (is_effected_lasso(&data, vi.co)) + if (is_effected_lasso(&data, vi.co)) { + if (!any_masked) { + any_masked = true; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BKE_pbvh_node_mark_redraw(nodes[i]); + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } + mask_flood_fill_set_elem(vi.mask, mode, value); + } } BKE_pbvh_vertex_iter_end; - - BKE_pbvh_node_mark_update(nodes[i]); - if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) - multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); } sculpt_undo_push_end(); |