From 9508bb0d419fb160e9f39d693f6a14acccfb4e12 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 26 Apr 2003 18:01:01 +0000 Subject: [PATCH] comments translated for blenloader files --- source/blender/blenloader/intern/readfile.c | 301 +++++++------------ source/blender/blenloader/intern/writefile.c | 137 +++++---- 2 files changed, 175 insertions(+), 263 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b87b4d11695..f62d4a72b07 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1,4 +1,8 @@ -/** +/* + * readfile.c + * + * .blend file reading + * * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** @@ -28,7 +32,7 @@ * Contributor(s): none yet. * * ***** END GPL/BL DUAL LICENSE BLOCK ***** - * .blend file reading + * */ #ifdef HAVE_CONFIG_H @@ -127,50 +131,52 @@ #include "mydevice.h" /* -ZWAK PUNT: newadres berekening en meerdere files: oplossen -bijvoorbeeld door per file aparte newadresarrays te maken? + Remark: still a weak point is the newadress() function, that doesnt solve reading from + multiple files at the same time + + (added remark: oh, i thought that was solved? will look at that... (ton) -LEZEN -- Bestaande Library (Main) pushen of vrijgeven -- Nieuwe Main alloceren +READ +- Existing Library (Main) push or free +- allocate new Main - load file - read SDNA - for each LibBlock - read LibBlock - - als Library + - if a Library - make a new Main - - ID's eraan hangen + - attach ID's to it - else - - lees bijhorende direkte data - - link direkte data (intern en aan LibBlock) -- lees FileGlobal -- lees USER data, als aangegeven (~/.B.blend) -- file vrijgeven -- per Library met Scene (per Main) - - file inlezen - - lees SDNA - - alle LibBlocks uit Scene opzoeken en ID's aan Main hagen - - als extern LibBlock - - zoek Main's af - - is al ingelezen: - - nog niet ingelezen - - of nieuwe Main maken + - read associated 'direct data' + - link direct data (internal and to LibBlock) +- read FileGlobal +- read USER data, only when indicated (file is ~/.B.blend) +- free file +- per Library (per Main) + - read file + - read SDNA + - find LibBlocks and attach IDs to Main + - if external LibBlock + - search all Main's + - or it's already read, + - or not read yet + - or make new Main - per LibBlock - - recursief dieper lezen - - lees bijhorende direkte data - - link direkte data (intern en aan LibBlock) - - file vrijgeven -- per Library met nog niet gelezen LibBlocks - - file inlezen - - lees SDNA + - read recursive + - read associated direct data + - link direct data (internal and to LibBlock) + - free file +- per Library with unread LibBlocks + - read file + - read SDNA - per LibBlock - - recursief dieper lezen - - lees bijhorende direkte data - - link direkte data (intern en aan LibBlock) - - file vrijgeven -- alle Main's samenvoegen -- alle LibBlocks linken en indirekte pointers naar libblocks -- FileGlobal goedzetten en pointers naar Global kopieeren + - read recursive + - read associated direct data + - link direct data (internal and to LibBlock) + - free file +- join all Mains +- link all LibBlocks and indirect pointers to libblocks +- initialize FileGlobal and copy pointers to Global */ /* also occurs in library.c */ @@ -370,7 +376,7 @@ static void oldnewmap_free(OldNewMap *onm) { static void read_libraries(FileData *basefd, ListBase *mainlist); -/* ************ OTHER CRAP ***************** */ +/* ************ help functions ***************** */ static void add_main_to_main(Main *mainvar, Main *from) { @@ -467,7 +473,7 @@ static Main *blo_find_main(ListBase *mainlist, char *name) static void switch_endian_bh4(BHead4 *bhead) { - /* de ID_.. codes */ + /* the ID_.. codes */ if((bhead->code & 0xFFFF)==0) bhead->code >>=16; if (bhead->code != ENDB) { @@ -479,7 +485,7 @@ static void switch_endian_bh4(BHead4 *bhead) static void switch_endian_bh8(BHead8 *bhead) { - /* de ID_.. codes */ + /* the ID_.. codes */ if((bhead->code & 0xFFFF)==0) bhead->code >>=16; if (bhead->code != ENDB) { @@ -890,7 +896,7 @@ static void *newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */ return oldnewmap_liblookup_and_inc(fd->libmap, adr, lib); } -static void *newlibadr_us_type(FileData *fd, short type, void *adr) /* alleen Lib datablokken */ +static void *newlibadr_us_type(FileData *fd, short type, void *adr) /* only Lib data */ { ID *id= oldnewmap_typelookup_and_inc(fd->libmap, adr, type); @@ -901,7 +907,7 @@ static void *newlibadr_us_type(FileData *fd, short type, void *adr) /* alleen Li return id; } -static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* hoogt usernummer op */ +static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */ { ID *id= newlibadr(fd, lib, adr); @@ -926,7 +932,7 @@ static void change_libadr(FileData *fd, void *old, void *new) * Ton seemed to think it was necessary to look * through all entries, and not return after finding * a match, leaving this cryptic comment, - * // geen return blijkbaar kunnen er meer zijn? + * // no return, maybe there can be more? * * That doesn't make sense to me either but I am * too scared to remove it... it only would make @@ -941,6 +947,12 @@ static void change_libadr(FileData *fd, void *old, void *new) * but I'm afraid I don't have time now. -zr * */ + /* the code is nasty, and needs a lot of energy to get into full understanding + again... i now translate dutch comments, maybe that gives me more insight! + But i guess it has to do with the assumption that 2 addresses can be allocated + in different sessions, and therefore be the same... like the remark in the top + of this c file (ton) */ + for (i=0; ilibmap->nentries; i++) { OldNew *entry= &fd->libmap->entries[i]; @@ -952,7 +964,7 @@ static void change_libadr(FileData *fd, void *old, void *new) } -/* ********** END OUDE POINTERS ****************** */ +/* ********** END OLD POINTERS ****************** */ /* ********** READ FILE ****************** */ static void switch_endian_structs(struct SDNA *filesdna, BHead *bhead) @@ -992,7 +1004,7 @@ static void *read_struct(FileData *fd, BHead *bh) return temp; } -static void link_list(FileData *fd, ListBase *lb) /* alleen direkte data */ +static void link_list(FileData *fd, ListBase *lb) /* only direct data */ { Link *ln, *prev; @@ -1154,7 +1166,7 @@ static void direct_link_ika(FileData *fd, Ika *ika) ika->def= newdataadr(fd, ika->def); - /* afvangen fout uit V.138 en ouder */ + /* error from V.138 and older */ if(ika->def==0) ika->totdef= 0; } @@ -1468,7 +1480,7 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb) cp= key->elemstr; poin= data; - while( cp[0] ) { /* cp[0]==aantal */ + while( cp[0] ) { /* cp[0]==amount */ switch(cp[1]) { /* cp[1]= type */ case IPO_FLOAT: @@ -1872,7 +1884,7 @@ static void direct_link_material(FileData *fd, Material *ma) for(a=0; a<8; a++) { ma->mtex[a]= newdataadr(fd, ma->mtex[a]); } - ma->ren= 0; /* mag niet blijven hangen, maarja */ + ma->ren= 0; /* should not be needed, nevertheless... */ } /* ************ READ MESH ***************** */ @@ -2004,9 +2016,7 @@ static void lib_link_object(FileData *fd, Main *main) for(a=0; atotcol; a++) ob->mat[a]= newlibadr_us(fd, ob->id.lib, ob->mat[a]); ob->id.flag -= LIB_NEEDLINK; - /* dit stond er eerst: weggehaald omdat de fie give_base_to... er niet meer is */ - /* if(ob->id.us) ob->id.flag -= LIB_NEEDLINK; */ - /* als us==0 wordt verderop nog een base gemaakt */ + /* if id.us==0 a new base will be created later on */ /* WARNING! Also check expand_object(), should reflect the stuff below. */ lib_link_pose(fd, &ob->id, ob->pose); @@ -2286,7 +2296,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) ed->metastack.first= ed->metastack.last= 0; - /* recursief sequenties linken, ook lb wordt goedgezet */ + /* recursive link sequences, lb will be correctly initialized */ link_recurs_seq(fd, &ed->seqbase); ed->seqbasep= &ed->seqbase; @@ -2295,7 +2305,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) seq->seq1= newdataadr(fd, seq->seq1); seq->seq2= newdataadr(fd, seq->seq2); seq->seq3= newdataadr(fd, seq->seq3); - /* eigenlijk een patch: na invoering drie-seq effects */ + /* a patch: after introduction of effects with 3 input strips */ if(seq->seq3==0) seq->seq3= seq->seq2; seq->curelem= 0; @@ -2307,7 +2317,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) if(seq->strip && seq->strip->done==0) { seq->strip->done= 1; - /* standaard: strips van effecten/meta's worden niet weggeschreven, wel malloccen */ + /* standard: strips from effects/metas are not written, but are mallocced */ if(seq->type==SEQ_IMAGE) { seq->strip->stripdata= newdataadr(fd, seq->strip->stripdata); @@ -2320,7 +2330,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) } } else if(seq->type==SEQ_MOVIE) { - /* alleen eerste stripelem zit in file */ + /* only first stripelem is in file */ se= newdataadr(fd, seq->strip->stripdata); if(se) { @@ -2526,7 +2536,7 @@ static void direct_link_library(FileData *fd, Library *lib) { Main *newmain; - /* nieuwe main */ + /* new main */ newmain= MEM_callocN(sizeof(Main), "directlink"); BLI_addtail(&fd->mainlist, newmain); newmain->curlib= lib; @@ -2618,12 +2628,12 @@ static void lib_link_group(FileData *fd, Main *main) } } -/* ************** ALG & MAIN ******************** */ +/* ************** GENERAL & MAIN ******************** */ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID **id_r) { - /* deze routine leest libblock en direkte data. Met linkfunkties - * alles aan elkaar hangen. + /* this routine reads a libblock and its direct data. Use link functions + * to connect it all */ ID *id; @@ -2638,7 +2648,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID lb= wich_libbase(main, bhead->code); } - /* libblock inlezen */ + /* read libblock */ id = read_struct(fd, bhead); if (id_r) *id_r= id; @@ -2648,21 +2658,20 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID oldnewmap_insert(fd->libmap, bhead->old, id, 1); BLI_addtail(lb, id); - /* eerste acht bits wissen */ + /* clear first 8 bits */ id->flag= (id->flag & 0xFF00) | flag | LIB_NEEDLINK; id->lib= main->curlib; if(id->flag & LIB_FAKEUSER) id->us= 1; else id->us= 0; - /* deze mag niet door de direct_link molen: is alleen het ID deel */ - + /* this case cannot be direct_linked: it's just the ID part */ if(bhead->code==ID_ID) { return blo_nextbhead(fd, bhead); } bhead = blo_nextbhead(fd, bhead); - /* alle data inlezen */ + /* read all data */ while(bhead && bhead->code==DATA) { void *data= read_struct(fd, bhead); @@ -2673,7 +2682,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID bhead = blo_nextbhead(fd, bhead); } - /* pointers directe data goedzetten */ + /* init pointers direct data */ switch( GS(id->name) ) { case ID_SCR: direct_link_screen(fd, (bScreen *)id); @@ -2805,10 +2814,10 @@ static int map_223_keybd_code_to_224_keybd_code(int code) static void do_versions(Main *main) { - /* PAS OP: pointers van libdata zijn nog niet omgezet */ + /* watch it: pointers from libdata have not been converted */ if(main->versionfile == 100) { - /* tex->extend en tex->imageflag veranderd: */ + /* tex->extend and tex->imageflag have changed: */ Tex *tex = main->tex.first; while(tex) { if(tex->id.flag & LIB_NEEDLINK) { @@ -2840,7 +2849,7 @@ static void do_versions(Main *main) } } if(main->versionfile <= 102) { - /* init halo's op 1.0 */ + /* init halo's at 1.0 */ Material *ma = main->mat.first; while(ma) { ma->add= 1.0; @@ -2848,7 +2857,7 @@ static void do_versions(Main *main) } } if(main->versionfile <= 103) { - /* nieuwe variabele in object: colbits */ + /* new variable in object: colbits */ Object *ob = main->object.first; int a; while(ob) { @@ -2862,7 +2871,7 @@ static void do_versions(Main *main) } } if(main->versionfile <= 104) { - /* de timeoffs zit op betere plek */ + /* timeoffs moved */ Object *ob = main->object.first; while(ob) { if(ob->transflag & 1) { @@ -2881,7 +2890,7 @@ static void do_versions(Main *main) } } if(main->versionfile <= 106) { - /* mcol is veranderd */ + /* mcol changed */ Mesh *me = main->mesh.first; while(me) { if(me->mcol) vcol_to_fcol(me); @@ -2905,7 +2914,7 @@ static void do_versions(Main *main) } if(main->versionfile <= 109) { - /* nieuwe variabele: gridlines */ + /* new variable: gridlines */ bScreen *sc = main->screen.first; while(sc) { ScrArea *sa= sc->areabase.first; @@ -2945,7 +2954,7 @@ static void do_versions(Main *main) MFace *mface; int a_int; - /* edge drawflags veranderd */ + /* edge drawflags changed */ while(me) { a_int= me->totface; mface= me->mface; @@ -2960,74 +2969,8 @@ static void do_versions(Main *main) } } - /* eentje overgeslagen voor bug in freeware versie */ - if(main->versionfile <= 121) { - /* O2 versie gemaakt. */ - } - if(main->versionfile <= 122) { - /* dithering gaat soms af (backbuf, pas sinds 121) */ - /* relatieve paden hersteld */ - /* sequences: endframe van seq wordt op betere plek geprint */ - } - if(main->versionfile <= 123) { - /* nog een paar O2 foutjes: keylines in ipo window */ - /* vertices halo object (O2) nu ook goed */ - /* zoomwin: ook op O2 */ - /* bug eruit: schaduw render in ortho */ - } - if(main->versionfile <= 124) { - /* inventor lezer */ - /* key kleur 24 bits beveiligd */ - /* schrijf plaatje: je kun niet naderhand 24bits naar 32 - * omzetten */ - } - if(main->versionfile <= 125) { - /* bug vanwege compileer fout (makefile/.h dependency)*/ - } - if(main->versionfile <= 126) { - /* overdraw text beter (clever numbuts) */ - /* bug uit inventor lezer: node ambientColor werd niet - * herkend */ - /* bugje uit toolbox: clear loc= alt-g */ - } - - if(main->versionfile <= 131) { - /* jpeq quality button */ - /* anim5 and blacksmith demo */ - /* foutje uit transp zbuf: te vroege afbreek */ - /* geen paarse code meer als imap onvindbaar is meer */ - /* locx werd niet geprint: string overflow! */ - /* unieke namen: werkte niet */ - /* toolbox menu: ook alt en ctrl keys */ - } - if(main->versionfile <= 132) { - /* strings in Userdef: eroverheen! */ - /* betere overdraw implementatie (numbuts) */ - /* snapmenu redraw */ - /* warp met 1 vertex */ - } - if(main->versionfile <= 133) { - /* bug uit 'make edge face' (array overflow */ - /* volledig X getekende menu's */ - /* storage.c terug */ - } if(main->versionfile <= 134) { - /* Play (flipbook) restored */ - /* Timecursor restored */ - /* Debug option -d; prints a lot of info in console */ - /* Text Object. Accentcodes fixed: ALT+BACKSPACE */ - /* Cursor was sometimes wrong after reading files */ - /* Texspace draw error: dashed lines */ - /* Draw Schematic View now with icons in Objects */ - /* Ortho camera: zbuffer improved. Near/far still not OK */ - /* Text Object. Character pound= alt-l */ - /* In editmode and 'set', draw error fixed. */ - /* Scanline display during rendering had dropouts */ - /* Sometimes-after render- frontbuffer drawing wasnt disabled */ - /* Sometimes the render window got black and Blender 'hung' */ - /* Better 'active window' implementation. */ - /* Automatic name was too critical, more intuitive now */ Tex *tex = main->tex.first; while (tex) { if ((tex->rfac == 0.0) && @@ -3041,39 +2984,6 @@ static void do_versions(Main *main) tex = tex->id.next; } } - if(main->versionfile <= 135) { - /* 'Windows' key resistant */ - /* Preview-render: RGB flip (material, lamp, world) */ - /* Fileselect draw error: 2nd time no redraw! */ - /* Names error: names were not unique automatically */ - /* Metaball display error: because of previous */ - /* CTRL and ALT and SHIFT keys sometimes were locked */ - } - if(main->versionfile <= 136) { - /* Files incompatibility Colorband PC-SGI solved */ - /* RightMouse selecting was blocked after border-select */ - /* Border select: print size */ - /* Inventor: reads some 2.0 syntaxes too. Under development */ - /* Shift/Ctrl/Alt release events got lost while moving view */ - /* Particles draw (size) error fixed */ - /* Display type 'DispView' works */ - /* Metaballs convert to Mesh, normals error fixed. */ - } - if(main->versionfile <= 137) { - /* who know */ - } - if(main->versionfile <= 138) { - /* fixed: z buffer draw and Mesh with no materials: coredump! */ - /* bug removed from calculation 3D Bevel Objects */ - /* view translation in perspective fixed */ - /* Drawing with ortho camera fixed */ - /* timing error FreeBSD version fixed */ - /* Mesa 3.0 included in static version */ - /* New: LeftMouse+RightMouse allowed at numerber-button - * to type in values */ - /* Vertex paint bug fixed */ - /* New: ALT+(1, 2, 3...) for layers 11, 12, 13... */ - } if(main->versionfile <= 140) { /* r-g-b-fac in texure */ Tex *tex = main->tex.first; @@ -3766,7 +3676,7 @@ static void do_versions(Main *main) } } - /* onder in blender.c de nummers wijzigen! */ + /* don't forget to set version number in blender.c! */ } static void lib_link_all(FileData *fd, Main *main) @@ -3793,9 +3703,9 @@ static void lib_link_all(FileData *fd, Main *main) lib_link_action(fd, main); lib_link_vfont(fd, main); - lib_link_mesh(fd, main); /* als laatste: tpage images met users op nul */ + lib_link_mesh(fd, main); /* as last: tpage images with users at zero */ - lib_link_library(fd, main); /* alleen users goedzetten */ + lib_link_library(fd, main); /* only init users */ } BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r) @@ -3851,7 +3761,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r) blo_join_main(&fd->mainlist); lib_link_all(fd, bfd->main); - link_global(fd, bfd, fg); /* als laatste */ + link_global(fd, bfd, fg); /* as last */ if (!bfd->curscreen) bfd->curscreen= bfd->main->screen.first; @@ -3960,7 +3870,7 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old) } else { oldnewmap_insert(fd->libmap, bhead->old, id, 1); - /* printf("expand: al ingelezen %s\n", id->name); */ + /* printf("expand: already read %s\n", id->name); */ } } } @@ -4356,7 +4266,7 @@ static void give_base_to_objects(Scene *sce, ListBase *lb) Object *ob; Base *base; - /* alle objects die LIB_EXTERN en LIB_NEEDLINK zijn, een base geven */ + /* give all objects which are LIB_EXTERN and LIB_NEEDLINK a base */ ob= lb->first; while(ob) { @@ -4416,7 +4326,7 @@ static void append_named_part(SpaceFile *sfile, Main *mainvar, Scene *scene, cha } } - if(idcode==ID_OB) { /* los object: base geven */ + if(idcode==ID_OB) { /* loose object: give a base */ base= MEM_callocN( sizeof(Base), "app_nam_part"); BLI_addtail(&scene->base, base); @@ -4457,7 +4367,7 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) } - /* append aan G.scene */ + /* append to G.scene */ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) { FileData *fd= (FileData*) sfile->libfiledata; @@ -4465,7 +4375,7 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) Main *mainl; int a, totsel=0; - /* zijn er geselecteerde files? */ + /* are there files selected? */ for(a=0; atotfile; a++) { if(sfile->filelist[a].flags & ACTIVE) { totsel++; @@ -4473,7 +4383,7 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) } if(totsel==0) { - /* is de aangegeven file in de filelist? */ + /* is the indicated file in the filelist? */ if(sfile->file[0]) { for(a=0; atotfile; a++) { if( strcmp(sfile->filelist[a].relname, sfile->file)==0) break; @@ -4488,15 +4398,15 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) return; } } - /* nu hebben OF geselecteerde, OF 1 aangegeven file */ + /* now we have or selected, or an indicated file */ mainlist.first= mainlist.last= G.main; G.main->next= NULL; - /* mains maken */ + /* make mains */ blo_split_main(&mainlist); - /* welke moeten wij hebben? */ + /* which one do we need? */ mainl = blo_find_main(&mainlist, dir); if(totsel==0) { @@ -4510,10 +4420,10 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) } } - /* de main consistent maken */ + /* make main consistant */ expand_main(fd, mainl); - /* als expand nog andere libs gevonden heeft: */ + /* do this when expand found other libs */ read_libraries(fd, &mainlist); blo_join_main(&mainlist); @@ -4521,14 +4431,11 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) lib_link_all(fd, G.main); - /* losse objects aan G.scene hangen deze hebben nog een linkflag - moet na lib_link ivm gelinkte scenes (ob->us==0) */ - - /* indirecte objects kunnen geen kwaad */ - /* als je deze terugzet, denk aan de 'need_link' flag: doe een find naar 'give_base_to' */ + /* give a base to loose objects */ /* give_base_to_objects(G.scene, &(G.main->object)); */ + /* has been removed... erm, why? (ton) */ - /* voorlopige patch om te voorkomen dat de switch_endian 2x gebeurt */ + /* patch to prevent switch_endian happens twice */ if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) { blo_freefiledata((FileData*) sfile->libfiledata); sfile->libfiledata= 0; @@ -4563,7 +4470,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) while(doit) { doit= 0; - /* test 1: inlezen libdata */ + /* test 1: read libdata */ mainptr= main->next; while(mainptr) { @@ -4620,7 +4527,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) } mainptr= main->next; while(mainptr) { - /* test of er libblocken niet zijn gelezen */ + /* test if there are unread libblocks */ a= set_listbasepointers(mainptr, lbarray); while(a--) { ID *id= lbarray[a]->first; @@ -4638,8 +4545,8 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) } } - /* sommige mains moeten nog worden ingelezen, dan is - * versionfile nog nul! */ + /* some mains still have to be read, then + * versionfile is still zero! */ if(mainptr->versionfile) do_versions(mainptr); if(mainptr->curlib->filedata) blo_freefiledata(mainptr->curlib->filedata); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e0e3fd5645e..c7db707cceb 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1,4 +1,7 @@ -/** +/* writefile.c + * + * .blend file writing + * * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** @@ -28,52 +31,54 @@ * Contributor(s): none yet. * * ***** END GPL/BL DUAL LICENSE BLOCK ***** - * .blend file writing */ /* -MIXED MODEL -FILEFORMAAT: IFF-achtige structuur (niet meer IFF compatible!) +FILEFORMAT: IFF-style structure (but not IFF compatible!) start file: BLENDER_V100 12 bytes (versie 1.00) V = big endian, v = little endian _ = 4 byte pointer, - = 8 byte pointer -datablokken: zie ook struct BHead +datablocks: also see struct BHead 4 chars - int, len data achter BHead - void, oude pointer + int, len data after BHead + void, old pointer int - int, bij array: aantal structs + int, in case of array: amount of structs data ... ... -Vrijwel alle data in blender zijn structs. Elke struct krijgt -een BHead header mee. Met BHead kan de struktuur weer worden -gelinkt en wordt met StructDNA vergeleken. +Almost all data in Blender are structures. Each struct saved +gets a BHead header. With BHead the struct can be linked again +and compared with StructDNA . -SCHRIJVEN +WRITE -Voorkeur volgorde schrijven: (waarschijnlijk mag ook door -elkaar, maar waarom zou je? ) In ieder geval MOET indirekte data -ACHTER LibBlock +Preferred writing order: (not really a must, but why would you do it random?) +Any case: direct data is ALWAYS after the lib block -(Locale data) -- voor elk LibBlock - - schrijf LibBlock - - schrijf bijhorende direkte data -(Externe data) +(Local file data) +- for each LibBlock + - write LibBlock + - write associated direct data +(External file data) - per library - - schrijf library block + - write library block - per LibBlock - - schrijf ID LibBlock -- schrijf FileGlobal (een selectie uit globale data ) -- schrijf SDNA -- schrijf USER als aangegeven (~/.B.blend) + - write the ID of LibBlock +- write FileGlobal (some global vars) +- write SDNA +- write USER if filename is ~/.B.blend */ +/* for version 2.2+ +Important to know is that 'streaming' has been added to files, for Blender Publisher +*/ + + #ifdef HAVE_CONFIG_H #include #endif @@ -399,7 +404,7 @@ static void writestruct(WriteData *wd, int filecode, char *structname, int nr, v if(adr==0 || nr==0) return; - /* BHead vullen met data */ + /* init BHead */ bh.code= filecode; bh.old= adr; bh.nr= nr; @@ -419,7 +424,7 @@ static void writestruct(WriteData *wd, int filecode, char *structname, int nr, v mywrite(wd, adr, bh.len); } -static void writedata(WriteData *wd, int filecode, int len, void *adr) /* geen struct */ +static void writedata(WriteData *wd, int filecode, int len, void *adr) /* do not use for structs */ { BHead bh; @@ -429,7 +434,7 @@ static void writedata(WriteData *wd, int filecode, int len, void *adr) /* geen s len+= 3; len-= ( len % 4); - /* BHead vullen met data */ + /* init BHead */ bh.code= filecode; bh.old= adr; bh.nr= 1; @@ -446,7 +451,7 @@ static void write_scriptlink(WriteData *wd, ScriptLink *slink) writedata(wd, DATA, sizeof(short)*slink->totscript, slink->flag); } -static void write_renderinfo(WriteData *wd) /* alleen voor renderdaemon */ +static void write_renderinfo(WriteData *wd) /* for renderdaemon */ { Scene *sce; int data[8]; @@ -729,10 +734,10 @@ static void write_objects(WriteData *wd, ListBase *idbase) ob= idbase->first; while(ob) { if(ob->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_OB, "Object", 1, ob); - /* alle direkte data */ + /* direct data */ writedata(wd, DATA, sizeof(void *)*ob->totcol, ob->mat); write_effects(wd, &ob->effect); write_properties(wd, &ob->prop); @@ -759,10 +764,10 @@ static void write_vfonts(WriteData *wd, ListBase *idbase) vf= idbase->first; while(vf) { if(vf->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_VF, "VFont", 1, vf); - /* alle direkte data */ + /* direct data */ if (vf->packedfile) { pf = vf->packedfile; @@ -783,10 +788,10 @@ static void write_ipos(WriteData *wd, ListBase *idbase) ipo= idbase->first; while(ipo) { if(ipo->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_IP, "Ipo", 1, ipo); - /* alle direkte data */ + /* direct data */ icu= ipo->curve.first; while(icu) { writestruct(wd, DATA, "IpoCurve", 1, icu); @@ -813,10 +818,10 @@ static void write_keys(WriteData *wd, ListBase *idbase) key= idbase->first; while(key) { if(key->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_KE, "Key", 1, key); - /* alle direkte data */ + /* direct data */ kb= key->block.first; while(kb) { writestruct(wd, DATA, "KeyBlock", 1, kb); @@ -836,10 +841,10 @@ static void write_cameras(WriteData *wd, ListBase *idbase) cam= idbase->first; while(cam) { if(cam->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_CA, "Camera", 1, cam); - /* alle direkte data */ + /* direct data */ write_scriptlink(wd, &cam->scriptlink); } @@ -855,10 +860,10 @@ static void write_mballs(WriteData *wd, ListBase *idbase) mb= idbase->first; while(mb) { if(mb->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_MB, "MetaBall", 1, mb); - /* alle direkte data */ + /* direct data */ writedata(wd, DATA, sizeof(void *)*mb->totcol, mb->mat); ml= mb->elems.first; @@ -879,17 +884,17 @@ static void write_curves(WriteData *wd, ListBase *idbase) cu= idbase->first; while(cu) { if(cu->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_CU, "Curve", 1, cu); - /* alle direkte data */ + /* direct data */ writedata(wd, DATA, sizeof(void *)*cu->totcol, cu->mat); if(cu->vfont) { writedata(wd, DATA, cu->len+1, cu->str); } else { - /* is ook volgorde van inlezen */ + /* is also the order of reading */ nu= cu->nurb.first; while(nu) { writestruct(wd, DATA, "Nurb", 1, nu); @@ -935,10 +940,10 @@ static void write_meshs(WriteData *wd, ListBase *idbase) mesh= idbase->first; while(mesh) { if(mesh->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_ME, "Mesh", 1, mesh); - /* alle direkte data */ + /* direct data */ writedata(wd, DATA, sizeof(void *)*mesh->totcol, mesh->mat); writestruct(wd, DATA, "MVert", mesh->totvert, mesh->mvert); write_dverts(wd, mesh->totvert, mesh->dvert); @@ -960,7 +965,7 @@ static void write_images(WriteData *wd, ListBase *idbase) ima= idbase->first; while(ima) { if(ima->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_IM, "Image", 1, ima); if (ima->packedfile) { @@ -980,10 +985,10 @@ static void write_textures(WriteData *wd, ListBase *idbase) tex= idbase->first; while(tex) { if(tex->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_TE, "Tex", 1, tex); - /* alle direkte data */ + /* direct data */ if(tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin); if(tex->coba) writestruct(wd, DATA, "ColorBand", 1, tex->coba); if(tex->env) writestruct(wd, DATA, "EnvMap", 1, tex->env); @@ -1000,7 +1005,7 @@ static void write_materials(WriteData *wd, ListBase *idbase) ma= idbase->first; while(ma) { if(ma->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_MA, "Material", 1, ma); for(a=0; a<8; a++) { @@ -1021,7 +1026,7 @@ static void write_worlds(WriteData *wd, ListBase *idbase) wrld= idbase->first; while(wrld) { if(wrld->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_WO, "World", 1, wrld); for(a=0; a<8; a++) { @@ -1042,10 +1047,10 @@ static void write_lamps(WriteData *wd, ListBase *idbase) la= idbase->first; while(la) { if(la->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_LA, "Lamp", 1, la); - /* alle direkte data */ + /* direct data */ for(a=0; a<8; a++) { if(la->mtex[a]) writestruct(wd, DATA, "MTex", 1, la->mtex[a]); } @@ -1063,10 +1068,10 @@ static void write_lattices(WriteData *wd, ListBase *idbase) lt= idbase->first; while(lt) { if(lt->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_LT, "Lattice", 1, lt); - /* alle direkte data */ + /* direct data */ writestruct(wd, DATA, "BPoint", lt->pntsu*lt->pntsv*lt->pntsw, lt->def); } lt= lt->id.next; @@ -1081,10 +1086,10 @@ static void write_ikas(WriteData *wd, ListBase *idbase) ika= idbase->first; while(ika) { if(ika->id.us>0) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_IK, "Ika", 1, ika); - /* alle direkte data */ + /* direct data */ li= ika->limbbase.first; while(li) { writestruct(wd, DATA, "Limb", 1, li); @@ -1107,10 +1112,10 @@ static void write_scenes(WriteData *wd, ListBase *scebase) sce= scebase->first; while(sce) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_SCE, "Scene", 1, sce); - /* alle direkte data */ + /* direct data */ base= sce->base.first; while(base) { writestruct(wd, DATA, "Base", 1, base); @@ -1124,7 +1129,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase) if(ed) { writestruct(wd, DATA, "Editing", 1, ed); - /* ook schrijfflags op nul */ + /* reset write flags too */ WHILE_SEQ(&ed->seqbase) { if(seq->strip) seq->strip->done= 0; writestruct(wd, DATA, "Sequence", 1, seq); @@ -1133,7 +1138,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase) WHILE_SEQ(&ed->seqbase) { if(seq->strip && seq->strip->done==0) { - /* strip wegschrijven met done op 0 ivm readfile */ + /* write strip with 'done' at 0 because readfile */ if(seq->plugin) writestruct(wd, DATA, "PluginSeq", 1, seq->plugin); @@ -1172,10 +1177,10 @@ static void write_screens(WriteData *wd, ListBase *scrbase) sc= scrbase->first; while(sc) { - /* schrijf LibData */ + /* write LibData */ writestruct(wd, ID_SCR, "Screen", 1, sc); - /* alle direkte data */ + /* direct data */ sv= sc->vertbase.first; while(sv) { writestruct(wd, DATA, "ScrVert", 1, sv); @@ -1229,7 +1234,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase) oops= oopsn; } - /* NA de cleanup, ivm listbase! */ + /* ater cleanup, because of listbase! */ writestruct(wd, DATA, "SpaceOops", 1, so); oops= so->oops.first; @@ -1276,7 +1281,7 @@ static void write_libraries(WriteData *wd, Main *main) a=tot= set_listbasepointers(main, lbarray); - /* test: wordt lib nog gebruikt */ + /* test: is lib being used */ foundone= 0; while(tot--) { id= lbarray[tot]->first; @@ -1541,7 +1546,7 @@ static int write_file_handle(int handle, int write_user_block, int write_flags) write_userdef(wd); } - /* dna als laatste i.v.m. (nog te schrijven) test op welke gebruikt zijn */ + /* dna as last, because (to be implemented) test for which structs are written */ writedata(wd, DNA1, wd->sdna->datalen, wd->sdna->data); data= ENDB;