svn merge ^/trunk/blender -r43918:43934
authorCampbell Barton <ideasman42@gmail.com>
Mon, 6 Feb 2012 22:21:41 +0000 (22:21 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 6 Feb 2012 22:21:41 +0000 (22:21 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_image/space_image.c

index 8a58687f61cc1ec7896d4883bb2daed772235247,5f737ea4e5315af71dae03f26938a7a318bdf257..5faa6a8776bb91c5e9cc12258a2510a928ecfd54
  #include "BLI_utildefines.h"
  #include "BLI_blenlib.h"
  #include "BLI_math.h"
 +#include "BLI_edgehash.h"
  
  #include "BKE_anim.h"
  #include "BKE_action.h"
@@@ -2704,16 -2703,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 -3625,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).
 +                       */
 +                      BKE_mesh_calc_tessface(me);
 +
                        me->id.flag -= LIB_NEEDLINK;
                }
                me= me->id.next;
@@@ -3723,17 -3674,10 +3723,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= MEM_mallocN(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;
                }
        }
@@@ -3746,18 -3690,7 +3746,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 = MEM_mallocN(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 */
@@@ -3807,17 -3740,12 +3807,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);
@@@ -4843,8 -4769,8 +4843,8 @@@ static void lib_link_scene(FileData *fd
                        (void)marker;
  #endif
  
-                       if(sce->ed)
-                               seq_update_muting(sce->ed);
+                       seq_update_muting(sce->ed);
+                       seq_update_sound_bounds_all(sce);
                        
                        if(sce->nodetree) {
                                lib_link_ntree(fd, &sce->id, sce->nodetree);
@@@ -6675,7 -6601,7 +6675,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*/
@@@ -12377,7 -12303,7 +12377,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)){
index 3d97972c82951266f36c643907b73d4e78e9d4bf,3a5793461eaf46a8257c30b8512768d9b1a6a82e..4d74322fc56d379c0eafd1796dfffb71ff936359
@@@ -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;
                }
        
@@@ -580,18 -581,18 +580,18 @@@ static void image_refresh(const bContex
        ima= ED_space_image(sima);
  
        if(sima->iuser.flag & IMA_ANIM_ALWAYS)
-               BKE_image_user_calc_frame(&sima->iuser, CTX_data_scene(C)->r.cfra, 0);
+               BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0);
        
        /* check if we have to set the image from the editmesh */
        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);
        }
  }