Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoel Spruit <roel@spruitje.nl>2004-06-23 22:22:51 +0400
committerRoel Spruit <roel@spruitje.nl>2004-06-23 22:22:51 +0400
commit629e526b25741a2d8faa422ff27adce7ffe3a8be (patch)
treefbd7d1260e0d8ba7f392f385673edd3c44de0bc5 /source/blender/blenloader/intern/writefile.c
parent3bf5e671d0dc04e1b04ee8106ade3f4fa0d4f3f8 (diff)
- Added correct Writing/Reading of the new Sweep sequence effect (Thanks Ton, where would I be without you)
- Sweep effect updates after you change the type of sweep now.
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r--source/blender/blenloader/intern/writefile.c427
1 files changed, 217 insertions, 210 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 2aa4b869cfd..953f76f3317 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -35,7 +35,7 @@
/*
FILEFORMAT: IFF-style structure (but not IFF compatible!)
-
+
start file:
BLENDER_V100 12 bytes (versie 1.00)
V = big endian, v = little endian
@@ -47,7 +47,7 @@ datablocks: also see struct BHead
<bh.old> void, old pointer
<bh.SDNAnr> int
<bh.nr> int, in case of array: amount of structs
- data
+ data
...
...
@@ -83,7 +83,7 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
#include <config.h>
#endif
-#ifndef WIN32
+#ifndef WIN32
#include <unistd.h>
#else
#include "winsock2.h"
@@ -139,7 +139,7 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
#include "DNA_action_types.h"
#include "DNA_nla_types.h"
-#include "MEM_guardedalloc.h" // MEM_freeN
+#include "MEM_guardedalloc.h" // MEM_freeN
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
@@ -167,7 +167,7 @@ typedef struct {
int file;
unsigned char *buf;
-
+
int tot, count, error;
} WriteData;
@@ -175,18 +175,18 @@ static WriteData *writedata_new(int file)
{
extern char DNAstr[]; /* DNA.c */
extern int DNAlen;
-
+
WriteData *wd= MEM_callocN(sizeof(*wd), "writedata");
/* XXX, see note about this in readfile.c, remove
* once we have an xp lock - zr
*/
wd->sdna= dna_sdna_from_data(DNAstr, DNAlen, 0);
-
+
wd->file= file;
wd->buf= MEM_mallocN(100000, "wd->buf");
-
+
return wd;
}
@@ -197,7 +197,7 @@ static void writedata_do_write(WriteData *wd, void *mem, int memlen)
wd->error= 1;
}
-static void writedata_free(WriteData *wd)
+static void writedata_free(WriteData *wd)
{
dna_freestructDNA(wd->sdna);
@@ -217,7 +217,7 @@ int mywfile;
*/
static void
mywrite(
- WriteData *wd,
+ WriteData *wd,
void *adr,
int len)
{
@@ -235,7 +235,7 @@ mywrite(
}
if(len+wd->count>99999) {
writedata_do_write(wd, wd->buf, wd->count);
- wd->count= 0;
+ wd->count= 0;
}
memcpy(&wd->buf[wd->count], adr, len);
wd->count+= len;
@@ -249,11 +249,11 @@ mywrite(
*/
static WriteData *
bgnwrite(
- int file,
+ int file,
int write_flags)
{
WriteData *wd= writedata_new(file);
-
+
return wd;
}
@@ -268,15 +268,15 @@ endwrite(
WriteData *wd)
{
int err;
-
+
if (wd->count) {
writedata_do_write(wd, wd->buf, wd->count);
- wd->count= 0;
+ wd->count= 0;
}
-
+
err= wd->error;
writedata_free(wd);
-
+
return err;
}
@@ -286,25 +286,25 @@ static void writestruct(WriteData *wd, int filecode, char *structname, int nr, v
{
BHead bh;
short *sp;
-
+
if(adr==0 || nr==0) return;
-
+
/* init BHead */
bh.code= filecode;
bh.old= adr;
bh.nr= nr;
-
+
bh.SDNAnr= dna_findstruct_nr(wd->sdna, structname);
if(bh.SDNAnr== -1) {
printf("error: can't find SDNA code %s\n", structname);
return;
}
sp= wd->sdna->structs[bh.SDNAnr];
-
+
bh.len= nr*wd->sdna->typelens[sp[0]];
-
+
if(bh.len==0) return;
-
+
mywrite(wd, &bh, sizeof(BHead));
mywrite(wd, adr, bh.len);
}
@@ -312,43 +312,43 @@ static void writestruct(WriteData *wd, int filecode, char *structname, int nr, v
static void writedata(WriteData *wd, int filecode, int len, void *adr) /* do not use for structs */
{
BHead bh;
-
+
if(adr==0) return;
if(len==0) return;
-
+
len+= 3;
len-= ( len % 4);
-
+
/* init BHead */
bh.code= filecode;
bh.old= adr;
bh.nr= 1;
- bh.SDNAnr= 0;
+ bh.SDNAnr= 0;
bh.len= len;
-
+
mywrite(wd, &bh, sizeof(BHead));
if(len) mywrite(wd, adr, len);
}
static void write_scriptlink(WriteData *wd, ScriptLink *slink)
{
- writedata(wd, DATA, sizeof(void *)*slink->totscript, slink->scripts);
- writedata(wd, DATA, sizeof(short)*slink->totscript, slink->flag);
+ writedata(wd, DATA, sizeof(void *)*slink->totscript, slink->scripts);
+ writedata(wd, DATA, sizeof(short)*slink->totscript, slink->flag);
}
static void write_renderinfo(WriteData *wd) /* for renderdaemon */
{
Scene *sce;
int data[8];
-
+
sce= G.main->scene.first;
while(sce) {
if(sce->id.lib==0 && ( sce==G.scene || (sce->r.scemode & R_BG_RENDER)) ) {
data[0]= sce->r.sfra;
data[1]= sce->r.efra;
-
+
strncpy((char *)(data+2), sce->id.name+2, 23);
-
+
writedata(wd, REND, 32, data);
}
sce= sce->id.next;
@@ -358,9 +358,9 @@ static void write_renderinfo(WriteData *wd) /* for renderdaemon */
static void write_userdef(WriteData *wd)
{
bTheme *btheme;
-
+
writestruct(wd, USER, "UserDef", 1, &U);
-
+
btheme= U.themes.first;
while(btheme) {
writestruct(wd, DATA, "bTheme", 1, btheme);
@@ -371,24 +371,24 @@ static void write_userdef(WriteData *wd)
static void write_effects(WriteData *wd, ListBase *lb)
{
Effect *eff;
-
+
eff= lb->first;
while(eff) {
-
+
switch(eff->type) {
case EFF_BUILD:
writestruct(wd, DATA, "BuildEff", 1, eff);
- break;
+ break;
case EFF_PARTICLE:
writestruct(wd, DATA, "PartEff", 1, eff);
- break;
+ break;
case EFF_WAVE:
writestruct(wd, DATA, "WaveEff", 1, eff);
- break;
+ break;
default:
writedata(wd, DATA, MEM_allocN_len(eff), eff);
}
-
+
eff= eff->next;
}
}
@@ -396,14 +396,14 @@ static void write_effects(WriteData *wd, ListBase *lb)
static void write_properties(WriteData *wd, ListBase *lb)
{
bProperty *prop;
-
+
prop= lb->first;
while(prop) {
writestruct(wd, DATA, "bProperty", 1, prop);
-
- if(prop->poin && prop->poin != &prop->data)
+
+ if(prop->poin && prop->poin != &prop->data)
writedata(wd, DATA, MEM_allocN_len(prop->poin), prop->poin);
-
+
prop= prop->next;
}
}
@@ -411,13 +411,13 @@ static void write_properties(WriteData *wd, ListBase *lb)
static void write_sensors(WriteData *wd, ListBase *lb)
{
bSensor *sens;
-
+
sens= lb->first;
while(sens) {
writestruct(wd, DATA, "bSensor", 1, sens);
-
+
writedata(wd, DATA, sizeof(void *)*sens->totlinks, sens->links);
-
+
switch(sens->type) {
case SENS_NEAR:
writestruct(wd, DATA, "bNearSensor", 1, sens->data);
@@ -452,7 +452,7 @@ static void write_sensors(WriteData *wd, ListBase *lb)
default:
; /* error: don't know how to write this file */
}
-
+
sens= sens->next;
}
}
@@ -460,13 +460,13 @@ static void write_sensors(WriteData *wd, ListBase *lb)
static void write_controllers(WriteData *wd, ListBase *lb)
{
bController *cont;
-
+
cont= lb->first;
while(cont) {
writestruct(wd, DATA, "bController", 1, cont);
-
+
writedata(wd, DATA, sizeof(void *)*cont->totlinks, cont->links);
-
+
switch(cont->type) {
case CONT_EXPRESSION:
writestruct(wd, DATA, "bExpressionCont", 1, cont->data);
@@ -477,7 +477,7 @@ static void write_controllers(WriteData *wd, ListBase *lb)
default:
; /* error: don't know how to write this file */
}
-
+
cont= cont->next;
}
}
@@ -485,11 +485,11 @@ static void write_controllers(WriteData *wd, ListBase *lb)
static void write_actuators(WriteData *wd, ListBase *lb)
{
bActuator *act;
-
+
act= lb->first;
while(act) {
writestruct(wd, DATA, "bActuator", 1, act);
-
+
switch(act->type) {
case ACT_ACTION:
writestruct(wd, DATA, "bActionActuator", 1, act->data);
@@ -539,7 +539,7 @@ static void write_actuators(WriteData *wd, ListBase *lb)
default:
; /* error: don't know how to write this file */
}
-
+
act= act->next;
}
}
@@ -555,7 +555,7 @@ static void write_nlastrips(WriteData *wd, ListBase *nlabase)
static void write_constraints(WriteData *wd, ListBase *conlist)
{
bConstraint *con;
-
+
for (con=conlist->first; con; con=con->next) {
/* Write the specific data */
switch (con->type) {
@@ -593,26 +593,26 @@ static void write_constraints(WriteData *wd, ListBase *conlist)
static void write_pose(WriteData *wd, bPose *pose)
{
bPoseChannel *chan;
-
+
/* Write each channel */
-
+
if (!pose)
return;
-
+
// Write channels
for (chan=pose->chanbase.first; chan; chan=chan->next) {
write_constraints(wd, &chan->constraints);
writestruct(wd, DATA, "bPoseChannel", 1, chan);
}
-
- // Write this pose
+
+ // Write this pose
writestruct(wd, DATA, "bPose", 1, pose);
}
static void write_defgroups(WriteData *wd, ListBase *defbase)
{
bDeformGroup *defgroup;
-
+
for (defgroup=defbase->first; defgroup; defgroup=defgroup->next)
writestruct(wd, DATA, "bDeformGroup", 1, defgroup);
}
@@ -623,19 +623,19 @@ static void write_constraint_channels(WriteData *wd, ListBase *chanbase)
for (chan = chanbase->first; chan; chan=chan->next)
writestruct(wd, DATA, "bConstraintChannel", 1, chan);
-
+
}
static void write_objects(WriteData *wd, ListBase *idbase)
{
Object *ob;
-
+
ob= idbase->first;
while(ob) {
if(ob->id.us>0) {
/* write LibData */
writestruct(wd, ID_OB, "Object", 1, ob);
-
+
/* direct data */
writedata(wd, DATA, sizeof(void *)*ob->totcol, ob->mat);
write_effects(wd, &ob->effect);
@@ -659,22 +659,22 @@ static void write_vfonts(WriteData *wd, ListBase *idbase)
{
VFont *vf;
PackedFile * pf;
-
+
vf= idbase->first;
while(vf) {
if(vf->id.us>0) {
/* write LibData */
writestruct(wd, ID_VF, "VFont", 1, vf);
-
+
/* direct data */
-
+
if (vf->packedfile) {
pf = vf->packedfile;
writestruct(wd, DATA, "PackedFile", 1, pf);
writedata(wd, DATA, pf->size, pf->data);
}
}
-
+
vf= vf->id.next;
}
}
@@ -683,20 +683,20 @@ static void write_ipos(WriteData *wd, ListBase *idbase)
{
Ipo *ipo;
IpoCurve *icu;
-
+
ipo= idbase->first;
while(ipo) {
if(ipo->id.us>0) {
/* write LibData */
writestruct(wd, ID_IP, "Ipo", 1, ipo);
-
+
/* direct data */
icu= ipo->curve.first;
while(icu) {
writestruct(wd, DATA, "IpoCurve", 1, icu);
icu= icu->next;
}
-
+
icu= ipo->curve.first;
while(icu) {
if(icu->bezt) writestruct(wd, DATA, "BezTriple", icu->totvert, icu->bezt);
@@ -704,7 +704,7 @@ static void write_ipos(WriteData *wd, ListBase *idbase)
icu= icu->next;
}
}
-
+
ipo= ipo->id.next;
}
}
@@ -713,13 +713,13 @@ static void write_keys(WriteData *wd, ListBase *idbase)
{
Key *key;
KeyBlock *kb;
-
+
key= idbase->first;
while(key) {
if(key->id.us>0) {
/* write LibData */
writestruct(wd, ID_KE, "Key", 1, key);
-
+
/* direct data */
kb= key->block.first;
while(kb) {
@@ -728,7 +728,7 @@ static void write_keys(WriteData *wd, ListBase *idbase)
kb= kb->next;
}
}
-
+
key= key->id.next;
}
}
@@ -736,17 +736,17 @@ static void write_keys(WriteData *wd, ListBase *idbase)
static void write_cameras(WriteData *wd, ListBase *idbase)
{
Camera *cam;
-
+
cam= idbase->first;
while(cam) {
if(cam->id.us>0) {
/* write LibData */
writestruct(wd, ID_CA, "Camera", 1, cam);
-
+
/* direct data */
write_scriptlink(wd, &cam->scriptlink);
}
-
+
cam= cam->id.next;
}
}
@@ -755,16 +755,16 @@ static void write_mballs(WriteData *wd, ListBase *idbase)
{
MetaBall *mb;
MetaElem *ml;
-
+
mb= idbase->first;
while(mb) {
if(mb->id.us>0) {
/* write LibData */
writestruct(wd, ID_MB, "MetaBall", 1, mb);
-
+
/* direct data */
writedata(wd, DATA, sizeof(void *)*mb->totcol, mb->mat);
-
+
ml= mb->elems.first;
while(ml) {
writestruct(wd, DATA, "MetaElem", 1, ml);
@@ -779,16 +779,16 @@ static void write_curves(WriteData *wd, ListBase *idbase)
{
Curve *cu;
Nurb *nu;
-
+
cu= idbase->first;
while(cu) {
if(cu->id.us>0) {
/* write LibData */
writestruct(wd, ID_CU, "Curve", 1, cu);
-
+
/* direct data */
writedata(wd, DATA, sizeof(void *)*cu->totcol, cu->mat);
-
+
if(cu->vfont) {
writedata(wd, DATA, cu->len+1, cu->str);
}
@@ -801,7 +801,7 @@ static void write_curves(WriteData *wd, ListBase *idbase)
}
nu= cu->nurb.first;
while(nu) {
- if( (nu->type & 7)==CU_BEZIER)
+ if( (nu->type & 7)==CU_BEZIER)
writestruct(wd, DATA, "BezTriple", nu->pntsu, nu->bezt);
else {
writestruct(wd, DATA, "BPoint", nu->pntsu*nu->pntsv, nu->bp);
@@ -819,15 +819,15 @@ static void write_curves(WriteData *wd, ListBase *idbase)
static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist)
{
int i;
-
+
/* Write the dvert list */
writestruct(wd, DATA, "MDeformVert", count, dvlist);
-
+
/* Write deformation data for each dvert */
if (dvlist) {
for (i=0; i<count; i++) {
if (dvlist[i].dw)
- writestruct(wd, DATA, "MDeformWeight", dvlist[i].totweight, dvlist[i].dw);
+ writestruct(wd, DATA, "MDeformWeight", dvlist[i].totweight, dvlist[i].dw);
}
}
}
@@ -835,13 +835,13 @@ static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist)
static void write_meshs(WriteData *wd, ListBase *idbase)
{
Mesh *mesh;
-
+
mesh= idbase->first;
while(mesh) {
if(mesh->id.us>0) {
/* write LibData */
writestruct(wd, ID_ME, "Mesh", 1, mesh);
-
+
/* direct data */
writedata(wd, DATA, sizeof(void *)*mesh->totcol, mesh->mat);
writestruct(wd, DATA, "MVert", mesh->totvert, mesh->mvert);
@@ -850,7 +850,7 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
writestruct(wd, DATA, "TFace", mesh->totface, mesh->tface);
writestruct(wd, DATA, "MCol", 4*mesh->totface, mesh->mcol);
writestruct(wd, DATA, "MSticky", mesh->totvert, mesh->msticky);
-
+
}
mesh= mesh->id.next;
}
@@ -860,13 +860,13 @@ static void write_images(WriteData *wd, ListBase *idbase)
{
Image *ima;
PackedFile * pf;
-
+
ima= idbase->first;
while(ima) {
if(ima->id.us>0) {
/* write LibData */
writestruct(wd, ID_IM, "Image", 1, ima);
-
+
if (ima->packedfile) {
pf = ima->packedfile;
writestruct(wd, DATA, "PackedFile", 1, pf);
@@ -880,13 +880,13 @@ static void write_images(WriteData *wd, ListBase *idbase)
static void write_textures(WriteData *wd, ListBase *idbase)
{
Tex *tex;
-
+
tex= idbase->first;
while(tex) {
if(tex->id.us>0) {
/* write LibData */
writestruct(wd, ID_TE, "Tex", 1, tex);
-
+
/* direct data */
if(tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin);
if(tex->coba) writestruct(wd, DATA, "ColorBand", 1, tex->coba);
@@ -900,17 +900,17 @@ static void write_materials(WriteData *wd, ListBase *idbase)
{
Material *ma;
int a;
-
+
ma= idbase->first;
while(ma) {
if(ma->id.us>0) {
/* write LibData */
writestruct(wd, ID_MA, "Material", 1, ma);
-
+
for(a=0; a<8; a++) {
if(ma->mtex[a]) writestruct(wd, DATA, "MTex", 1, ma->mtex[a]);
}
-
+
write_scriptlink(wd, &ma->scriptlink);
}
ma= ma->id.next;
@@ -921,17 +921,17 @@ static void write_worlds(WriteData *wd, ListBase *idbase)
{
World *wrld;
int a;
-
+
wrld= idbase->first;
while(wrld) {
if(wrld->id.us>0) {
/* write LibData */
writestruct(wd, ID_WO, "World", 1, wrld);
-
+
for(a=0; a<8; a++) {
if(wrld->mtex[a]) writestruct(wd, DATA, "MTex", 1, wrld->mtex[a]);
}
-
+
write_scriptlink(wd, &wrld->scriptlink);
}
wrld= wrld->id.next;
@@ -942,18 +942,18 @@ static void write_lamps(WriteData *wd, ListBase *idbase)
{
Lamp *la;
int a;
-
+
la= idbase->first;
while(la) {
if(la->id.us>0) {
/* write LibData */
writestruct(wd, ID_LA, "Lamp", 1, la);
-
+
/* direct data */
for(a=0; a<8; a++) {
if(la->mtex[a]) writestruct(wd, DATA, "MTex", 1, la->mtex[a]);
}
-
+
write_scriptlink(wd, &la->scriptlink);
}
la= la->id.next;
@@ -963,13 +963,13 @@ static void write_lamps(WriteData *wd, ListBase *idbase)
static void write_lattices(WriteData *wd, ListBase *idbase)
{
Lattice *lt;
-
+
lt= idbase->first;
while(lt) {
if(lt->id.us>0) {
/* write LibData */
writestruct(wd, ID_LT, "Lattice", 1, lt);
-
+
/* direct data */
writestruct(wd, DATA, "BPoint", lt->pntsu*lt->pntsv*lt->pntsw, lt->def);
}
@@ -981,20 +981,20 @@ static void write_ikas(WriteData *wd, ListBase *idbase)
{
Ika *ika;
Limb *li;
-
+
ika= idbase->first;
while(ika) {
if(ika->id.us>0) {
/* write LibData */
writestruct(wd, ID_IK, "Ika", 1, ika);
-
+
/* direct data */
li= ika->limbbase.first;
while(li) {
writestruct(wd, DATA, "Limb", 1, li);
li= li->next;
}
-
+
writestruct(wd, DATA, "Deform", ika->totdef, ika->def);
}
ika= ika->id.next;
@@ -1008,53 +1008,60 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
Editing *ed;
Sequence *seq;
Strip *strip;
-
+
sce= scebase->first;
while(sce) {
/* write LibData */
writestruct(wd, ID_SCE, "Scene", 1, sce);
-
+
/* direct data */
base= sce->base.first;
while(base) {
writestruct(wd, DATA, "Base", 1, base);
base= base->next;
}
-
+
writestruct(wd, DATA, "Radio", 1, sce->radio);
writestruct(wd, DATA, "FreeCamera", 1, sce->fcam);
-
+
ed= sce->ed;
if(ed) {
writestruct(wd, DATA, "Editing", 1, ed);
-
+
/* reset write flags too */
WHILE_SEQ(&ed->seqbase) {
if(seq->strip) seq->strip->done= 0;
writestruct(wd, DATA, "Sequence", 1, seq);
}
END_SEQ
-
+
WHILE_SEQ(&ed->seqbase) {
if(seq->strip && seq->strip->done==0) {
/* write strip with 'done' at 0 because readfile */
-
+
if(seq->plugin) writestruct(wd, DATA, "PluginSeq", 1, seq->plugin);
-
+ if(seq->effectdata) {
+ switch(seq->type){
+ case SEQ_SWEEP:
+ writestruct(wd, DATA, "SweepVars", 1, seq->effectdata);
+ break;
+ }
+ }
+
strip= seq->strip;
writestruct(wd, DATA, "Strip", 1, strip);
-
- if(seq->type==SEQ_IMAGE)
+
+ if(seq->type==SEQ_IMAGE)
writestruct(wd, DATA, "StripElem", strip->len, strip->stripdata);
else if(seq->type==SEQ_MOVIE || seq->type==SEQ_SOUND)
writestruct(wd, DATA, "StripElem", 1, strip->stripdata);
-
+
strip->done= 1;
}
}
END_SEQ
}
-
+
write_scriptlink(wd, &sce->scriptlink);
if (sce->r.avicodecdata) {
@@ -1062,7 +1069,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
if (sce->r.avicodecdata->lpFormat) writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
if (sce->r.avicodecdata->lpParms) writedata(wd, DATA, sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
}
-
+
if (sce->r.qtcodecdata) {
writestruct(wd, DATA, "QuicktimeCodecData", 1, sce->r.qtcodecdata);
if (sce->r.qtcodecdata->cdParms) writedata(wd, DATA, sce->r.qtcodecdata->cdSize, sce->r.qtcodecdata->cdParms);
@@ -1078,38 +1085,38 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
ScrArea *sa;
ScrVert *sv;
ScrEdge *se;
-
+
sc= scrbase->first;
while(sc) {
/* write LibData */
writestruct(wd, ID_SCR, "Screen", 1, sc);
-
+
/* direct data */
sv= sc->vertbase.first;
while(sv) {
writestruct(wd, DATA, "ScrVert", 1, sv);
sv= sv->next;
}
-
+
se= sc->edgebase.first;
while(se) {
writestruct(wd, DATA, "ScrEdge", 1, se);
se= se->next;
}
-
+
sa= sc->areabase.first;
while(sa) {
SpaceLink *sl;
Panel *pa;
writestruct(wd, DATA, "ScrArea", 1, sa);
-
+
pa= sa->panels.first;
while(pa) {
writestruct(wd, DATA, "Panel", 1, pa);
pa= pa->next;
}
-
+
sl= sa->spacedata.first;
while(sl) {
if(sl->spacetype==SPACE_VIEW3D) {
@@ -1133,7 +1140,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
else if(sl->spacetype==SPACE_OOPS) {
SpaceOops *so= (SpaceOops *)sl;
Oops *oops;
-
+
/* cleanup */
oops= so->oops.first;
while(oops) {
@@ -1144,10 +1151,10 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
}
oops= oopsn;
}
-
+
/* ater cleanup, because of listbase! */
writestruct(wd, DATA, "SpaceOops", 1, so);
-
+
oops= so->oops.first;
while(oops) {
writestruct(wd, DATA, "Oops", 1, oops);
@@ -1177,10 +1184,10 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
}
sl= sl->next;
}
-
+
sa= sa->next;
}
-
+
sc= sc->id.next;
}
}
@@ -1190,11 +1197,11 @@ static void write_libraries(WriteData *wd, Main *main)
ListBase *lbarray[30];
ID *id;
int a, tot, foundone;
-
+
while(main) {
-
+
a=tot= set_listbasepointers(main, lbarray);
-
+
/* test: is lib being used */
foundone= 0;
while(tot--) {
@@ -1208,22 +1215,22 @@ static void write_libraries(WriteData *wd, Main *main)
}
if(foundone) break;
}
-
- if(foundone) {
+
+ if(foundone) {
writestruct(wd, ID_LI, "Library", 1, main->curlib);
-
+
while(a--) {
id= lbarray[a]->first;
while(id) {
if(id->us>0 && (id->flag & LIB_EXTERN)) {
-
+
writestruct(wd, ID_ID, "ID", 1, id);
}
id= id->next;
}
}
}
-
+
main= main->next;
}
}
@@ -1231,13 +1238,13 @@ static void write_libraries(WriteData *wd, Main *main)
static void write_bone(WriteData *wd, Bone* bone)
{
Bone* cbone;
-
-// write_constraints(wd, &bone->constraints);
-
- // Write this bone
+
+// write_constraints(wd, &bone->constraints);
+
+ // Write this bone
writestruct(wd, DATA, "Bone", 1, bone);
-
- // Write Children
+
+ // Write Children
cbone= bone->childbase.first;
while(cbone) {
write_bone(wd, cbone);
@@ -1249,12 +1256,12 @@ static void write_armatures(WriteData *wd, ListBase *idbase)
{
bArmature *arm;
Bone *bone;
-
+
arm=idbase->first;
while (arm) {
if (arm->id.us>0) {
writestruct(wd, ID_AR, "bArmature", 1, arm);
-
+
/* Direct data */
bone= arm->bonebase.first;
while(bone) {
@@ -1274,7 +1281,7 @@ static void write_actions(WriteData *wd, ListBase *idbase)
while (act) {
if (act->id.us>0) {
writestruct(wd, ID_AC, "bAction", 1, act);
-
+
for (chan=act->chanbase.first; chan; chan=chan->next) {
writestruct(wd, DATA, "bActionChannel", 1, chan);
write_constraint_channels(wd, &chan->constraintChannels);
@@ -1288,23 +1295,23 @@ static void write_texts(WriteData *wd, ListBase *idbase)
{
Text *text;
TextLine *tmp;
-
+
text= idbase->first;
while(text) {
if ( (text->flags & TXT_ISMEM) && (text->flags & TXT_ISEXT)) text->flags &= ~TXT_ISEXT;
-
+
/* write LibData */
writestruct(wd, ID_TXT, "Text", 1, text);
if(text->name) writedata(wd, DATA, strlen(text->name)+1, text->name);
-
- if(!(text->flags & TXT_ISEXT)) {
+
+ if(!(text->flags & TXT_ISEXT)) {
/* now write the text data, in two steps for optimization in the readfunction */
tmp= text->lines.first;
while (tmp) {
writestruct(wd, DATA, "TextLine", 1, tmp);
tmp= tmp->next;
}
-
+
tmp= text->lines.first;
while (tmp) {
writedata(wd, DATA, tmp->len+1, tmp->line);
@@ -1319,17 +1326,17 @@ static void write_sounds(WriteData *wd, ListBase *idbase)
{
bSound *sound;
bSample *sample;
-
+
PackedFile * pf;
-
+
// set all samples to unsaved status
-
+
sample = samples->first;
while (sample) {
sample->flags |= SAMPLE_NEEDS_SAVE;
sample = sample->id.next;
}
-
+
sound= idbase->first;
while(sound) {
if(sound->id.us>0) {
@@ -1343,16 +1350,16 @@ static void write_sounds(WriteData *wd, ListBase *idbase)
sound->newpackedfile = NULL;
}
}
-
+
/* write LibData */
writestruct(wd, ID_SO, "bSound", 1, sound);
-
+
if (sound->newpackedfile) {
pf = sound->newpackedfile;
writestruct(wd, DATA, "PackedFile", 1, pf);
writedata(wd, DATA, pf->size, pf->data);
}
-
+
if (sample) {
sound->newpackedfile = sample->packedfile;
}
@@ -1367,19 +1374,19 @@ static void write_groups(WriteData *wd, ListBase *idbase)
GroupKey *gk;
GroupObject *go;
ObjectKey *ok;
-
+
group= idbase->first;
while(group) {
if(group->id.us>0) {
/* write LibData */
writestruct(wd, ID_GR, "Group", 1, group);
-
+
gk= group->gkey.first;
while(gk) {
writestruct(wd, DATA, "GroupKey", 1, gk);
gk= gk->next;
}
-
+
go= group->gobject.first;
while(go) {
writestruct(wd, DATA, "GroupObject", 1, go);
@@ -1394,7 +1401,7 @@ static void write_groups(WriteData *wd, ListBase *idbase)
}
go= go->next;
}
-
+
}
group= group->id.next;
}
@@ -1403,35 +1410,35 @@ static void write_groups(WriteData *wd, ListBase *idbase)
static void write_global(WriteData *wd)
{
FileGlobal fg;
-
+
fg.curscreen= G.curscreen;
fg.displaymode= R.displaymode;
fg.winpos= R.winpos;
fg.fileflags= G.fileflags;
fg.globalf= G.f;
-
+
writestruct(wd, GLOB, "FileGlobal", 1, &fg);
}
-static int write_file_handle(int handle, int write_user_block, int write_flags)
+static int write_file_handle(int handle, int write_user_block, int write_flags)
{
ListBase mainlist;
char buf[13];
WriteData *wd;
int data;
-
+
mainlist.first= mainlist.last= G.main;
G.main->next= NULL;
-
+
blo_split_main(&mainlist);
-
+
wd= bgnwrite(handle, write_flags);
sprintf(buf, "BLENDER%c%c%.3d", (sizeof(void*)==8)?'-':'_', (G.order==B_ENDIAN)?'V':'v', G.version);
mywrite(wd, buf, 12);
-
+
write_renderinfo(wd);
-
+
write_screens (wd, &G.main->screen);
write_scenes (wd, &G.main->scene);
write_objects (wd, &G.main->object);
@@ -1460,19 +1467,19 @@ static int write_file_handle(int handle, int write_user_block, int write_flags)
if (write_user_block) {
write_userdef(wd);
}
-
+
/* dna as last, because (to be implemented) test for which structs are written */
writedata(wd, DNA1, wd->sdna->datalen, wd->sdna->data);
-
+
data= ENDB;
mywrite(wd, &data, 4);
-
+
data= 0;
mywrite(wd, &data, 4);
-
+
blo_join_main(&mainlist);
G.main= mainlist.first;
-
+
return endwrite(wd);
}
@@ -1484,7 +1491,7 @@ int BLO_write_file(char *dir, int write_flags, char **error_r)
#ifdef WIN32
char tmpdir[FILE_MAXDIR+FILE_MAXFILE];
#endif
-
+
sprintf(tempname, "%s@", dir);
file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
@@ -1492,14 +1499,14 @@ int BLO_write_file(char *dir, int write_flags, char **error_r)
*error_r= "Unable to open";
return 0;
}
-
+
BLI_make_file_string(G.sce, userfilename, BLI_gethome(), ".B.blend");
write_user_block= BLI_streq(dir, userfilename);
fout= write_file_handle(file, write_user_block, write_flags);
close(file);
-
+
if(!fout) {
if(BLI_rename(tempname, dir) < 0) {
*error_r= "Can't change old file. File saved with @";
@@ -1511,7 +1518,7 @@ int BLO_write_file(char *dir, int write_flags, char **error_r)
*error_r= "Not enough diskspace";
return 0;
}
-
+
return 1;
}
@@ -1521,7 +1528,7 @@ int BLO_write_file(char *dir, int write_flags, char **error_r)
#define PATHSEPERATOR "\\"
#else
#define PATHSEPERATOR "/"
-#endif
+#endif
static char *get_install_dir(void) {
extern char bprogname[];
@@ -1534,7 +1541,7 @@ static char *get_install_dir(void) {
#endif
cut = BLI_last_slash(tmpname);
-
+
if (cut) {
cut[0] = 0;
return tmpname;
@@ -1546,7 +1553,7 @@ static char *get_install_dir(void) {
static char *get_runtime_path(char *exename) {
char *installpath= get_install_dir();
-
+
if (!installpath) {
return NULL;
} else {
@@ -1554,9 +1561,9 @@ static char *get_runtime_path(char *exename) {
strcpy(path, installpath);
strcat(path, PATHSEPERATOR);
strcat(path, exename);
-
+
MEM_freeN(installpath);
-
+
return path;
}
}
@@ -1567,12 +1574,12 @@ static int recursive_copy_runtime(char *outname, char *exename, char **cause_r)
char *cause = NULL, *runtime = get_runtime_path(exename);
char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
int progfd = -1;
-
+
if (!runtime) {
cause= "Unable to find runtime";
goto cleanup;
}
-
+
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
if (progfd==-1) {
cause= "Unable to find runtime";
@@ -1589,7 +1596,7 @@ cleanup:
close(progfd);
if (runtime)
MEM_freeN(runtime);
-
+
if (cause) {
*cause_r= cause;
return 0;
@@ -1601,21 +1608,21 @@ void BLO_write_runtime(char *file, char *exename) {
char gamename[FILE_MAXDIR+FILE_MAXFILE];
int outfd = -1;
char *cause= NULL;
-
+
// remove existing file / bundle
BLI_delete(file, NULL, TRUE);
-
+
if (!recursive_copy_runtime(file, exename, &cause))
goto cleanup;
-
+
strcpy(gamename, file);
strcat(gamename, "/Contents/Resources/game.blend");
-
+
outfd= open(gamename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
if (outfd != -1) {
write_file_handle(outfd, 0, G.fileflags);
-
+
if (write(outfd, " ", 1) != 1) {
cause= "Unable to write to output file";
goto cleanup;
@@ -1623,11 +1630,11 @@ void BLO_write_runtime(char *file, char *exename) {
} else {
cause = "Unable to open blenderfile";
}
-
+
cleanup:
if (outfd!=-1)
close(outfd);
-
+
if (cause)
error("Unable to make runtime: %s", cause);
}
@@ -1638,12 +1645,12 @@ static int handle_append_runtime(int handle, char *exename, char **cause_r) {
char *cause= NULL, *runtime= get_runtime_path(exename);
unsigned char buf[1024];
int count, progfd= -1;
-
+
if (!runtime) {
cause= "Unable to find runtime";
goto cleanup;
}
-
+
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
if (progfd==-1) {
cause= "Unable to find runtime";
@@ -1656,13 +1663,13 @@ static int handle_append_runtime(int handle, char *exename, char **cause_r) {
goto cleanup;
}
}
-
+
cleanup:
if (progfd!=-1)
close(progfd);
if (runtime)
MEM_freeN(runtime);
-
+
if (cause) {
*cause_r= cause;
return 0;
@@ -1676,7 +1683,7 @@ static int handle_write_msb_int(int handle, int i) {
buf[1]= (i>>16)&0xFF;
buf[2]= (i>>8)&0xFF;
buf[3]= (i>>0)&0xFF;
-
+
return (write(handle, buf, 4)==4);
}
@@ -1684,27 +1691,27 @@ void BLO_write_runtime(char *file, char *exename) {
int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
char *cause= NULL;
int datastart;
-
+
if (!outfd) {
cause= "Unable to open output file";
goto cleanup;
}
if (!handle_append_runtime(outfd, exename, &cause))
goto cleanup;
-
+
datastart= lseek(outfd, 0, SEEK_CUR);
write_file_handle(outfd, 0, G.fileflags);
-
+
if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
cause= "Unable to write to output file";
goto cleanup;
}
-
+
cleanup:
if (outfd!=-1)
close(outfd);
-
+
if (cause)
error("Unable to make runtime: %s", cause);
}