fix for weight paint face selection.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 5 Feb 2012 03:25:13 +0000 (03:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 5 Feb 2012 03:25:13 +0000 (03:25 +0000)
since removing tesselation faces we can no longer rely on me->totface & me->mface being set. now use polygons instead.

source/blender/editors/mesh/editface.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_select.c

index 8d56fa2b0b0f8bcdd7da68e66943cba79d9f525b..3962768222db83ebe648a1a5ef07b11fac9cffcb 100644 (file)
@@ -147,7 +147,7 @@ static int facesel_face_pick(struct bContext *C, Mesh *me, Object *ob, const int
                   on an edge in the backbuf, we can still select a face */
 
                int dist;
-               *index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, me->totface+1, &dist,0,NULL, NULL);
+               *index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, me->totpoly+1, &dist,0,NULL, NULL);
        }
        else {
                /* sample only on the exact position */
@@ -610,10 +610,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
        int sy= rect->ymax-rect->ymin+1;
        
        me= get_mesh(ob);
-       if(me==0) return 0;
-       if(me->totpoly==0) return 0;
 
-       if(me==NULL || me->totface==0 || sx*sy <= 0)
+       if(me==NULL || me->totpoly==0 || sx*sy <= 0)
                return OPERATOR_CANCELLED;
 
        selar= MEM_callocN(me->totpoly+1, "selar");
@@ -640,7 +638,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
        while(a--) {
                if(*rt) {
                        index= WM_framebuffer_to_index(*rt);
-                       if(index<=me->totface) selar[index]= 1;
+                       if(index<=me->totpoly) selar[index]= 1;
                }
                rt++;
        }
index de3c28ca919433fdb64f4d8dbb442eef5e86f241..1f4f4bd7031e40fd2a21dc75bec6140312d990cb 100644 (file)
@@ -115,25 +115,23 @@ static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flag
 static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
 {
        EdgeHash *eh = BLI_edgehash_new();
-       MFace *mf;
-       int i;
+       MPoly *mp;
+       MLoop *ml;
+       MLoop *ml_next;
+       int i, j;
        
-       for(i=0; i<me->totface; i++) {
-               mf = &me->mface[i];
+       for(i=0; i<me->totpoly; i++) {
+               mp = &me->mpoly[i];
 
-               if(!(mf->flag & ME_HIDE)) {
+               if (!(mp->flag & ME_HIDE)) {
                        unsigned int flags = eEdge_Visible;
-                       if(mf->flag & ME_FACE_SEL) flags |= eEdge_Select;
-
-                       get_marked_edge_info__orFlags(eh, mf->v1, mf->v2, flags);
-                       get_marked_edge_info__orFlags(eh, mf->v2, mf->v3, flags);
+                       if (mp->flag & ME_FACE_SEL) flags |= eEdge_Select;
 
-                       if(mf->v4) {
-                               get_marked_edge_info__orFlags(eh, mf->v3, mf->v4, flags);
-                               get_marked_edge_info__orFlags(eh, mf->v4, mf->v1, flags);
+                       ml = me->mloop + mp->loopstart;
+                       for (j=0; j<mp->totloop; j++, ml++) {
+                               ml_next = ME_POLY_LOOP_NEXT(me->mloop, mp, j);
+                               get_marked_edge_info__orFlags(eh, ml->v, ml_next->v, flags);
                        }
-                       else
-                               get_marked_edge_info__orFlags(eh, mf->v3, mf->v1, flags);
                }
        }
 
@@ -592,8 +590,8 @@ static int wpaint__setSolidDrawOptions_material(void *userData, int index, int *
 static int wpaint__setSolidDrawOptions_facemask(void *userData, int index, int *drawSmooth_r)
 {
        Mesh *me = (Mesh*)userData;
-       MFace *mface = &me->mface[index];
-       if (mface->flag & ME_HIDE) return 0;
+       MPoly *mp = &me->mpoly[index];
+       if (mp->flag & ME_HIDE) return 0;
        *drawSmooth_r = 1;
        return 1;
 }
@@ -863,9 +861,9 @@ static int tex_mat_set_face_mesh_cb(void *userData, int index)
        /* faceselect mode face hiding */
        TexMatCallback *data= (TexMatCallback*)userData;
        Mesh *me = (Mesh*)data->me;
-       MPoly *mface = &me->mpoly[index];
+       MPoly *mp = &me->mpoly[index];
 
-       return !(mface->flag & ME_HIDE);
+       return !(mp->flag & ME_HIDE);
 }
 
 static int tex_mat_set_face_editmesh_cb(void *userData, int index)
index 2bca87c564e6f4f45c1bef1580b157e266d3ecda..8c05e1c6a4796e9b641446458639df539d2e0e26 100644 (file)
@@ -3239,7 +3239,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        /* weight paint in solid mode, special case. focus on making the weights clear
                         * rather than the shading, this is also forced in wire view */
                        GPU_enable_material(0, NULL);
-                       dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me->mface, 1);
+                       dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me->mpoly, 1);
                
                        bglPolygonOffset(rv3d->dist, 1.0);
                        glDepthMask(0); // disable write in zbuffer, selected edge wires show better
@@ -3364,7 +3364,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                                glEnable(GL_LIGHTING);
                                glEnable(GL_COLOR_MATERIAL);
 
-                               dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me->mface, 1);
+                               dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me->mpoly, 1);
                                glDisable(GL_COLOR_MATERIAL);
                                glDisable(GL_LIGHTING);
 
@@ -7144,7 +7144,7 @@ static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index, int *UNUS
 {
        Mesh *me = userData;
 
-       if (!(me->mface[index].flag&ME_HIDE)) {
+       if (!(me->mpoly[index].flag&ME_HIDE)) {
                WM_set_framebuffer_index_color(index+1);
                return 1;
        } else {
@@ -7157,7 +7157,7 @@ static int bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index, int *UNU
 {
        Mesh *me = userData;
 
-       if (!(me->mface[index].flag & ME_HIDE)) {
+       if (!(me->mpoly[index].flag & ME_HIDE)) {
                return 1;
        } else {
                return 0;
index ee3c0ee82344b88899608abb462061a2524fb538..204fa132c181c85ae2cd38314fecb03c3377f4be 100644 (file)
@@ -857,7 +857,7 @@ static void do_lasso_select_paintface(ViewContext *vc, int mcords[][2], short mo
        Mesh *me= ob?ob->data:NULL;
        rcti rect;
 
-       if(me==NULL || me->totface==0)
+       if(me==NULL || me->totpoly==0)
                return;
 
        if(extend==0 && select)