flush selection when switching weight paint vertex/face selection modes.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 22 Dec 2012 13:42:06 +0000 (13:42 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 22 Dec 2012 13:42:06 +0000 (13:42 +0000)
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/mesh.c
source/blender/makesrna/intern/rna_mesh.c

index c8218488b3a5965251d5b8716e87244edc81ad3d..eb0fc5b103c06f3d3751d7f72b8d276ec547bd37 100644 (file)
@@ -128,6 +128,11 @@ void BKE_mesh_flush_select_from_polys(struct MVert *mvert,       const int totve
                                       struct MEdge *medge,       const int totedge,
                                       const struct MPoly *mpoly, const int totpoly);
 
                                       struct MEdge *medge,       const int totedge,
                                       const struct MPoly *mpoly, const int totpoly);
 
+void BKE_mesh_flush_select_from_verts(const struct MVert *mvert, const int totvert,
+                                      struct MLoop *mloop,
+                                      struct MEdge *medge,       const int totedge,
+                                      struct MPoly *mpoly,       const int totpoly);
+
 void BKE_mesh_unlink(struct Mesh *me);
 void BKE_mesh_free(struct Mesh *me, int unlink);
 struct Mesh *BKE_mesh_add(const char *name);
 void BKE_mesh_unlink(struct Mesh *me);
 void BKE_mesh_free(struct Mesh *me, int unlink);
 struct Mesh *BKE_mesh_add(const char *name);
index a5fe32e6fe8813d09313514cb82a6c99ed5bb8d4..cc6489b68f9940ed44f41dee81124d8c74020786 100644 (file)
@@ -3146,6 +3146,53 @@ void BKE_mesh_flush_select_from_polys(MVert *mvert,       const int totvert,
        }
 }
 
        }
 }
 
+void BKE_mesh_flush_select_from_verts(const MVert *mvert, const int UNUSED(totvert),
+                                      MLoop *mloop,
+                                      MEdge *medge,       const int totedge,
+                                      MPoly *mpoly,       const int totpoly)
+{
+       MEdge *med;
+       MPoly *mp;
+       int i;
+
+       /* edges */
+       i = totedge;
+       for (med = medge; i--; med++) {
+               if ((med->flag & ME_HIDE) == 0) {
+                       if ((mvert[med->v1].flag & SELECT) && (mvert[med->v2].flag & SELECT)) {
+                               med->flag |= SELECT;
+                       }
+                       else {
+                               med->flag &= ~SELECT;
+                       }
+               }
+       }
+
+       /* polys */
+       i = totpoly;
+       for (mp = mpoly; i--; mp++) {
+               if ((mp->flag & ME_HIDE) == 0) {
+                       int ok = TRUE;
+                       MLoop *ml;
+                       int j;
+                       j = mp->totloop;
+                       for (ml = &mloop[mp->loopstart]; j--; ml++) {
+                               if ((mvert[ml->v].flag & SELECT) == 0) {
+                                       ok = FALSE;
+                                       break;
+                               }
+                       }
+
+                       if (ok) {
+                               mp->flag |= ME_FACE_SEL;
+                       }
+                       else {
+                               mp->flag &= ~ME_FACE_SEL;
+                       }
+               }
+       }
+}
+
 /* basic vertex data functions */
 int BKE_mesh_minmax(Mesh *me, float r_min[3], float r_max[3])
 {
 /* basic vertex data functions */
 int BKE_mesh_minmax(Mesh *me, float r_min[3], float r_max[3])
 {
index cdf8d6614f33d6bf5653b7f71d8523f6a44527d3..c02942128216a04a1405048fcdc71c277d57381f 100644 (file)
@@ -153,7 +153,11 @@ static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        Mesh *me = ptr->data;
        if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
 {
        Mesh *me = ptr->data;
        if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
-               me->editflag ^= ME_EDIT_PAINT_MASK;
+               me->editflag &= ~ME_EDIT_PAINT_MASK;
+               BKE_mesh_flush_select_from_polys(me->mvert, me->totvert,
+                                                me->mloop,
+                                                me->medge, me->totedge,
+                                                me->mpoly, me->totpoly);
        }
        rna_Mesh_update_draw(bmain, scene, ptr);
 }
        }
        rna_Mesh_update_draw(bmain, scene, ptr);
 }
@@ -162,7 +166,11 @@ static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        Mesh *me = ptr->data;
        if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
 {
        Mesh *me = ptr->data;
        if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
-               me->editflag ^= ME_EDIT_VERT_SEL;
+               me->editflag &= ~ME_EDIT_VERT_SEL;
+               BKE_mesh_flush_select_from_verts(me->mvert, me->totvert,
+                                                me->mloop,
+                                                me->medge, me->totedge,
+                                                me->mpoly, me->totpoly);
        }
        rna_Mesh_update_draw(bmain, scene, ptr);
 }
        }
        rna_Mesh_update_draw(bmain, scene, ptr);
 }