diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-26 09:00:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-26 09:00:54 +0400 |
commit | 081a3412a94705e5a95b08d7b41c1bbb879290d8 (patch) | |
tree | fa980a6b8d9f617c2ee2571f89017ab3f554f389 /source | |
parent | 1dd7e759a0df10b05f23527eb6ba0c8e7377fbea (diff) |
Paint API: add BKE_paint_select_elem_test: to check on paint selection
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 14 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 20 |
10 files changed, 37 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 2f166dd2dac..e62bd2b4697 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -103,8 +103,9 @@ void BKE_paint_brush_set(struct Paint *paint, struct Brush *br); /* testing face select mode * Texture paint could be removed since selected faces are not used * however hiding faces is useful */ -bool paint_facesel_test(struct Object *ob); -bool paint_vertsel_test(struct Object *ob); +bool BKE_paint_select_face_test(struct Object *ob); +bool BKE_paint_select_vert_test(struct Object *ob); +bool BKE_paint_select_elem_test(struct Object *ob); /* partial visibility */ bool paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index f7a6adc813f..d7bdbb45752 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2223,7 +2223,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask, int build_shapekey_layers) { Object *obact = scene->basact ? scene->basact->object : NULL; - int editing = paint_facesel_test(ob); + bool editing = BKE_paint_select_face_test(ob); /* weight paint and face select need original indices because of selection buffer drawing */ int needMapping = (ob == obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT))); @@ -2286,7 +2286,7 @@ static CustomDataMask object_get_datamask(Scene *scene, Object *ob) if (ob == actob) { /* check if we need tfaces & mcols due to face select or texture paint */ - if (paint_facesel_test(ob) || (ob->mode & OB_MODE_TEXTURE_PAINT)) { + if (BKE_paint_select_face_test(ob) || (ob->mode & OB_MODE_TEXTURE_PAINT)) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 690217a0779..5a38445ee02 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -265,7 +265,7 @@ void BKE_paint_brush_set(Paint *p, Brush *br) } /* are we in vertex paint or weight pain face select mode? */ -bool paint_facesel_test(Object *ob) +bool BKE_paint_select_face_test(Object *ob) { return ( (ob != NULL) && (ob->type == OB_MESH) && @@ -276,7 +276,7 @@ bool paint_facesel_test(Object *ob) } /* are we in weight paint vertex select mode? */ -bool paint_vertsel_test(Object *ob) +bool BKE_paint_select_vert_test(Object *ob) { return ( (ob != NULL) && (ob->type == OB_MESH) && @@ -286,6 +286,16 @@ bool paint_vertsel_test(Object *ob) ); } +/** + * used to check if selection is possible + * (when we don't care if its face or vert) + */ +bool BKE_paint_select_elem_test(Object *ob) +{ + return (BKE_paint_select_vert_test(ob) || + BKE_paint_select_face_test(ob)); +} + void BKE_paint_init(Paint *p, const char col[3]) { Brush *brush; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 25d97db9ba3..3ed14633376 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -271,7 +271,7 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short /* method in use for face selecting too */ if (vc->obedit == NULL) { - if (!(paint_facesel_test(vc->obact) || paint_vertsel_test(vc->obact))) { + if (!BKE_paint_select_elem_test(vc->obact)) { return false; } } @@ -320,7 +320,7 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) /* method in use for face selecting too */ if (vc->obedit == NULL) { - if (!(paint_facesel_test(vc->obact) || paint_vertsel_test(vc->obact))) { + if (!BKE_paint_select_elem_test(vc->obact)) { return false; } } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index dd638ab93cd..56cba57747d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1128,16 +1128,16 @@ int image_texture_paint_poll(bContext *C) int facemask_paint_poll(bContext *C) { - return paint_facesel_test(CTX_data_active_object(C)); + return BKE_paint_select_face_test(CTX_data_active_object(C)); } int vert_paint_poll(bContext *C) { - return paint_vertsel_test(CTX_data_active_object(C)); + return BKE_paint_select_vert_test(CTX_data_active_object(C)); } int mask_paint_poll(bContext *C) { - return paint_facesel_test(CTX_data_active_object(C)) || paint_vertsel_test(CTX_data_active_object(C)); + return BKE_paint_select_elem_test(CTX_data_active_object(C)); } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 04b2b4c5c55..cfc3cfcabf8 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -630,7 +630,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) if (ob->mode & OB_MODE_EDIT) return; else if (ob == OBACT) - if (paint_facesel_test(ob) || paint_vertsel_test(ob)) + if (BKE_paint_select_elem_test(ob)) return; ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5d30b4e6299..9112c04b0d6 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3412,7 +3412,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D int /* totvert,*/ totedge, totface; DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); const bool is_obact = (ob == OBACT); - int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0; + int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0; if (!dm) return; @@ -3622,7 +3622,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } - if (is_obact && paint_vertsel_test(ob)) { + if (is_obact && BKE_paint_select_vert_test(ob)) { const int use_depth = (v3d->flag & V3D_ZBUF_SELECT); glColor3f(0.0f, 0.0f, 0.0f); glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index ab867472bdd..f9b72b2b496 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1276,7 +1276,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || - paint_facesel_test(base->object))) + BKE_paint_select_face_test(base->object))) { /* do nothing */ } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 26d79e9910f..e8b08f3dd07 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2745,7 +2745,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) } } } - else if (paint_facesel_test(ob)) { + else if (BKE_paint_select_face_test(ob)) { ok = paintface_minmax(ob, min, max); } else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 2bc3773ce9a..85987669d8a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -275,7 +275,7 @@ static int view3d_selectable_data(bContext *C) } else { if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) && - !paint_facesel_test(ob) && !paint_vertsel_test(ob)) + !BKE_paint_select_elem_test(ob)) { return 0; } @@ -820,9 +820,9 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc, Object *ob = CTX_data_active_object(C); if (vc->obedit == NULL) { /* Object Mode */ - if (paint_facesel_test(ob)) + if (BKE_paint_select_face_test(ob)) do_lasso_select_paintface(vc, mcords, moves, extend, select); - else if (paint_vertsel_test(ob)) + else if (BKE_paint_select_vert_test(ob)) do_lasso_select_paintvert(vc, mcords, moves, extend, select); else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { /* pass */ @@ -2122,10 +2122,10 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) { ret = do_sculpt_mask_box_select(&vc, &rect, select, extend); } - else if (vc.obact && paint_facesel_test(vc.obact)) { + else if (vc.obact && BKE_paint_select_face_test(vc.obact)) { ret = do_paintface_box_select(&vc, &rect, select, extend); } - else if (vc.obact && paint_vertsel_test(vc.obact)) { + else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) { ret = do_paintvert_box_select(&vc, &rect, select, extend); } else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) { @@ -2252,9 +2252,9 @@ static int view3d_select_exec(bContext *C, wmOperator *op) } else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) return PE_mouse_particles(C, location, extend, deselect, toggle); - else if (obact && paint_facesel_test(obact)) + else if (obact && BKE_paint_select_face_test(obact)) retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle); - else if (paint_vertsel_test(obact)) + else if (BKE_paint_select_vert_test(obact)) retval = mouse_weight_paint_vertex_select(C, location, extend, deselect, toggle, obact); else retval = mouse_select(C, location, extend, deselect, toggle, center, enumerate, object); @@ -2766,7 +2766,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")}; - if (CTX_data_edit_object(C) || paint_facesel_test(obact) || paint_vertsel_test(obact) || + if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact) || (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) ) { ViewContext vc; @@ -2779,11 +2779,11 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) obedit_circle_select(&vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } - else if (paint_facesel_test(obact)) { + else if (BKE_paint_select_face_test(obact)) { paint_facesel_circle_select(&vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } - else if (paint_vertsel_test(obact)) { + else if (BKE_paint_select_vert_test(obact)) { paint_vertsel_circle_select(&vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } |