https://svn.blender.org/svnroot/bf-blender/trunk/blender, in sync with trunk now
authorCampbell Barton <ideasman42@gmail.com>
Fri, 5 Aug 2011 08:28:03 +0000 (08:28 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 5 Aug 2011 08:28:03 +0000 (08:28 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/editors/transform/transform_generics.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_object_api.c

index 2c287441f3851504c6691d792c7c104f3ee1844e,44c8ca97be9d4d99373df0217024882d90225521..a76353fa0c7af12828f0a2cee17ab7a263368edf
  
  #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"
@@@ -2512,16 -2510,6 +2512,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);
                        
@@@ -3426,26 -3414,6 +3426,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);
 +                      }
 +                      
                        me->id.flag -= LIB_NEEDLINK;
                }
                me= me->id.next;
@@@ -3498,17 -3460,10 +3498,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;
                }
        }
@@@ -3521,18 -3476,7 +3521,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 */
        }
  }
  
 +/*this isn't really a public api function, so prototyped here*/
  static void direct_link_customdata(FileData *fd, CustomData *data, int count)
  {
        int i = 0;
                        i++;
                }
        }
 +
 +      CustomData_update_typemap(data);
  }
  
  static void direct_link_mesh(FileData *fd, Mesh *mesh)
        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->pv ? mesh->pv->totvert : mesh->totvert);
        direct_link_customdata(fd, &mesh->edata, mesh->pv ? mesh->pv->totedge : mesh->totedge);
        direct_link_customdata(fd, &mesh->fdata, mesh->pv ? mesh->pv->totface : mesh->totface);
 -
 +      direct_link_customdata(fd, &mesh->ldata, mesh->totloop);
 +      direct_link_customdata(fd, &mesh->pdata, mesh->totpoly);
 +      
        mesh->bb= NULL;
        mesh->mselect = NULL;
 -      mesh->edit_mesh= NULL;
 +      mesh->edit_btmesh= NULL;
        
        /* Multires data */
        mesh->mr= newdataadr(fd, mesh->mr);
@@@ -11679,7 -11613,7 +11679,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_tessface_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
        }
  
        if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)){
@@@ -13041,9 -12975,8 +13041,8 @@@ static void append_id_part(FileData *fd
  
  /* common routine to append/link something from a library */
  
- static Main* library_append_begin(const bContext *C, FileData **fd, const char *filepath)
+ static Main* library_append_begin(Main *mainvar, FileData **fd, const char *filepath)
  {
-       Main *mainvar= CTX_data_main(C);
        Main *mainl;
  
        /* make mains */
        return mainl;
  }
  
- Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, const char *filepath)
+ Main* BLO_library_append_begin(Main *mainvar, BlendHandle** bh, const char *filepath)
  {
        FileData *fd= (FileData*)(*bh);
-       return library_append_begin(C, &fd, filepath);
+       return library_append_begin(mainvar, &fd, filepath);
  }
  
- static void append_do_cursor(Scene *scene, Library *curlib, short flag)
- {
-       Base *centerbase;
-       Object *ob;
-       float *curs, centerloc[3], vec[3], min[3], max[3];
-       int count= 0;
-       /* when not linking (appending)... */
-       if(flag & FILE_LINK) 
-               return;
-       /* we're not appending at cursor */
-       if((flag & FILE_ATCURSOR) == 0) 
-               return;
-       
-       /* find the center of everything appended */
-       INIT_MINMAX(min, max);
-       centerbase= (scene->base.first);
-       while(centerbase) {
-               if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
-                       VECCOPY(vec, centerbase->object->loc);
-                       DO_MINMAX(vec, min, max);
-                       count++;
-               }
-               centerbase= centerbase->next;
-       }
-       /* we haven't found any objects to move to cursor */
-       if(!count) 
-               return;
-       
-       /* move from the center of the appended objects to cursor */
-       mid_v3_v3v3(centerloc, min, max);
-       curs = scene->cursor;
-       VECSUB(centerloc,curs,centerloc);
-       
-       /* now translate the center of the objects */
-       centerbase= (scene->base.first);
-       while(centerbase) {
-               if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
-                       ob= centerbase->object;
-                       ob->loc[0] += centerloc[0];
-                       ob->loc[1] += centerloc[1];
-                       ob->loc[2] += centerloc[2];
-               }
-               centerbase= centerbase->next;
-       }
- }
  
+ /* Context == NULL signifies not to do any scene manipulation */
  static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
  {
        Main *mainvar;
-       Scene *scene= CTX_data_scene(C);
        Library *curlib;
  
        /* make main consistent */
        lib_verify_nodetree(mainvar, FALSE);
        fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */
  
-       /* give a base to loose objects. If group append, do it for objects too */
-       if(scene) {
-               const short is_link= (flag & FILE_LINK) != 0;
-               if(idcode==ID_SCE) {
-                       /* dont instance anything when linking in scenes, assume the scene its self instances the data */
-               }
-               else {
-                       give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
+       if(C) {
+               Scene *scene= CTX_data_scene(C);
  
-                       if (flag & FILE_GROUP_INSTANCE) {
-                               give_base_to_groups(mainvar, scene);
+               /* give a base to loose objects. If group append, do it for objects too */
+               if(scene) {
+                       const short is_link= (flag & FILE_LINK) != 0;
+                       if(idcode==ID_SCE) {
+                               /* dont instance anything when linking in scenes, assume the scene its self instances the data */
+                       }
+                       else {
+                               give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
+                               if (flag & FILE_GROUP_INSTANCE) {
+                                       give_base_to_groups(mainvar, scene);
+                               }
                        }
                }
-       }
-       else {
-               printf("library_append_end, scene is NULL (objects wont get bases)\n");
+               else {
+                       printf("library_append_end, scene is NULL (objects wont get bases)\n");
+               }
        }
        /* has been removed... erm, why? s..ton) */
        /* 20040907: looks like they are give base already in append_named_part(); -Nathan L */
                blo_freefiledata( *fd );
                *fd = NULL;
        }       
-       append_do_cursor(scene, curlib, flag);
  }
  
  void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
index 9df00163302f2dee9ef7814e0f2c9e62d1250f76,c81c398e6961c3a84269944f6c67e16e89875043..d5ff475566e3170ba4c32fa66ae8406aefedec8f
@@@ -72,7 -72,6 +72,7 @@@
  #include "BKE_mesh.h"
  #include "BKE_nla.h"
  #include "BKE_context.h"
 +#include "BKE_tessmesh.h"
  
  #include "ED_anim_api.h"
  #include "ED_armature.h"
@@@ -233,10 -232,10 +233,10 @@@ static void clipMirrorModifier(TransInf
  }
  
  /* assumes obedit set to mesh object */
 -static void editmesh_apply_to_mirror(TransInfo *t)
 +static void editbmesh_apply_to_mirror(TransInfo *t)
  {
        TransData *td = t->data;
 -      EditVert *eve;
 +      BMVert *eve;
        int i;
        
        for(i = 0 ; i < t->total; i++, td++) {
@@@ -673,7 -672,7 +673,7 @@@ void recalcData(TransInfo *t
                                if(la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt);
                        }
                        else if (t->obedit->type == OB_MESH) {
 -                              EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh;
 +                              BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh;
                                /* mirror modifier clipping? */
                                if(t->state != TRANS_CANCEL) {
                                        /* apply clipping after so we never project past the clip plane [#25423] */
                                        clipMirrorModifier(t, t->obedit);
                                }
                                if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR))
 -                                      editmesh_apply_to_mirror(t);
 +                                      editbmesh_apply_to_mirror(t);
                                        
                                DAG_id_tag_update(t->obedit->data, 0);  /* sets recalc flags */
                                
 -                              recalc_editnormals(em);
 +                              EDBM_RecalcNormals(em);
 +                              BMEdit_RecalcTesselation(em);
                        }
                        else if(t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */
                                bArmature *arm= t->obedit->data;
@@@ -889,6 -887,7 +889,7 @@@ void resetTransRestrictions(TransInfo *
        t->flag &= ~T_ALL_RESTRICTIONS;
  }
  
+ /* the *op can be NULL */
  int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
  {
        Scene *sce = CTX_data_scene(C);
                }
  
                /* initialize UV transform from */
-               if (RNA_struct_find_property(op->ptr, "correct_uv")) {
+               if (op && RNA_struct_find_property(op->ptr, "correct_uv")) {
                        if(RNA_property_is_set(op->ptr, "correct_uv")) {
                                if(RNA_boolean_get(op->ptr, "correct_uv")) {
                                        t->settings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT;
@@@ -1462,13 -1461,13 +1463,13 @@@ void calculateCenter(TransInfo *t
                /* EDIT MODE ACTIVE EDITMODE ELEMENT */
  
                if (t->obedit && t->obedit->type == OB_MESH) {
 -                      EditSelection ese;
 -                      EditMesh *em = BKE_mesh_get_editmesh(t->obedit->data);
 +                      BMEditSelection ese;
 +                      BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh;
                        
 -                      if (EM_get_actSelection(em, &ese)) {
 -                              EM_editselection_center(t->center, &ese);
 -                              calculateCenter2D(t);
 -                              break;
 +                      if (EDBM_get_actSelection(em, &ese)) {
 +                      EDBM_editselection_center(em, t->center, &ese);
 +                      calculateCenter2D(t);
 +                      break;
                        }
                } /* END EDIT MODE ACTIVE ELEMENT */
                
index 86e9d65a62f9a8f954edf56538142aaa94c40066,aa6da3aaeca63750b0d3e8b72e6ce5ae5eba69f0..17c66d9804e929e8cdc9e143631241f9b59c346e
@@@ -220,7 -220,7 +220,7 @@@ typedef struct ThemeSpace 
        char console_cursor[4];
        
        char vertex_size, outline_width, facedot_size;
-       char bpad;
+       char noodle_curving;
  
        char syntaxl[4], syntaxn[4], syntaxb[4]; // syntax for textwindow and nodes
        char syntaxv[4], syntaxc[4];
@@@ -392,7 -392,7 +392,7 @@@ typedef struct UserDef 
        struct ColorBand coba_weight;   /* from texture.h */
  
        float sculpt_paint_overlay_col[3];
 -      int pad3;
 +      int loopcut_finish_on_release;
  
        char author[80];        /* author name for file formats supporting it */
  } UserDef;
index b54f11f62ff2780ba7a7ac7b823f74e2559bb8ee,d48f1c93da82b6928b3d6e0b873e06736ca0edc0..0ebf90437494007a4d4601692f23ea43c0d5f748
@@@ -45,9 -45,9 +45,9 @@@
  
  // #include "ED_mesh.h"
  
- #include "BLI_math.h"
  
  #ifdef RNA_RUNTIME
+ #include "BLI_math.h"
  
  #include "BKE_main.h"
  #include "BKE_global.h"
@@@ -160,7 -160,7 +160,7 @@@ static Mesh *rna_Object_to_mesh(Object 
                                dm = mesh_create_derived_view( sce, ob, mask );
                        
                        tmpmesh = add_mesh( "Mesh" );
 -                      DM_to_mesh( dm, tmpmesh );
 +                      DM_to_mesh( dm, tmpmesh, ob );
                        dm->release( dm );
                }
                
@@@ -544,7 -544,8 +544,8 @@@ void RNA_api_object(StructRNA *srna
        /* location of point for test and max distance */
        parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
        RNA_def_property_flag(parm, PROP_REQUIRED);
-       RNA_def_float(func, "max_dist", sqrt(FLT_MAX), 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
+       /* default is sqrt(FLT_MAX) */
+       RNA_def_float(func, "max_dist", 1.844674352395373e+19, 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
  
        /* return location and normal */
        parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4);