Revision: 41006
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41006
Author:   ender79
Date:     2011-10-14 09:05:20 +0000 (Fri, 14 Oct 2011)
Log Message:
-----------
Fix vertex paint face selection

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenloader/intern/writefile.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
    branches/bmesh/blender/source/blender/editors/mesh/editface.c

Modified: branches/bmesh/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/bmesh/blender/source/blender/blenloader/intern/writefile.c 
2011-10-14 08:06:59 UTC (rev 41005)
+++ branches/bmesh/blender/source/blender/blenloader/intern/writefile.c 
2011-10-14 09:05:20 UTC (rev 41006)
@@ -1667,6 +1667,7 @@
                                write_customdata(wd, &mesh->id, 
mesh->pv->totvert, &mesh->vdata, -1, 0);
                                write_customdata(wd, &mesh->id, 
mesh->pv->totedge, &mesh->edata,
                                        CD_MEDGE, mesh->totedge);
+                               /* BMESH_TODO: probably need to deal with polys 
here */
                                write_customdata(wd, &mesh->id, 
mesh->pv->totface, &mesh->fdata,
                                        CD_MFACE, mesh->totface);
                        }

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c   
2011-10-14 08:06:59 UTC (rev 41005)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c   
2011-10-14 09:05:20 UTC (rev 41006)
@@ -360,14 +360,13 @@
 
 mdisps is a grid of displacements, ordered thus:
 
-v1/center -- v4/next -> x
-|                 |
-|                                |
-v2/prev ---- v3/cur
-|
-V
-
-y
+ v1/center----v4/next -> x
+     |           |
+     |           |
+  v2/prev------v3/cur
+     |
+     V
+     y
 */
 
 static int compute_mdisp_quad(BMLoop *l, double v1[3], double v2[3], double 
v3[3], double v4[3], double e1[3], double e2[3])
@@ -611,15 +610,15 @@
                /*****
                mdisps is a grid of displacements, ordered thus:
                
-                             v4/next
-                               |                               
-                |       v1/cent-mid2 ---> x
-                |       |       | 
-                |       |       |
-               v2/prev--mid1--v3/cur
-                        |
-                        V
-                        y
+                                  v4/next
+                                    |                          
+                |      v1/cent-----mid2 ---> x
+                |         |         | 
+                |         |         |
+               v2/prev---mid1-----v3/cur
+                          |
+                          V
+                          y
                *****/
                  
                sides = sqrt(mdp->totdisp);
@@ -642,15 +641,15 @@
                /*****
                mdisps is a grid of displacements, ordered thus:
                
-                             v4/next
-                               |                               
-                |       v1/cent-mid2 ---> x
-                |       |       | 
-                |       |       |
-               v2/prev--mid1--v3/cur
-                        |
-                        V
-                        y
+                                  v4/next
+                                    |                          
+                |      v1/cent-----mid2 ---> x
+                |         |         | 
+                |         |         |
+               v2/prev---mid1-----v3/cur
+                          |
+                          V
+                          y
                *****/
                 
                if (l->radial_next == l)
@@ -737,8 +736,8 @@
        else if(yn>=xn && yn>=zn) {ax= 0; ay= 2;}
        else {ax= 1; ay= 2;} 
        
-       /*scale source face coordinates a bit, so points sitting directonly on 
an
-      edge will work.*/
+       /* scale source face coordinates a bit, so points sitting directonly on 
an
+          edge will work.*/
        mul_v3_fl(cent, 1.0f/(float)source->len);
        for (i=0; i<source->len; i++) {
                float vec[3], tmp[3];

Modified: branches/bmesh/blender/source/blender/editors/mesh/editface.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/editface.c       
2011-10-14 08:06:59 UTC (rev 41005)
+++ branches/bmesh/blender/source/blender/editors/mesh/editface.c       
2011-10-14 09:05:20 UTC (rev 41006)
@@ -69,28 +69,50 @@
 
 /* copy the face flags, most importantly selection from the mesh to the final 
derived mesh,
  * use in object mode when selecting faces (while painting) */
+
 void paintface_flush_flags(Object *ob)
 {
-       Mesh *me= get_mesh(ob);
-       DerivedMesh *dm= ob->derivedFinal;
-       MPoly *mf_orig, *mp;
-       int *index = NULL;
-       int totface;
+       Mesh *me = get_mesh(ob);
+       DerivedMesh *dm = ob->derivedFinal;
+       MPoly *polys, *mp_orig;
+       MFace *faces, *mf;
+       int *index_array = NULL;
+       int totface, totpoly;
        int i;
        
-       if(me==NULL || dm==NULL)
+       if (me==NULL || dm==NULL) {
                return;
+       }
 
-       totface = dm->getNumFaces(dm);
-       index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
-       mp = dm->getPolyArray(dm);
-       for (i=0; i<dm->numPolyData; i++, index++, mp++) {
-               if (!index)
-                       break;
+       /*
+        * Try to push updated mesh poly flags to two other data sets:
+        *  - Mesh polys => Mesh tess faces
+        *  - Mesh polys => Final derived mesh polys
+        */
 
-               mf_orig = me->mpoly + *index;
-               mp->flag = mf_orig->flag;
+       if (index_array = CustomData_get_layer(&me->fdata, CD_ORIGINDEX)) {
+               faces = me->mface;
+               totface = me->totface;
+               
+               /* loop over tessfaces */
+               for (i= 0; i<totface; i++) {
+                       /* Copy flags onto the tessface from its poly */
+                       mp_orig = me->mpoly + index_array[i];
+                       faces[i].flag = mp_orig->flag;
+               }
        }
+
+       if (index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX)) {
+               polys = dm->getPolyArray(dm);
+               totpoly = dm->getNumFaces(dm);
+
+               /* loop over final derived polys */
+               for (i= 0; i<totpoly; i++) {
+                       /* Copy flags onto the mesh poly from its final derived 
poly */
+                       mp_orig = me->mpoly + index_array[i];
+                       polys[i].flag = mp_orig->flag;
+               }
+       }
 }
 
 /* returns 0 if not found, otherwise 1 */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to