Add missing COW updates when selection changes in paint modes.

This commit is contained in:
Alexander Gavrilov 2018-11-23 18:28:36 +03:00
parent d891c8f1f8
commit 1cc7bcd8d8
6 changed files with 33 additions and 10 deletions

View File

@ -243,6 +243,7 @@ void EDBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
/* editface.c */
void paintface_flush_flags(struct Object *ob, short flag);
void paintface_tag_select_update(struct bContext *C, struct Object *ob);
bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int sel_op);
void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
@ -255,6 +256,7 @@ void paintface_reveal(struct Object *ob, const bool select);
void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags);
void paintvert_flush_flags(struct Object *ob);
void paintvert_tag_select_update(struct bContext *C, struct Object *ob);
/* mirrtopo */
typedef struct MirrTopoStore_t {

View File

@ -75,6 +75,7 @@ enum eGPUFXFlags;
/* for derivedmesh drawing callbacks, for view3d_select, .... */
typedef struct ViewContext {
struct bContext *C;
struct Main *bmain;
struct Depsgraph *depsgraph;
struct Scene *scene;

View File

@ -105,6 +105,12 @@ void paintface_flush_flags(Object *ob, short flag)
BKE_mesh_batch_cache_dirty_tag(me, BKE_MESH_BATCH_DIRTY_ALL);
}
void paintface_tag_select_update(struct bContext *C, struct Object *ob)
{
DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
}
void paintface_hide(Object *ob, const bool unselected)
{
Mesh *me;
@ -252,6 +258,7 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
select_linked_tfaces_with_seams(me, index, select);
paintface_flush_flags(ob, SELECT);
paintface_tag_select_update(C, ob);
}
void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags)
@ -386,8 +393,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
/* image window redraw */
paintface_flush_flags(ob, SELECT);
DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
paintface_tag_select_update(C, ob);
ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
return true;
}
@ -458,6 +464,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int sel_op)
#endif
paintface_flush_flags(vc->obact, SELECT);
paintface_tag_select_update(vc->C, vc->obact);
return OPERATOR_FINISHED;
}
@ -509,6 +516,13 @@ void paintvert_flush_flags(Object *ob)
BKE_mesh_batch_cache_dirty_tag(me, BKE_MESH_BATCH_DIRTY_ALL);
}
void paintvert_tag_select_update(struct bContext *C, struct Object *ob)
{
DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
}
/* note: if the caller passes false to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
{

View File

@ -2801,7 +2801,7 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
vgroup_select_verts(ob, 1);
DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
return OPERATOR_FINISHED;
@ -2827,7 +2827,7 @@ static int vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
vgroup_select_verts(ob, 0);
DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
return OPERATOR_FINISHED;

View File

@ -656,6 +656,7 @@ static int face_select_all_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
paintface_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), true);
paintface_tag_select_update(C, ob);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@ -680,6 +681,7 @@ static int vert_select_all_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
paintvert_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), true);
paintvert_tag_select_update(C, ob);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@ -711,6 +713,7 @@ static int vert_select_ungrouped_exec(bContext *C, wmOperator *op)
}
paintvert_select_ungrouped(ob, RNA_boolean_get(op->ptr, "extend"), true);
paintvert_tag_select_update(C, ob);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@ -737,6 +740,7 @@ static int face_select_hide_exec(bContext *C, wmOperator *op)
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
Object *ob = CTX_data_active_object(C);
paintface_hide(ob, unselected);
paintface_tag_select_update(C, ob);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@ -760,6 +764,7 @@ static int face_select_reveal_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
Object *ob = CTX_data_active_object(C);
paintface_reveal(ob, select);
paintface_tag_select_update(C, ob);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}

View File

@ -119,6 +119,7 @@ float ED_view3d_select_dist_px(void)
void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc)
{
memset(vc, 0, sizeof(ViewContext));
vc->C = C;
vc->ar = CTX_wm_region(C);
vc->bmain = CTX_data_main(C);
vc->depsgraph = CTX_data_depsgraph(C);
@ -911,6 +912,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh
BKE_mesh_mselect_validate(me);
}
paintvert_flush_flags(ob);
paintvert_tag_select_update(vc->C, ob);
}
static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
{
@ -935,6 +937,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
EDBM_backbuf_free();
paintface_flush_flags(ob, SELECT);
paintface_tag_select_update(vc->C, ob);
}
#if 0
@ -1986,6 +1989,7 @@ static int do_paintvert_box_select(
BKE_mesh_mselect_validate(me);
}
paintvert_flush_flags(vc->obact);
paintvert_tag_select_update(vc->C, vc->obact);
return OPERATOR_FINISHED;
}
@ -2677,8 +2681,7 @@ static bool ed_wpaint_vertex_select_pick(
}
paintvert_flush_flags(obact);
DEG_id_tag_update(obact->data, DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
paintvert_tag_select_update(C, obact);
return true;
}
return false;
@ -2907,6 +2910,7 @@ static void paint_facesel_circle_select(ViewContext *vc, const bool select, cons
edbm_backbuf_check_and_select_tfaces(me, select ? SEL_OP_ADD : SEL_OP_SUB);
EDBM_backbuf_free();
paintface_flush_flags(ob, SELECT);
paintface_tag_select_update(vc->C, ob);
}
}
@ -2948,6 +2952,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, const bool select, cons
BKE_mesh_mselect_validate(me);
}
paintvert_flush_flags(ob);
paintvert_tag_select_update(vc->C, ob);
}
@ -3275,13 +3280,9 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
}
else if (BKE_paint_select_face_test(obact)) {
paint_facesel_circle_select(&vc, select, mval, (float)radius);
DEG_id_tag_update(obact->data, DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
else if (BKE_paint_select_vert_test(obact)) {
paint_vertsel_circle_select(&vc, select, mval, (float)radius);
DEG_id_tag_update(obact->data, DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
else if (obact->mode & OB_MODE_POSE) {
pose_circle_select(&vc, select, mval, (float)radius);