diff options
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 416 |
1 files changed, 246 insertions, 170 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 851f1bac018..cac072b76b2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -29,11 +29,6 @@ #include "zlib.h" -#ifdef WIN32 -#include "winsock2.h" -#include "BLI_winstuff.h" -#endif - #include <limits.h> #include <stdio.h> // for printf fopen fwrite fclose sprintf FILE #include <stdlib.h> // for getenv atoi @@ -46,6 +41,8 @@ #include <sys/param.h> // for MAXPATHLEN #else #include <io.h> // for open close read +#include "winsock2.h" +#include "BLI_winstuff.h" #endif #include "DNA_anim_types.h" @@ -117,6 +114,7 @@ #include "BKE_cloth.h" #include "BKE_colortools.h" #include "BKE_constraint.h" +#include "BKE_context.h" #include "BKE_curve.h" #include "BKE_customdata.h" #include "BKE_deform.h" @@ -127,7 +125,6 @@ #include "BKE_group.h" #include "BKE_image.h" #include "BKE_ipo.h" -#include "BKE_key.h" //void set_four_ipo #include "BKE_lattice.h" #include "BKE_library.h" // for wich_libbase #include "BKE_main.h" // for Main @@ -136,6 +133,7 @@ #include "BKE_multires.h" #include "BKE_node.h" // for tree type defines #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_property.h" // for get_ob_property @@ -144,7 +142,6 @@ #include "BKE_scene.h" #include "BKE_softbody.h" // sbNew() #include "BKE_bullet.h" // bsbNew() -#include "BKE_sculpt.h" #include "BKE_sequence.h" #include "BKE_texture.h" // for open_plugin_tex #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND @@ -1070,6 +1067,46 @@ int BLO_has_bfile_extension(char *str) return (BLI_testextensie(str, ".ble") || BLI_testextensie(str, ".blend")||BLI_testextensie(str, ".blend.gz")); } +int BLO_is_a_library(char *path, char *dir, char *group) +{ + /* return ok when a blenderfile, in dir is the filename, + * in group the type of libdata + */ + int len; + char *fd; + + strcpy(dir, path); + len= strlen(dir); + if(len<7) return 0; + if( dir[len-1] != '/' && dir[len-1] != '\\') return 0; + + group[0]= 0; + dir[len-1]= 0; + + /* Find the last slash */ + fd= (strrchr(dir, '/')>strrchr(dir, '\\'))?strrchr(dir, '/'):strrchr(dir, '\\'); + + if(fd==0) return 0; + *fd= 0; + if(BLO_has_bfile_extension(fd+1)) { + /* the last part of the dir is a .blend file, no group follows */ + *fd= '/'; /* put back the removed slash separating the dir and the .blend file name */ + } + else { + char *gp = fd+1; // in case we have a .blend file, gp points to the group + + /* Find the last slash */ + fd= (strrchr(dir, '/')>strrchr(dir, '\\'))?strrchr(dir, '/'):strrchr(dir, '\\'); + if (!fd || !BLO_has_bfile_extension(fd+1)) return 0; + + /* now we know that we are in a blend file and it is safe to + assume that gp actually points to a group */ + if (BLI_streq("Screen", gp)==0) + BLI_strncpy(group, gp, GROUP_MAX); + } + return 1; +} + /* ************** OLD POINTERS ******************* */ static void *newdataadr(FileData *fd, void *adr) /* only direct databocks */ @@ -1374,12 +1411,10 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData prop->totallen = prop->len; prop->data.pointer = newdataadr(fd, prop->data.pointer); - if (switch_endian) { - array= (IDProperty*) prop->data.pointer; + array= (IDProperty*) prop->data.pointer; - for(i=0; i<prop->len; i++) - IDP_DirectLinkProperty(&array[i], switch_endian, fd); - } + for(i=0; i<prop->len; i++) + IDP_DirectLinkProperty(&array[i], switch_endian, fd); } static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *fd) @@ -1391,19 +1426,22 @@ static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *f prop->totallen = prop->len; prop->data.pointer = newdataadr(fd, prop->data.pointer); - if (switch_endian) { - if(prop->subtype == IDP_GROUP) { - test_pointer_array(fd, prop->data.pointer); - array= prop->data.pointer; + if(prop->subtype == IDP_GROUP) { + test_pointer_array(fd, prop->data.pointer); + array= prop->data.pointer; - for(i=0; i<prop->len; i++) - IDP_DirectLinkProperty(array[i], switch_endian, fd); - } - else if(prop->subtype == IDP_DOUBLE) { + for(i=0; i<prop->len; i++) + IDP_DirectLinkProperty(array[i], switch_endian, fd); + } + else if(prop->subtype == IDP_DOUBLE) { + if (switch_endian) { for (i=0; i<prop->len; i++) { SWITCH_LONGINT(((double*)prop->data.pointer)[i]); } - } else { + } + } + else { + if (switch_endian) { for (i=0; i<prop->len; i++) { SWITCH_INT(((int*)prop->data.pointer)[i]); } @@ -2963,8 +3001,10 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) else cache->mem_cache.first = cache->mem_cache.last = NULL; - cache->flag &= ~(PTCACHE_SIMULATION_VALID|PTCACHE_BAKE_EDIT_ACTIVE); + cache->flag &= ~PTCACHE_SIMULATION_VALID; cache->simframe= 0; + cache->edit= NULL; + cache->free_edit= NULL; } static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache) @@ -3053,11 +3093,8 @@ static void direct_link_particlesettings(FileData *fd, ParticleSettings *part) static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles) { ParticleSystem *psys, *psysnext; - int a; for(psys=particles->first; psys; psys=psysnext){ - ParticleData *pa; - psysnext= psys->next; psys->part = newlibadr_us(fd, id->lib, psys->part); @@ -3068,12 +3105,6 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase pt->ob=newlibadr(fd, id->lib, pt->ob); psys->target_ob = newlibadr(fd, id->lib, psys->target_ob); - - for(a=0,pa=psys->particles; a<psys->totpart; a++,pa++){ - pa->stick_ob=newlibadr(fd, id->lib, pa->stick_ob); - } - - } else { /* particle modifier must be removed before particle system */ @@ -3124,20 +3155,9 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) psys->child=newdataadr(fd,psys->child); psys->effectors.first=psys->effectors.last=0; - psys->soft= newdataadr(fd, psys->soft); - if(psys->soft) { - SoftBody *sb = psys->soft; - sb->particles = psys; - sb->bpoint= NULL; // init pointers so it gets rebuilt nicely - sb->bspring= NULL; - sb->scratch= NULL; - - direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache); - } - link_list(fd, &psys->targets); - psys->edit = 0; + psys->edit = NULL; psys->free_edit = NULL; psys->pathcache = 0; psys->childcache = 0; @@ -3147,6 +3167,23 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache); + if(psys->clmd) { + psys->clmd = newdataadr(fd, psys->clmd); + psys->clmd->clothObject = NULL; + + psys->clmd->sim_parms= newdataadr(fd, psys->clmd->sim_parms); + psys->clmd->coll_parms= newdataadr(fd, psys->clmd->coll_parms); + + if(psys->clmd->sim_parms) { + if(psys->clmd->sim_parms->presets > 10) + psys->clmd->sim_parms->presets = 0; + } + + psys->hair_in_dm = psys->hair_out_dm = NULL; + + psys->clmd->point_cache = psys->pointcache; + } + psys->tree = NULL; } return; @@ -3617,6 +3654,8 @@ static void lib_link_object(FileData *fd, Main *main) } for(a=0; a<ob->totcol; a++) ob->mat[a]= newlibadr_us(fd, ob->id.lib, ob->mat[a]); + ob->gpd= newlibadr_us(fd, ob->id.lib, ob->gpd); + ob->id.flag -= LIB_NEEDLINK; /* if id.us==0 a new base will be created later on */ @@ -3860,8 +3899,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) smd->domain->smd = smd; smd->domain->fluid = NULL; - smd->domain->view3d = NULL; + smd->domain->wt = NULL; + smd->domain->shadow = NULL; smd->domain->tex = NULL; + smd->domain->tex_shadow = NULL; + smd->domain->tex_wt = NULL; direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0])); direct_link_pointcache_list(fd, &(smd->domain->ptcaches[1]), &(smd->domain->point_cache[1])); @@ -4210,6 +4252,7 @@ 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->gpd= newlibadr_us(fd, sce->id.lib, sce->gpd); link_paint(fd, sce, &sce->toolsettings->sculpt->paint); link_paint(fd, sce, &sce->toolsettings->vpaint->paint); @@ -4517,11 +4560,14 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) static void lib_link_windowmanager(FileData *fd, Main *main) { wmWindowManager *wm; + wmWindow *win; for(wm= main->wm.first; wm; wm= wm->id.next) { - wmWindow *win; - for(win= wm->windows.first; win; win= win->next) { - win->screen= newlibadr(fd, NULL, win->screen); + if(wm->id.flag & LIB_NEEDLINK) { + for(win= wm->windows.first; win; win= win->next) + win->screen= newlibadr(fd, NULL, win->screen); + + wm->id.flag -= LIB_NEEDLINK; } } } @@ -4983,6 +5029,10 @@ static void view3d_split_250(View3D *v3d, ListBase *regions) QUATCOPY(rv3d->viewquat, v3d->viewquat); } } + + /* this was not initialized correct always */ + if(v3d->twtype == 0) + v3d->twtype= V3D_MANIP_TRANSLATE; } static void direct_link_screen(FileData *fd, bScreen *sc) @@ -5228,7 +5278,7 @@ static void fix_relpaths_library(const char *basepath, Main *main) static void direct_link_sound(FileData *fd, bSound *sound) { - sound->snd_sound = NULL; + sound->handle = NULL; sound->packedfile = direct_link_packedfile(fd, sound->packedfile); sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile); @@ -5243,9 +5293,11 @@ static void lib_link_sound(FileData *fd, Main *main) if(sound->id.flag & LIB_NEEDLINK) { sound->id.flag -= LIB_NEEDLINK; sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system - sound->stream = 0; - + sound_load(main, sound); + + if(sound->cache) + sound_cache(sound, 1); } sound= sound->id.next; } @@ -8508,8 +8560,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches); for(psys=ob->particlesystem.first; psys; psys=psys->next) { - if(psys->soft && !psys->soft->pointcache) - psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches); + //if(psys->soft && !psys->soft->pointcache) + // psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches); if(!psys->pointcache) psys->pointcache= BKE_ptcache_add(&psys->ptcaches); } @@ -9388,6 +9440,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Material *ma; Camera *cam; Mesh *me; + Curve *cu; Scene *sce; Tex *tx; ParticleSettings *part; @@ -9534,6 +9587,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) //BLI_freelistN(&pidlist); } + + /* type was a mixed flag & enum. move the 2d flag elsewhere */ + for(cu = main->curve.first; cu; cu= cu->id.next) { + Nurb *nu; + + for(nu= cu->nurb.first; nu; nu= nu->next) { + nu->flag |= (nu->type & CU_2D); + nu->type &= CU_TYPE; + } + } } if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) { @@ -9754,6 +9817,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) { Scene *sce; + Object *ob; for(sce = main->scene.first; sce; sce = sce->id.next) { if(fd->fileflags & G_FILE_ENABLE_ALL_FRAMES) @@ -9786,10 +9850,33 @@ static void do_versions(FileData *fd, Library *lib, Main *main) sce->gm.flag |= GAME_DISPLAY_LISTS; } + + for(ob = main->object.first; ob; ob = ob->id.next) { + if(ob->flag & 8192) // OB_POSEMODE = 8192 + ob->mode |= OB_MODE_POSE; + } } /* put 2.50 compatibility code here until next subversion bump */ { + Scene *sce; + Object *ob; + + for(sce = main->scene.first; sce; sce = sce->id.next) + if(sce->unit.scale_length == 0.0f) + sce->unit.scale_length= 1.0f; + + for(ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + + /* add backwards pointer for fluidsim modifier RNA access */ + for (md=ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Fluidsim) { + FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + fluidmd->fss->fmd = fluidmd; + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ @@ -9843,16 +9930,6 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->user->uifonts.first= bfd->user->uifonts.last= NULL; bfd->user->uistyles.first= bfd->user->uistyles.last= NULL; - // AUD_XXX - if(bfd->user->audiochannels == 0) - bfd->user->audiochannels = 2; - if(bfd->user->audiodevice == 0) - bfd->user->audiodevice = 1; - if(bfd->user->audioformat == 0) - bfd->user->audioformat = 0x12; - if(bfd->user->audiorate == 0) - bfd->user->audiorate = 44100; - bhead = blo_nextbhead(fd, bhead); /* read all attached data */ @@ -9865,7 +9942,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) return bhead; } -BlendFileData *blo_read_file_internal(FileData *fd) +BlendFileData *blo_read_file_internal(FileData *fd, char *file) { BHead *bhead= blo_firstbhead(fd); BlendFileData *bfd; @@ -9876,6 +9953,9 @@ BlendFileData *blo_read_file_internal(FileData *fd) bfd->main->versionfile= fd->fileversion; + bfd->type= BLENFILETYPE_BLEND; + strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1); + while(bhead) { switch(bhead->code) { case DATA: @@ -10580,6 +10660,8 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_doit(fd, mainvar, ob->poselib); expand_constraints(fd, mainvar, &ob->constraints); + expand_doit(fd, mainvar, ob->gpd); + // XXX depreceated - old animation system (for version patching only) expand_doit(fd, mainvar, ob->ipo); expand_doit(fd, mainvar, ob->action); @@ -10715,6 +10797,9 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) if(sce->r.dometext) expand_doit(fd, mainvar, sce->gm.dome.warptext); + + if(sce->gpd) + expand_doit(fd, mainvar, sce->gpd); } static void expand_camera(FileData *fd, Main *mainvar, Camera *ca) @@ -10875,8 +10960,9 @@ static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, int is } -static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *name, int idcode, short flag) +static void append_named_part(const bContext *C, Main *mainl, FileData *fd, char *name, int idcode, short flag) { + Scene *scene= CTX_data_scene(C); Object *ob; Base *base; BHead *bhead; @@ -10892,9 +10978,9 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n if(strcmp(idname+2, name)==0) { - id= is_yet_read(fd, mainvar, bhead); + id= is_yet_read(fd, mainl, bhead); if(id==NULL) { - read_libblock(fd, mainvar, bhead, LIB_TESTEXT, NULL); + read_libblock(fd, mainl, bhead, LIB_TESTEXT, NULL); } else { printf("append: already linked\n"); @@ -10909,13 +10995,18 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n base= MEM_callocN( sizeof(Base), "app_nam_part"); BLI_addtail(&scene->base, base); - if(id==NULL) ob= mainvar->object.last; + if(id==NULL) ob= mainl->object.last; else ob= (Object *)id; - /* XXX use context to find view3d->lay */ - //if((flag & FILE_ACTIVELAY)) { - // scene->lay; - //} + /* link at active layer (view3d->lay if in context, else scene->lay */ + if((flag & FILE_ACTIVELAY)) { + View3D *v3d = CTX_wm_view3d(C); + if (v3d) { + ob->lay = v3d->layact; + } else { + ob->lay = scene->lay; + } + } base->lay= ob->lay; base->object= ob; ob->id.us++; @@ -10934,6 +11025,12 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n } } +void BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, char *name, int idcode, short flag) +{ + FileData *fd= (FileData*)(*bh); + append_named_part(C, mainl, fd, name, idcode, flag); +} + static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) { BHead *bhead; @@ -10956,11 +11053,10 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) /* common routine to append/link something from a library */ -static Library* library_append(Main *mainvar, Scene *scene, char* file, char *dir, int idcode, - int totsel, FileData **fd, struct direntry* filelist, int totfile, short flag) +static Main* library_append_begin(const bContext *C, FileData **fd, char *dir) { + Main *mainvar= CTX_data_main(C); Main *mainl; - Library *curlib; /* make mains */ blo_split_main(&(*fd)->mainlist, mainvar); @@ -10970,19 +11066,69 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di mainl->versionfile= (*fd)->fileversion; /* needed for do_version */ - curlib= mainl->curlib; + return mainl; +} + +Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, char *dir) +{ + FileData *fd= (FileData*)(*bh); + return library_append_begin(C, &fd, dir); +} + +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; - if(totsel==0) { - append_named_part(*fd, mainl, scene, file, idcode, flag); + /* 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; } - else { - int a; - for(a=0; a<totfile; a++) { - if(filelist[a].flags & ACTIVE) { - append_named_part(*fd, mainl, scene, filelist[a].relname, idcode, flag); - } + /* we haven't found any objects to move to cursor */ + if(!count) + return; + + /* move from the center of the appended objects to cursor */ + centerloc[0]= (min[0]+max[0])/2; + centerloc[1]= (min[1]+max[1])/2; + centerloc[2]= (min[2]+max[2])/2; + 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; } +} + +static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag) +{ + Main *mainvar= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); /* make main consistant */ expand_main(*fd, mainl); @@ -10990,6 +11136,7 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di /* do this when expand found other libs */ read_libraries(*fd, &(*fd)->mainlist); + /* make the lib path relative if required */ if(flag & FILE_STRINGCODE) { /* use the full path, this could have been read by other library even */ @@ -11012,7 +11159,7 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di if (flag & FILE_LINK) { give_base_to_objects(mainvar, scene, NULL, 0); } else { - give_base_to_objects(mainvar, scene, curlib, 1); + give_base_to_objects(mainvar, scene, mainl->curlib, 1); } } else { give_base_to_objects(mainvar, scene, NULL, 0); @@ -11028,14 +11175,23 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di *fd = NULL; } - return curlib; + append_do_cursor(scene, mainl->curlib, flag); +} + +void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag) +{ + FileData *fd= (FileData*)(*bh); + library_append_end(C, mainl, &fd, idcode, flag); + *bh= (BlendHandle*)fd; } /* this is a version of BLO_library_append needed by the BPython API, so * scripts can load data from .blend files -- see Blender.Library module.*/ /* append to scene */ /* this should probably be moved into the Python code anyway */ - +/* tentatively removed, Python should be able to use the split functions too: */ +/* BLO_library_append_begin, BLO_library_append_end, BLO_library_append_named_part */ +#if 0 void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, Main *mainvar, Scene *scene, ReportList *reports) { @@ -11052,88 +11208,7 @@ void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, *bh= (BlendHandle*)fd; } - -/* append to scene */ -void BLO_library_append(BlendHandle** bh, struct direntry* filelist, int totfile, - char *dir, char* file, short flag, int idcode, Main *mainvar, Scene *scene, ReportList *reports) -{ - FileData *fd= (FileData*)(*bh); - Library *curlib; - Base *centerbase; - Object *ob; - int a, totsel=0; - - /* are there files selected? */ - for(a=0; a<totfile; a++) { - if(filelist[a].flags & ACTIVE) { - totsel++; - } - } - - if(totsel==0) { - /* is the indicated file in the filelist? */ - if(file[0]) { - for(a=0; a<totfile; a++) { - if( strcmp(filelist[a].relname, file)==0) break; - } - if(a==totfile) { - BKE_report(reports, RPT_ERROR, "Wrong indicated name"); - return; - } - } - else { - BKE_report(reports, RPT_ERROR, "Nothing indicated"); - return; - } - } - /* now we have or selected, or an indicated file */ - - if(flag & FILE_AUTOSELECT) scene_deselect_all(scene); - - fd->reports= reports; - curlib = library_append(mainvar, scene, file, dir, idcode, totsel, &fd, filelist, totfile,flag ); - if(fd) fd->reports= NULL; - - *bh= (BlendHandle*)fd; - - /* when not linking (appending)... */ - if((flag & FILE_LINK)==0) { - if(flag & FILE_ATCURSOR) { - float *curs, centerloc[3], vec[3], min[3], max[3]; - int count= 0; - - 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; - } - if(count) { - centerloc[0]= (min[0]+max[0])/2; - centerloc[1]= (min[1]+max[1])/2; - centerloc[2]= (min[2]+max[2])/2; - curs = scene->cursor; - VECSUB(centerloc,curs,centerloc); - - 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; - } - } - } - } -} +#endif /* ************* READ LIBRARY ************** */ @@ -11177,9 +11252,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) printf("read library: lib %s\n", mainptr->curlib->name); fd= blo_openblenderfile(mainptr->curlib->filename, &reports); - fd->reports= basefd->reports; if (fd) { + fd->reports= basefd->reports; + if (fd->libmap) oldnewmap_free(fd->libmap); @@ -11293,7 +11369,7 @@ BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize, return NULL; fd->reports= reports; - bfd= blo_read_file_internal(fd); + bfd= blo_read_file_internal(fd, ""); blo_freefiledata(fd); return bfd; |