svn merge ^/trunk/blender/ -r41453:41458
authorCampbell Barton <ideasman42@gmail.com>
Wed, 2 Nov 2011 06:19:04 +0000 (06:19 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 2 Nov 2011 06:19:04 +0000 (06:19 +0000)
1  2 
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/transform/transform.c
source/blender/makesdna/DNA_mesh_types.h

index 0e0b1ae2bf24c6a597d638b2a804878c5149d5c7,57f926b06126010a85e2a5e7cc53a72e69b28b73..7599cf1117aca32a82486d75f58e34d9d9cf906f
@@@ -466,37 -387,16 +466,16 @@@ void vpaint_fill(Object *ob, unsigned i
  /* fills in the selected faces with the current weight and vertex group */
  void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
  {
-       Mesh *me;
-       MFace *mface;
+       Mesh *me= ob->data;
 -      MFace *mf;
++      MPoly *mf;
        MDeformWeight *dw, *uw;
-       int *indexar;
-       unsigned int index;
        int vgroup, vgroup_mirror= -1;
-       int selected;
-       
-       int use_vert_sel;
-       me= ob->data;
-       if(me==NULL || me->totface==0 || me->dvert==NULL || !me->mface) return;
-       
-       selected= (me->editflag & ME_EDIT_PAINT_MASK);
-       
-       use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+       unsigned int index;
  
-       indexar= get_indexarray(me);
+       /* mutually exclusive, could be made into a */
+       const short paint_selmode= ME_EDIT_PAINT_SEL_MODE(me);
  
-       if(selected) {
-               for(index=0, mface=me->mface; index<me->totface; index++, mface++) {
-                       if((mface->flag & ME_FACE_SEL)==0)
-                               indexar[index]= 0;
-                       else
-                               indexar[index]= index+1;
-               }
-       }
-       else {
-               for(index=0; index<me->totface; index++)
-                       indexar[index]= index+1;
-       }
 -      if(me->totface==0 || me->dvert==NULL || !me->mface) return;
++      if(me->totpoly==0 || me->dvert==NULL || !me->mpoly) return;
        
        vgroup= ob->actdef-1;
  
        
        copy_wpaint_prev(wp, me->dvert, me->totvert);
        
-       for(index=0; index<me->totface; index++) {
-               if(indexar[index] && indexar[index]<=me->totface) {
-                       MFace *mf= &me->mface[indexar[index]-1];
-                       unsigned int fidx= mf->v4 ? 3:2;
 -      for(index=0, mf= me->mface; index < me->totface; index++, mf++) {
 -              unsigned int fidx= mf->v4 ? 3:2;
++      for(index=0, mf= me->mpoly; index < me->totpoly; index++, mf++) {
++              unsigned int fidx= mf->totloop - 1;
+               if ((paint_selmode == SCE_SELECT_FACE) && !(mf->flag & ME_FACE_SEL)) {
+                       continue;
+               }
  
-                       do {
-                               unsigned int vidx= *(&mf->v1 + fidx);
+               do {
 -                      unsigned int vidx= *(&mf->v1 + fidx);
++                      unsigned int vidx= me->mloop[mf->loopstart + fidx].v;
  
-                               if(!me->dvert[vidx].flag) {
-                                       if(use_vert_sel && !(me->mvert[vidx].flag & SELECT)) {
-                                               continue;
-                                       }
+                       if(!me->dvert[vidx].flag) {
+                               if((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) {
+                                       continue;
+                               }
  
-                                       dw= defvert_verify_index(&me->dvert[vidx], vgroup);
-                                       if(dw) {
-                                               uw= defvert_verify_index(wp->wpaint_prev+vidx, vgroup);
-                                               uw->weight= dw->weight; /* set the undo weight */
-                                               dw->weight= paintweight;
-                                               if(me->editflag & ME_EDIT_MIRROR_X) {   /* x mirror painting */
-                                                       int j= mesh_get_x_mirror_vert(ob, vidx);
-                                                       if(j>=0) {
-                                                               /* copy, not paint again */
-                                                               if(vgroup_mirror != -1) {
-                                                                       dw= defvert_verify_index(me->dvert+j, vgroup_mirror);
-                                                                       uw= defvert_verify_index(wp->wpaint_prev+j, vgroup_mirror);
-                                                               } else {
-                                                                       dw= defvert_verify_index(me->dvert+j, vgroup);
-                                                                       uw= defvert_verify_index(wp->wpaint_prev+j, vgroup);
-                                                               }
-                                                               uw->weight= dw->weight; /* set the undo weight */
-                                                               dw->weight= paintweight;
+                               dw= defvert_verify_index(&me->dvert[vidx], vgroup);
+                               if(dw) {
+                                       uw= defvert_verify_index(wp->wpaint_prev+vidx, vgroup);
+                                       uw->weight= dw->weight; /* set the undo weight */
+                                       dw->weight= paintweight;
+                                       if(me->editflag & ME_EDIT_MIRROR_X) {   /* x mirror painting */
+                                               int j= mesh_get_x_mirror_vert(ob, vidx);
+                                               if(j>=0) {
+                                                       /* copy, not paint again */
+                                                       if(vgroup_mirror != -1) {
+                                                               dw= defvert_verify_index(me->dvert+j, vgroup_mirror);
+                                                               uw= defvert_verify_index(wp->wpaint_prev+j, vgroup_mirror);
+                                                       } else {
+                                                               dw= defvert_verify_index(me->dvert+j, vgroup);
+                                                               uw= defvert_verify_index(wp->wpaint_prev+j, vgroup);
                                                        }
+                                                       uw->weight= dw->weight; /* set the undo weight */
+                                                       dw->weight= paintweight;
                                                }
                                        }
-                                       me->dvert[vidx].flag= 1;
                                }
+                               me->dvert[vidx].flag= 1;
+                       }
  
-                       } while (fidx--);
-               }
+               } while (fidx--);
        }
  
        {
@@@ -1000,10 -899,10 +978,10 @@@ static int weight_sample_invoke(bContex
                                mval_f[0]= (float)event->mval[0];
                                mval_f[1]= (float)event->mval[1];
  
-                               fidx= mf->totloop;
 -                              fidx= mf->v4 ? 3:2;
++                              fidx= mf->totloop - 1;
                                do {
                                        float co[3], sco[3], len;
 -                                      const int v_idx= (*(&mf->v1 + fidx));
 +                                      const int v_idx= me->mloop[mf->loopstart + fidx].v;
                                        dm->getVertCo(dm, v_idx, co);
                                        project_float_noclip(vc.ar, co, sco);
                                        len= len_squared_v2v2(mval_f, sco);
@@@ -1069,8 -968,8 +1047,8 @@@ static EnumPropertyItem *weight_paint_s
                                if(index && index<=me->totface) {
                                        const int totgroup= BLI_countlist(&vc.obact->defbase);
                                        if(totgroup) {
 -                                              MFace *mf= ((MFace *)me->mface) + index-1;
 -                                              unsigned int fidx= mf->v4 ? 3:2;
 +                                              MPoly *mf= ((MPoly *)me->mpoly) + index-1;
-                                               unsigned int fidx= mf->totloop;
++                                              unsigned int fidx= mf->totloop - 1;
                                                int *groups= MEM_callocN(totgroup*sizeof(int), "groups");
                                                int found= FALSE;