diff options
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 47 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 12 |
3 files changed, 62 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index c8218488b3a..eb0fc5b103c 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -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); +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); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a5fe32e6fe8..cc6489b68f9 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -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]) { diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index cdf8d6614f3..c0294212821 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -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)) { - 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); } @@ -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)) { - 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); } |