diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-05-29 05:47:42 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-05-29 05:48:06 +0400 |
commit | a6bd6a8366044a377026d699c38672078cd335d8 (patch) | |
tree | 40f4a2b5d4ce4468f5790d5428227edad2e90b82 /source | |
parent | 11a156255dfadc5ab54d9303f919d5ff217aabac (diff) |
Add notifiers and reuse update calls for flood fill operators
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_sculpt.h | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_mask.c | 61 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 2 |
3 files changed, 26 insertions, 39 deletions
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index e89b0c53a10..2e092f7e7fe 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -46,7 +46,7 @@ void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob); void ED_sculpt_get_average_stroke(struct Object *ob, float stroke[3]); bool ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]); -int do_sculpt_mask_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend); +int do_sculpt_mask_box_select(struct bContext *C, struct ViewContext *vc, struct rcti *rect, bool select, bool extend); /* paint_ops.c */ void ED_operatortypes_paint(void); diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 49b62140fe6..4264c813001 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -86,10 +86,8 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); struct Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - struct MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); PaintMaskFloodMode mode; float value; - DerivedMesh *dm; PBVH *pbvh; PBVHNode **nodes; int totnode, i; @@ -98,14 +96,9 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) mode = RNA_enum_get(op->ptr, "mode"); value = RNA_float_get(op->ptr, "value"); - BKE_sculpt_mask_layers_ensure(ob, mmd); + BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true); - dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - pbvh = dm->getPBVH(ob, dm); - ob->sculpt->pbvh = pbvh; - - ob->sculpt->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE; - pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color); + pbvh = ob->sculpt->pbvh; BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); @@ -122,10 +115,11 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) } BKE_pbvh_vertex_iter_end; BKE_pbvh_node_mark_redraw(nodes[i]); - if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) - multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); } - + + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + sculpt_undo_push_end(); if (nodes) @@ -133,6 +127,8 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) ED_region_tag_redraw(ar); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + return OPERATOR_FINISHED; } @@ -185,7 +181,7 @@ static void flip_plane(float out[4], const float in[4], const char symm) out[3] = in[3]; } -int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNUSED(extend)) +int do_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, rcti *rect, bool select, bool UNUSED(extend)) { Sculpt *sd = vc->scene->toolsettings->sculpt; BoundBox bb; @@ -195,10 +191,8 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU ARegion *ar = vc->ar; struct Scene *scene = vc->scene; Object *ob = vc->obact; - struct MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); PaintMaskFloodMode mode; float value; - DerivedMesh *dm; PBVH *pbvh; PBVHNode **nodes; int totnode, i, symmpass; @@ -212,14 +206,8 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect); mul_m4_fl(clip_planes, -1.0f); - BKE_sculpt_mask_layers_ensure(ob, mmd); - - dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - pbvh = dm->getPBVH(ob, dm); - ob->sculpt->pbvh = pbvh; - - ob->sculpt->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE; - pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color); + BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true); + pbvh = ob->sculpt->pbvh; sculpt_undo_push_begin("Mask box fill"); @@ -251,8 +239,6 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU 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); } @@ -264,10 +250,15 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU } } + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + sculpt_undo_push_end(); ED_region_tag_redraw(ar); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + return OPERATOR_FINISHED; } @@ -325,10 +316,9 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) Object *ob; ViewContext vc; LassoMaskData data; + struct Scene *scene = CTX_data_scene(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; - struct MultiresModifierData *mmd; - DerivedMesh *dm; PBVH *pbvh; PBVHNode **nodes; int totnode, i, symmpass; @@ -359,14 +349,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) ED_view3d_clipping_calc(&bb, clip_planes, &mats, &data.rect); mul_m4_fl(clip_planes, -1.0f); - mmd = BKE_sculpt_multires_active(vc.scene, ob); - BKE_sculpt_mask_layers_ensure(ob, mmd); - dm = mesh_get_derived_final(vc.scene, ob, CD_MASK_BAREMESH); - pbvh = dm->getPBVH(ob, dm); - ob->sculpt->pbvh = pbvh; - - ob->sculpt->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE; - pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color); + BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true); + pbvh = ob->sculpt->pbvh; sculpt_undo_push_begin("Mask lasso fill"); @@ -401,8 +385,6 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) 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); @@ -415,12 +397,17 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) } } + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + sculpt_undo_push_end(); ED_region_tag_redraw(vc.ar); MEM_freeN((void *)mcords); MEM_freeN(data.px); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + return OPERATOR_FINISHED; } return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index d18eab6da48..063f828c3b0 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -2128,7 +2128,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) } else { /* no editmode, unified for bones and objects */ if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) { - ret = do_sculpt_mask_box_select(&vc, &rect, select, extend); + ret = do_sculpt_mask_box_select(C, &vc, &rect, select, extend); } else if (vc.obact && BKE_paint_select_face_test(vc.obact)) { ret = do_paintface_box_select(&vc, &rect, select, extend); |