2.5: Various
[blender.git] / source / blender / blenloader / intern / readfile.c
index f8657125014c888a9263ed164d04c3232397bc8a..c36a287b9811d6dc970e35a825a6fb3a7db2128d 100644 (file)
 
 #include "readfile.h"
 
+#include "PIL_time.h"
+
 #include <errno.h>
 
 /*
@@ -611,10 +613,16 @@ static BHeadN *get_bhead(FileData *fd)
        BHead  bhead;
        BHeadN *new_bhead = 0;
        int readsize;
-
+       
        if (fd) {
                if ( ! fd->eof) {
 
+                       /* not strictly needed but shuts valgrind up
+                        * since uninitialized memory gets compared */
+                       memset(&bhead8, 0, sizeof(BHead8));
+                       memset(&bhead4, 0, sizeof(BHead4));
+                       memset(&bhead,  0, sizeof(BHead));
+                       
                        // First read the bhead structure.
                        // Depending on the platform the file was written on this can
                        // be a big or little endian BHead4 or BHead8 structure.
@@ -1489,6 +1497,8 @@ static void lib_link_brush(FileData *fd, Main *main)
                if(brush->id.flag & LIB_NEEDLINK) {
                        brush->id.flag -= LIB_NEEDLINK;
 
+                       brush->clone.image= newlibadr_us(fd, brush->id.lib, brush->clone.image);
+                       
                        for(a=0; a<MAX_MTEX; a++) {
                                mtex= brush->mtex[a];
                                if(mtex)
@@ -2868,6 +2878,16 @@ static void direct_link_material(FileData *fd, Material *ma)
 
 static void direct_link_pointcache(FileData *fd, PointCache *cache)
 {
+       if((cache->flag & PTCACHE_DISK_CACHE)==0) {
+               PTCacheMem *pm;
+
+               link_list(fd, &cache->mem_cache);
+
+               pm = cache->mem_cache.first;
+
+               for(; pm; pm=pm->next)
+                       pm->data = newdataadr(fd, pm->data);
+       }
        cache->flag &= ~(PTCACHE_SIMULATION_VALID|PTCACHE_BAKE_EDIT_ACTIVE);
        cache->simframe= 0;
 }
@@ -2879,7 +2899,9 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
        part= main->particle.first;
        while(part) {
                if(part->id.flag & LIB_NEEDLINK) {
+                       if (part->adt) lib_link_animdata(fd, &part->id, part->adt);
                        part->ipo= newlibadr_us(fd, part->id.lib, part->ipo); // XXX depreceated - old animation system
+                       
                        part->dup_ob = newlibadr(fd, part->id.lib, part->dup_ob);
                        part->dup_group = newlibadr(fd, part->id.lib, part->dup_group);
                        part->eff_group = newlibadr(fd, part->id.lib, part->eff_group);
@@ -2892,6 +2914,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
 
 static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
 {
+       part->adt= newdataadr(fd, part->adt);
        part->pd= newdataadr(fd, part->pd);
        part->pd2= newdataadr(fd, part->pd2);
 }
@@ -3132,10 +3155,8 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
                direct_link_dverts(fd, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
                direct_link_customdata(fd, &mesh->mr->fdata, lvl->totface);
                
-               if(!mesh->mr->edge_flags)
-                       mesh->mr->edge_flags= MEM_callocN(sizeof(short)*lvl->totedge, "Multires Edge Flags");
-               if(!mesh->mr->edge_creases)
-                       mesh->mr->edge_creases= MEM_callocN(sizeof(char)*lvl->totedge, "Multires Edge Creases");
+               mesh->mr->edge_flags= newdataadr(fd, mesh->mr->edge_flags);
+               mesh->mr->edge_creases= newdataadr(fd, mesh->mr->edge_creases);
 
                mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
                        
@@ -3146,6 +3167,18 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
                        lvl->colfaces= newdataadr(fd, lvl->colfaces);
                }
        }
+
+       /* Gracefully handle corrupted mesh */
+       if(mesh->mr && !mesh->mr->verts) {
+               /* If totals match, simply load the current mesh verts into multires */
+               if(mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert)
+                       mesh->mr->verts = MEM_dupallocN(mesh->mvert);
+               else {
+                       /* Otherwise, we can't recover the data, silently remove multires */
+                       multires_free(mesh->mr);
+                       mesh->mr = NULL;
+               }
+       }
        
        if((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) {
                TFace *tf= mesh->tface;
@@ -3337,6 +3370,10 @@ static void lib_link_object(FileData *fd, Main *main)
                                        bAddObjectActuator *eoa= act->data;
                                        if(eoa) eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
                                }
+                               else if(act->type==ACT_OBJECT) {
+                                       bObjectActuator *oa= act->data;
+                                       oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+                               }
                                else if(act->type==ACT_EDIT_OBJECT) {
                                        bEditObjectActuator *eoa= act->data;
                                        if(eoa==NULL) {
@@ -3347,6 +3384,15 @@ static void lib_link_object(FileData *fd, Main *main)
                                                eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
                                        }
                                }
+                               else if(act->type==ACT_OBJECT) {
+                                       bObjectActuator *oa= act->data;
+                                       if(oa==NULL) {
+                                               init_actuator(act);
+                                       }
+                                       else {
+                                               oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+                                       }
+                               }
                                else if(act->type==ACT_SCENE) {
                                        bSceneActuator *sa= act->data;
                                        sa->camera= newlibadr(fd, ob->id.lib, sa->camera);
@@ -3451,6 +3497,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
 
                        smd->emCache = smd->mCache = 0;
                }
+               else if (md->type==eModifierType_Armature) {
+                       ArmatureModifierData *amd = (ArmatureModifierData*) md;
+                       
+                       amd->prevCos= NULL;
+               }
                else if (md->type==eModifierType_Cloth) {
                        ClothModifierData *clmd = (ClothModifierData*) md;
                        
@@ -3787,12 +3838,19 @@ static void lib_link_scene(FileData *fd, Main *main)
                        sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
                        sce->set= newlibadr(fd, sce->id.lib, sce->set);
                        sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima);
+                       
                        sce->toolsettings->imapaint.brush=
                                newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush);
                        if(sce->toolsettings->sculpt)
                                sce->toolsettings->sculpt->brush=
                                        newlibadr_us(fd, sce->id.lib, sce->toolsettings->sculpt->brush);
-
+                       if(sce->toolsettings->vpaint)
+                               sce->toolsettings->vpaint->brush=
+                                       newlibadr_us(fd, sce->id.lib, sce->toolsettings->vpaint->brush);
+                       if(sce->toolsettings->wpaint)
+                               sce->toolsettings->wpaint->brush=
+                                       newlibadr_us(fd, sce->id.lib, sce->toolsettings->wpaint->brush);
+                       
                        sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template);
 
                        for(base= sce->base.first; base; base= next) {
@@ -3886,8 +3944,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
        direct_link_keyingsets(fd, &sce->keyingsets);
        
        sce->basact= newdataadr(fd, sce->basact);
-
-       sce->radio= newdataadr(fd, sce->radio);
        
        sce->toolsettings= newdataadr(fd, sce->toolsettings);
        if(sce->toolsettings) {
@@ -3957,6 +4013,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
                                if (seq->flag & SEQ_USE_PROXY) {
                                        seq->strip->proxy = newdataadr(
                                                fd, seq->strip->proxy);
+                                       seq->strip->proxy->anim = 0;
                                } else {
                                        seq->strip->proxy = 0;
                                }
@@ -4190,6 +4247,7 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceButs *sbuts= (SpaceButs *)sl;
                                                sbuts->lockpoin= NULL;
                                                sbuts->ri= NULL;
+                                               sbuts->pinid= newlibadr(fd, sc->id.lib, sbuts->pinid);
                                                if(main->versionfile<132)
                                                        butspace_version_132(sbuts);
                                        }
@@ -4387,23 +4445,37 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
                                        /* not very nice, but could help */
                                        if((v3d->layact & v3d->lay)==0) v3d->layact= v3d->lay;
                                        
+                               }
+                               else if(sl->spacetype==SPACE_IPO) {
+                                       /* XXX animato */
+#if 0
+                                       SpaceIpo *sipo= (SpaceIpo *)sl;
+
+                                       sipo->ipo= restore_pointer_by_name(newmain, (ID *)sipo->ipo, 0);
+                                       if(sipo->blocktype==ID_SEQ) 
+                                               sipo->from= (ID *)find_sequence_from_ipo_helper(newmain, sipo->ipo);
+                                       else 
+                                               sipo->from= restore_pointer_by_name(newmain, (ID *)sipo->from, 0);
+                                       
+                                       // not free sipo->ipokey, creates dependency with src/
+                                       if(sipo->editipo) MEM_freeN(sipo->editipo);
+                                       sipo->editipo= NULL;
+#endif
                                }
                                else if(sl->spacetype==SPACE_BUTS) {
                                        SpaceButs *sbuts= (SpaceButs *)sl;
                                        sbuts->lockpoin= NULL;
+                                       sbuts->pinid = restore_pointer_by_name(newmain, sbuts->pinid, 0);
                                        //XXX if (sbuts->ri) sbuts->ri->curtile = 0;
                                }
                                else if(sl->spacetype==SPACE_FILE) {
                                        
                                        SpaceFile *sfile= (SpaceFile *)sl;
                                        sfile->files= NULL;
+                                       sfile->folders_prev= NULL;
+                                       sfile->folders_next= NULL;
                                        sfile->params= NULL;
                                        sfile->op= NULL;
-                                       /* XXX needs checking - best solve in filesel itself 
-                                       if(sfile->libfiledata)  
-                                               BLO_blendhandle_close(sfile->libfiledata);
-                                       sfile->libfiledata= 0;
-                                       */
                                }
                                else if(sl->spacetype==SPACE_IMASEL) {
                     SpaceImaSel *simasel= (SpaceImaSel *)sl;
@@ -4667,6 +4739,14 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                }
                                snode->nodetree= snode->edittree= NULL;
                        }
+                       else if(sl->spacetype==SPACE_LOGIC) {
+                               SpaceLogic *slogic= (SpaceLogic *)sl;
+                               
+                               if(slogic->gpd) {
+                                       slogic->gpd= newdataadr(fd, slogic->gpd);
+                                       direct_link_gpencil(fd, slogic->gpd);
+                               }
+                       }
                        else if(sl->spacetype==SPACE_SEQ) {
                                SpaceSeq *sseq= (SpaceSeq *)sl;
                                if(sseq->gpd) {
@@ -4674,6 +4754,10 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                        direct_link_gpencil(fd, sseq->gpd);
                                }
                        }
+                       else if(sl->spacetype==SPACE_BUTS) {
+                               SpaceButs *sbuts= (SpaceButs *)sl;
+                               sbuts->path= NULL;
+                       }
                }
                
                sa->actionzones.first= sa->actionzones.last= NULL;
@@ -5508,20 +5592,15 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
                                /* temporarily hide it */
                                ar->flag = RGN_FLAG_HIDDEN;
                                break;
-                               
-                       case SPACE_FILE:
-                               /* channel (bookmarks/directories) region */
+#if 0
+                       case SPACE_BUTS:
+                               /* context UI region */
                                ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
                                BLI_addtail(lb, ar);
                                ar->regiontype= RGN_TYPE_CHANNELS;
-                               ar->alignment= RGN_ALIGN_LEFT;
-                               ar->v2d.scroll= V2D_SCROLL_RIGHT;
-                               /* button UI region */
-                               ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
-                               BLI_addtail(lb, ar);
-                               ar->regiontype= RGN_TYPE_UI;
                                ar->alignment= RGN_ALIGN_TOP;
                                break;
+#endif
                }
        }
 
@@ -6744,26 +6823,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        
                                                if(sbuts->mainb==BUTS_LAMP) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
                                                }
                                                else if(sbuts->mainb==BUTS_MAT) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
                                                }
                                                else if(sbuts->mainb==BUTS_TEX) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
                                                }
                                                else if(sbuts->mainb==BUTS_ANIM) {
                                                        sbuts->mainb= CONTEXT_OBJECT;
                                                }
                                                else if(sbuts->mainb==BUTS_WORLD) {
                                                        sbuts->mainb= CONTEXT_SCENE;
-                                                       sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
+                                                       //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
                                                }
                                                else if(sbuts->mainb==BUTS_RENDER) {
                                                        sbuts->mainb= CONTEXT_SCENE;
-                                                       sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
+                                                       //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
                                                }
                                                else if(sbuts->mainb==BUTS_GAME) {
                                                        sbuts->mainb= CONTEXT_LOGIC;
@@ -6773,7 +6852,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                }
                                                else if(sbuts->mainb==BUTS_RADIO) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
                                                }
                                                else if(sbuts->mainb==BUTS_CONSTRAINT) {
                                                        sbuts->mainb= CONTEXT_OBJECT;
@@ -7008,22 +7087,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        
 
        if(main->versionfile <= 234) {
-               Scene *sce;
                World *wo;
                bScreen *sc;
-               int set_zbuf_sel=0;
                
                // force sumo engine to be active
                for (wo = main->world.first; wo; wo= wo->id.next) {
                        if(wo->physicsEngine==0) wo->physicsEngine = 2;
                }
                
-               for (sce= main->scene.first; sce; sce= sce->id.next) {
-                       if(sce->selectmode==0) {
-                               sce->selectmode= SCE_SELECT_VERTEX;
-                               set_zbuf_sel= 1;
-                       }
-               }
                for (sc= main->screen.first; sc; sc= sc->id.next) {
                        ScrArea *sa;
                        for (sa= sc->areabase.first; sa; sa= sa->next) {
@@ -7031,7 +7102,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                for (sl= sa->spacedata.first; sl; sl= sl->next) {
                                        if(sl->spacetype==SPACE_VIEW3D) {
                                                View3D *v3d= (View3D *)sl;
-                                               if(set_zbuf_sel) v3d->flag |= V3D_ZBUF_SELECT;
+                                               v3d->flag |= V3D_ZBUF_SELECT;
                                        }
                                        else if(sl->spacetype==SPACE_TEXT) {
                                                SpaceText *st= (SpaceText *)sl;
@@ -7066,16 +7137,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        }
        if(main->versionfile <= 236) {
                Object *ob;
-               Scene *sce= main->scene.first;
                Camera *cam= main->camera.first;
                Material *ma;
                bScreen *sc;
 
-               while(sce) {
-                       if(sce->editbutsize==0.0) sce->editbutsize= 0.1f;
-                       
-                       sce= sce->id.next;
-               }
                while(cam) {
                        if(cam->ortho_scale==0.0) {
                                cam->ortho_scale= 256.0f/cam->lens;
@@ -8400,7 +8465,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
 
                                                part->draw_as = PART_DRAW_PATH;
                                                part->type = PART_HAIR;
-                                               psys->recalc |= PSYS_RECALC_HAIR;
+                                               psys->recalc |= PSYS_RECALC_REDO;
 
                                                part->normfac *= fac;
                                                part->randfac *= fac;
@@ -8701,15 +8766,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
        }
-       /* autokey mode settings now used from scene, but need to be initialised off userprefs */
-       if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 8)) {
-               Scene *sce;
-               
-               for (sce= main->scene.first; sce; sce= sce->id.next) {
-                       if (sce->autokey_mode == 0)
-                               sce->autokey_mode= U.autokey_mode;
-               }
-       }
 
        if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) {
                Lamp *la= main->lamp.first;
@@ -8836,7 +8892,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                /* Adjustments needed after Bullets update */
                for(ob = main->object.first; ob; ob= ob->id.next) {
                        ob->damping *= 0.635f;
-                       ob->rdamping = 0.1 + (0.59f * ob->rdamping);
+                       ob->rdamping = 0.1 + (0.8f * ob->rdamping);
                }
        }
        
@@ -8848,9 +8904,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                for (sce= main->scene.first; sce; sce= sce->id.next) {
                        sce->r.domeangle = 180;
                        sce->r.domemode = 1;
-                       sce->r.domesize = 1.0f;
                        sce->r.domeres = 4;
                        sce->r.domeresbuf = 1.0f;
+                       sce->r.dometilt = 0;
                }
                /* DBVT culling by default */
                for(wrld=main->world.first; wrld; wrld= wrld->id.next) {
@@ -8859,6 +8915,77 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
+       if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) {
+               Object *ob;
+               World *wrld;
+               for(ob = main->object.first; ob; ob= ob->id.next) {
+                       ob->m_contactProcessingThreshold = 1.; //pad3 is used for m_contactProcessingThreshold
+                       if(ob->parent) {
+                               /* check if top parent has compound shape set and if yes, set this object
+                                  to compound shaper as well (was the behaviour before, now it's optional) */
+                               Object *parent= newlibadr(fd, lib, ob->parent);
+                               while (parent && parent->parent != NULL) {
+                                       parent = newlibadr(fd, lib, parent->parent);
+                               }
+                               if(parent) {
+                                       if (parent->gameflag & OB_CHILD)
+                                               ob->gameflag |= OB_CHILD;
+                               }
+                       }
+               }
+               for(wrld=main->world.first; wrld; wrld= wrld->id.next) {
+                       wrld->ticrate = 60;
+                       wrld->maxlogicstep = 5;
+                       wrld->physubstep = 1;
+                       wrld->maxphystep = 5;
+               }
+       }
+
+       if (main->versionfile < 249) {
+               Scene *sce;
+               for (sce= main->scene.first; sce; sce= sce->id.next)
+                       sce->r.renderer= 0;
+               
+       }
+       
+       // correct introduce of seed for wind force
+       if (main->versionfile < 249 && main->subversionfile < 1) {
+               Object *ob;
+               for(ob = main->object.first; ob; ob= ob->id.next) {
+                       if(ob->pd)
+                               ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128;
+               }
+       
+       }
+
+       if (main->versionfile < 249 && main->subversionfile < 2) {
+               Scene *sce= main->scene.first;
+               Sequence *seq;
+               Editing *ed;
+               
+               while(sce) {
+                       ed= sce->ed;
+                       if(ed) {
+                               SEQP_BEGIN(ed, seq) {
+                                       if (seq->strip && seq->strip->proxy){
+                                               if (sce->r.size != 100.0) {
+                                                       seq->strip->proxy->size
+                                                               = sce->r.size;
+                                               } else {
+                                                       seq->strip->proxy->size
+                                                               = 25.0;
+                                               }
+                                               seq->strip->proxy->quality =90;
+                                       }
+                               }
+                               SEQ_END
+                       }
+                       
+                       sce= sce->id.next;
+               }
+
+       }
+
        if (main->versionfile < 250) {
                bScreen *screen;
                Scene *scene;
@@ -8866,6 +8993,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                Mesh *me;
                Scene *sce;
                Tex *tx;
+               ParticleSettings *part;
+               Object *ob;
+               PTCacheID *pid;
+               ListBase pidlist;
                
                for(screen= main->screen.first; screen; screen= screen->id.next) {
                        do_versions_windowmanager_2_50(screen);
@@ -8877,13 +9008,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                 */
                //do_versions_ipos_to_animato(main);
                
-               /* struct audio data moved to renderdata */
-               for(scene= main->scene.first; scene; scene= scene->id.next) {
+               /* toolsettings */
+               for(scene= main->scene.first; scene; scene= scene->id.next)
                        scene->r.audio = scene->audio;
-                       
-                       if(!scene->toolsettings->uv_selectmode)
-                               scene->toolsettings->uv_selectmode= UV_SELECT_VERTEX;
-               }
                
                /* shader, composit and texture node trees have id.name empty, put something in
                 * to have them show in RNA viewer and accessible otherwise.
@@ -8907,6 +9034,34 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                for(me= main->mesh.first; me; me= me->id.next) {
                        me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
                }
+
+               /* particle draw and render types */
+               for(part= main->particle.first; part; part= part->id.next) {
+                       if(part->draw_as) {
+                               if(part->draw_as == PART_DRAW_DOT) {
+                                       part->ren_as = PART_DRAW_HALO;
+                                       part->draw_as = PART_DRAW_REND;
+                               }
+                               else if(part->draw_as <= PART_DRAW_AXIS) {
+                                       part->ren_as = PART_DRAW_HALO;
+                               }
+                               else {
+                                       part->ren_as = part->draw_as;
+                                       part->draw_as = PART_DRAW_REND;
+                               }
+                       }
+                       part->path_end = 1.0f;
+               }
+               /* set old pointcaches to have disk cache flag */
+               for(ob = main->object.first; ob; ob= ob->id.next) {
+
+                       BKE_ptcache_ids_from_object(&pidlist, ob);
+
+                       for(pid=pidlist.first; pid; pid=pid->next)
+                               pid->cache->flag |= PTCACHE_DISK_CACHE;
+
+                       BLI_freelistN(&pidlist);
+               }
        }
 
        /* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can
@@ -8914,6 +9069,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        {
                Object *ob;
                Material *ma;
+               Scene *sce;
+               ToolSettings *ts;
                int i;
 
                for(ob = main->object.first; ob; ob = ob->id.next) {
@@ -8923,7 +9080,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                void *olddata = ob->data;
                                ob->data = me;
 
-                               if(me && me->mr) {
+                               if(me && me->id.lib==NULL && me->mr) { /* XXX - library meshes crash on loading most yoFrankie levels, the multires pointer gets invalid -  Campbell */
                                        MultiresLevel *lvl;
                                        ModifierData *md;
                                        MultiresModifierData *mmd;
@@ -8967,7 +9124,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        
                                        multires_load_old(dm, me->mr);
 
-                                       *MultiresDM_get_flags(dm) |= MULTIRES_DM_UPDATE_ALWAYS;
+                                       MultiresDM_mark_as_modified(dm);
                                        dm->release(dm);
                                        orig->release(orig);
 
@@ -8986,6 +9143,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                ma->mode &= ~MA_HALO;
                        }
                }
+
+               for(sce = main->scene.first; sce; sce = sce->id.next) {
+                       ts= sce->toolsettings;
+                       if(ts->normalsize == 0.0 || !ts->uv_selectmode || ts->vgroup_weight == 0.0) {
+                               ts->normalsize= 0.1f;
+                               ts->selectmode= SCE_SELECT_VERTEX;
+                               ts->autokey_mode= U.autokey_mode;
+                               ts->uv_selectmode= UV_SELECT_VERTEX;
+                               ts->vgroup_weight= 1.0f;
+                       }
+               }
        }
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
@@ -9339,6 +9507,8 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting
        expand_doit(fd, mainvar, part->dup_group);
        expand_doit(fd, mainvar, part->eff_group);
        expand_doit(fd, mainvar, part->bb_ob);
+       
+       expand_animdata(fd, mainvar, part->adt);
 }
 
 static void expand_group(FileData *fd, Main *mainvar, Group *group)
@@ -9814,6 +9984,10 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
                                expand_doit(fd, mainvar, eoa->me);
                        }
                }
+               else if(act->type==ACT_OBJECT) {
+                       bObjectActuator *oa= act->data;
+                       expand_doit(fd, mainvar, oa->reference);
+               }
                else if(act->type==ACT_SCENE) {
                        bSceneActuator *sa= act->data;
                        expand_doit(fd, mainvar, sa->camera);