diff options
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 63 | ||||
-rw-r--r-- | source/blender/editors/mesh/editface.c | 18 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_hide.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_multires.c | 12 |
5 files changed, 88 insertions, 29 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 339d13b06b2..7481a403dc8 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -138,18 +138,26 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v); /* update the hide flag for edges and polys from the corresponding * flag in verts */ -void BKE_mesh_flush_hidden_from_verts(const struct MVert *mvert, - const struct MLoop *mloop, - struct MEdge *medge, int totedge, - struct MPoly *mpoly, int totpoly); +void BKE_mesh_flush_hidden_from_verts_ex(const struct MVert *mvert, + const struct MLoop *mloop, + struct MEdge *medge, const int totedge, + struct MPoly *mpoly, const int totpoly); +void BKE_mesh_flush_hidden_from_verts(struct Mesh *me); + +void BKE_mesh_flush_hidden_from_polys_ex(struct MVert *mvert, + const struct MLoop *mloop, + struct MEdge *medge, int totedge, + const struct MPoly *mpoly, const int totpoly); +void BKE_mesh_flush_hidden_from_polys(struct Mesh *me); + void BKE_mesh_flush_select_from_polys_ex(struct MVert *mvert, const int totvert, - struct MLoop *mloop, + const struct MLoop *mloop, struct MEdge *medge, const int totedge, const struct MPoly *mpoly, const int totpoly); void BKE_mesh_flush_select_from_polys(struct Mesh *me); void BKE_mesh_flush_select_from_verts_ex(const struct MVert *mvert, const int totvert, - struct MLoop *mloop, + const struct MLoop *mloop, struct MEdge *medge, const int totedge, struct MPoly *mpoly, const int totpoly); void BKE_mesh_flush_select_from_verts(struct Mesh *me); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 2b59aa4a8bb..8c6c5d9fd83 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -3437,10 +3437,10 @@ int BKE_mesh_edge_other_vert(const MEdge *e, int v) /* update the hide flag for edges and faces from the corresponding * flag in verts */ -void BKE_mesh_flush_hidden_from_verts(const MVert *mvert, - const MLoop *mloop, - MEdge *medge, int totedge, - MPoly *mpoly, int totpoly) +void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert, + const MLoop *mloop, + MEdge *medge, const int totedge, + MPoly *mpoly, const int totpoly) { int i, j; @@ -3464,12 +3464,59 @@ void BKE_mesh_flush_hidden_from_verts(const MVert *mvert, } } } +void BKE_mesh_flush_hidden_from_verts(Mesh *me) +{ + BKE_mesh_flush_hidden_from_verts_ex(me->mvert, me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); +} + +void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert, + const MLoop *mloop, + MEdge *medge, const int UNUSED(totedge), + const MPoly *mpoly, const int totpoly) +{ + const MPoly *mp; + int i; + + i = totpoly; + for (mp = mpoly; i--; mp++) { + if (mp->flag & ME_HIDE) { + const MLoop *ml; + int j; + j = mp->totloop; + for (ml = &mloop[mp->loopstart]; j--; ml++) { + mvert[ml->v].flag |= ME_HIDE; + medge[ml->e].flag |= ME_HIDE; + } + } + } + + i = totpoly; + for (mp = mpoly; i--; mp++) { + if ((mp->flag & ME_HIDE) == 0) { + const MLoop *ml; + int j; + j = mp->totloop; + for (ml = &mloop[mp->loopstart]; j--; ml++) { + mvert[ml->v].flag &= ~ME_HIDE; + medge[ml->e].flag &= ~ME_HIDE; + } + } + } +} +void BKE_mesh_flush_hidden_from_polys(Mesh *me) +{ + BKE_mesh_flush_hidden_from_polys_ex(me->mvert, me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); +} /** * simple poly -> vert/edge selection. */ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert, - MLoop *mloop, + const MLoop *mloop, MEdge *medge, const int totedge, const MPoly *mpoly, const int totpoly) { @@ -3493,7 +3540,7 @@ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert, /* assume if its selected its not hidden and none of its verts/edges are hidden * (a common assumption)*/ if (mp->flag & ME_FACE_SEL) { - MLoop *ml; + const MLoop *ml; int j; j = mp->totloop; for (ml = &mloop[mp->loopstart]; j--; ml++) { @@ -3512,7 +3559,7 @@ void BKE_mesh_flush_select_from_polys(Mesh *me) } void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(totvert), - MLoop *mloop, + const MLoop *mloop, MEdge *medge, const int totedge, MPoly *mpoly, const int totpoly) { @@ -3538,7 +3585,7 @@ void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(to for (mp = mpoly; i--; mp++) { if ((mp->flag & ME_HIDE) == 0) { int ok = TRUE; - MLoop *ml; + const MLoop *ml; int j; j = mp->totloop; for (ml = &mloop[mp->loopstart]; j--; ml++) { diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index e194f990739..82d958a5c7b 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -74,6 +74,8 @@ void paintface_flush_flags(Object *ob) if (me == NULL) return; + /* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */ + /* we could call this directly in all areas that change selection, * since this could become slow for realtime updates (circle-select for eg) */ BKE_mesh_flush_select_from_polys(me); @@ -139,18 +141,20 @@ void paintface_hide(Object *ob, const bool unselected) a = me->totpoly; while (a--) { if ((mpoly->flag & ME_HIDE) == 0) { - if (unselected) { - if ((mpoly->flag & ME_FACE_SEL) == 0) mpoly->flag |= ME_HIDE; - } - else { - if ((mpoly->flag & ME_FACE_SEL)) mpoly->flag |= ME_HIDE; + if (((mpoly->flag & ME_FACE_SEL) == 0) == unselected) { + mpoly->flag |= ME_HIDE; } } - if (mpoly->flag & ME_HIDE) mpoly->flag &= ~ME_FACE_SEL; + + if (mpoly->flag & ME_HIDE) { + mpoly->flag &= ~ME_FACE_SEL; + } mpoly++; } + BKE_mesh_flush_hidden_from_polys(me); + paintface_flush_flags(ob); } @@ -174,6 +178,8 @@ void paintface_reveal(Object *ob) mpoly++; } + BKE_mesh_flush_hidden_from_polys(me); + paintface_flush_flags(ob); } diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index e0d578ec210..3db0bd61f03 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -416,9 +416,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) /* ensure that edges and faces get hidden as well (not used by * sculpt but it looks wrong when entering editmode otherwise) */ if (pbvh_type == PBVH_FACES) { - BKE_mesh_flush_hidden_from_verts(me->mvert, me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_hidden_from_verts(me); } ED_region_tag_redraw(ar); diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 4292246d8cc..848f7ee0fc1 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -118,12 +118,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, cddm->getVertArray(cddm), mdisps); - BKE_mesh_flush_hidden_from_verts(cddm->getVertArray(cddm), - cddm->getLoopArray(cddm), - cddm->getEdgeArray(cddm), - cddm->getNumEdges(cddm), - cddm->getPolyArray(cddm), - cddm->getNumPolys(cddm)); + BKE_mesh_flush_hidden_from_verts_ex(cddm->getVertArray(cddm), + cddm->getLoopArray(cddm), + cddm->getEdgeArray(cddm), + cddm->getNumEdges(cddm), + cddm->getPolyArray(cddm), + cddm->getNumPolys(cddm)); } if (grid_paint_mask) { float *paint_mask = CustomData_add_layer(&cddm->vertData, |