diff options
author | Jason Hays <jason_hays22@mymail.eku.edu> | 2011-09-19 20:13:34 +0400 |
---|---|---|
committer | Jason Hays <jason_hays22@mymail.eku.edu> | 2011-09-19 20:13:34 +0400 |
commit | 535668eef01b29b18b71022d1d8f04962251e34c (patch) | |
tree | e024febb4d3871f52021589dffdd95ada582e0a1 /source/blender/editors/mesh | |
parent | d78231734d6ccf224738ea76307c26f8c0d4dab4 (diff) | |
parent | 2cbf475fb2c3c020029e1704c8e6cee04a267323 (diff) |
Merging radish branch into trunk.
http://wiki.blender.org/index.php?title=User:Jason_hays22/GSoC-2011
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh.c | 98 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_mods.c | 2 |
2 files changed, 100 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index c56a4238239..6a263fca915 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1958,3 +1958,101 @@ void em_setup_viewcontext(bContext *C, ViewContext *vc) vc->em= me->edit_mesh; } } + + +/* (similar to void paintface_flush_flags(Object *ob)) + * copy the vertex flags, most importantly selection from the mesh to the final derived mesh, + * use in object mode when selecting vertices (while painting) */ +void paintvert_flush_flags(Object *ob) +{ + Mesh *me= get_mesh(ob); + DerivedMesh *dm= ob->derivedFinal; + MVert *dm_mvert, *dm_mv; + int *index_array = NULL; + int totvert; + int i; + + if(me==NULL || dm==NULL) + return; + + index_array = dm->getVertDataArray(dm, CD_ORIGINDEX); + + dm_mvert = dm->getVertArray(dm); + totvert = dm->getNumVerts(dm); + + dm_mv= dm_mvert; + + if(index_array) { + int orig_index; + for (i= 0; i<totvert; i++, dm_mv++) { + orig_index= index_array[i]; + if(orig_index != ORIGINDEX_NONE) { + dm_mv->flag= me->mvert[index_array[i]].flag; + } + } + } + else { + for (i= 0; i<totvert; i++, dm_mv++) { + dm_mv->flag= me->mvert[i].flag; + } + } +} +/* note: if the caller passes FALSE to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */ +void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) +{ + Mesh *me; + MVert *mvert; + int a; + + me= get_mesh(ob); + if(me==NULL) return; + + if(action == SEL_INVERT) { + mvert= me->mvert; + a= me->totvert; + while(a--) { + if((mvert->flag & ME_HIDE) == 0) { + mvert->flag ^= SELECT; + } + mvert++; + } + } + else { + if (action == SEL_TOGGLE) { + action = SEL_SELECT; + + mvert= me->mvert; + a= me->totvert; + while(a--) { + if((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) { + action = SEL_DESELECT; + break; + } + mvert++; + } + } + + mvert= me->mvert; + a= me->totvert; + while(a--) { + if((mvert->flag & ME_HIDE) == 0) { + switch (action) { + case SEL_SELECT: + mvert->flag |= SELECT; + break; + case SEL_DESELECT: + mvert->flag &= ~SELECT; + break; + case SEL_INVERT: + mvert->flag ^= SELECT; + break; + } + } + mvert++; + } + } + + if(flush_flags) { + paintvert_flush_flags(ob); + } +} diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 9783f25466e..b256eeac4bc 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -266,6 +266,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, int mcords[][2], short tot, sho /* method in use for face selecting too */ if(vc->obedit==NULL) { if(paint_facesel_test(vc->obact)); + else if(paint_vertsel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -328,6 +329,7 @@ int EM_init_backbuf_circle(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)); + else if (paint_vertsel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; |