svn merge -r41575:41602 ^/trunk/blender
authorCampbell Barton <ideasman42@gmail.com>
Mon, 7 Nov 2011 07:01:24 +0000 (07:01 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 7 Nov 2011 07:01:24 +0000 (07:01 +0000)
46 files changed:
1  2 
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/bvhutils.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/fluidsim.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/intern/math_vector_inline.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/armature/meshlaplacian.c
source/blender/editors/curve/editcurve.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_lattice.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_transform.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/particle_object.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/drawvolume.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/util/crazyspace.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/modifiers/intern/MOD_build.c
source/blender/modifiers/intern/MOD_particleinstance.c
source/blender/modifiers/intern/MOD_simpledeform.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/strand.c

@@@ -736,9 -1539,9 +736,10 @@@ static float *get_editbmesh_orco_verts(
        
        orco = MEM_mallocN(sizeof(float)*3*totvert, "EditMesh Orco");
  
 -      for(a=0, eve=em->verts.first; eve; eve=eve->next, a+=3) {
 +      eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
-       for (a=0; eve; eve=BMIter_Step(&iter), a+=3)
-               VECCOPY(orco+a, eve->co);
++      for (a=0; eve; eve=BMIter_Step(&iter), a+=3) {
+               copy_v3_v3(orco+a, eve->co);
+       }
        
        return orco;
  }
@@@ -1464,18 -2139,15 +1465,18 @@@ static void mesh_calc_modifiers(Scene *
        BLI_linklist_free(datamasks, NULL);
  }
  
 -float (*editmesh_get_vertex_cos(EditMesh *em, int *numVerts_r))[3]
 +float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *numVerts_r))[3]
  {
 -      int i, numVerts = *numVerts_r = BLI_countlist(&em->verts);
 +      int i, numVerts = *numVerts_r = em->bm->totvert;
        float (*cos)[3];
 -      EditVert *eve;
 +      BMIter iter;
 +      BMVert *eve;
  
 -      cos = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos");
 -      for (i=0,eve=em->verts.first; i<numVerts; i++,eve=eve->next) {
 +      cos = MEM_mallocN(sizeof(float)*3*numVerts, "vertexcos");
 +
 +      eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
 +      for (i=0; eve; eve=BMIter_Step(&iter), i++) {
-               VECCOPY(cos[i], eve->co);
+               copy_v3_v3(cos[i], eve->co);
        }
  
        return cos;
@@@ -581,79 -582,19 +580,79 @@@ BVHTree* bvhtree_from_mesh_faces(BVHTre
                        tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis);
                        if(tree != NULL)
                        {
 -                              /* XXX, for snap only, em & dm are assumed to be aligned, since dm is the em's cage */
 -                              EditMesh *em= data->em_evil;
 +                              BMEditMesh *em= data->em_evil;
                                if(em) {
 -                                      EditFace *efa= em->faces.first;
 -                                      for(i = 0; i < numFaces; i++, efa= efa->next) {
 -                                              if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) {
 +                                      /*data->em_evil is only set for snapping, and only for the mesh of the object
 +                                        which is currently open in edit mode. When set, the bvhtree should not contain
 +                                        faces that will interfere with snapping (e.g. faces that are hidden/selected
 +                                        or faces that have selected verts).*/
 +
 +                                      /* XXX, for snap only, em & dm are assumed to be aligned, since dm is the em's cage */
 +
 +                                      /*Insert BMesh-tesselation triangles into the bvh tree, unless they are hidden
 +                                        and/or selected. Even if the faces themselves are not selected for the snapped
 +                                        transform, having a vertex selected means the face (and thus it's tesselated
 +                                        triangles) will be moving and will not be a good snap targets.*/
 +                                      for (i = 0; i < em->tottri; i++) {
 +                                              BMLoop **tri = em->looptris[i];
 +                                              BMFace *f;
 +                                              BMVert *v;
 +                                              BMIter iter;
 +                                              int insert;
 +
 +                                              /*Each loop of the triangle points back to the BMFace it was tesselated from.
 +                                                All three should point to the same face, so just use the face from the first
 +                                                loop.*/
 +                                              f = tri[0]->f;
 +
 +                                              /*If the looptris is ordered such that all triangles tesselated from a single
 +                                                faces are consecutive elements in the array, then we could speed up the tests
 +                                                below by using the insert value from the previous iteration.*/
 +
 +                                              /*Start with the assumption the triangle should be included for snapping.*/
 +                                              insert = 1;
 +
 +                                              if (BM_TestHFlag(f, BM_SELECT) || BM_TestHFlag(f, BM_HIDDEN)) {
 +                                                      /*Don't insert triangles tesselated from faces that are hidden
 +                                                        or selected*/
 +                                                      insert = 0;
 +                                              }
 +                                              else {
 +                                                      BM_ITER(v, &iter, em->bm, BM_VERTS_OF_FACE, f) {
 +                                                              if (BM_TestHFlag(v, BM_SELECT)) {
 +                                                                      /*Don't insert triangles tesselated from faces that have
 +                                                                        any selected verts.*/
 +                                                                      insert = 0;
 +                                                              }
 +                                                      }
 +                                              }
 +
 +                                              if (insert)
 +                                              {
 +                                                      /*No reason found to block hit-testing the triangle for snap,
 +                                                        so insert it now.*/
 +                                                      float co[4][3];
-                                                       VECCOPY(co[0], tri[0]->v->co);
-                                                       VECCOPY(co[1], tri[1]->v->co);
-                                                       VECCOPY(co[2], tri[2]->v->co);
++                                                      copy_v3_v3(co[0], tri[0]->v->co);
++                                                      copy_v3_v3(co[1], tri[1]->v->co);
++                                                      copy_v3_v3(co[2], tri[2]->v->co);
 +                                      
 +                                                      BLI_bvhtree_insert(tree, i, co[0], 3);
 +                                              }
 +                                      }
 +                              }
 +                              else {
 +                                      MVert *vert     = mesh->getVertDataArray(mesh, CD_MVERT);
 +                                      MFace *face = mesh->getTessFaceDataArray(mesh, CD_MFACE);
 +
 +                                      if (vert != NULL && face != NULL) {
 +                                              for(i = 0; i < numFaces; i++) {
                                                        float co[4][3];
-                                                       VECCOPY(co[0], vert[ face[i].v1 ].co);
-                                                       VECCOPY(co[1], vert[ face[i].v2 ].co);
-                                                       VECCOPY(co[2], vert[ face[i].v3 ].co);
+                                                       copy_v3_v3(co[0], vert[ face[i].v1 ].co);
+                                                       copy_v3_v3(co[1], vert[ face[i].v2 ].co);
+                                                       copy_v3_v3(co[2], vert[ face[i].v3 ].co);
                                                        if(face[i].v4)
-                                                               VECCOPY(co[3], vert[ face[i].v4 ].co);
+                                                               copy_v3_v3(co[3], vert[ face[i].v4 ].co);
 -                                      
 +                              
                                                        BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
                                                }
                                        }
@@@ -513,10 -204,9 +513,10 @@@ Mesh *copy_mesh(Mesh *me
  {
        Mesh *men;
        MTFace *tface;
 +      MTexPoly *txface;
        int a, i;
        
-       men= copy_libblock(me);
+       men= copy_libblock(&me->id);
        
        men->mat= MEM_dupallocN(me->mat);
        for(a=0; a<men->totcol; a++) {
@@@ -3326,15 -3325,15 +3327,15 @@@ static void psys_face_mat(Object *ob, D
  
        int i = pa->num_dmcache==DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache;
        
 -      if (i==-1 || i >= dm->getNumFaces(dm)) { unit_m4(mat); return; }
 +      if (i==-1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; }
  
 -      mface=dm->getFaceData(dm,i,CD_MFACE);
 -      osface=dm->getFaceData(dm,i,CD_ORIGSPACE);
 +      mface=dm->getTessFaceData(dm,i,CD_MFACE);
 +      osface=dm->getTessFaceData(dm,i,CD_ORIGSPACE);
        
        if(orco && (orcodata=dm->getVertDataArray(dm, CD_ORCO))) {
-               VECCOPY(v[0], orcodata[mface->v1]);
-               VECCOPY(v[1], orcodata[mface->v2]);
-               VECCOPY(v[2], orcodata[mface->v3]);
+               copy_v3_v3(v[0], orcodata[mface->v1]);
+               copy_v3_v3(v[1], orcodata[mface->v2]);
+               copy_v3_v3(v[2], orcodata[mface->v3]);
  
                /* ugly hack to use non-transformed orcos, since only those
                 * give symmetric results for mirroring in particle mode */
@@@ -4514,10 -4514,11 +4515,10 @@@ void psys_make_billboard(ParticleBillbo
        mul_v3_fl(xvec, bb->size[0]);
        mul_v3_fl(yvec, bb->size[1]);
  
-       VECADDFAC(center, bb->vec, xvec, bb->offset[0]);
-       VECADDFAC(center, center, yvec, bb->offset[1]);
+       madd_v3_v3v3fl(center, bb->vec, xvec, bb->offset[0]);
+       madd_v3_v3fl(center, yvec, bb->offset[1]);
  }
  
 -
  void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) {
        ParticleSimulationData sim= {0};
        sim.scene= scene;
@@@ -1138,12 -1138,12 +1138,12 @@@ static int distribute_threads_init_data
                orcodata= dm->getVertDataArray(dm, CD_ORCO);
  
                for(i=0; i<totelem; i++){
 -                      MFace *mf=dm->getFaceData(dm,i,CD_MFACE);
 +                      MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
  
                        if(orcodata) {
-                               VECCOPY(co1, orcodata[mf->v1]);
-                               VECCOPY(co2, orcodata[mf->v2]);
-                               VECCOPY(co3, orcodata[mf->v3]);
+                               copy_v3_v3(co1, orcodata[mf->v1]);
+                               copy_v3_v3(co2, orcodata[mf->v2]);
+                               copy_v3_v3(co3, orcodata[mf->v3]);
                                transform_mesh_orco_verts((Mesh*)ob->data, &co1, 1, 1);
                                transform_mesh_orco_verts((Mesh*)ob->data, &co2, 1, 1);
                                transform_mesh_orco_verts((Mesh*)ob->data, &co3, 1, 1);
@@@ -354,12 -354,12 +354,12 @@@ static void fill_scs_points(Object *ob
        for(i = 0; i < dm->getNumVerts(dm); i++)
        {
                float tmpvec[3];
-               VECCOPY(tmpvec, mvert[i].co);
+               copy_v3_v3(tmpvec, mvert[i].co);
                mul_m4_v3(ob->obmat, tmpvec);
-               VECCOPY(&scs->points[i * 3], tmpvec);
+               copy_v3_v3(&scs->points[i * 3], tmpvec);
        }
        
 -      for(i = 0, facecounter = 0; i < dm->getNumFaces(dm); i++)
 +      for(i = 0, facecounter = 0; i < dm->getNumTessFaces(dm); i++)
        {
                int again = 0;
                do
@@@ -3101,12 -3104,12 +3105,12 @@@ static int particle_intersect_dm(Scene 
                DO_MINMAX(co2,p_min,p_max);
        }
        else{
-               VECCOPY(p_min,pa_minmax);
-               VECCOPY(p_max,pa_minmax+3);
+               copy_v3_v3(p_min,pa_minmax);
+               copy_v3_v3(p_max,pa_minmax+3);
        }
  
 -      totface=dm->getNumFaces(dm);
 -      mface=dm->getFaceDataArray(dm,CD_MFACE);
 +      totface=dm->getNumTessFaces(dm);
 +      mface=dm->getTessFaceDataArray(dm,CD_MFACE);
        mvert=dm->getVertDataArray(dm,CD_MVERT);
        
        /* lets intersect the faces */
@@@ -2337,9 -2320,9 +2338,9 @@@ void sculpt_vertcos_to_key(Object *ob, 
                MVert *mvert= me->mvert;
  
                for (a= 0; a < me->totvert; a++, mvert++)
-                       VECCOPY(mvert->co, vertCos[a]);
+                       copy_v3_v3(mvert->co, vertCos[a]);
  
 -              mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
 +              mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
        }
  
        /* apply new coords on active key block */
@@@ -4362,329 -4320,405 +4362,329 @@@ static int createSlideVerts(TransInfo *
                }
        }
  
 -      // Get # of selected verts
 -      for(ev=em->verts.first;ev;ev=ev->next) {
 -              if(ev->f & SELECT) vertsel++;
 +      j = 0;
 +      BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +              if (BM_TestHFlag(v, BM_SELECT)) {
 +                      BM_SetHFlag(v, BM_TMP_TAG);
 +                      BLI_smallhash_insert(&table, (uintptr_t)v, SET_INT_IN_POINTER(j));
 +                      j += 1;
 +              }
 +              else {
 +                      BM_ClearHFlag(v, BM_TMP_TAG);
 +              }
        }
  
 -      // Test for multiple segments
 -      if(vertsel > numsel+1) {
 -              //BKE_report(op->reports, RPT_ERROR, "Please choose a single edge loop");
 -              MEM_freeN(sld);
 +      if (!j)
                return 0;
 -      }
  
 -      // Get the edgeloop in order - mark f1 with SELECT once added
 -      for(eed=em->edges.first;eed;eed=eed->next) {
 -              if((eed->f & SELECT) && !(eed->f1 & SELECT)) {
 -                      // If this is the first edge added, just put it in
 -                      if(!edgelist) {
 -                              BLI_linklist_prepend(&edgelist,eed);
 -                              numadded++;
 -                              first = eed;
 -                              last  = eed;
 -                              eed->f1 = SELECT;
 -                      } else {
 -                              if(editedge_getSharedVert(eed, last)) {
 -                                      BLI_linklist_append(&edgelist,eed);
 -                                      eed->f1 = SELECT;
 -                                      numadded++;
 -                                      last = eed;
 -                              }  else if(editedge_getSharedVert(eed, first)) {
 -                                      BLI_linklist_prepend(&edgelist,eed);
 -                                      eed->f1 = SELECT;
 -                                      numadded++;
 -                                      first = eed;
 -                              }
 -                      }
 -              }
 -              if(eed->next == NULL && numadded != numsel) {
 -                      eed=em->edges.first;
 -                      timesthrough++;
 -              }
 +      tempsv = MEM_callocN(sizeof(TransDataSlideVert)*j, "tempsv");
 +
 +      j = 0;
 +      while (1) {
 +              v = NULL;
 +              BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                      if (BM_TestHFlag(v, BM_TMP_TAG))
 +                              break;
  
 -              // It looks like there was an unexpected case - Hopefully should not happen
 -              if(timesthrough >= numsel*2) {
 -                      BLI_linklist_free(edgelist,NULL);
 -                      //BKE_report(op->reports, RPT_ERROR, "Could not order loop");
 -                      MEM_freeN(sld);
 -                      return 0;
                }
 -      }
  
 -      // Put the verts in order in a linklist
 -      look = edgelist;
 -      while(look) {
 -              eed = look->link;
 -              if(!vertlist) {
 -                      if(look->next) {
 -                              temp = look->next->link;
 +              if (!v)
 +                      break;
  
 -                              //This is the first entry takes care of extra vert
 -                              if(eed->v1 != temp->v1 && eed->v1 != temp->v2) {
 -                                      BLI_linklist_append(&vertlist,eed->v1);
 -                                      eed->v1->f1 = 1;
 -                              } else {
 -                                      BLI_linklist_append(&vertlist,eed->v2);
 -                                      eed->v2->f1 = 1;
 -                              }
 -                      } else {
 -                              //This is the case that we only have 1 edge
 -                              BLI_linklist_append(&vertlist,eed->v1);
 -                              eed->v1->f1 = 1;
 -                      }
 -              }
 -              // for all the entries
 -              if(eed->v1->f1 != 1) {
 -                      BLI_linklist_append(&vertlist,eed->v1);
 -                      eed->v1->f1 = 1;
 -              } else  if(eed->v2->f1 != 1) {
 -                      BLI_linklist_append(&vertlist,eed->v2);
 -                      eed->v2->f1 = 1;
 -              }
 -              look = look->next;
 -      }
 -
 -      // populate the SlideVerts
 -
 -      vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createSlideVerts gh");
 -      look = vertlist;
 -      while(look) {
 -              i=0;
 -              j=0;
 -              ev = look->link;
 -              tempsv = (struct TransDataSlideVert*)MEM_mallocN(sizeof(struct TransDataSlideVert),"SlideVert");
 -              tempsv->up = NULL;
 -              tempsv->down = NULL;
 -              tempsv->origvert.co[0] = ev->co[0];
 -              tempsv->origvert.co[1] = ev->co[1];
 -              tempsv->origvert.co[2] = ev->co[2];
 -              tempsv->origvert.no[0] = ev->no[0];
 -              tempsv->origvert.no[1] = ev->no[1];
 -              tempsv->origvert.no[2] = ev->no[2];
 -              // i is total edges that vert is on
 -              // j is total selected edges that vert is on
 -
 -              for(eed=em->edges.first;eed;eed=eed->next) {
 -                      if(eed->v1 == ev || eed->v2 == ev) {
 -                              i++;
 -                              if(eed->f & SELECT) {
 -                                       j++;
 -                              }
 -                      }
 -              }
 -              // If the vert is in the middle of an edge loop, it touches 2 selected edges and 2 unselected edges
 -              if(i == 4 && j == 2) {
 -                      for(eed=em->edges.first;eed;eed=eed->next) {
 -                              if(editedge_containsVert(eed, ev)) {
 -                                      if(!(eed->f & SELECT)) {
 -                                              if(!tempsv->up) {
 -                                                      tempsv->up = eed;
 -                                              } else if (!(tempsv->down)) {
 -                                                      tempsv->down = eed;
 -                                              }
 -                                      }
 -                              }
 -                      }
 -              }
 -              // If it is on the end of the loop, it touches 1 selected and as least 2 more unselected
 -              if(i >= 3 && j == 1) {
 -                      for(eed=em->edges.first;eed;eed=eed->next) {
 -                              if(editedge_containsVert(eed, ev) && eed->f & SELECT) {
 -                                      for(efa = em->faces.first;efa;efa=efa->next) {
 -                                              if(editface_containsEdge(efa, eed)) {
 -                                                      if(editedge_containsVert(efa->e1, ev) && efa->e1 != eed) {
 -                                                              if(!tempsv->up) {
 -                                                                      tempsv->up = efa->e1;
 -                                                              } else if (!(tempsv->down)) {
 -                                                                      tempsv->down = efa->e1;
 -                                                              }
 -                                                      }
 -                                                      if(editedge_containsVert(efa->e2, ev) && efa->e2 != eed) {
 -                                                              if(!tempsv->up) {
 -                                                                      tempsv->up = efa->e2;
 -                                                              } else if (!(tempsv->down)) {
 -                                                                      tempsv->down = efa->e2;
 -                                                              }
 -                                                      }
 -                                                      if(editedge_containsVert(efa->e3, ev) && efa->e3 != eed) {
 -                                                              if(!tempsv->up) {
 -                                                                      tempsv->up = efa->e3;
 -                                                              } else if (!(tempsv->down)) {
 -                                                                      tempsv->down = efa->e3;
 -                                                              }
 -                                                      }
 -                                                      if(efa->e4) {
 -                                                              if(editedge_containsVert(efa->e4, ev) && efa->e4 != eed) {
 -                                                                      if(!tempsv->up) {
 -                                                                              tempsv->up = efa->e4;
 -                                                                      } else if (!(tempsv->down)) {
 -                                                                              tempsv->down = efa->e4;
 -                                                                      }
 -                                                              }
 -                                                      }
 +              if (!v->e)
 +                      continue;
 +              
 +              first = v;
  
 -                                              }
 -                                      }
 -                              }
 +              /*walk along the edge loop*/
 +              e = v->e;
 +
 +              /*first, rewind*/
 +              numsel = 0;
 +              do {
 +                      e = get_other_edge(bm, v, e);
 +                      if (!e) {
 +                              e = v->e;
 +                              break;
                        }
 -              }
 -              if(i > 4 && j == 2) {
 -                      BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
 -                      BLI_linklist_free(vertlist,NULL);
 -                      BLI_linklist_free(edgelist,NULL);
 -                      return 0;
 -              }
 -              BLI_ghash_insert(vertgh,ev,tempsv);
  
 -              look = look->next;
 -      }
 +                      numsel += 1;
 +
 +                      if (!BM_TestHFlag(BM_OtherEdgeVert(e, v), BM_TMP_TAG))
 +                              break;
  
 -      // make sure the UPs and DOWNs are 'faceloops'
 -      // Also find the nearest slidevert to the cursor
 +                      v = BM_OtherEdgeVert(e, v);
 +              } while (e != first->e);
  
 -      look = vertlist;
 -      nearest = NULL;
 -      while(look) {
 -              tempsv  = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
 +              BM_ClearHFlag(v, BM_TMP_TAG);
  
 -              if(!tempsv->up || !tempsv->down) {
 -                      //BKE_report(op->reports, RPT_ERROR, "Missing rails");
 -                      BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
 -                      BLI_linklist_free(vertlist,NULL);
 -                      BLI_linklist_free(edgelist,NULL);
 -                      return 0;
 -              }
 +              l1 = l2 = l = NULL;
 +              l1 = e->l;
 +              l2 = e->l->radial_next;
  
 -              if(me->drawflag & ME_DRAWEXTRA_EDGELEN) {
 -                      if(!(tempsv->up->f & SELECT)) {
 -                              tempsv->up->f |= SELECT;
 -                              tempsv->up->f2 |= 16;
 -                      } else {
 -                              tempsv->up->f2 |= ~16;
 -                      }
 -                      if(!(tempsv->down->f & SELECT)) {
 -                              tempsv->down->f |= SELECT;
 -                              tempsv->down->f2 |= 16;
 -                      } else {
 -                              tempsv->down->f2 |= ~16;
 -                      }
 -              }
 +              l = BM_OtherFaceLoop(l1->e, l1->f, v);
 +              sub_v3_v3v3(vec, BM_OtherEdgeVert(l->e, v)->co, v->co);
  
 -              if(look->next != NULL) {
 -                      TransDataSlideVert *sv;
 -                      
 -                      ev = (EditVert*)look->next->link;
 -                      sv = BLI_ghash_lookup(vertgh, ev);
 +              if (l2 != l1) {
 +                      l = BM_OtherFaceLoop(l2->e, l2->f, v);
 +                      sub_v3_v3v3(vec2, BM_OtherEdgeVert(l->e, v)->co, v->co);
 +              } else {
 +                      l2 = NULL;
 +              }
  
 -                      if(sv) {
 -                              float co[3], co2[3], tvec[3];
 +              /*iterate over the loop*/
 +              first = v;
 +              do {
 +                      TransDataSlideVert *sv = tempsv + j;
  
 -                              ev = (EditVert*)look->link;
 +                      sv->v = v;
 +                      sv->origvert = *v;
-                       VECCOPY(sv->upvec, vec);
++                      copy_v3_v3(sv->upvec, vec);
 +                      if (l2)
-                               VECCOPY(sv->downvec, vec2);
++                              copy_v3_v3(sv->downvec, vec2);
  
 -                              if(!sharesFace(em, tempsv->up,sv->up)) {
 -                                      EditEdge *swap;
 -                                      swap = sv->up;
 -                                      sv->up = sv->down;
 -                                      sv->down = swap;
 -                              }
 -                              
 -                              if (v3d) {
 -                                      ED_view3d_project_float(t->ar, tempsv->up->v1->co, co, projectMat);
 -                                      ED_view3d_project_float(t->ar, tempsv->up->v2->co, co2, projectMat);
 -                              }
 +                      l = BM_OtherFaceLoop(l1->e, l1->f, v);
 +                      sv->up = BM_OtherEdgeVert(l->e, v);
  
 -                              if (ev == tempsv->up->v1) {
 -                                      sub_v3_v3v3(tvec, co, co2);
 -                              } else {
 -                                      sub_v3_v3v3(tvec, co2, co);
 -                              }
 +                      if (l2) {
 +                              l = BM_OtherFaceLoop(l2->e, l2->f, v);
 +                              sv->down = BM_OtherEdgeVert(l->e, v);
 +                      }
  
 -                              add_v3_v3(start, tvec);
 +                      v2=v, v = BM_OtherEdgeVert(e, v);
  
 -                              if (v3d) {
 -                                      ED_view3d_project_float(t->ar, tempsv->down->v1->co, co, projectMat);
 -                                      ED_view3d_project_float(t->ar, tempsv->down->v2->co, co2, projectMat);
 -                              }
 +                      e1 = e;
 +                      e = get_other_edge(bm, v, e);
 +                      if (!e) {
 +                              //v2=v, v = BM_OtherEdgeVert(l1->e, v);
  
 -                              if (ev == tempsv->down->v1) {
 -                                      sub_v3_v3v3(tvec, co2, co);
 -                              } else {
 -                                      sub_v3_v3v3(tvec, co, co2);
 +                              sv = tempsv + j + 1;
 +                              sv->v = v;
 +                              sv->origvert = *v;
 +                              
 +                              l = BM_OtherFaceLoop(l1->e, l1->f, v);
 +                              sv->up = BM_OtherEdgeVert(l->e, v);
 +                              sub_v3_v3v3(sv->upvec, BM_OtherEdgeVert(l->e, v)->co, v->co);
 +
 +                              if (l2) {
 +                                      l = BM_OtherFaceLoop(l2->e, l2->f, v);
 +                                      sv->down = BM_OtherEdgeVert(l->e, v);
 +                                      sub_v3_v3v3(sv->downvec, BM_OtherEdgeVert(l->e, v)->co, v->co);
                                }
  
 -                              add_v3_v3(end, tvec);
 -
 -                              totvec += 1.0f;
 -                              nearest = (EditVert*)look->link;
 +                              BM_ClearHFlag(v, BM_TMP_TAG);
 +                              BM_ClearHFlag(v2, BM_TMP_TAG);
 +                              
 +                              j += 2;
 +                              break;
                        }
 -              }
  
 +                      l1 = get_next_loop(bm, v, l1, e1, e, vec);
 +                      l2 = l2 ? get_next_loop(bm, v, l2, e1, e, vec2) : NULL;
  
 +                      j += 1;
  
 -              look = look->next;
 +                      BM_ClearHFlag(v, BM_TMP_TAG);
 +                      BM_ClearHFlag(v2, BM_TMP_TAG);
 +              } while (e != first->e && l1);
        }
  
 -      add_v3_v3(start, end);
 -      mul_v3_fl(start, 0.5f*(1.0f/totvec));
 -      copy_v3_v3(vec, start);
 -      start[0] = t->mval[0];
 -      start[1] = t->mval[1];
 -      add_v3_v3v3(end, start, vec);
 +      //EDBM_clear_flag_all(em, BM_SELECT);
  
 +      sld->sv = tempsv;
 +      sld->totsv = j;
 +      
 +      /*find mouse vector*/
 +      dis = z = -1.0f;
 +      size = 50.0;
 +      zero_v3(lastvec); zero_v3(dir);
 +      ee = le = NULL;
 +      BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +              if (BM_TestHFlag(e, BM_SELECT)) {
 +                      BMIter iter2;
 +                      BMEdge *e2;
 +                      float vec1[3], dis2, mval[2] = {t->mval[0], t->mval[1]}, d;
 +                                              
 +                      /*search cross edges for visible edge to the mouse cursor,
 +              then use the shared vertex to calculate screen vector*/
 +                      dis2 = -1.0f;
 +                      for (i=0; i<2; i++) {
 +                              v = i?e->v1:e->v2;
 +                              BM_ITER(e2, &iter2, em->bm, BM_EDGES_OF_VERT, v) {
 +                                      if (BM_TestHFlag(e2, BM_SELECT))
 +                                              continue;
 +                                      
 +                                      if (!BMBVH_EdgeVisible(btree, e2, ar, v3d, t->obedit))
 +                                              continue;
 +                                      
 +                                      j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v));
 +
 +                                      if (tempsv[j].down) {
 +                                              ED_view3d_project_float_v3(ar, tempsv[j].down->co, vec1, projectMat);
 +                                      } else {
 +                                              add_v3_v3v3(vec1, v->co, tempsv[j].downvec);
 +                                              ED_view3d_project_float_v3(ar, vec1, vec1, projectMat);
 +                                      }
 +                                      
 +                                      if (tempsv[j].up) {
 +                                              ED_view3d_project_float_v3(ar, tempsv[j].up->co, vec2, projectMat);
 +                                      } else {
 +                                              add_v3_v3v3(vec1, v->co, tempsv[j].upvec);
 +                                              ED_view3d_project_float_v3(ar, vec2, vec2, projectMat);
 +                                      }
  
 -      /* Ensure minimum screen distance, when looking top down on edge loops */
 -#define EDGE_SLIDE_MIN 30
 -      if (len_squared_v2v2(start, end) < (EDGE_SLIDE_MIN * EDGE_SLIDE_MIN)) {
 -              if(ABS(start[0]-end[0]) + ABS(start[1]-end[1]) < 4.0f) {
 -                      /* even more exceptional case, points are ontop of each other */
 -                      end[0]= start[0];
 -                      end[1]= start[1] + EDGE_SLIDE_MIN;
 -              }
 -              else {
 -                      sub_v2_v2(end, start);
 -                      normalize_v2(end);
 -                      mul_v2_fl(end, EDGE_SLIDE_MIN);
 -                      add_v2_v2(end, start);
 +                                      d = dist_to_line_segment_v2(mval, vec1, vec2);
 +                                      if (dis2 == -1.0f || d < dis2) {
 +                                              dis2 = d;
 +                                              ee = e2;
 +                                              size = len_v3v3(vec1, vec2);
 +                                              sub_v3_v3v3(dir, vec1, vec2);
 +                                      }
 +                              }
 +                      }
                }
        }
 -#undef EDGE_SLIDE_MIN
 +      
 +      em->bm->ob = t->obedit;
 +      bmesh_begin_edit(em->bm, BMOP_UNTAN_MULTIRES);
  
 +      /*create copies of faces for customdata projection*/
 +      tempsv = sld->sv;
 +      for (i=0; i<sld->totsv; i++, tempsv++) {
 +              BMIter fiter, liter;
 +              BMFace *f;
 +              BMLoop *l;
 +              
 +              BM_ITER(f, &fiter, em->bm, BM_FACES_OF_VERT, tempsv->v) {
 +                      
 +                      if (!BLI_smallhash_haskey(&sld->origfaces, (uintptr_t)f)) {
 +                              BMFace *copyf = BM_Copy_Face(em->bm, f, 1, 1);
 +                              
 +                              BM_Select(em->bm, copyf, 0);
 +                              BM_SetHFlag(copyf, BM_HIDDEN);
 +                              BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, copyf) {
 +                                      BM_Select(em->bm, l->v, 0);
 +                                      BM_SetHFlag(l->v, BM_HIDDEN);
 +                                      BM_Select(em->bm, l->e, 0);
 +                                      BM_SetHFlag(l->e, BM_HIDDEN);
 +                              }
  
 -      sld->start[0] = (int) start[0];
 -      sld->start[1] = (int) start[1];
 -      sld->end[0] = (int) end[0];
 -      sld->end[1] = (int) end[1];
 +                              BLI_smallhash_insert(&sld->origfaces, (uintptr_t)f, copyf);
 +                      }
 +              }
 +
 +              BLI_smallhash_insert(&sld->vhash, (uintptr_t)tempsv->v, tempsv);
 +      }
 +      
 +      sld->em = em;
        
 -      if (uvlay_tot) {
 -              int maxnum = 0;
 +      /*zero out start*/
 +      zero_v3(start);
 +      
 +      /*dir holds a vector along edge loop*/
 +      copy_v3_v3(end, dir);
 +      mul_v3_fl(end, 0.5);
 +      
 +      sld->start[0] = t->mval[0] + start[0];
 +      sld->start[1] = t->mval[1] + start[1];
  
 -              uvarray = MEM_callocN( uvlay_tot * sizeof(GHash *), "SlideUVs Array");
 -              sld->totuv = uvlay_tot;
 -              suv_last = slideuvs = MEM_callocN( uvlay_tot * (numadded+1) * sizeof(TransDataSlideUv), "SlideUVs"); /* uvLayers * verts */
 -              suv = NULL;
 +      sld->end[0] = t->mval[0] + end[0];
 +      sld->end[1] = t->mval[1] + end[1];
 +      
 +      sld->perc = 0.0f;
 +      
 +      t->customData = sld;
 +      
 +      BLI_smallhash_release(&table);
 +      BMBVH_FreeBVH(btree);
 +      
 +      return 1;
 +}
  
 -              for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
 +void projectSVData(TransInfo *t, int final)
 +{
 +      SlideData *sld = t->customData;
 +      TransDataSlideVert *tempsv;
 +      BMEditMesh *em = sld->em;
 +      SmallHash visit;
 +      int i;
 +      
 +      if (!em)
 +              return;
 +      
 +      /* BMESH_TODO, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)
 +       * currently all vertex data is interpolated which is nice mostly
 +       * except for shape keys where you dont want to modify UVs for eg.
 +       * current BMesh code doesnt make it easy to pick which data we interpolate
 +       * - campbell */
  
 -                      uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createSlideVerts2 gh");
 +      BLI_smallhash_init(&visit);
 +      
 +              for (i=0, tempsv=sld->sv; i<sld->totsv; i++, tempsv++) {
 +              BMIter fiter;
 +              BMFace *f;
 +              
 +              BM_ITER(f, &fiter, em->bm, BM_FACES_OF_VERT, tempsv->v) {
 +                      BMIter liter2;
 +                      BMFace *copyf, *copyf2;
 +                      BMLoop *l2;
 +                      int sel, hide, do_vdata;
 +                      
 +                      if (BLI_smallhash_haskey(&visit, (uintptr_t)f))
 +                              continue;
 +                      
 +                      BLI_smallhash_insert(&visit, (uintptr_t)f, NULL);
 +                      
 +                      /*the face attributes of the copied face will get
 +                        copied over, so its necessary to save the selection
 +                        and hidden state*/
 +                      sel = BM_TestHFlag(f, BM_SELECT);
 +                      hide = BM_TestHFlag(f, BM_HIDDEN);
 +                      
 +                      copyf2 = BLI_smallhash_lookup(&sld->origfaces, (uintptr_t)f);
 +                      
 +                      /*project onto copied projection face*/
 +                      BM_ITER(l2, &liter2, em->bm, BM_LOOPS_OF_FACE, f) {
 +                              copyf = copyf2;
 +                              do_vdata = l2->v==tempsv->v;
 +                              
 +                              if (BM_TestHFlag(l2->e, BM_SELECT) || BM_TestHFlag(l2->prev->e, BM_SELECT)) {
 +                                      BMLoop *l3 = l2;
 +                                      
 +                                      do_vdata = 1;
 +                                      
 +                                      if (!BM_TestHFlag(l2->e, BM_SELECT))
 +                                              l3 = l3->prev;
 +                                      
 +                                      if (sld->perc < 0.0 && BM_Vert_In_Face(l3->radial_next->f, tempsv->down)) {
 +                                              copyf = BLI_smallhash_lookup(&sld->origfaces, (uintptr_t)l3->radial_next->f);
 +                                      } else if (sld->perc > 0.0 && BM_Vert_In_Face(l3->radial_next->f, tempsv->up)) {
 +                                              copyf = BLI_smallhash_lookup(&sld->origfaces, (uintptr_t)l3->radial_next->f);
 +                                      }
 +                                      if (!copyf)
 +                                              continue;  /* shouldn't happen, but protection */
 +                              }
 +                              
 +                              BM_loop_interp_from_face(em->bm, l2, copyf, do_vdata, 0);
  
 -                      for(ev=em->verts.first;ev;ev=ev->next) {
 -                              ev->tmp.l = 0;
 -                      }
 -                      look = vertlist;
 -                      while(look) {
 -                              float *uv_new;
 -                              tempsv  = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
 -
 -                              ev = look->link;
 -                              suv = NULL;
 -                              for(efa = em->faces.first;efa;efa=efa->next) {
 -                                      if (ev->tmp.l != -1) { /* test for self, in this case its invalid */
 -                                              int k=-1; /* face corner */
 -
 -                                              /* Is this vert in the faces corner? */
 -                                              if              (efa->v1==ev)                           k=0;
 -                                              else if (efa->v2==ev)                           k=1;
 -                                              else if (efa->v3==ev)                           k=2;
 -                                              else if (efa->v4 && efa->v4==ev)        k=3;
 -
 -                                              if (k != -1) {
 -                                                      MTFace *tf = CustomData_em_get_n(&em->fdata, efa->data, CD_MTFACE, uvlay_idx);
 -                                                      EditVert *ev_up, *ev_down;
 -
 -                                                      uv_new = tf->uv[k];
 -
 -                                                      if (ev->tmp.l) {
 -                                                              if (fabsf(suv->origuv[0]-uv_new[0]) > 0.0001f || fabs(suv->origuv[1]-uv_new[1]) > 0.0001f) {
 -                                                                      ev->tmp.l = -1; /* Tag as invalid */
 -                                                                      BLI_linklist_free(suv->fuv_list,NULL);
 -                                                                      suv->fuv_list = NULL;
 -                                                                      BLI_ghash_remove(uvarray[uvlay_idx],ev, NULL, NULL);
 -                                                                      suv = NULL;
 -                                                                      break;
 -                                                              }
 -                                                      } else {
 -                                                              ev->tmp.l = 1;
 -                                                              suv = suv_last;
 -
 -                                                              suv->fuv_list = NULL;
 -                                                              suv->uv_up = suv->uv_down = NULL;
 -                                                              suv->origuv[0] = uv_new[0];
 -                                                              suv->origuv[1] = uv_new[1];
 -
 -                                                              BLI_linklist_prepend(&suv->fuv_list, uv_new);
 -                                                              BLI_ghash_insert(uvarray[uvlay_idx],ev,suv);
 -
 -                                                              suv_last++; /* advance to next slide UV */
 -                                                              maxnum++;
 -                                                      }
 -
 -                                                      /* Now get the uvs along the up or down edge if we can */
 -                                                      if (suv) {
 -                                                              if (!suv->uv_up) {
 -                                                                      ev_up = editedge_getOtherVert(tempsv->up,ev);
 -                                                                      if              (efa->v1==ev_up)                                suv->uv_up = tf->uv[0];
 -                                                                      else if (efa->v2==ev_up)                                suv->uv_up = tf->uv[1];
 -                                                                      else if (efa->v3==ev_up)                                suv->uv_up = tf->uv[2];
 -                                                                      else if (efa->v4 && efa->v4==ev_up)             suv->uv_up = tf->uv[3];
 -                                                              }
 -                                                              if (!suv->uv_down) { /* if the first face was apart of the up edge, it cant be apart of the down edge */
 -                                                                      ev_down = editedge_getOtherVert(tempsv->down,ev);
 -                                                                      if              (efa->v1==ev_down)                              suv->uv_down = tf->uv[0];
 -                                                                      else if (efa->v2==ev_down)                              suv->uv_down = tf->uv[1];
 -                                                                      else if (efa->v3==ev_down)                              suv->uv_down = tf->uv[2];
 -                                                                      else if (efa->v4 && efa->v4==ev_down)   suv->uv_down = tf->uv[3];
 -                                                              }
 -
 -                                                              /* Copy the pointers to the face UV's */
 -                                                              BLI_linklist_prepend(&suv->fuv_list, uv_new);
 -                                                      }
 -                                              }
 +                              if (final) {
 +                                      BM_loop_interp_multires(em->bm, l2, copyf);     
 +                                      if (copyf2 != copyf) {
 +                                              BM_loop_interp_multires(em->bm, l2, copyf2);
                                        }
                                }
 -                              look = look->next;
                        }
 -              } /* end uv layer loop */
 -      } /* end uvlay_tot */
 -
 -      sld->uvhash = uvarray;
 -      sld->slideuv = slideuvs;
 -      sld->vhash = vertgh;
 -      sld->nearest = nearest;
 -      sld->vertlist = vertlist;
 -      sld->edgelist = edgelist;
 -      sld->suv_last = suv_last;
 -      sld->uvlay_tot = uvlay_tot;
 -
 -      // we should have enough info now to slide
 -
 -      t->customData = sld;
 -
 -      return 1;
 +                      
 +                      /*make sure face-attributes are correct (e.g. MTexPoly)*/
 +                      BM_Copy_Attributes(em->bm, em->bm, copyf2, f);
 +                      
 +                      /*restore selection and hidden flags*/
 +                      BM_Select(em->bm, f, sel);
 +                      BM_Hide(em->bm, f, hide);
 +              }
 +      }
 +      
 +      BLI_smallhash_release(&visit);
  }
  
  void freeSlideVerts(TransInfo *t)
@@@ -599,18 -598,17 +599,18 @@@ int getTransformOrientation(const bCont
                        }
                        else
                        {
 -                              if (em->totfacesel >= 1)
 +                              if (em->bm->totfacesel >= 1)
                                {
 -                                      EditFace *efa;
 -                                      
 -                                      for(efa= em->faces.first; efa; efa= efa->next)
 -                                      {
 -                                              if(efa->f & SELECT)
 -                                              {
 -                                                      add_v3_v3(normal, efa->n);
 -                                                      sub_v3_v3v3(vec, efa->v2->co, efa->v1->co);
 +                                      BMFace *efa;
 +                                      BMIter iter;
 +
 +                                      BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
 +                                              if(BM_TestHFlag(efa, BM_SELECT)) {
-                                                       VECADD(normal, normal, efa->no);
++                                                      add_v3_v3(normal, efa->no);
 +                                                      sub_v3_v3v3(vec,
 +                                                                  ((BMLoopList*)efa->loops.first)->first->v->co,
 +                                                                  (((BMLoopList*)efa->loops.first)->first->next)->v->co);
-                                                       VECADD(plane, plane, vec);
+                                                       add_v3_v3(plane, vec);
                                                }
                                        }
                                        
  
                                        result = ORIENTATION_FACE;
                                }
 -                              else if (em->totedgesel == 1)
 +                              else if (em->bm->totedgesel == 1)
                                {
 -                                      EditEdge *eed;
 -
 -                                      for(eed= em->edges.first; eed; eed= eed->next) {
 -                                              if(eed->f & SELECT) {
 +                                      BMEdge *eed = NULL;
 +                                      BMIter iter;
 +                                      
 +                                      BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                                              if(BM_TestHFlag(eed, BM_SELECT)) {
                                                        /* use average vert normals as plane and edge vector as normal */
                                                        copy_v3_v3(plane, eed->v1->no);
-                                                       VECADD(plane, plane, eed->v2->no);
+                                                       add_v3_v3(plane, eed->v2->no);
                                                        sub_v3_v3v3(normal, eed->v2->co, eed->v1->co);
                                                        break;
                                                }
@@@ -2783,25 -2522,21 +2783,25 @@@ static void UV_OT_snap_cursor(wmOperato
  
  static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, SpaceImage *sima)
  {
 -      EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data);
 -      EditFace *efa;
 -      MTFace *tface;
 +      BMEditMesh *em= ((Mesh*)obedit->data)->edit_btmesh;
 +      BMFace *efa;
 +      BMLoop *l;
 +      BMIter iter, liter;
 +      MTexPoly *tface;
 +      MLoopUV *luv;
        short change= 0;
  
 -      for(efa= em->faces.first; efa; efa= efa->next) {
 -              tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 -              if(uvedit_face_visible(scene, ima, efa, tface)) {
 -                      if(uvedit_uv_selected(scene, efa, tface, 0))            copy_v2_v2(tface->uv[0], sima->cursor);
 -                      if(uvedit_uv_selected(scene, efa, tface, 1))            copy_v2_v2(tface->uv[1], sima->cursor);
 -                      if(uvedit_uv_selected(scene, efa, tface, 2))            copy_v2_v2(tface->uv[2], sima->cursor);
 -                      if(efa->v4)
 -                              if(uvedit_uv_selected(scene, efa, tface, 3))    copy_v2_v2(tface->uv[3], sima->cursor);
 +      BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
 +              tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
 +              if(!uvedit_face_visible(scene, ima, efa, tface))
 +                      continue;
  
 -                      change= 1;
 +              BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
 +                      if(uvedit_uv_selected(em, scene, l)) {
 +                              luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-                               VECCOPY2D(luv->uv, sima->cursor);
++                              copy_v2_v2(luv->uv, sima->cursor);
 +                              change= 1;
 +                      }
                }
        }
  
@@@ -257,11 -257,11 +257,11 @@@ static DerivedMesh * applyModifier(Modi
                mul_qt_v3(state.rot,mv->co);
                if(pimd->flag & eParticleInstanceFlag_UseSize)
                        mul_v3_fl(mv->co, size[i/totvert]);
-               VECADD(mv->co,mv->co,state.co);
+               add_v3_v3(mv->co, state.co);
        }
  
 -      mface=result->getFaceArray(result);
 -      orig_mface=dm->getFaceArray(dm);
 +      mface=result->getTessFaceArray(result);
 +      orig_mface=dm->getTessFaceArray(dm);
  
        for(i=0; i<maxface; i++){
                MFace *inMF;