Commit: 081a3412a94705e5a95b08d7b41c1bbb879290d8
Author: Campbell Barton
Date:   Wed Feb 26 16:00:54 2014 +1100
https://developer.blender.org/rB081a3412a94705e5a95b08d7b41c1bbb879290d8

Paint API: add BKE_paint_select_elem_test: to check on paint selection

===================================================================

M       source/blender/blenkernel/BKE_paint.h
M       source/blender/blenkernel/intern/DerivedMesh.c
M       source/blender/blenkernel/intern/paint.c
M       source/blender/editors/mesh/editmesh_select.c
M       source/blender/editors/sculpt_paint/paint_image.c
M       source/blender/editors/space_view3d/drawmesh.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/editors/space_view3d/view3d_draw.c
M       source/blender/editors/space_view3d/view3d_edit.c
M       source/blender/editors/space_view3d/view3d_select.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 2f166dd..e62bd2b 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 f7a6adc..d7bdbb4 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 690217a..5a38445 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 25d97db..3ed1463 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 dd638ab..56cba57 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 04b2b4c..cfc3cfc 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 5d30b4e..9112c04 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 ab86747..f9b72b2 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 26d79e9..e8b08f3 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 2bc3773..8598766 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, 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to