svn merge -r39800:39900 https://svn.blender.org/svnroot/bf-blender/trunk/blender
authorCampbell Barton <ideasman42@gmail.com>
Tue, 13 Sep 2011 07:19:36 +0000 (07:19 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 13 Sep 2011 07:19:36 +0000 (07:19 +0000)
1  2 
source/blender/editors/mesh/editmesh.c

index 132db6caaeb6856e5285b0eb306e2b1f8a807a4b,e371c346f362c7ddddb8efb9f193d667e736d502..7673bd8f31c35fce5385c8d8c11ea05a9cac50a5
@@@ -1099,7 -1099,7 +1099,7 @@@ void load_editMesh(Scene *scene, Objec
                int j;
  
                for (ob=G.main->object.first; ob; ob=ob->id.next) {
-                       if (ob->parent==ob && ELEM(ob->partype, PARVERT1,PARVERT3)) {
+                       if (ob->parent==obedit && ELEM(ob->partype, PARVERT1,PARVERT3)) {
                                
                                /* duplicate code from below, make it function later...? */
                                if (!vertMap) {
@@@ -1958,96 -1958,3 +1958,96 @@@ void em_setup_viewcontext(bContext *C, 
                vc->em= me->edit_mesh;
        }
  }
 +
 +
 +/* Jason (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 *verts, *mv, *mv_orig;
 +      int *index_array = NULL;
 +      int totvert;
 +      int i;
 +      
 +      if(me==NULL || dm==NULL)
 +              return;
 +
 +      index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
 +      
 +      verts = dm->getVertArray(dm);
 +      totvert = dm->getNumVerts(dm);
 +      
 +      mv= verts;
 +      
 +      for (i= 0; i<totvert; i++, mv++) { /* loop over derived mesh faces */
 +              if(index_array) {
 +                      mv_orig= me->mvert + index_array[i];
 +                      mv->flag= mv_orig->flag;
 +              } else {
 +                      mv_orig= me->mvert + i;
 +                      mv->flag= mv_orig->flag;
 +              }
 +      }
 +}
 +/* Jason note: caller needs to run paintvert_flush_flags(ob) after this */
 +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);
 +      }
 +}