svn merge ^/trunk/blender -r43392:43420
authorCampbell Barton <ideasman42@gmail.com>
Mon, 16 Jan 2012 11:50:17 +0000 (11:50 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 16 Jan 2012 11:50:17 +0000 (11:50 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/editors/object/object_ops.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/space_image/space_image.c

index 0328be060cc4832920f2d185d6114faf6f040da1,0c05655b8d730e476e6772006947e6faf5c9af63..7e1634d6eca50790b101a36c93a42c459b4ad61f
  
  #include "MEM_guardedalloc.h"
  
 +#include "BLI_utildefines.h"
  #include "BLI_blenlib.h"
  #include "BLI_math.h"
 -#include "BLI_utildefines.h"
 +#include "BLI_cellalloc.h"
 +#include "BLI_edgehash.h"
  
  #include "BKE_anim.h"
  #include "BKE_action.h"
@@@ -2704,16 -2702,6 +2704,16 @@@ static void lib_link_key(FileData *fd, 
  
        key= main->key.first;
        while(key) {
 +              /*check if we need to generate unique ids for the shapekeys*/
 +              if (!key->uidgen) {
 +                      KeyBlock *block;
 +
 +                      key->uidgen = 1;
 +                      for (block=key->block.first; block; block=block->next) {
 +                              block->uid = key->uidgen++;
 +                      }
 +              }
 +
                if(key->id.flag & LIB_NEEDLINK) {
                        if(key->adt) lib_link_animdata(fd, &key->id, key->adt);
                        
@@@ -3636,26 -3624,6 +3636,26 @@@ static void lib_link_customdata_mtface(
  
  }
  
 +static void lib_link_customdata_mtpoly(FileData *fd, Mesh *me, CustomData *pdata, int totface)
 +{
 +      int i;
 +
 +      for(i=0; i<pdata->totlayer; i++) {
 +              CustomDataLayer *layer = &pdata->layers[i];
 +              
 +              if(layer->type == CD_MTEXPOLY) {
 +                      MTexPoly *tf= layer->data;
 +                      int i;
 +
 +                      for (i=0; i<totface; i++, tf++) {
 +                              tf->tpage= newlibadr(fd, me->id.lib, tf->tpage);
 +                              if(tf->tpage && tf->tpage->id.us==0)
 +                                      tf->tpage->id.us= 1;
 +                      }
 +              }
 +      }
 +}
 +
  static void lib_link_mesh(FileData *fd, Main *main)
  {
        Mesh *me;
                        me->texcomesh= newlibadr_us(fd, me->id.lib, me->texcomesh);
  
                        lib_link_customdata_mtface(fd, me, &me->fdata, me->totface);
 +                      lib_link_customdata_mtpoly(fd, me, &me->pdata, me->totpoly);
                        if(me->mr && me->mr->levels.first)
                                lib_link_customdata_mtface(fd, me, &me->mr->fdata,
                                                           ((MultiresLevel*)me->mr->levels.first)->totface);
  
 +                      /*check if we need to convert mfaces to mpolys*/
 +                      if (me->totface && !me->totpoly) {
 +                              convert_mfaces_to_mpolys(me);
 +                      }
 +                      
 +                      /*
 +                       * Re-tesselate, even if the polys were just created from tessfaces, this
 +                       * is important because it:
 +                       *  - fill the CD_POLYINDEX layer
 +                       *  - gives consistency of tessface between loading from a file and
 +                       *    converting an edited BMesh back into a mesh (i.e. it replaces
 +                       *    quad tessfaces in a loaded mesh immediately, instead of lazily
 +                       *    waiting until edit mode has been entered/exited, making it easier
 +                       *    to recognize problems that would otherwise only show up after edits).
 +                       */
 +                      me->totface = mesh_recalcTesselation(
 +                              &me->fdata, &me->ldata, &me->pdata,
 +                              me->mvert, me->totface, me->totloop, me->totpoly);
 +
 +                      mesh_update_customdata_pointers(me, TRUE);
 +
                        me->id.flag -= LIB_NEEDLINK;
                }
                me= me->id.next;
@@@ -3727,17 -3673,10 +3727,17 @@@ static void direct_link_dverts(FileDat
        }
  
        for (i= count; i > 0; i--, mdverts++) {
 -              if(mdverts->dw) {
 -                      mdverts->dw= newdataadr(fd, mdverts->dw);
 +              /*convert to vgroup allocation system*/
 +              MDeformWeight *dw;
 +              if(mdverts->dw && (dw= newdataadr(fd, mdverts->dw))) {
 +                      const ssize_t dw_len= mdverts->totweight * sizeof(MDeformWeight);
 +                      void *dw_tmp= BLI_cellalloc_malloc(dw_len, "direct_link_dverts");
 +                      memcpy(dw_tmp, dw, dw_len);
 +                      mdverts->dw= dw_tmp;
 +                      MEM_freeN(dw);
                }
 -              if (mdverts->dw == NULL) {
 +              else {
 +                      mdverts->dw= NULL;
                        mdverts->totweight= 0;
                }
        }
@@@ -3750,18 -3689,7 +3750,18 @@@ static void direct_link_mdisps(FileDat
  
                for(i = 0; i < count; ++i) {
                        mdisps[i].disps = newdataadr(fd, mdisps[i].disps);
 -
 +                      
 +                      /*put .disps into cellalloc system*/
 +                      if (mdisps[i].disps) {
 +                              float *disp2;
 +                              
 +                              disp2 = BLI_cellalloc_malloc(MEM_allocN_len(mdisps[i].disps), "cellalloc .disps copy");
 +                              memcpy(disp2, mdisps[i].disps, MEM_allocN_len(mdisps[i].disps));
 +                              
 +                              MEM_freeN(mdisps[i].disps);
 +                              mdisps[i].disps = (float (*)[3])disp2;
 +                      }
 +                      
                        if( (fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps) ) {
                                /* DNA_struct_switch_endian doesn't do endian swap for (*disps)[] */
                                /* this does swap for data written at write_mdisps() - readfile.c */
@@@ -3811,17 -3739,12 +3811,17 @@@ static void direct_link_mesh(FileData *
        mesh->mvert= newdataadr(fd, mesh->mvert);
        mesh->medge= newdataadr(fd, mesh->medge);
        mesh->mface= newdataadr(fd, mesh->mface);
 +      mesh->mloop= newdataadr(fd, mesh->mloop);
 +      mesh->mpoly= newdataadr(fd, mesh->mpoly);
        mesh->tface= newdataadr(fd, mesh->tface);
        mesh->mtface= newdataadr(fd, mesh->mtface);
        mesh->mcol= newdataadr(fd, mesh->mcol);
        mesh->msticky= newdataadr(fd, mesh->msticky);
        mesh->dvert= newdataadr(fd, mesh->dvert);
 -      
 +      mesh->mloopcol= newdataadr(fd, mesh->mloopcol);
 +      mesh->mloopuv= newdataadr(fd, mesh->mloopuv);
 +      mesh->mtpoly= newdataadr(fd, mesh->mtpoly);
 +
        /* animdata */
        mesh->adt= newdataadr(fd, mesh->adt);
        direct_link_animdata(fd, mesh->adt);
        direct_link_customdata(fd, &mesh->vdata, mesh->totvert);
        direct_link_customdata(fd, &mesh->edata, mesh->totedge);
        direct_link_customdata(fd, &mesh->fdata, mesh->totface);
 -
 +      direct_link_customdata(fd, &mesh->ldata, mesh->totloop);
 +      direct_link_customdata(fd, &mesh->pdata, mesh->totpoly);
 +      
  
  #ifdef USE_BMESH_FORWARD_COMPAT
        /* NEVER ENABLE THIS CODE INTO BMESH!
  
        mesh->bb= NULL;
        mesh->mselect = NULL;
 -      mesh->edit_mesh= NULL;
 +      mesh->edit_btmesh= NULL;
        
        /* Multires data */
        mesh->mr= newdataadr(fd, mesh->mr);
@@@ -5239,7 -5160,6 +5239,6 @@@ static void lib_link_screen(FileData *f
                                        }
                                        else if(sl->spacetype==SPACE_BUTS) {
                                                SpaceButs *sbuts= (SpaceButs *)sl;
-                                               sbuts->ri= NULL;
                                                sbuts->pinid= newlibadr(fd, sc->id.lib, sbuts->pinid);
                                                sbuts->mainbo= sbuts->mainb;
                                                sbuts->mainbuser= sbuts->mainb;
@@@ -6652,7 -6572,7 +6651,7 @@@ static void customdata_version_242(Mes
                }
        }
  
 -      mesh_update_customdata_pointers(me);
 +      mesh_update_customdata_pointers(me, TRUE);
  }
  
  /*only copy render texface layer from active*/
@@@ -12354,7 -12274,7 +12353,7 @@@ static void do_versions(FileData *fd, L
                Mesh *me;
  
                for(me= main->mesh.first; me; me= me->id.next)
 -                      mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
 +                      mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL);
        }
  
        if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)){
@@@ -14517,7 -14437,7 +14516,7 @@@ static void read_libraries(FileData *ba
                                        /* allow typing in a new lib path */
                                        if(G.rt==-666) {
                                                while(fd==NULL) {
-                                                       char newlib_path[240] = { 0 };
+                                                       char newlib_path[FILE_MAX] = { 0 };
                                                        printf("Missing library...'\n");
                                                        printf("        current file: %s\n", G.main->name);
                                                        printf("        absolute lib: %s\n", mainptr->curlib->filepath);
index 68d11837d0d8d7dc62667befe97b0082741bd9c3,521865280eaa884c88d77d024ff890c397fdfd21..eba4dd1878a82f8ec7da4294dca9f83c7995b71a
@@@ -214,9 -214,8 +214,9 @@@ void ED_operatortypes_object(void
  
        WM_operatortype_append(OBJECT_OT_bake_image);
        WM_operatortype_append(OBJECT_OT_drop_named_material);
 -}
  
 +      WM_operatortype_append(OBJECT_OT_test_multires);
 +}
  
  void ED_operatormacros_object(void)
  {
@@@ -269,20 -268,20 +269,20 @@@ void ED_keymap_object(wmKeyConfig *keyc
        
        /* Note: this keymap works disregarding mode */
        kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
-               RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
-               RNA_boolean_set(kmi->ptr, "toggle", 1);
+       RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
+       RNA_boolean_set(kmi->ptr, "toggle", TRUE);
  
        kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
-               RNA_enum_set(kmi->ptr, "mode", OB_MODE_POSE);
-               RNA_boolean_set(kmi->ptr, "toggle", 1);
+       RNA_enum_set(kmi->ptr, "mode", OB_MODE_POSE);
+       RNA_boolean_set(kmi->ptr, "toggle", TRUE);
  
        kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0);
-               RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT);
-               RNA_boolean_set(kmi->ptr, "toggle", 1);
+       RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT);
+       RNA_boolean_set(kmi->ptr, "toggle", TRUE);
        
        kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
-               RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT);
-               RNA_boolean_set(kmi->ptr, "toggle", 1);
+       RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT);
+       RNA_boolean_set(kmi->ptr, "toggle", TRUE);
        
        WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0);
  
        WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0);
  
        kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
-               RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
        kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
-               RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
+       RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
  
        WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
        
-       kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
-               RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
-               RNA_boolean_set(kmi->ptr, "extend", FALSE);
-       kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
-               RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
-               RNA_boolean_set(kmi->ptr, "extend", TRUE);
-       kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
-               RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
-               RNA_boolean_set(kmi->ptr, "extend", FALSE);
-       kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
-               RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
-               RNA_boolean_set(kmi->ptr, "extend", TRUE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+       RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
+       RNA_boolean_set(kmi->ptr, "extend", FALSE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
+       RNA_boolean_set(kmi->ptr, "extend", TRUE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+       RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
+       RNA_boolean_set(kmi->ptr, "extend", FALSE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
+       RNA_boolean_set(kmi->ptr, "extend", TRUE);
  
        WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0);
        
        WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0);
-       WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0);
+       RNA_boolean_set(kmi->ptr, "unselected", FALSE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_boolean_set(kmi->ptr, "unselected", TRUE);
  
        /* same as above but for rendering */
        WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_clear", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_CTRL, 0);
- //    RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "unselected", 1); // conflicts, removing
+       /* conflicts, removing */
+ #if 0
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)
+       RNA_boolean_set(kmi->ptr, "unselected", TRUE);
+ #endif
  
        WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0);
        
-       WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "use_global", TRUE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
+       RNA_boolean_set(kmi->ptr, "use_global", FALSE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_boolean_set(kmi->ptr, "use_global", TRUE);
        WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "use_global", TRUE);
+       RNA_boolean_set(kmi->ptr, "use_global", FALSE);
+       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_boolean_set(kmi->ptr, "use_global", TRUE);
  
        WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
  
        
        WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
        
-               /* menus */
+       /* menus */
        WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
  
        ED_object_generic_keymap(keyconf, keymap, 2);
index eaca87f2d6fc6fff809b7a5979f209f9fd967dfc,30cb9e8e53f220ebc3dd36fe7e34c8d4baad7c49..a3874c9f28abe7f4cd61dc5719b91eb8bd095dea
@@@ -54,7 -54,6 +54,7 @@@
  #include "BKE_report.h"
  #include "BKE_scene.h"
  #include "BKE_screen.h"
 +#include "BKE_tessmesh.h"
  #include "BKE_sound.h"
  
  #include "WM_api.h"
@@@ -314,7 -313,7 +314,7 @@@ int ED_operator_editmesh(bContext *C
  {
        Object *obedit= CTX_data_edit_object(C);
        if(obedit && obedit->type==OB_MESH)
 -              return NULL != ((Mesh *)obedit->data)->edit_mesh;
 +              return NULL != ((Mesh *)obedit->data)->edit_btmesh;
        return 0;
  }
  
@@@ -367,15 -366,18 +367,15 @@@ int ED_operator_uvedit(bContext *C
  int ED_operator_uvmap(bContext *C)
  {
        Object *obedit= CTX_data_edit_object(C);
 -      EditMesh *em= NULL;
 +      BMEditMesh *em= NULL;
        
        if(obedit && obedit->type==OB_MESH)
 -              em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
 +              em= ((Mesh *)obedit->data)->edit_btmesh;
        
 -      if(em && (em->faces.first)) {
 -              BKE_mesh_end_editmesh(obedit->data, em);
 +      if(em && (em->bm->totface)) {
                return 1;
        }
        
 -      if(obedit)
 -              BKE_mesh_end_editmesh(obedit->data, em);
        return 0;
  }
  
@@@ -3604,11 -3606,11 +3604,11 @@@ void ED_keymap_screen(wmKeyConfig *keyc
  #if 0 // XXX: disabled for restoring later... bad implementation
        keymap= WM_keymap_find(keyconf, "Frames", 0, 0);
        kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
-               RNA_boolean_set(kmi->ptr, "cycle_speed", 1);
+               RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE);
        
        kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", LEFTARROWKEY, KM_PRESS, KM_ALT, 0);
-               RNA_boolean_set(kmi->ptr, "reverse", 1);
-               RNA_boolean_set(kmi->ptr, "cycle_speed", 1);
+               RNA_boolean_set(kmi->ptr, "reverse", TRUE);
+               RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE);
        
        WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0);
  #endif
index 6b8637579325d91d499c2c6419584a8551c6467c,0705ea29985910969ccdc54ad602cb6e8369405c..702937658135e58ee946d53f2cb25f28444ab182
@@@ -152,7 -152,7 +152,7 @@@ void projectf(bglMats *mats, const floa
        p[1]= uy;
  }
  
- float paint_calc_object_space_radius(ViewContext *vc, float center[3],
+ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
                                     float pixel_radius)
  {
        Object *ob = vc->obact;
@@@ -250,9 -250,9 +250,9 @@@ static void imapaint_tri_weights(Objec
  void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
  {
        DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
 -      const int *index = dm->getFaceDataArray(dm, CD_ORIGINDEX);
 -      MTFace *tface = dm->getFaceDataArray(dm, CD_MTFACE), *tf;
 -      int numfaces = dm->getNumFaces(dm), a, findex;
 +      const int *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
 +      MTFace *tface = dm->getTessFaceDataArray(dm, CD_MTFACE), *tf;
 +      int numfaces = dm->getNumTessFaces(dm), a, findex;
        float p[2], w[3], absw, minabsw;
        MFace mf;
        MVert mv[4];
                findex= index ? index[a]: a;
  
                if(findex == faceindex) {
 -                      dm->getFace(dm, a, &mf);
 +                      dm->getTessFace(dm, a, &mf);
  
                        dm->getVert(dm, mf.v1, &mv[0]);
                        dm->getVert(dm, mf.v2, &mv[1]);
index c9cb5bd406d411c2c7160b87fae23d5b8e7f9f63,66a3838955553aca77f850c573ed049f7f59d902..6fce836af988143024d90708fea7310e82fa1f9f
@@@ -52,7 -52,6 +52,7 @@@
  #include "BKE_mesh.h"
  #include "BKE_scene.h"
  #include "BKE_screen.h"
 +#include "BKE_tessmesh.h"
  
  #include "IMB_imbuf_types.h"
  
@@@ -276,11 -275,12 +276,11 @@@ int ED_space_image_show_uvedit(SpaceIma
                return 0;
  
        if(obedit && obedit->type == OB_MESH) {
 -              EditMesh *em = BKE_mesh_get_editmesh(obedit->data);
 +              struct BMEditMesh *em = ((Mesh*)obedit->data)->edit_btmesh;
                int ret;
                
 -              ret = EM_texFaceCheck(em);
 +              ret = EDBM_texFaceCheck(em);
                
 -              BKE_mesh_end_editmesh(obedit->data, em);
                return ret;
        }
        
@@@ -294,11 -294,12 +294,11 @@@ int ED_space_image_show_uvshadow(SpaceI
        
        if(ED_space_image_show_paint(sima))
                if(obedit && obedit->type == OB_MESH) {
 -                      EditMesh *em = BKE_mesh_get_editmesh(obedit->data);
 +                      struct BMEditMesh *em = ((Mesh*)obedit->data)->edit_btmesh;
                        int ret;
                        
 -                      ret = EM_texFaceCheck(em);
 +                      ret = EDBM_texFaceCheck(em);
                        
 -                      BKE_mesh_end_editmesh(obedit->data, em);
                        return ret;
                }
        
@@@ -542,7 -543,7 +542,7 @@@ static void image_keymap(struct wmKeyCo
        /* toggle editmode is handy to have while UV unwrapping */
        kmi= WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
        RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
-       RNA_boolean_set(kmi->ptr, "toggle", 1);
+       RNA_boolean_set(kmi->ptr, "toggle", TRUE);
  }
  
  /* dropboxes */
@@@ -586,12 -587,12 +586,12 @@@ static void image_refresh(const bContex
        if(ima && (ima->source==IMA_SRC_VIEWER || sima->pin));
        else if(obedit && obedit->type == OB_MESH) {
                Mesh *me= (Mesh*)obedit->data;
 -              EditMesh *em= BKE_mesh_get_editmesh(me);
 +              struct BMEditMesh *em= me->edit_btmesh;
                int sloppy= 1; /* partially selected face is ok */
  
                if(scene_use_new_shading_nodes(scene)) {
                        /* new shading system, get image from material */
 -                      EditFace *efa= EM_get_actFace(em, sloppy);
 +                      BMFace *efa = BM_get_actFace(em->bm, sloppy);
  
                        if(efa) {
                                Image *node_ima;
                }
                else {
                        /* old shading system, we set texface */
 -                      MTFace *tf;
 +                      MTexPoly *tf;
                        
 -                      if(em && EM_texFaceCheck(em)) {
 +                      if(em && EDBM_texFaceCheck(em)) {
                                sima->image= NULL;
                                
 -                              tf = EM_get_active_mtface(em, NULL, NULL, sloppy);
 +                              tf = EDBM_get_active_mtexpoly(em, NULL, 1); /* partially selected face is ok */
                                
                                if(tf) {
                                        /* don't need to check for pin here, see above */
                                }
                        }
                }
 -
 -              BKE_mesh_end_editmesh(obedit->data, em);
        }
  }