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.
This commit is contained in:
Antony Riakiotakis
2013-11-15 23:00:15 +02:00
parent f06c02b8dd
commit e9c9706ce6
3 changed files with 35 additions and 16 deletions

View File

@@ -151,8 +151,9 @@ typedef enum {
void BKE_pbvh_node_mark_update(PBVHNode *node);
void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node);
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
void BKE_pbvh_node_mark_redraw(PBVHNode *node);
void BKE_pbvh_node_mark_topology_update(PBVHNode *node);
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,

View File

@@ -1283,6 +1283,11 @@ void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node)
node->flag |= PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw;
}
void BKE_pbvh_node_mark_redraw(PBVHNode *node)
{
node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw;
}
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden)
{
BLI_assert(node->flag & PBVH_Leaf);

View File

@@ -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,18 +234,25 @@ 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))
mask_flood_fill_set_elem(vi.mask, mode, value);
} BKE_pbvh_vertex_iter_end;
if (is_effected(clip_planes_final, vi.co)) {
if (!any_masked) {
any_masked = true;
BKE_pbvh_node_mark_update(nodes[i]);
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;
}
if (nodes)
MEM_freeN(nodes);
@@ -359,19 +366,25 @@ 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;
bool any_masked = false;
BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) {
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_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) {
if (is_effected_lasso(&data, vi.co))
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);
}
mask_flood_fill_set_elem(vi.mask, mode, value);
}
} BKE_pbvh_vertex_iter_end;
}
sculpt_undo_push_end();
if (nodes)