Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/writefile.c
| Show First 20 Lines • Show All 791 Lines • ▼ Show 20 Lines | if (fcu->driver) { | ||||
| } | } | ||||
| } | } | ||||
| /* write F-Modifiers */ | /* write F-Modifiers */ | ||||
| write_fmodifiers(wd, &fcu->modifiers); | write_fmodifiers(wd, &fcu->modifiers); | ||||
| } | } | ||||
| } | } | ||||
| static void write_actions(WriteData *wd, ListBase *idbase) | static void write_action(WriteData *wd, bAction *act) | ||||
| { | { | ||||
| for (bAction *act = idbase->first; act; act = act->id.next) { | |||||
| if (act->id.us > 0 || wd->current) { | if (act->id.us > 0 || wd->current) { | ||||
| writestruct(wd, ID_AC, bAction, 1, act); | writestruct(wd, ID_AC, bAction, 1, act); | ||||
| write_iddata(wd, &act->id); | write_iddata(wd, &act->id); | ||||
| write_fcurves(wd, &act->curves); | write_fcurves(wd, &act->curves); | ||||
| for (bActionGroup *grp = act->groups.first; grp; grp = grp->next) { | for (bActionGroup *grp = act->groups.first; grp; grp = grp->next) { | ||||
| writestruct(wd, DATA, bActionGroup, 1, grp); | writestruct(wd, DATA, bActionGroup, 1, grp); | ||||
| } | } | ||||
| for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { | for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { | ||||
| writestruct(wd, DATA, TimeMarker, 1, marker); | writestruct(wd, DATA, TimeMarker, 1, marker); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_keyingsets(WriteData *wd, ListBase *list) | static void write_keyingsets(WriteData *wd, ListBase *list) | ||||
| { | { | ||||
| KeyingSet *ks; | KeyingSet *ks; | ||||
| KS_Path *ksp; | KS_Path *ksp; | ||||
| for (ks = list->first; ks; ks = ks->next) { | for (ks = list->first; ks; ks = ks->next) { | ||||
| /* KeyingSet */ | /* KeyingSet */ | ||||
| writestruct(wd, DATA, KeyingSet, 1, ks); | writestruct(wd, DATA, KeyingSet, 1, ks); | ||||
| ▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | if (sock->prop) { | ||||
| IDP_WriteProperty(sock->prop, wd); | IDP_WriteProperty(sock->prop, wd); | ||||
| } | } | ||||
| if (sock->default_value) { | if (sock->default_value) { | ||||
| writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value); | writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value); | ||||
| } | } | ||||
| } | } | ||||
| /* this is only direct data, tree itself should have been written */ | /* this is only direct data, tree itself should have been written */ | ||||
| static void write_nodetree(WriteData *wd, bNodeTree *ntree) | static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree) | ||||
| { | { | ||||
| bNode *node; | bNode *node; | ||||
| bNodeSocket *sock; | bNodeSocket *sock; | ||||
| bNodeLink *link; | bNodeLink *link; | ||||
| /* for link_list() speed, we write per list */ | /* for link_list() speed, we write per list */ | ||||
| if (ntree->adt) { | if (ntree->adt) { | ||||
| ▲ Show 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | if ((cache->flag & PTCACHE_DISK_CACHE) == 0) { | ||||
| } | } | ||||
| writestruct(wd, DATA, PTCacheExtra, 1, extra); | writestruct(wd, DATA, PTCacheExtra, 1, extra); | ||||
| writestruct_id(wd, DATA, ptcache_extra_struct[extra->type], extra->totdata, extra->data); | writestruct_id(wd, DATA, ptcache_extra_struct[extra->type], extra->totdata, extra->data); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void write_particlesettings(WriteData *wd, ListBase *idbase) | |||||
| static void write_particlesettings(WriteData *wd, ParticleSettings *part) | |||||
| { | { | ||||
| for (ParticleSettings *part = idbase->first; part; part = part->id.next) { | |||||
| if (part->id.us > 0 || wd->current) { | if (part->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_PA, ParticleSettings, 1, part); | writestruct(wd, ID_PA, ParticleSettings, 1, part); | ||||
| write_iddata(wd, &part->id); | write_iddata(wd, &part->id); | ||||
| if (part->adt) { | if (part->adt) { | ||||
| write_animdata(wd, part->adt); | write_animdata(wd, part->adt); | ||||
| } | } | ||||
| writestruct(wd, DATA, PartDeflect, 1, part->pd); | writestruct(wd, DATA, PartDeflect, 1, part->pd); | ||||
| writestruct(wd, DATA, PartDeflect, 1, part->pd2); | writestruct(wd, DATA, PartDeflect, 1, part->pd2); | ||||
| writestruct(wd, DATA, EffectorWeights, 1, part->effector_weights); | writestruct(wd, DATA, EffectorWeights, 1, part->effector_weights); | ||||
| if (part->clumpcurve) { | if (part->clumpcurve) { | ||||
| write_curvemapping(wd, part->clumpcurve); | write_curvemapping(wd, part->clumpcurve); | ||||
| } | } | ||||
| if (part->roughcurve) { | if (part->roughcurve) { | ||||
| write_curvemapping(wd, part->roughcurve); | write_curvemapping(wd, part->roughcurve); | ||||
| } | } | ||||
| for (ParticleDupliWeight *dw = part->dupliweights.first; dw; dw = dw->next) { | for (ParticleDupliWeight *dw = part->dupliweights.first; dw; dw = dw->next) { | ||||
| /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */ | /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */ | ||||
| if (dw->ob != NULL) { | if (dw->ob != NULL) { | ||||
| dw->index = 0; | dw->index = 0; | ||||
| if (part->dup_group) { /* can be NULL if lining fails or set to None */ | if (part->dup_group) { /* can be NULL if lining fails or set to None */ | ||||
| for (GroupObject *go = part->dup_group->gobject.first; | for (GroupObject *go = part->dup_group->gobject.first; | ||||
| go && go->ob != dw->ob; | go && go->ob != dw->ob; | ||||
| go = go->next, dw->index++); | go = go->next, dw->index++); | ||||
| } | } | ||||
| } | } | ||||
| writestruct(wd, DATA, ParticleDupliWeight, 1, dw); | writestruct(wd, DATA, ParticleDupliWeight, 1, dw); | ||||
| } | } | ||||
| if (part->boids && part->phystype == PART_PHYS_BOIDS) { | if (part->boids && part->phystype == PART_PHYS_BOIDS) { | ||||
| writestruct(wd, DATA, BoidSettings, 1, part->boids); | writestruct(wd, DATA, BoidSettings, 1, part->boids); | ||||
| for (BoidState *state = part->boids->states.first; state; state = state->next) { | for (BoidState *state = part->boids->states.first; state; state = state->next) { | ||||
| write_boid_state(wd, state); | write_boid_state(wd, state); | ||||
| } | } | ||||
| } | } | ||||
| if (part->fluid && part->phystype == PART_PHYS_FLUID) { | if (part->fluid && part->phystype == PART_PHYS_FLUID) { | ||||
| writestruct(wd, DATA, SPHFluidSettings, 1, part->fluid); | writestruct(wd, DATA, SPHFluidSettings, 1, part->fluid); | ||||
| } | } | ||||
| for (int a = 0; a < MAX_MTEX; a++) { | for (int a = 0; a < MAX_MTEX; a++) { | ||||
| if (part->mtex[a]) { | if (part->mtex[a]) { | ||||
| writestruct(wd, DATA, MTex, 1, part->mtex[a]); | writestruct(wd, DATA, MTex, 1, part->mtex[a]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_particlesystems(WriteData *wd, ListBase *particles) | static void write_particlesystems(WriteData *wd, ListBase *particles) | ||||
| { | { | ||||
| ParticleSystem *psys = particles->first; | ParticleSystem *psys = particles->first; | ||||
| ParticleTarget *pt; | ParticleTarget *pt; | ||||
| int a; | int a; | ||||
| for (; psys; psys = psys->next) { | for (; psys; psys = psys->next) { | ||||
| writestruct(wd, DATA, ParticleSystem, 1, psys); | writestruct(wd, DATA, ParticleSystem, 1, psys); | ||||
| ▲ Show 20 Lines • Show All 477 Lines • ▼ Show 20 Lines | else if (md->type == eModifierType_CorrectiveSmooth) { | ||||
| if (csmd->bind_coords) { | if (csmd->bind_coords) { | ||||
| writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords); | writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void write_objects(WriteData *wd, ListBase *idbase) | static void write_object(WriteData *wd, Object *ob) | ||||
| { | { | ||||
| for (Object *ob = idbase->first; ob; ob = ob->id.next) { | |||||
| if (ob->id.us > 0 || wd->current) { | if (ob->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_OB, Object, 1, ob); | writestruct(wd, ID_OB, Object, 1, ob); | ||||
| write_iddata(wd, &ob->id); | write_iddata(wd, &ob->id); | ||||
| if (ob->adt) { | if (ob->adt) { | ||||
| write_animdata(wd, ob->adt); | write_animdata(wd, ob->adt); | ||||
| } | } | ||||
| /* direct data */ | /* direct data */ | ||||
| writedata(wd, DATA, sizeof(void *) * ob->totcol, ob->mat); | writedata(wd, DATA, sizeof(void *) * ob->totcol, ob->mat); | ||||
| writedata(wd, DATA, sizeof(char) * ob->totcol, ob->matbits); | writedata(wd, DATA, sizeof(char) * ob->totcol, ob->matbits); | ||||
| /* write_effects(wd, &ob->effect); */ /* not used anymore */ | /* write_effects(wd, &ob->effect); */ /* not used anymore */ | ||||
| write_properties(wd, &ob->prop); | write_properties(wd, &ob->prop); | ||||
| write_sensors(wd, &ob->sensors); | write_sensors(wd, &ob->sensors); | ||||
| write_controllers(wd, &ob->controllers); | write_controllers(wd, &ob->controllers); | ||||
| write_actuators(wd, &ob->actuators); | write_actuators(wd, &ob->actuators); | ||||
| if (ob->type == OB_ARMATURE) { | if (ob->type == OB_ARMATURE) { | ||||
| bArmature *arm = ob->data; | bArmature *arm = ob->data; | ||||
| if (arm && ob->pose && arm->act_bone) { | if (arm && ob->pose && arm->act_bone) { | ||||
| BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone)); | BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone)); | ||||
| } | } | ||||
| } | } | ||||
| write_pose(wd, ob->pose); | write_pose(wd, ob->pose); | ||||
| write_defgroups(wd, &ob->defbase); | write_defgroups(wd, &ob->defbase); | ||||
| write_constraints(wd, &ob->constraints); | write_constraints(wd, &ob->constraints); | ||||
| write_motionpath(wd, ob->mpath); | write_motionpath(wd, ob->mpath); | ||||
| writestruct(wd, DATA, PartDeflect, 1, ob->pd); | writestruct(wd, DATA, PartDeflect, 1, ob->pd); | ||||
| writestruct(wd, DATA, SoftBody, 1, ob->soft); | writestruct(wd, DATA, SoftBody, 1, ob->soft); | ||||
| if (ob->soft) { | if (ob->soft) { | ||||
| write_pointcaches(wd, &ob->soft->ptcaches); | write_pointcaches(wd, &ob->soft->ptcaches); | ||||
| writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights); | writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights); | ||||
| } | } | ||||
| writestruct(wd, DATA, BulletSoftBody, 1, ob->bsoft); | writestruct(wd, DATA, BulletSoftBody, 1, ob->bsoft); | ||||
| if (ob->rigidbody_object) { | if (ob->rigidbody_object) { | ||||
| /* TODO: if any extra data is added to handle duplis, will need separate function then */ | /* TODO: if any extra data is added to handle duplis, will need separate function then */ | ||||
| writestruct(wd, DATA, RigidBodyOb, 1, ob->rigidbody_object); | writestruct(wd, DATA, RigidBodyOb, 1, ob->rigidbody_object); | ||||
| } | } | ||||
| if (ob->rigidbody_constraint) { | if (ob->rigidbody_constraint) { | ||||
| writestruct(wd, DATA, RigidBodyCon, 1, ob->rigidbody_constraint); | writestruct(wd, DATA, RigidBodyCon, 1, ob->rigidbody_constraint); | ||||
| } | } | ||||
| if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) { | if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) { | ||||
| writestruct(wd, DATA, ImageUser, 1, ob->iuser); | writestruct(wd, DATA, ImageUser, 1, ob->iuser); | ||||
| } | } | ||||
| write_particlesystems(wd, &ob->particlesystem); | write_particlesystems(wd, &ob->particlesystem); | ||||
| write_modifiers(wd, &ob->modifiers); | write_modifiers(wd, &ob->modifiers); | ||||
| writelist(wd, DATA, LinkData, &ob->pc_ids); | writelist(wd, DATA, LinkData, &ob->pc_ids); | ||||
| writelist(wd, DATA, LodLevel, &ob->lodlevels); | writelist(wd, DATA, LodLevel, &ob->lodlevels); | ||||
| write_previews(wd, ob->preview); | write_previews(wd, ob->preview); | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_vfonts(WriteData *wd, ListBase *idbase) | static void write_vfont(WriteData *wd, VFont *vf) | ||||
| { | { | ||||
| for (VFont *vf = idbase->first; vf; vf = vf->id.next) { | |||||
| if (vf->id.us > 0 || wd->current) { | if (vf->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_VF, VFont, 1, vf); | writestruct(wd, ID_VF, VFont, 1, vf); | ||||
| write_iddata(wd, &vf->id); | write_iddata(wd, &vf->id); | ||||
| /* direct data */ | /* direct data */ | ||||
| if (vf->packedfile) { | if (vf->packedfile) { | ||||
| PackedFile *pf = vf->packedfile; | PackedFile *pf = vf->packedfile; | ||||
| writestruct(wd, DATA, PackedFile, 1, pf); | writestruct(wd, DATA, PackedFile, 1, pf); | ||||
| writedata(wd, DATA, pf->size, pf->data); | writedata(wd, DATA, pf->size, pf->data); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_keys(WriteData *wd, ListBase *idbase) | static void write_key(WriteData *wd, Key *key) | ||||
| { | { | ||||
| for (Key *key = idbase->first; key; key = key->id.next) { | |||||
| if (key->id.us > 0 || wd->current) { | if (key->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_KE, Key, 1, key); | writestruct(wd, ID_KE, Key, 1, key); | ||||
| write_iddata(wd, &key->id); | write_iddata(wd, &key->id); | ||||
| if (key->adt) { | if (key->adt) { | ||||
| write_animdata(wd, key->adt); | write_animdata(wd, key->adt); | ||||
| } | } | ||||
| /* direct data */ | /* direct data */ | ||||
| for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { | for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { | ||||
| writestruct(wd, DATA, KeyBlock, 1, kb); | writestruct(wd, DATA, KeyBlock, 1, kb); | ||||
| if (kb->data) { | if (kb->data) { | ||||
| writedata(wd, DATA, kb->totelem * key->elemsize, kb->data); | writedata(wd, DATA, kb->totelem * key->elemsize, kb->data); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_camera(WriteData *wd, Camera *cam) | ||||
| } | |||||
| static void write_cameras(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Camera *cam = idbase->first; cam; cam = cam->id.next) { | |||||
| if (cam->id.us > 0 || wd->current) { | if (cam->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_CA, Camera, 1, cam); | writestruct(wd, ID_CA, Camera, 1, cam); | ||||
| write_iddata(wd, &cam->id); | write_iddata(wd, &cam->id); | ||||
| if (cam->adt) { | if (cam->adt) { | ||||
| write_animdata(wd, cam->adt); | write_animdata(wd, cam->adt); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_mballs(WriteData *wd, ListBase *idbase) | static void write_mball(WriteData *wd, MetaBall *mb) | ||||
| { | { | ||||
| for (MetaBall *mb = idbase->first; mb; mb = mb->id.next) { | |||||
| if (mb->id.us > 0 || wd->current) { | if (mb->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_MB, MetaBall, 1, mb); | writestruct(wd, ID_MB, MetaBall, 1, mb); | ||||
| write_iddata(wd, &mb->id); | write_iddata(wd, &mb->id); | ||||
| /* direct data */ | /* direct data */ | ||||
| writedata(wd, DATA, sizeof(void *) * mb->totcol, mb->mat); | writedata(wd, DATA, sizeof(void *) * mb->totcol, mb->mat); | ||||
| if (mb->adt) { | if (mb->adt) { | ||||
| write_animdata(wd, mb->adt); | write_animdata(wd, mb->adt); | ||||
| } | } | ||||
| for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) { | for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) { | ||||
| writestruct(wd, DATA, MetaElem, 1, ml); | writestruct(wd, DATA, MetaElem, 1, ml); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_curves(WriteData *wd, ListBase *idbase) | static void write_curve(WriteData *wd, Curve *cu) | ||||
| { | { | ||||
| for (Curve *cu = idbase->first; cu; cu = cu->id.next) { | |||||
| if (cu->id.us > 0 || wd->current) { | if (cu->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_CU, Curve, 1, cu); | writestruct(wd, ID_CU, Curve, 1, cu); | ||||
| write_iddata(wd, &cu->id); | write_iddata(wd, &cu->id); | ||||
| /* direct data */ | /* direct data */ | ||||
| writedata(wd, DATA, sizeof(void *) * cu->totcol, cu->mat); | writedata(wd, DATA, sizeof(void *) * cu->totcol, cu->mat); | ||||
| if (cu->adt) { | if (cu->adt) { | ||||
| write_animdata(wd, cu->adt); | write_animdata(wd, cu->adt); | ||||
| } | } | ||||
| if (cu->vfont) { | if (cu->vfont) { | ||||
| writedata(wd, DATA, cu->len + 1, cu->str); | writedata(wd, DATA, cu->len + 1, cu->str); | ||||
| writestruct(wd, DATA, CharInfo, cu->len_wchar + 1, cu->strinfo); | writestruct(wd, DATA, CharInfo, cu->len_wchar + 1, cu->strinfo); | ||||
| writestruct(wd, DATA, TextBox, cu->totbox, cu->tb); | writestruct(wd, DATA, TextBox, cu->totbox, cu->tb); | ||||
| } | } | ||||
| else { | else { | ||||
| /* is also the order of reading */ | /* is also the order of reading */ | ||||
| for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { | for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { | ||||
| writestruct(wd, DATA, Nurb, 1, nu); | writestruct(wd, DATA, Nurb, 1, nu); | ||||
| } | } | ||||
| for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { | for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { | ||||
| if (nu->type == CU_BEZIER) { | if (nu->type == CU_BEZIER) { | ||||
| writestruct(wd, DATA, BezTriple, nu->pntsu, nu->bezt); | writestruct(wd, DATA, BezTriple, nu->pntsu, nu->bezt); | ||||
| } | } | ||||
| else { | else { | ||||
| writestruct(wd, DATA, BPoint, nu->pntsu * nu->pntsv, nu->bp); | writestruct(wd, DATA, BPoint, nu->pntsu * nu->pntsv, nu->bp); | ||||
| if (nu->knotsu) { | if (nu->knotsu) { | ||||
| writedata(wd, DATA, KNOTSU(nu) * sizeof(float), nu->knotsu); | writedata(wd, DATA, KNOTSU(nu) * sizeof(float), nu->knotsu); | ||||
| } | } | ||||
| if (nu->knotsv) { | if (nu->knotsv) { | ||||
| writedata(wd, DATA, KNOTSV(nu) * sizeof(float), nu->knotsv); | writedata(wd, DATA, KNOTSV(nu) * sizeof(float), nu->knotsv); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist) | static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist) | ||||
| { | { | ||||
| if (dvlist) { | if (dvlist) { | ||||
| /* Write the dvert list */ | /* Write the dvert list */ | ||||
| writestruct(wd, DATA, MDeformVert, count, dvlist); | writestruct(wd, DATA, MDeformVert, count, dvlist); | ||||
| /* Write deformation data for each dvert */ | /* Write deformation data for each dvert */ | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | for (i = 0; i < data->totlayer; i++) { | ||||
| } | } | ||||
| } | } | ||||
| if (data->external) { | if (data->external) { | ||||
| writestruct(wd, DATA, CustomDataExternal, 1, data->external); | writestruct(wd, DATA, CustomDataExternal, 1, data->external); | ||||
| } | } | ||||
| } | } | ||||
| static void write_meshes(WriteData *wd, ListBase *idbase) | static void write_mesh(WriteData *wd, Mesh *mesh) | ||||
| { | { | ||||
| #ifdef USE_BMESH_SAVE_AS_COMPAT | #ifdef USE_BMESH_SAVE_AS_COMPAT | ||||
| const bool save_for_old_blender = wd->use_mesh_compat; /* option to save with older mesh format */ | const bool save_for_old_blender = wd->use_mesh_compat; /* option to save with older mesh format */ | ||||
| #else | #else | ||||
| const bool save_for_old_blender = false; | const bool save_for_old_blender = false; | ||||
| #endif | #endif | ||||
| for (Mesh *mesh = idbase->first; mesh; mesh = mesh->id.next) { | |||||
| CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE]; | CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE]; | ||||
| CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE]; | CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE]; | ||||
| CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE]; | CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE]; | ||||
| CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE]; | CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE]; | ||||
| CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE]; | CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE]; | ||||
| if (mesh->id.us > 0 || wd->current) { | if (mesh->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| if (!save_for_old_blender) { | if (!save_for_old_blender) { | ||||
| /* write a copy of the mesh, don't modify in place because it is | /* write a copy of the mesh, don't modify in place because it is | ||||
| * not thread safe for threaded renders that are reading this */ | * not thread safe for threaded renders that are reading this */ | ||||
| Mesh *old_mesh = mesh; | Mesh *old_mesh = mesh; | ||||
| Mesh copy_mesh = *mesh; | Mesh copy_mesh = *mesh; | ||||
| mesh = ©_mesh; | mesh = ©_mesh; | ||||
| #ifdef USE_BMESH_SAVE_WITHOUT_MFACE | #ifdef USE_BMESH_SAVE_WITHOUT_MFACE | ||||
| /* cache only - don't write */ | /* cache only - don't write */ | ||||
| mesh->mface = NULL; | mesh->mface = NULL; | ||||
| mesh->totface = 0; | mesh->totface = 0; | ||||
| memset(&mesh->fdata, 0, sizeof(mesh->fdata)); | memset(&mesh->fdata, 0, sizeof(mesh->fdata)); | ||||
| #endif /* USE_BMESH_SAVE_WITHOUT_MFACE */ | #endif /* USE_BMESH_SAVE_WITHOUT_MFACE */ | ||||
| /** | /** | ||||
| * Those calls: | * Those calls: | ||||
| * - Reduce mesh->xdata.totlayer to number of layers to write. | * - Reduce mesh->xdata.totlayer to number of layers to write. | ||||
| * - Fill xlayers with those layers to be written. | * - Fill xlayers with those layers to be written. | ||||
| * Note that mesh->xdata is from now on invalid for Blender, but this is why the whole mesh is | * Note that mesh->xdata is from now on invalid for Blender, but this is why the whole mesh is | ||||
| * a temp local copy! | * a temp local copy! | ||||
| */ | */ | ||||
| CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); | CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); | ||||
| CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); | CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); | ||||
| #ifndef USE_BMESH_SAVE_WITHOUT_MFACE /* Do not copy org fdata in this case!!! */ | #ifndef USE_BMESH_SAVE_WITHOUT_MFACE /* Do not copy org fdata in this case!!! */ | ||||
| CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff)); | CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff)); | ||||
| #else | #else | ||||
| flayers = flayers_buff; | flayers = flayers_buff; | ||||
| #endif | #endif | ||||
| CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); | CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); | ||||
| CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); | CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); | ||||
| writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); | writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); | ||||
| write_iddata(wd, &mesh->id); | write_iddata(wd, &mesh->id); | ||||
| /* direct data */ | /* direct data */ | ||||
| if (mesh->adt) { | if (mesh->adt) { | ||||
| write_animdata(wd, mesh->adt); | write_animdata(wd, mesh->adt); | ||||
| } | } | ||||
| writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat); | writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat); | ||||
| writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); | writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); | ||||
| write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0); | ||||
| write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0); | ||||
| /* fdata is really a dummy - written so slots align */ | /* fdata is really a dummy - written so slots align */ | ||||
| write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0); | ||||
| write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0); | ||||
| write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0); | write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0); | ||||
| /* restore pointer */ | /* restore pointer */ | ||||
| mesh = old_mesh; | mesh = old_mesh; | ||||
| } | } | ||||
| else { | else { | ||||
| #ifdef USE_BMESH_SAVE_AS_COMPAT | #ifdef USE_BMESH_SAVE_AS_COMPAT | ||||
| /* write a copy of the mesh, don't modify in place because it is | /* write a copy of the mesh, don't modify in place because it is | ||||
| * not thread safe for threaded renders that are reading this */ | * not thread safe for threaded renders that are reading this */ | ||||
| Mesh *old_mesh = mesh; | Mesh *old_mesh = mesh; | ||||
| Mesh copy_mesh = *mesh; | Mesh copy_mesh = *mesh; | ||||
| mesh = ©_mesh; | mesh = ©_mesh; | ||||
| mesh->mpoly = NULL; | mesh->mpoly = NULL; | ||||
| mesh->mface = NULL; | mesh->mface = NULL; | ||||
| mesh->totface = 0; | mesh->totface = 0; | ||||
| mesh->totpoly = 0; | mesh->totpoly = 0; | ||||
| mesh->totloop = 0; | mesh->totloop = 0; | ||||
| CustomData_reset(&mesh->fdata); | CustomData_reset(&mesh->fdata); | ||||
| CustomData_reset(&mesh->pdata); | CustomData_reset(&mesh->pdata); | ||||
| CustomData_reset(&mesh->ldata); | CustomData_reset(&mesh->ldata); | ||||
| mesh->edit_btmesh = NULL; | mesh->edit_btmesh = NULL; | ||||
| /* now fill in polys to mfaces */ | /* now fill in polys to mfaces */ | ||||
| /* XXX This breaks writing design, by using temp allocated memory, which will likely generate | /* XXX This breaks writing design, by using temp allocated memory, which will likely generate | ||||
| * duplicates in stored 'old' addresses. | * duplicates in stored 'old' addresses. | ||||
| * This is very bad, but do not see easy way to avoid this, aside from generating those data | * This is very bad, but do not see easy way to avoid this, aside from generating those data | ||||
| * outside of save process itself. | * outside of save process itself. | ||||
| * Maybe we can live with this, though? | * Maybe we can live with this, though? | ||||
| */ | */ | ||||
| mesh->totface = BKE_mesh_mpoly_to_mface(&mesh->fdata, &old_mesh->ldata, &old_mesh->pdata, | mesh->totface = BKE_mesh_mpoly_to_mface(&mesh->fdata, &old_mesh->ldata, &old_mesh->pdata, | ||||
| mesh->totface, old_mesh->totloop, old_mesh->totpoly); | mesh->totface, old_mesh->totloop, old_mesh->totpoly); | ||||
| BKE_mesh_update_customdata_pointers(mesh, false); | BKE_mesh_update_customdata_pointers(mesh, false); | ||||
| CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); | CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); | ||||
| CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); | CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); | ||||
| CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff)); | CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff)); | ||||
| #if 0 | #if 0 | ||||
| CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); | CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); | ||||
| CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); | CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); | ||||
| #endif | #endif | ||||
| writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); | writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); | ||||
| write_iddata(wd, &mesh->id); | write_iddata(wd, &mesh->id); | ||||
| /* direct data */ | /* direct data */ | ||||
| if (mesh->adt) { | if (mesh->adt) { | ||||
| write_animdata(wd, mesh->adt); | write_animdata(wd, mesh->adt); | ||||
| } | } | ||||
| writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat); | writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat); | ||||
| /* writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); */ /* pre-bmesh NULL's */ | /* writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); */ /* pre-bmesh NULL's */ | ||||
| write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0); | ||||
| write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0); | ||||
| write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0); | ||||
| /* harmless for older blender versioins but _not_ writing these keeps file size down */ | /* harmless for older blender versioins but _not_ writing these keeps file size down */ | ||||
| #if 0 | #if 0 | ||||
| write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0); | write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0); | ||||
| write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0); | write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0); | ||||
| #endif | #endif | ||||
| CustomData_free(&mesh->fdata, mesh->totface); | CustomData_free(&mesh->fdata, mesh->totface); | ||||
| flayers = NULL; | flayers = NULL; | ||||
| /* restore pointer */ | /* restore pointer */ | ||||
| mesh = old_mesh; | mesh = old_mesh; | ||||
| #endif /* USE_BMESH_SAVE_AS_COMPAT */ | #endif /* USE_BMESH_SAVE_AS_COMPAT */ | ||||
| } | } | ||||
| } | } | ||||
| if (vlayers && vlayers != vlayers_buff) { | if (vlayers && vlayers != vlayers_buff) { | ||||
| MEM_freeN(vlayers); | MEM_freeN(vlayers); | ||||
| } | } | ||||
| if (elayers && elayers != elayers_buff) { | if (elayers && elayers != elayers_buff) { | ||||
| MEM_freeN(elayers); | MEM_freeN(elayers); | ||||
| } | } | ||||
| if (flayers && flayers != flayers_buff) { | if (flayers && flayers != flayers_buff) { | ||||
| MEM_freeN(flayers); | MEM_freeN(flayers); | ||||
| } | } | ||||
| if (llayers && llayers != llayers_buff) { | if (llayers && llayers != llayers_buff) { | ||||
| MEM_freeN(llayers); | MEM_freeN(llayers); | ||||
| } | } | ||||
| if (players && players != players_buff) { | if (players && players != players_buff) { | ||||
| MEM_freeN(players); | MEM_freeN(players); | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_lattice(WriteData *wd, Lattice *lt) | ||||
| } | |||||
| static void write_lattices(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Lattice *lt = idbase->first; lt; lt = lt->id.next) { | |||||
| if (lt->id.us > 0 || wd->current) { | if (lt->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_LT, Lattice, 1, lt); | writestruct(wd, ID_LT, Lattice, 1, lt); | ||||
| write_iddata(wd, <->id); | write_iddata(wd, <->id); | ||||
| /* write animdata */ | /* write animdata */ | ||||
| if (lt->adt) { | if (lt->adt) { | ||||
| write_animdata(wd, lt->adt); | write_animdata(wd, lt->adt); | ||||
| } | } | ||||
| /* direct data */ | /* direct data */ | ||||
| writestruct(wd, DATA, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def); | writestruct(wd, DATA, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def); | ||||
| write_dverts(wd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert); | write_dverts(wd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert); | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_image(WriteData *wd, Image *ima) | ||||
| } | |||||
| static void write_images(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Image *ima = idbase->first; ima; ima = ima->id.next) { | |||||
| if (ima->id.us > 0 || wd->current) { | if (ima->id.us > 0 || wd->current) { | ||||
| ImagePackedFile *imapf; | ImagePackedFile *imapf; | ||||
| /* Some trickery to keep forward compatibility of packed images. */ | /* Some trickery to keep forward compatibility of packed images. */ | ||||
| BLI_assert(ima->packedfile == NULL); | BLI_assert(ima->packedfile == NULL); | ||||
| if (ima->packedfiles.first != NULL) { | if (ima->packedfiles.first != NULL) { | ||||
| imapf = ima->packedfiles.first; | imapf = ima->packedfiles.first; | ||||
| ima->packedfile = imapf->packedfile; | ima->packedfile = imapf->packedfile; | ||||
| } | } | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_IM, Image, 1, ima); | writestruct(wd, ID_IM, Image, 1, ima); | ||||
| write_iddata(wd, &ima->id); | write_iddata(wd, &ima->id); | ||||
| for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) { | for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) { | ||||
| writestruct(wd, DATA, ImagePackedFile, 1, imapf); | writestruct(wd, DATA, ImagePackedFile, 1, imapf); | ||||
| if (imapf->packedfile) { | if (imapf->packedfile) { | ||||
| PackedFile *pf = imapf->packedfile; | PackedFile *pf = imapf->packedfile; | ||||
| writestruct(wd, DATA, PackedFile, 1, pf); | writestruct(wd, DATA, PackedFile, 1, pf); | ||||
| writedata(wd, DATA, pf->size, pf->data); | writedata(wd, DATA, pf->size, pf->data); | ||||
| } | } | ||||
| } | } | ||||
| write_previews(wd, ima->preview); | write_previews(wd, ima->preview); | ||||
| for (ImageView *iv = ima->views.first; iv; iv = iv->next) { | for (ImageView *iv = ima->views.first; iv; iv = iv->next) { | ||||
| writestruct(wd, DATA, ImageView, 1, iv); | writestruct(wd, DATA, ImageView, 1, iv); | ||||
| } | } | ||||
| writestruct(wd, DATA, Stereo3dFormat, 1, ima->stereo3d_format); | writestruct(wd, DATA, Stereo3dFormat, 1, ima->stereo3d_format); | ||||
| ima->packedfile = NULL; | ima->packedfile = NULL; | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_texture(WriteData *wd, Tex *tex) | ||||
| } | |||||
| static void write_textures(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Tex *tex = idbase->first; tex; tex = tex->id.next) { | |||||
| if (tex->id.us > 0 || wd->current) { | if (tex->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_TE, Tex, 1, tex); | writestruct(wd, ID_TE, Tex, 1, tex); | ||||
| write_iddata(wd, &tex->id); | write_iddata(wd, &tex->id); | ||||
| if (tex->adt) { | if (tex->adt) { | ||||
| write_animdata(wd, tex->adt); | write_animdata(wd, tex->adt); | ||||
| } | } | ||||
| /* direct data */ | /* direct data */ | ||||
| if (tex->coba) { | if (tex->coba) { | ||||
| writestruct(wd, DATA, ColorBand, 1, tex->coba); | writestruct(wd, DATA, ColorBand, 1, tex->coba); | ||||
| } | } | ||||
| if (tex->type == TEX_ENVMAP && tex->env) { | if (tex->type == TEX_ENVMAP && tex->env) { | ||||
| writestruct(wd, DATA, EnvMap, 1, tex->env); | writestruct(wd, DATA, EnvMap, 1, tex->env); | ||||
| } | } | ||||
| if (tex->type == TEX_POINTDENSITY && tex->pd) { | if (tex->type == TEX_POINTDENSITY && tex->pd) { | ||||
| writestruct(wd, DATA, PointDensity, 1, tex->pd); | writestruct(wd, DATA, PointDensity, 1, tex->pd); | ||||
| if (tex->pd->coba) { | if (tex->pd->coba) { | ||||
| writestruct(wd, DATA, ColorBand, 1, tex->pd->coba); | writestruct(wd, DATA, ColorBand, 1, tex->pd->coba); | ||||
| } | } | ||||
| if (tex->pd->falloff_curve) { | if (tex->pd->falloff_curve) { | ||||
| write_curvemapping(wd, tex->pd->falloff_curve); | write_curvemapping(wd, tex->pd->falloff_curve); | ||||
| } | } | ||||
| } | } | ||||
| if (tex->type == TEX_VOXELDATA) { | if (tex->type == TEX_VOXELDATA) { | ||||
| writestruct(wd, DATA, VoxelData, 1, tex->vd); | writestruct(wd, DATA, VoxelData, 1, tex->vd); | ||||
| } | } | ||||
| if (tex->type == TEX_OCEAN && tex->ot) { | if (tex->type == TEX_OCEAN && tex->ot) { | ||||
| writestruct(wd, DATA, OceanTex, 1, tex->ot); | writestruct(wd, DATA, OceanTex, 1, tex->ot); | ||||
| } | } | ||||
| /* nodetree is integral part of texture, no libdata */ | /* nodetree is integral part of texture, no libdata */ | ||||
| if (tex->nodetree) { | if (tex->nodetree) { | ||||
| writestruct(wd, DATA, bNodeTree, 1, tex->nodetree); | writestruct(wd, DATA, bNodeTree, 1, tex->nodetree); | ||||
| write_nodetree(wd, tex->nodetree); | write_nodetree_nolib(wd, tex->nodetree); | ||||
| } | } | ||||
| write_previews(wd, tex->preview); | write_previews(wd, tex->preview); | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_material(WriteData *wd, Material *ma) | ||||
| } | |||||
| static void write_materials(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Material *ma = idbase->first; ma; ma = ma->id.next) { | |||||
| if (ma->id.us > 0 || wd->current) { | if (ma->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_MA, Material, 1, ma); | writestruct(wd, ID_MA, Material, 1, ma); | ||||
| write_iddata(wd, &ma->id); | write_iddata(wd, &ma->id); | ||||
| if (ma->adt) { | if (ma->adt) { | ||||
| write_animdata(wd, ma->adt); | write_animdata(wd, ma->adt); | ||||
| } | } | ||||
| for (int a = 0; a < MAX_MTEX; a++) { | for (int a = 0; a < MAX_MTEX; a++) { | ||||
| if (ma->mtex[a]) { | if (ma->mtex[a]) { | ||||
| writestruct(wd, DATA, MTex, 1, ma->mtex[a]); | writestruct(wd, DATA, MTex, 1, ma->mtex[a]); | ||||
| } | } | ||||
| } | } | ||||
| if (ma->ramp_col) { | if (ma->ramp_col) { | ||||
| writestruct(wd, DATA, ColorBand, 1, ma->ramp_col); | writestruct(wd, DATA, ColorBand, 1, ma->ramp_col); | ||||
| } | } | ||||
| if (ma->ramp_spec) { | if (ma->ramp_spec) { | ||||
| writestruct(wd, DATA, ColorBand, 1, ma->ramp_spec); | writestruct(wd, DATA, ColorBand, 1, ma->ramp_spec); | ||||
| } | } | ||||
| /* nodetree is integral part of material, no libdata */ | /* nodetree is integral part of material, no libdata */ | ||||
| if (ma->nodetree) { | if (ma->nodetree) { | ||||
| writestruct(wd, DATA, bNodeTree, 1, ma->nodetree); | writestruct(wd, DATA, bNodeTree, 1, ma->nodetree); | ||||
| write_nodetree(wd, ma->nodetree); | write_nodetree_nolib(wd, ma->nodetree); | ||||
| } | } | ||||
| write_previews(wd, ma->preview); | write_previews(wd, ma->preview); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_worlds(WriteData *wd, ListBase *idbase) | static void write_world(WriteData *wd, World *wrld) | ||||
| { | { | ||||
| for (World *wrld = idbase->first; wrld; wrld = wrld->id.next) { | |||||
| if (wrld->id.us > 0 || wd->current) { | if (wrld->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_WO, World, 1, wrld); | writestruct(wd, ID_WO, World, 1, wrld); | ||||
| write_iddata(wd, &wrld->id); | write_iddata(wd, &wrld->id); | ||||
| if (wrld->adt) { | if (wrld->adt) { | ||||
| write_animdata(wd, wrld->adt); | write_animdata(wd, wrld->adt); | ||||
| } | } | ||||
| for (int a = 0; a < MAX_MTEX; a++) { | for (int a = 0; a < MAX_MTEX; a++) { | ||||
| if (wrld->mtex[a]) { | if (wrld->mtex[a]) { | ||||
| writestruct(wd, DATA, MTex, 1, wrld->mtex[a]); | writestruct(wd, DATA, MTex, 1, wrld->mtex[a]); | ||||
| } | } | ||||
| } | } | ||||
| /* nodetree is integral part of world, no libdata */ | /* nodetree is integral part of world, no libdata */ | ||||
| if (wrld->nodetree) { | if (wrld->nodetree) { | ||||
| writestruct(wd, DATA, bNodeTree, 1, wrld->nodetree); | writestruct(wd, DATA, bNodeTree, 1, wrld->nodetree); | ||||
| write_nodetree(wd, wrld->nodetree); | write_nodetree_nolib(wd, wrld->nodetree); | ||||
| } | } | ||||
| write_previews(wd, wrld->preview); | write_previews(wd, wrld->preview); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_lamps(WriteData *wd, ListBase *idbase) | static void write_lamp(WriteData *wd, Lamp *la) | ||||
| { | { | ||||
| for (Lamp *la = idbase->first; la; la = la->id.next) { | |||||
| if (la->id.us > 0 || wd->current) { | if (la->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_LA, Lamp, 1, la); | writestruct(wd, ID_LA, Lamp, 1, la); | ||||
| write_iddata(wd, &la->id); | write_iddata(wd, &la->id); | ||||
| if (la->adt) { | if (la->adt) { | ||||
| write_animdata(wd, la->adt); | write_animdata(wd, la->adt); | ||||
| } | } | ||||
| /* direct data */ | /* direct data */ | ||||
| for (int a = 0; a < MAX_MTEX; a++) { | for (int a = 0; a < MAX_MTEX; a++) { | ||||
| if (la->mtex[a]) { | if (la->mtex[a]) { | ||||
| writestruct(wd, DATA, MTex, 1, la->mtex[a]); | writestruct(wd, DATA, MTex, 1, la->mtex[a]); | ||||
| } | } | ||||
| } | } | ||||
| if (la->curfalloff) { | if (la->curfalloff) { | ||||
| write_curvemapping(wd, la->curfalloff); | write_curvemapping(wd, la->curfalloff); | ||||
| } | } | ||||
| /* nodetree is integral part of lamps, no libdata */ | /* nodetree is integral part of lamps, no libdata */ | ||||
| if (la->nodetree) { | if (la->nodetree) { | ||||
| writestruct(wd, DATA, bNodeTree, 1, la->nodetree); | writestruct(wd, DATA, bNodeTree, 1, la->nodetree); | ||||
| write_nodetree(wd, la->nodetree); | write_nodetree_nolib(wd, la->nodetree); | ||||
| } | } | ||||
| write_previews(wd, la->preview); | write_previews(wd, la->preview); | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_sequence_modifiers(WriteData *wd, ListBase *modbase) | static void write_sequence_modifiers(WriteData *wd, ListBase *modbase) | ||||
| { | { | ||||
| SequenceModifierData *smd; | SequenceModifierData *smd; | ||||
| for (smd = modbase->first; smd; smd = smd->next) { | for (smd = modbase->first; smd; smd = smd->next) { | ||||
| const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); | const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); | ||||
| if (smti) { | if (smti) { | ||||
| Show All 25 Lines | |||||
| static void write_paint(WriteData *wd, Paint *p) | static void write_paint(WriteData *wd, Paint *p) | ||||
| { | { | ||||
| if (p->cavity_curve) { | if (p->cavity_curve) { | ||||
| write_curvemapping(wd, p->cavity_curve); | write_curvemapping(wd, p->cavity_curve); | ||||
| } | } | ||||
| } | } | ||||
| static void write_scenes(WriteData *wd, ListBase *scebase) | static void write_scene(WriteData *wd, Scene *sce) | ||||
| { | { | ||||
| for (Scene *sce = scebase->first; sce; sce = sce->id.next) { | |||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_SCE, Scene, 1, sce); | writestruct(wd, ID_SCE, Scene, 1, sce); | ||||
| write_iddata(wd, &sce->id); | write_iddata(wd, &sce->id); | ||||
| if (sce->adt) { | if (sce->adt) { | ||||
| write_animdata(wd, sce->adt); | write_animdata(wd, sce->adt); | ||||
| } | } | ||||
| write_keyingsets(wd, &sce->keyingsets); | write_keyingsets(wd, &sce->keyingsets); | ||||
| /* direct data */ | /* direct data */ | ||||
| for (Base *base = sce->base.first; base; base = base->next) { | for (Base *base = sce->base.first; base; base = base->next) { | ||||
| writestruct(wd, DATA, Base, 1, base); | writestruct(wd, DATA, Base, 1, base); | ||||
| } | } | ||||
| ToolSettings *tos = sce->toolsettings; | ToolSettings *tos = sce->toolsettings; | ||||
| writestruct(wd, DATA, ToolSettings, 1, tos); | writestruct(wd, DATA, ToolSettings, 1, tos); | ||||
| if (tos->vpaint) { | if (tos->vpaint) { | ||||
| writestruct(wd, DATA, VPaint, 1, tos->vpaint); | writestruct(wd, DATA, VPaint, 1, tos->vpaint); | ||||
| write_paint(wd, &tos->vpaint->paint); | write_paint(wd, &tos->vpaint->paint); | ||||
| } | } | ||||
| if (tos->wpaint) { | if (tos->wpaint) { | ||||
| writestruct(wd, DATA, VPaint, 1, tos->wpaint); | writestruct(wd, DATA, VPaint, 1, tos->wpaint); | ||||
| write_paint(wd, &tos->wpaint->paint); | write_paint(wd, &tos->wpaint->paint); | ||||
| } | } | ||||
| if (tos->sculpt) { | if (tos->sculpt) { | ||||
| writestruct(wd, DATA, Sculpt, 1, tos->sculpt); | writestruct(wd, DATA, Sculpt, 1, tos->sculpt); | ||||
| write_paint(wd, &tos->sculpt->paint); | write_paint(wd, &tos->sculpt->paint); | ||||
| } | } | ||||
| if (tos->uvsculpt) { | if (tos->uvsculpt) { | ||||
| writestruct(wd, DATA, UvSculpt, 1, tos->uvsculpt); | writestruct(wd, DATA, UvSculpt, 1, tos->uvsculpt); | ||||
| write_paint(wd, &tos->uvsculpt->paint); | write_paint(wd, &tos->uvsculpt->paint); | ||||
| } | } | ||||
| /* write grease-pencil drawing brushes to file */ | /* write grease-pencil drawing brushes to file */ | ||||
| writelist(wd, DATA, bGPDbrush, &tos->gp_brushes); | writelist(wd, DATA, bGPDbrush, &tos->gp_brushes); | ||||
| for (bGPDbrush *brush = tos->gp_brushes.first; brush; brush = brush->next) { | for (bGPDbrush *brush = tos->gp_brushes.first; brush; brush = brush->next) { | ||||
| if (brush->cur_sensitivity) { | if (brush->cur_sensitivity) { | ||||
| write_curvemapping(wd, brush->cur_sensitivity); | write_curvemapping(wd, brush->cur_sensitivity); | ||||
| } | } | ||||
| if (brush->cur_strength) { | if (brush->cur_strength) { | ||||
| write_curvemapping(wd, brush->cur_strength); | write_curvemapping(wd, brush->cur_strength); | ||||
| } | } | ||||
| if (brush->cur_jitter) { | if (brush->cur_jitter) { | ||||
| write_curvemapping(wd, brush->cur_jitter); | write_curvemapping(wd, brush->cur_jitter); | ||||
| } | } | ||||
| } | } | ||||
| /* write grease-pencil custom ipo curve to file */ | /* write grease-pencil custom ipo curve to file */ | ||||
| if (tos->gp_interpolate.custom_ipo) { | if (tos->gp_interpolate.custom_ipo) { | ||||
| write_curvemapping(wd, tos->gp_interpolate.custom_ipo); | write_curvemapping(wd, tos->gp_interpolate.custom_ipo); | ||||
| } | } | ||||
| write_paint(wd, &tos->imapaint.paint); | write_paint(wd, &tos->imapaint.paint); | ||||
| Editing *ed = sce->ed; | Editing *ed = sce->ed; | ||||
| if (ed) { | if (ed) { | ||||
| Sequence *seq; | Sequence *seq; | ||||
| writestruct(wd, DATA, Editing, 1, ed); | writestruct(wd, DATA, Editing, 1, ed); | ||||
| /* reset write flags too */ | /* reset write flags too */ | ||||
| SEQ_BEGIN(ed, seq) | SEQ_BEGIN(ed, seq) | ||||
| { | { | ||||
| if (seq->strip) { | if (seq->strip) { | ||||
| seq->strip->done = false; | seq->strip->done = false; | ||||
| } | } | ||||
| writestruct(wd, DATA, Sequence, 1, seq); | writestruct(wd, DATA, Sequence, 1, seq); | ||||
| } | } | ||||
| SEQ_END | SEQ_END | ||||
| SEQ_BEGIN(ed, seq) | SEQ_BEGIN(ed, seq) | ||||
| { | { | ||||
| if (seq->strip && seq->strip->done == 0) { | if (seq->strip && seq->strip->done == 0) { | ||||
| /* write strip with 'done' at 0 because readfile */ | /* write strip with 'done' at 0 because readfile */ | ||||
| if (seq->effectdata) { | if (seq->effectdata) { | ||||
| switch (seq->type) { | switch (seq->type) { | ||||
| case SEQ_TYPE_COLOR: | case SEQ_TYPE_COLOR: | ||||
| writestruct(wd, DATA, SolidColorVars, 1, seq->effectdata); | writestruct(wd, DATA, SolidColorVars, 1, seq->effectdata); | ||||
| break; | break; | ||||
| case SEQ_TYPE_SPEED: | case SEQ_TYPE_SPEED: | ||||
| writestruct(wd, DATA, SpeedControlVars, 1, seq->effectdata); | writestruct(wd, DATA, SpeedControlVars, 1, seq->effectdata); | ||||
| break; | break; | ||||
| case SEQ_TYPE_WIPE: | case SEQ_TYPE_WIPE: | ||||
| writestruct(wd, DATA, WipeVars, 1, seq->effectdata); | writestruct(wd, DATA, WipeVars, 1, seq->effectdata); | ||||
| break; | break; | ||||
| case SEQ_TYPE_GLOW: | case SEQ_TYPE_GLOW: | ||||
| writestruct(wd, DATA, GlowVars, 1, seq->effectdata); | writestruct(wd, DATA, GlowVars, 1, seq->effectdata); | ||||
| break; | break; | ||||
| case SEQ_TYPE_TRANSFORM: | case SEQ_TYPE_TRANSFORM: | ||||
| writestruct(wd, DATA, TransformVars, 1, seq->effectdata); | writestruct(wd, DATA, TransformVars, 1, seq->effectdata); | ||||
| break; | break; | ||||
| case SEQ_TYPE_GAUSSIAN_BLUR: | case SEQ_TYPE_GAUSSIAN_BLUR: | ||||
| writestruct(wd, DATA, GaussianBlurVars, 1, seq->effectdata); | writestruct(wd, DATA, GaussianBlurVars, 1, seq->effectdata); | ||||
| break; | break; | ||||
| case SEQ_TYPE_TEXT: | case SEQ_TYPE_TEXT: | ||||
| writestruct(wd, DATA, TextVars, 1, seq->effectdata); | writestruct(wd, DATA, TextVars, 1, seq->effectdata); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| writestruct(wd, DATA, Stereo3dFormat, 1, seq->stereo3d_format); | writestruct(wd, DATA, Stereo3dFormat, 1, seq->stereo3d_format); | ||||
| Strip *strip = seq->strip; | Strip *strip = seq->strip; | ||||
| writestruct(wd, DATA, Strip, 1, strip); | writestruct(wd, DATA, Strip, 1, strip); | ||||
| if (seq->flag & SEQ_USE_CROP && strip->crop) { | if (seq->flag & SEQ_USE_CROP && strip->crop) { | ||||
| writestruct(wd, DATA, StripCrop, 1, strip->crop); | writestruct(wd, DATA, StripCrop, 1, strip->crop); | ||||
| } | } | ||||
| if (seq->flag & SEQ_USE_TRANSFORM && strip->transform) { | if (seq->flag & SEQ_USE_TRANSFORM && strip->transform) { | ||||
| writestruct(wd, DATA, StripTransform, 1, strip->transform); | writestruct(wd, DATA, StripTransform, 1, strip->transform); | ||||
| } | } | ||||
| if (seq->flag & SEQ_USE_PROXY && strip->proxy) { | if (seq->flag & SEQ_USE_PROXY && strip->proxy) { | ||||
| writestruct(wd, DATA, StripProxy, 1, strip->proxy); | writestruct(wd, DATA, StripProxy, 1, strip->proxy); | ||||
| } | } | ||||
| if (seq->type == SEQ_TYPE_IMAGE) { | if (seq->type == SEQ_TYPE_IMAGE) { | ||||
| writestruct(wd, DATA, StripElem, | writestruct(wd, DATA, StripElem, | ||||
| MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem), | MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem), | ||||
| strip->stripdata); | strip->stripdata); | ||||
| } | } | ||||
| else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) { | else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) { | ||||
| writestruct(wd, DATA, StripElem, 1, strip->stripdata); | writestruct(wd, DATA, StripElem, 1, strip->stripdata); | ||||
| } | } | ||||
| strip->done = true; | strip->done = true; | ||||
| } | } | ||||
| if (seq->prop) { | if (seq->prop) { | ||||
| IDP_WriteProperty(seq->prop, wd); | IDP_WriteProperty(seq->prop, wd); | ||||
| } | } | ||||
| write_sequence_modifiers(wd, &seq->modifiers); | write_sequence_modifiers(wd, &seq->modifiers); | ||||
| } | } | ||||
| SEQ_END | SEQ_END | ||||
| /* new; meta stack too, even when its nasty restore code */ | /* new; meta stack too, even when its nasty restore code */ | ||||
| for (MetaStack *ms = ed->metastack.first; ms; ms = ms->next) { | for (MetaStack *ms = ed->metastack.first; ms; ms = ms->next) { | ||||
| writestruct(wd, DATA, MetaStack, 1, ms); | writestruct(wd, DATA, MetaStack, 1, ms); | ||||
| } | } | ||||
| } | } | ||||
| if (sce->r.avicodecdata) { | if (sce->r.avicodecdata) { | ||||
| writestruct(wd, DATA, AviCodecData, 1, sce->r.avicodecdata); | writestruct(wd, DATA, AviCodecData, 1, sce->r.avicodecdata); | ||||
| if (sce->r.avicodecdata->lpFormat) { | if (sce->r.avicodecdata->lpFormat) { | ||||
| writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat); | writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat); | ||||
| } | } | ||||
| if (sce->r.avicodecdata->lpParms) { | if (sce->r.avicodecdata->lpParms) { | ||||
| writedata(wd, DATA, sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms); | writedata(wd, DATA, sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms); | ||||
| } | } | ||||
| } | } | ||||
| if (sce->r.qtcodecdata) { | if (sce->r.qtcodecdata) { | ||||
| writestruct(wd, DATA, QuicktimeCodecData, 1, sce->r.qtcodecdata); | writestruct(wd, DATA, QuicktimeCodecData, 1, sce->r.qtcodecdata); | ||||
| if (sce->r.qtcodecdata->cdParms) { | if (sce->r.qtcodecdata->cdParms) { | ||||
| writedata(wd, DATA, sce->r.qtcodecdata->cdSize, sce->r.qtcodecdata->cdParms); | writedata(wd, DATA, sce->r.qtcodecdata->cdSize, sce->r.qtcodecdata->cdParms); | ||||
| } | } | ||||
| } | } | ||||
| if (sce->r.ffcodecdata.properties) { | if (sce->r.ffcodecdata.properties) { | ||||
| IDP_WriteProperty(sce->r.ffcodecdata.properties, wd); | IDP_WriteProperty(sce->r.ffcodecdata.properties, wd); | ||||
| } | } | ||||
| /* writing dynamic list of TimeMarkers to the blend file */ | /* writing dynamic list of TimeMarkers to the blend file */ | ||||
| for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) { | for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) { | ||||
| writestruct(wd, DATA, TimeMarker, 1, marker); | writestruct(wd, DATA, TimeMarker, 1, marker); | ||||
| } | } | ||||
| /* writing dynamic list of TransformOrientations to the blend file */ | /* writing dynamic list of TransformOrientations to the blend file */ | ||||
| for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) { | for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) { | ||||
| writestruct(wd, DATA, TransformOrientation, 1, ts); | writestruct(wd, DATA, TransformOrientation, 1, ts); | ||||
| } | } | ||||
| for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) { | for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) { | ||||
| writestruct(wd, DATA, SceneRenderLayer, 1, srl); | writestruct(wd, DATA, SceneRenderLayer, 1, srl); | ||||
| for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) { | for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) { | ||||
| writestruct(wd, DATA, FreestyleModuleConfig, 1, fmc); | writestruct(wd, DATA, FreestyleModuleConfig, 1, fmc); | ||||
| } | } | ||||
| for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) { | for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) { | ||||
| writestruct(wd, DATA, FreestyleLineSet, 1, fls); | writestruct(wd, DATA, FreestyleLineSet, 1, fls); | ||||
| } | } | ||||
| } | } | ||||
| /* writing MultiView to the blend file */ | /* writing MultiView to the blend file */ | ||||
| for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) { | for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) { | ||||
| writestruct(wd, DATA, SceneRenderView, 1, srv); | writestruct(wd, DATA, SceneRenderView, 1, srv); | ||||
| } | } | ||||
| if (sce->nodetree) { | if (sce->nodetree) { | ||||
| writestruct(wd, DATA, bNodeTree, 1, sce->nodetree); | writestruct(wd, DATA, bNodeTree, 1, sce->nodetree); | ||||
| write_nodetree(wd, sce->nodetree); | write_nodetree_nolib(wd, sce->nodetree); | ||||
| } | } | ||||
| write_view_settings(wd, &sce->view_settings); | write_view_settings(wd, &sce->view_settings); | ||||
| /* writing RigidBodyWorld data to the blend file */ | /* writing RigidBodyWorld data to the blend file */ | ||||
| if (sce->rigidbody_world) { | if (sce->rigidbody_world) { | ||||
| writestruct(wd, DATA, RigidBodyWorld, 1, sce->rigidbody_world); | writestruct(wd, DATA, RigidBodyWorld, 1, sce->rigidbody_world); | ||||
| writestruct(wd, DATA, EffectorWeights, 1, sce->rigidbody_world->effector_weights); | writestruct(wd, DATA, EffectorWeights, 1, sce->rigidbody_world->effector_weights); | ||||
| write_pointcaches(wd, &(sce->rigidbody_world->ptcaches)); | write_pointcaches(wd, &(sce->rigidbody_world->ptcaches)); | ||||
| } | } | ||||
| write_previews(wd, sce->preview); | write_previews(wd, sce->preview); | ||||
| write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve); | write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve); | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_gpencil(WriteData *wd, bGPdata *gpd) | ||||
| } | |||||
| static void write_gpencils(WriteData *wd, ListBase *lb) | |||||
| { | { | ||||
| for (bGPdata *gpd = lb->first; gpd; gpd = gpd->id.next) { | |||||
| if (gpd->id.us > 0 || wd->current) { | if (gpd->id.us > 0 || wd->current) { | ||||
| /* write gpd data block to file */ | /* write gpd data block to file */ | ||||
| writestruct(wd, ID_GD, bGPdata, 1, gpd); | writestruct(wd, ID_GD, bGPdata, 1, gpd); | ||||
| write_iddata(wd, &gpd->id); | write_iddata(wd, &gpd->id); | ||||
| if (gpd->adt) { | if (gpd->adt) { | ||||
| write_animdata(wd, gpd->adt); | write_animdata(wd, gpd->adt); | ||||
| } | } | ||||
| /* write grease-pencil layers to file */ | /* write grease-pencil layers to file */ | ||||
| writelist(wd, DATA, bGPDlayer, &gpd->layers); | writelist(wd, DATA, bGPDlayer, &gpd->layers); | ||||
| for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| /* write this layer's frames to file */ | /* write this layer's frames to file */ | ||||
| writelist(wd, DATA, bGPDframe, &gpl->frames); | writelist(wd, DATA, bGPDframe, &gpl->frames); | ||||
| for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | ||||
| /* write strokes */ | /* write strokes */ | ||||
| writelist(wd, DATA, bGPDstroke, &gpf->strokes); | writelist(wd, DATA, bGPDstroke, &gpf->strokes); | ||||
| for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { | for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { | ||||
| writestruct(wd, DATA, bGPDspoint, gps->totpoints, gps->points); | writestruct(wd, DATA, bGPDspoint, gps->totpoints, gps->points); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* write grease-pencil palettes */ | /* write grease-pencil palettes */ | ||||
| writelist(wd, DATA, bGPDpalette, &gpd->palettes); | writelist(wd, DATA, bGPDpalette, &gpd->palettes); | ||||
| for (bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) { | for (bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) { | ||||
| writelist(wd, DATA, bGPDpalettecolor, &palette->colors); | writelist(wd, DATA, bGPDpalettecolor, &palette->colors); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_windowmanager(WriteData *wd, wmWindowManager *wm) | ||||
| } | |||||
| static void write_windowmanagers(WriteData *wd, ListBase *lb) | |||||
| { | { | ||||
| for (wmWindowManager *wm = lb->first; wm; wm = wm->id.next) { | |||||
| writestruct(wd, ID_WM, wmWindowManager, 1, wm); | writestruct(wd, ID_WM, wmWindowManager, 1, wm); | ||||
| write_iddata(wd, &wm->id); | write_iddata(wd, &wm->id); | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | for (wmWindow *win = wm->windows.first; win; win = win->next) { | ||||
| writestruct(wd, DATA, wmWindow, 1, win); | writestruct(wd, DATA, wmWindow, 1, win); | ||||
| writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format); | writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format); | ||||
| } | } | ||||
| } | } | ||||
| /* typically flushing wouldn't be needed however this data _always_ changes, | |||||
| * so flush here for more efficient undo. */ | |||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_region(WriteData *wd, ARegion *ar, int spacetype) | static void write_region(WriteData *wd, ARegion *ar, int spacetype) | ||||
| { | { | ||||
| writestruct(wd, DATA, ARegion, 1, ar); | writestruct(wd, DATA, ARegion, 1, ar); | ||||
| if (ar->regiondata) { | if (ar->regiondata) { | ||||
| switch (spacetype) { | switch (spacetype) { | ||||
| case SPACE_VIEW3D: | case SPACE_VIEW3D: | ||||
| if (ar->regiontype == RGN_TYPE_WINDOW) { | if (ar->regiontype == RGN_TYPE_WINDOW) { | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | else { | ||||
| writestruct_at_address(wd, DATA, SpaceOops, 1, so, &so_flat); | writestruct_at_address(wd, DATA, SpaceOops, 1, so, &so_flat); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| writestruct(wd, DATA, SpaceOops, 1, so); | writestruct(wd, DATA, SpaceOops, 1, so); | ||||
| } | } | ||||
| } | } | ||||
| static void write_screens(WriteData *wd, ListBase *scrbase) | static void write_screen(WriteData *wd, bScreen *sc) | ||||
| { | { | ||||
| for (bScreen *sc = scrbase->first; sc; sc = sc->id.next) { | |||||
| /* write LibData */ | /* write LibData */ | ||||
| /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */ | /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */ | ||||
| writestruct(wd, ID_SCRN, bScreen, 1, sc); | writestruct(wd, ID_SCRN, bScreen, 1, sc); | ||||
| write_iddata(wd, &sc->id); | write_iddata(wd, &sc->id); | ||||
| /* direct data */ | /* direct data */ | ||||
| for (ScrVert *sv = sc->vertbase.first; sv; sv = sv->next) { | for (ScrVert *sv = sc->vertbase.first; sv; sv = sv->next) { | ||||
| writestruct(wd, DATA, ScrVert, 1, sv); | writestruct(wd, DATA, ScrVert, 1, sv); | ||||
| } | } | ||||
| for (ScrEdge *se = sc->edgebase.first; se; se = se->next) { | for (ScrEdge *se = sc->edgebase.first; se; se = se->next) { | ||||
| writestruct(wd, DATA, ScrEdge, 1, se); | writestruct(wd, DATA, ScrEdge, 1, se); | ||||
| } | } | ||||
| for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { | for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { | ||||
| SpaceLink *sl; | SpaceLink *sl; | ||||
| Panel *pa; | Panel *pa; | ||||
| uiList *ui_list; | uiList *ui_list; | ||||
| uiPreview *ui_preview; | uiPreview *ui_preview; | ||||
| PanelCategoryStack *pc_act; | PanelCategoryStack *pc_act; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| writestruct(wd, DATA, ScrArea, 1, sa); | writestruct(wd, DATA, ScrArea, 1, sa); | ||||
| for (ar = sa->regionbase.first; ar; ar = ar->next) { | for (ar = sa->regionbase.first; ar; ar = ar->next) { | ||||
| write_region(wd, ar, sa->spacetype); | write_region(wd, ar, sa->spacetype); | ||||
| for (pa = ar->panels.first; pa; pa = pa->next) { | for (pa = ar->panels.first; pa; pa = pa->next) { | ||||
| writestruct(wd, DATA, Panel, 1, pa); | writestruct(wd, DATA, Panel, 1, pa); | ||||
| } | } | ||||
| for (pc_act = ar->panels_category_active.first; pc_act; pc_act = pc_act->next) { | for (pc_act = ar->panels_category_active.first; pc_act; pc_act = pc_act->next) { | ||||
| writestruct(wd, DATA, PanelCategoryStack, 1, pc_act); | writestruct(wd, DATA, PanelCategoryStack, 1, pc_act); | ||||
| } | } | ||||
| for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) { | for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) { | ||||
| write_uilist(wd, ui_list); | write_uilist(wd, ui_list); | ||||
| } | } | ||||
| for (ui_preview = ar->ui_previews.first; ui_preview; ui_preview = ui_preview->next) { | for (ui_preview = ar->ui_previews.first; ui_preview; ui_preview = ui_preview->next) { | ||||
| writestruct(wd, DATA, uiPreview, 1, ui_preview); | writestruct(wd, DATA, uiPreview, 1, ui_preview); | ||||
| } | } | ||||
| } | } | ||||
| for (sl = sa->spacedata.first; sl; sl = sl->next) { | for (sl = sa->spacedata.first; sl; sl = sl->next) { | ||||
| for (ar = sl->regionbase.first; ar; ar = ar->next) { | for (ar = sl->regionbase.first; ar; ar = ar->next) { | ||||
| write_region(wd, ar, sl->spacetype); | write_region(wd, ar, sl->spacetype); | ||||
| } | } | ||||
| if (sl->spacetype == SPACE_VIEW3D) { | if (sl->spacetype == SPACE_VIEW3D) { | ||||
| View3D *v3d = (View3D *)sl; | View3D *v3d = (View3D *)sl; | ||||
| BGpic *bgpic; | BGpic *bgpic; | ||||
| writestruct(wd, DATA, View3D, 1, v3d); | writestruct(wd, DATA, View3D, 1, v3d); | ||||
| for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { | for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { | ||||
| writestruct(wd, DATA, BGpic, 1, bgpic); | writestruct(wd, DATA, BGpic, 1, bgpic); | ||||
| } | } | ||||
| if (v3d->localvd) { | if (v3d->localvd) { | ||||
| writestruct(wd, DATA, View3D, 1, v3d->localvd); | writestruct(wd, DATA, View3D, 1, v3d->localvd); | ||||
| } | } | ||||
| if (v3d->fx_settings.ssao) { | if (v3d->fx_settings.ssao) { | ||||
| writestruct(wd, DATA, GPUSSAOSettings, 1, v3d->fx_settings.ssao); | writestruct(wd, DATA, GPUSSAOSettings, 1, v3d->fx_settings.ssao); | ||||
| } | } | ||||
| if (v3d->fx_settings.dof) { | if (v3d->fx_settings.dof) { | ||||
| writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof); | writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof); | ||||
| } | } | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_IPO) { | else if (sl->spacetype == SPACE_IPO) { | ||||
| SpaceIpo *sipo = (SpaceIpo *)sl; | SpaceIpo *sipo = (SpaceIpo *)sl; | ||||
| ListBase tmpGhosts = sipo->ghostCurves; | ListBase tmpGhosts = sipo->ghostCurves; | ||||
| /* temporarily disable ghost curves when saving */ | /* temporarily disable ghost curves when saving */ | ||||
| sipo->ghostCurves.first = sipo->ghostCurves.last = NULL; | sipo->ghostCurves.first = sipo->ghostCurves.last = NULL; | ||||
| writestruct(wd, DATA, SpaceIpo, 1, sl); | writestruct(wd, DATA, SpaceIpo, 1, sl); | ||||
| if (sipo->ads) { | if (sipo->ads) { | ||||
| writestruct(wd, DATA, bDopeSheet, 1, sipo->ads); | writestruct(wd, DATA, bDopeSheet, 1, sipo->ads); | ||||
| } | } | ||||
| /* reenable ghost curves */ | /* reenable ghost curves */ | ||||
| sipo->ghostCurves = tmpGhosts; | sipo->ghostCurves = tmpGhosts; | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_BUTS) { | else if (sl->spacetype == SPACE_BUTS) { | ||||
| writestruct(wd, DATA, SpaceButs, 1, sl); | writestruct(wd, DATA, SpaceButs, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_FILE) { | else if (sl->spacetype == SPACE_FILE) { | ||||
| SpaceFile *sfile = (SpaceFile *)sl; | SpaceFile *sfile = (SpaceFile *)sl; | ||||
| writestruct(wd, DATA, SpaceFile, 1, sl); | writestruct(wd, DATA, SpaceFile, 1, sl); | ||||
| if (sfile->params) { | if (sfile->params) { | ||||
| writestruct(wd, DATA, FileSelectParams, 1, sfile->params); | writestruct(wd, DATA, FileSelectParams, 1, sfile->params); | ||||
| } | } | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_SEQ) { | else if (sl->spacetype == SPACE_SEQ) { | ||||
| writestruct(wd, DATA, SpaceSeq, 1, sl); | writestruct(wd, DATA, SpaceSeq, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_OUTLINER) { | else if (sl->spacetype == SPACE_OUTLINER) { | ||||
| SpaceOops *so = (SpaceOops *)sl; | SpaceOops *so = (SpaceOops *)sl; | ||||
| write_soops(wd, so); | write_soops(wd, so); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_IMAGE) { | else if (sl->spacetype == SPACE_IMAGE) { | ||||
| writestruct(wd, DATA, SpaceImage, 1, sl); | writestruct(wd, DATA, SpaceImage, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_TEXT) { | else if (sl->spacetype == SPACE_TEXT) { | ||||
| writestruct(wd, DATA, SpaceText, 1, sl); | writestruct(wd, DATA, SpaceText, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_SCRIPT) { | else if (sl->spacetype == SPACE_SCRIPT) { | ||||
| SpaceScript *scr = (SpaceScript *)sl; | SpaceScript *scr = (SpaceScript *)sl; | ||||
| scr->but_refs = NULL; | scr->but_refs = NULL; | ||||
| writestruct(wd, DATA, SpaceScript, 1, sl); | writestruct(wd, DATA, SpaceScript, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_ACTION) { | else if (sl->spacetype == SPACE_ACTION) { | ||||
| writestruct(wd, DATA, SpaceAction, 1, sl); | writestruct(wd, DATA, SpaceAction, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_NLA) { | else if (sl->spacetype == SPACE_NLA) { | ||||
| SpaceNla *snla = (SpaceNla *)sl; | SpaceNla *snla = (SpaceNla *)sl; | ||||
| writestruct(wd, DATA, SpaceNla, 1, snla); | writestruct(wd, DATA, SpaceNla, 1, snla); | ||||
| if (snla->ads) { | if (snla->ads) { | ||||
| writestruct(wd, DATA, bDopeSheet, 1, snla->ads); | writestruct(wd, DATA, bDopeSheet, 1, snla->ads); | ||||
| } | } | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_TIME) { | else if (sl->spacetype == SPACE_TIME) { | ||||
| writestruct(wd, DATA, SpaceTime, 1, sl); | writestruct(wd, DATA, SpaceTime, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_NODE) { | else if (sl->spacetype == SPACE_NODE) { | ||||
| SpaceNode *snode = (SpaceNode *)sl; | SpaceNode *snode = (SpaceNode *)sl; | ||||
| bNodeTreePath *path; | bNodeTreePath *path; | ||||
| writestruct(wd, DATA, SpaceNode, 1, snode); | writestruct(wd, DATA, SpaceNode, 1, snode); | ||||
| for (path = snode->treepath.first; path; path = path->next) { | for (path = snode->treepath.first; path; path = path->next) { | ||||
| writestruct(wd, DATA, bNodeTreePath, 1, path); | writestruct(wd, DATA, bNodeTreePath, 1, path); | ||||
| } | } | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_LOGIC) { | else if (sl->spacetype == SPACE_LOGIC) { | ||||
| writestruct(wd, DATA, SpaceLogic, 1, sl); | writestruct(wd, DATA, SpaceLogic, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_CONSOLE) { | else if (sl->spacetype == SPACE_CONSOLE) { | ||||
| SpaceConsole *con = (SpaceConsole *)sl; | SpaceConsole *con = (SpaceConsole *)sl; | ||||
| ConsoleLine *cl; | ConsoleLine *cl; | ||||
| for (cl = con->history.first; cl; cl = cl->next) { | for (cl = con->history.first; cl; cl = cl->next) { | ||||
| /* 'len_alloc' is invalid on write, set from 'len' on read */ | /* 'len_alloc' is invalid on write, set from 'len' on read */ | ||||
| writestruct(wd, DATA, ConsoleLine, 1, cl); | writestruct(wd, DATA, ConsoleLine, 1, cl); | ||||
| writedata(wd, DATA, cl->len + 1, cl->line); | writedata(wd, DATA, cl->len + 1, cl->line); | ||||
| } | } | ||||
| writestruct(wd, DATA, SpaceConsole, 1, sl); | writestruct(wd, DATA, SpaceConsole, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_USERPREF) { | else if (sl->spacetype == SPACE_USERPREF) { | ||||
| writestruct(wd, DATA, SpaceUserPref, 1, sl); | writestruct(wd, DATA, SpaceUserPref, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_CLIP) { | else if (sl->spacetype == SPACE_CLIP) { | ||||
| writestruct(wd, DATA, SpaceClip, 1, sl); | writestruct(wd, DATA, SpaceClip, 1, sl); | ||||
| } | } | ||||
| else if (sl->spacetype == SPACE_INFO) { | else if (sl->spacetype == SPACE_INFO) { | ||||
| writestruct(wd, DATA, SpaceInfo, 1, sl); | writestruct(wd, DATA, SpaceInfo, 1, sl); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_bone(WriteData *wd, Bone *bone) | static void write_bone(WriteData *wd, Bone *bone) | ||||
| { | { | ||||
| /* PATCH for upward compatibility after 2.37+ armature recode */ | /* PATCH for upward compatibility after 2.37+ armature recode */ | ||||
| bone->size[0] = bone->size[1] = bone->size[2] = 1.0f; | bone->size[0] = bone->size[1] = bone->size[2] = 1.0f; | ||||
| /* Write this bone */ | /* Write this bone */ | ||||
| writestruct(wd, DATA, Bone, 1, bone); | writestruct(wd, DATA, Bone, 1, bone); | ||||
| /* Write ID Properties -- and copy this comment EXACTLY for easy finding | /* Write ID Properties -- and copy this comment EXACTLY for easy finding | ||||
| * of library blocks that implement this.*/ | * of library blocks that implement this.*/ | ||||
| if (bone->prop) { | if (bone->prop) { | ||||
| IDP_WriteProperty(bone->prop, wd); | IDP_WriteProperty(bone->prop, wd); | ||||
| } | } | ||||
| /* Write Children */ | /* Write Children */ | ||||
| for (Bone *cbone = bone->childbase.first; cbone; cbone = cbone->next) { | for (Bone *cbone = bone->childbase.first; cbone; cbone = cbone->next) { | ||||
| write_bone(wd, cbone); | write_bone(wd, cbone); | ||||
| } | } | ||||
| } | } | ||||
| static void write_armatures(WriteData *wd, ListBase *idbase) | static void write_armature(WriteData *wd, bArmature *arm) | ||||
| { | { | ||||
| for (bArmature *arm = idbase->first; arm; arm = arm->id.next) { | |||||
| if (arm->id.us > 0 || wd->current) { | if (arm->id.us > 0 || wd->current) { | ||||
| writestruct(wd, ID_AR, bArmature, 1, arm); | writestruct(wd, ID_AR, bArmature, 1, arm); | ||||
| write_iddata(wd, &arm->id); | write_iddata(wd, &arm->id); | ||||
| if (arm->adt) { | if (arm->adt) { | ||||
| write_animdata(wd, arm->adt); | write_animdata(wd, arm->adt); | ||||
| } | } | ||||
| /* Direct data */ | /* Direct data */ | ||||
| for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) { | for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) { | ||||
| write_bone(wd, bone); | write_bone(wd, bone); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_text(WriteData *wd, Text *text) | ||||
| } | |||||
| static void write_texts(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Text *text = idbase->first; text; text = text->id.next) { | |||||
| if ((text->flags & TXT_ISMEM) && (text->flags & TXT_ISEXT)) { | if ((text->flags & TXT_ISMEM) && (text->flags & TXT_ISEXT)) { | ||||
| text->flags &= ~TXT_ISEXT; | text->flags &= ~TXT_ISEXT; | ||||
| } | } | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_TXT, Text, 1, text); | writestruct(wd, ID_TXT, Text, 1, text); | ||||
| write_iddata(wd, &text->id); | write_iddata(wd, &text->id); | ||||
| if (text->name) { | if (text->name) { | ||||
| writedata(wd, DATA, strlen(text->name) + 1, 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 */ | /* now write the text data, in two steps for optimization in the readfunction */ | ||||
| for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) { | for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) { | ||||
| writestruct(wd, DATA, TextLine, 1, tmp); | writestruct(wd, DATA, TextLine, 1, tmp); | ||||
| } | } | ||||
| for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) { | for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) { | ||||
| writedata(wd, DATA, tmp->len + 1, tmp->line); | writedata(wd, DATA, tmp->len + 1, tmp->line); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_speaker(WriteData *wd, Speaker *spk) | ||||
| } | |||||
| static void write_speakers(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Speaker *spk = idbase->first; spk; spk = spk->id.next) { | |||||
| if (spk->id.us > 0 || wd->current) { | if (spk->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_SPK, Speaker, 1, spk); | writestruct(wd, ID_SPK, Speaker, 1, spk); | ||||
| write_iddata(wd, &spk->id); | write_iddata(wd, &spk->id); | ||||
| if (spk->adt) { | if (spk->adt) { | ||||
| write_animdata(wd, spk->adt); | write_animdata(wd, spk->adt); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_sounds(WriteData *wd, ListBase *idbase) | static void write_sound(WriteData *wd, bSound *sound) | ||||
| { | { | ||||
| for (bSound *sound = idbase->first; sound; sound = sound->id.next) { | |||||
| if (sound->id.us > 0 || wd->current) { | if (sound->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_SO, bSound, 1, sound); | writestruct(wd, ID_SO, bSound, 1, sound); | ||||
| write_iddata(wd, &sound->id); | write_iddata(wd, &sound->id); | ||||
| if (sound->packedfile) { | if (sound->packedfile) { | ||||
| PackedFile *pf = sound->packedfile; | PackedFile *pf = sound->packedfile; | ||||
| writestruct(wd, DATA, PackedFile, 1, pf); | writestruct(wd, DATA, PackedFile, 1, pf); | ||||
| writedata(wd, DATA, pf->size, pf->data); | writedata(wd, DATA, pf->size, pf->data); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_group(WriteData *wd, Group *group) | ||||
| } | |||||
| static void write_groups(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Group *group = idbase->first; group; group = group->id.next) { | |||||
| if (group->id.us > 0 || wd->current) { | if (group->id.us > 0 || wd->current) { | ||||
| /* write LibData */ | /* write LibData */ | ||||
| writestruct(wd, ID_GR, Group, 1, group); | writestruct(wd, ID_GR, Group, 1, group); | ||||
| write_iddata(wd, &group->id); | write_iddata(wd, &group->id); | ||||
| write_previews(wd, group->preview); | write_previews(wd, group->preview); | ||||
| for (GroupObject *go = group->gobject.first; go; go = go->next) { | for (GroupObject *go = group->gobject.first; go; go = go->next) { | ||||
| writestruct(wd, DATA, GroupObject, 1, go); | writestruct(wd, DATA, GroupObject, 1, go); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_nodetree(WriteData *wd, bNodeTree *ntree) | ||||
| } | |||||
| static void write_nodetrees(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (bNodeTree *ntree = idbase->first; ntree; ntree = ntree->id.next) { | |||||
| if (ntree->id.us > 0 || wd->current) { | if (ntree->id.us > 0 || wd->current) { | ||||
| writestruct(wd, ID_NT, bNodeTree, 1, ntree); | writestruct(wd, ID_NT, bNodeTree, 1, ntree); | ||||
| /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot | /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot | ||||
| * be linked, etc., so we write actual id data here only, for 'real' ID trees. */ | * be linked, etc., so we write actual id data here only, for 'real' ID trees. */ | ||||
| write_iddata(wd, &ntree->id); | write_iddata(wd, &ntree->id); | ||||
| write_nodetree(wd, ntree); | write_nodetree_nolib(wd, ntree); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| #ifdef USE_NODE_COMPAT_CUSTOMNODES | #ifdef USE_NODE_COMPAT_CUSTOMNODES | ||||
| static void customnodes_add_deprecated_data(Main *mainvar) | static void customnodes_add_deprecated_data(Main *mainvar) | ||||
| { | { | ||||
| FOREACH_NODETREE(mainvar, ntree, id) { | FOREACH_NODETREE(mainvar, ntree, id) { | ||||
| bNodeLink *link, *last_link = ntree->links.last; | bNodeLink *link, *last_link = ntree->links.last; | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | for (link = ntree->links.first; link; link = next_link) { | ||||
| nodeRemLink(ntree, link); | nodeRemLink(ntree, link); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_NODETREE_END | FOREACH_NODETREE_END | ||||
| } | } | ||||
| #endif | #endif | ||||
| static void write_brushes(WriteData *wd, ListBase *idbase) | static void write_brush(WriteData *wd, Brush *brush) | ||||
| { | { | ||||
| for (Brush *brush = idbase->first; brush; brush = brush->id.next) { | |||||
| if (brush->id.us > 0 || wd->current) { | if (brush->id.us > 0 || wd->current) { | ||||
| writestruct(wd, ID_BR, Brush, 1, brush); | writestruct(wd, ID_BR, Brush, 1, brush); | ||||
| write_iddata(wd, &brush->id); | write_iddata(wd, &brush->id); | ||||
| if (brush->curve) { | if (brush->curve) { | ||||
| write_curvemapping(wd, brush->curve); | write_curvemapping(wd, brush->curve); | ||||
| } | } | ||||
| if (brush->gradient) { | if (brush->gradient) { | ||||
| writestruct(wd, DATA, ColorBand, 1, brush->gradient); | writestruct(wd, DATA, ColorBand, 1, brush->gradient); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_palettes(WriteData *wd, ListBase *idbase) | static void write_palette(WriteData *wd, Palette *palette) | ||||
| { | { | ||||
| for (Palette *palette = idbase->first; palette; palette = palette->id.next) { | |||||
| if (palette->id.us > 0 || wd->current) { | if (palette->id.us > 0 || wd->current) { | ||||
| PaletteColor *color; | PaletteColor *color; | ||||
| writestruct(wd, ID_PAL, Palette, 1, palette); | writestruct(wd, ID_PAL, Palette, 1, palette); | ||||
| write_iddata(wd, &palette->id); | write_iddata(wd, &palette->id); | ||||
| for (color = palette->colors.first; color; color = color->next) { | for (color = palette->colors.first; color; color = color->next) { | ||||
| writestruct(wd, DATA, PaletteColor, 1, color); | writestruct(wd, DATA, PaletteColor, 1, color); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_paintcurves(WriteData *wd, ListBase *idbase) | static void write_paintcurve(WriteData *wd, PaintCurve *pc) | ||||
| { | { | ||||
| for (PaintCurve *pc = idbase->first; pc; pc = pc->id.next) { | |||||
| if (pc->id.us > 0 || wd->current) { | if (pc->id.us > 0 || wd->current) { | ||||
| writestruct(wd, ID_PC, PaintCurve, 1, pc); | writestruct(wd, ID_PC, PaintCurve, 1, pc); | ||||
| write_iddata(wd, &pc->id); | write_iddata(wd, &pc->id); | ||||
| writestruct(wd, DATA, PaintCurvePoint, pc->tot_points, pc->points); | writestruct(wd, DATA, PaintCurvePoint, pc->tot_points, pc->points); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void write_movieTracks(WriteData *wd, ListBase *tracks) | static void write_movieTracks(WriteData *wd, ListBase *tracks) | ||||
| { | { | ||||
| MovieTrackingTrack *track; | MovieTrackingTrack *track; | ||||
| track = tracks->first; | track = tracks->first; | ||||
| while (track) { | while (track) { | ||||
| writestruct(wd, DATA, MovieTrackingTrack, 1, track); | writestruct(wd, DATA, MovieTrackingTrack, 1, track); | ||||
| Show All 23 Lines | |||||
| static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction) | static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction) | ||||
| { | { | ||||
| if (reconstruction->camnr) { | if (reconstruction->camnr) { | ||||
| writestruct(wd, DATA, MovieReconstructedCamera, reconstruction->camnr, reconstruction->cameras); | writestruct(wd, DATA, MovieReconstructedCamera, reconstruction->camnr, reconstruction->cameras); | ||||
| } | } | ||||
| } | } | ||||
| static void write_movieclips(WriteData *wd, ListBase *idbase) | static void write_movieclip(WriteData *wd, MovieClip *clip) | ||||
| { | { | ||||
| for (MovieClip *clip = idbase->first; clip; clip = clip->id.next) { | |||||
| if (clip->id.us > 0 || wd->current) { | if (clip->id.us > 0 || wd->current) { | ||||
| MovieTracking *tracking = &clip->tracking; | MovieTracking *tracking = &clip->tracking; | ||||
| MovieTrackingObject *object; | MovieTrackingObject *object; | ||||
| writestruct(wd, ID_MC, MovieClip, 1, clip); | writestruct(wd, ID_MC, MovieClip, 1, clip); | ||||
| write_iddata(wd, &clip->id); | write_iddata(wd, &clip->id); | ||||
| if (clip->adt) { | if (clip->adt) { | ||||
| write_animdata(wd, clip->adt); | write_animdata(wd, clip->adt); | ||||
| } | } | ||||
| write_movieTracks(wd, &tracking->tracks); | write_movieTracks(wd, &tracking->tracks); | ||||
| write_moviePlaneTracks(wd, &tracking->plane_tracks); | write_moviePlaneTracks(wd, &tracking->plane_tracks); | ||||
| write_movieReconstruction(wd, &tracking->reconstruction); | write_movieReconstruction(wd, &tracking->reconstruction); | ||||
| object = tracking->objects.first; | object = tracking->objects.first; | ||||
| while (object) { | while (object) { | ||||
| writestruct(wd, DATA, MovieTrackingObject, 1, object); | writestruct(wd, DATA, MovieTrackingObject, 1, object); | ||||
| write_movieTracks(wd, &object->tracks); | write_movieTracks(wd, &object->tracks); | ||||
| write_moviePlaneTracks(wd, &object->plane_tracks); | write_moviePlaneTracks(wd, &object->plane_tracks); | ||||
| write_movieReconstruction(wd, &object->reconstruction); | write_movieReconstruction(wd, &object->reconstruction); | ||||
| object = object->next; | object = object->next; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | static void write_mask(WriteData *wd, Mask *mask) | ||||
| } | |||||
| static void write_masks(WriteData *wd, ListBase *idbase) | |||||
| { | { | ||||
| for (Mask *mask = idbase->first; mask; mask = mask->id.next) { | |||||
| if (mask->id.us > 0 || wd->current) { | if (mask->id.us > 0 || wd->current) { | ||||
| MaskLayer *masklay; | MaskLayer *masklay; | ||||
| writestruct(wd, ID_MSK, Mask, 1, mask); | writestruct(wd, ID_MSK, Mask, 1, mask); | ||||
| write_iddata(wd, &mask->id); | write_iddata(wd, &mask->id); | ||||
| if (mask->adt) { | if (mask->adt) { | ||||
| write_animdata(wd, mask->adt); | write_animdata(wd, mask->adt); | ||||
| } | } | ||||
| for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | ||||
| MaskSpline *spline; | MaskSpline *spline; | ||||
| MaskLayerShape *masklay_shape; | MaskLayerShape *masklay_shape; | ||||
| writestruct(wd, DATA, MaskLayer, 1, masklay); | writestruct(wd, DATA, MaskLayer, 1, masklay); | ||||
| for (spline = masklay->splines.first; spline; spline = spline->next) { | for (spline = masklay->splines.first; spline; spline = spline->next) { | ||||
| int i; | int i; | ||||
| void *points_deform = spline->points_deform; | void *points_deform = spline->points_deform; | ||||
| spline->points_deform = NULL; | spline->points_deform = NULL; | ||||
| writestruct(wd, DATA, MaskSpline, 1, spline); | writestruct(wd, DATA, MaskSpline, 1, spline); | ||||
| writestruct(wd, DATA, MaskSplinePoint, spline->tot_point, spline->points); | writestruct(wd, DATA, MaskSplinePoint, spline->tot_point, spline->points); | ||||
| spline->points_deform = points_deform; | spline->points_deform = points_deform; | ||||
| for (i = 0; i < spline->tot_point; i++) { | for (i = 0; i < spline->tot_point; i++) { | ||||
| MaskSplinePoint *point = &spline->points[i]; | MaskSplinePoint *point = &spline->points[i]; | ||||
| if (point->tot_uw) { | if (point->tot_uw) { | ||||
| writestruct(wd, DATA, MaskSplinePointUW, point->tot_uw, point->uw); | writestruct(wd, DATA, MaskSplinePointUW, point->tot_uw, point->uw); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (masklay_shape = masklay->splines_shapes.first; | for (masklay_shape = masklay->splines_shapes.first; | ||||
| masklay_shape; | masklay_shape; | ||||
| masklay_shape = masklay_shape->next) | masklay_shape = masklay_shape->next) | ||||
| { | { | ||||
| writestruct(wd, DATA, MaskLayerShape, 1, masklay_shape); | writestruct(wd, DATA, MaskLayerShape, 1, masklay_shape); | ||||
| writedata(wd, DATA, | writedata(wd, DATA, | ||||
| masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, | masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, | ||||
| masklay_shape->data); | masklay_shape->data); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mywrite_flush(wd); | |||||
| } | |||||
| static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers) | static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers) | ||||
| { | { | ||||
| LineStyleModifier *m; | LineStyleModifier *m; | ||||
| for (m = modifiers->first; m; m = m->next) { | for (m = modifiers->first; m; m = m->next) { | ||||
| int struct_nr; | int struct_nr; | ||||
| switch (m->type) { | switch (m->type) { | ||||
| case LS_MODIFIER_ALONG_STROKE: | case LS_MODIFIER_ALONG_STROKE: | ||||
| ▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | switch (m->type) { | ||||
| break; | break; | ||||
| default: | default: | ||||
| struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */ | struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */ | ||||
| } | } | ||||
| writestruct_nr(wd, DATA, struct_nr, 1, m); | writestruct_nr(wd, DATA, struct_nr, 1, m); | ||||
| } | } | ||||
| } | } | ||||
| static void write_linestyles(WriteData *wd, ListBase *idbase) | static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle) | ||||
| { | { | ||||
| for (FreestyleLineStyle *linestyle = idbase->first; linestyle; linestyle = linestyle->id.next) { | |||||
| if (linestyle->id.us > 0 || wd->current) { | if (linestyle->id.us > 0 || wd->current) { | ||||
| writestruct(wd, ID_LS, FreestyleLineStyle, 1, linestyle); | writestruct(wd, ID_LS, FreestyleLineStyle, 1, linestyle); | ||||
| write_iddata(wd, &linestyle->id); | write_iddata(wd, &linestyle->id); | ||||
| if (linestyle->adt) { | if (linestyle->adt) { | ||||
| write_animdata(wd, linestyle->adt); | write_animdata(wd, linestyle->adt); | ||||
| } | } | ||||
| write_linestyle_color_modifiers(wd, &linestyle->color_modifiers); | write_linestyle_color_modifiers(wd, &linestyle->color_modifiers); | ||||
| write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers); | write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers); | ||||
| write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers); | write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers); | ||||
| write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers); | write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers); | ||||
| for (int a = 0; a < MAX_MTEX; a++) { | for (int a = 0; a < MAX_MTEX; a++) { | ||||
| if (linestyle->mtex[a]) { | if (linestyle->mtex[a]) { | ||||
| writestruct(wd, DATA, MTex, 1, linestyle->mtex[a]); | writestruct(wd, DATA, MTex, 1, linestyle->mtex[a]); | ||||
| } | } | ||||
| } | } | ||||
| if (linestyle->nodetree) { | if (linestyle->nodetree) { | ||||
| writestruct(wd, DATA, bNodeTree, 1, linestyle->nodetree); | writestruct(wd, DATA, bNodeTree, 1, linestyle->nodetree); | ||||
| write_nodetree(wd, linestyle->nodetree); | write_nodetree_nolib(wd, linestyle->nodetree); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void write_cachefiles(WriteData *wd, ListBase *idbase) | static void write_cachefile(WriteData *wd, CacheFile *cache_file) | ||||
| { | { | ||||
| for (CacheFile *cache_file = idbase->first; cache_file; cache_file = cache_file->id.next) { | |||||
| if (cache_file->id.us > 0 || wd->current) { | if (cache_file->id.us > 0 || wd->current) { | ||||
| writestruct(wd, ID_CF, CacheFile, 1, cache_file); | writestruct(wd, ID_CF, CacheFile, 1, cache_file); | ||||
| if (cache_file->adt) { | if (cache_file->adt) { | ||||
| write_animdata(wd, cache_file->adt); | write_animdata(wd, cache_file->adt); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| /* Keep it last of write_foodata functions. */ | /* Keep it last of write_foodata functions. */ | ||||
| static void write_libraries(WriteData *wd, Main *main) | static void write_libraries(WriteData *wd, Main *main) | ||||
| { | { | ||||
| ListBase *lbarray[MAX_LIBARRAY]; | ListBase *lbarray[MAX_LIBARRAY]; | ||||
| ID *id; | ID *id; | ||||
| int a, tot; | int a, tot; | ||||
| bool found_one; | bool found_one; | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | #endif | ||||
| write_renderinfo(wd, mainvar); | write_renderinfo(wd, mainvar); | ||||
| write_thumb(wd, thumb); | write_thumb(wd, thumb); | ||||
| write_global(wd, write_flags, mainvar); | write_global(wd, write_flags, mainvar); | ||||
| /* The windowmanager and screen often change, | /* The windowmanager and screen often change, | ||||
| * avoid thumbnail detecting changes because of this. */ | * avoid thumbnail detecting changes because of this. */ | ||||
| mywrite_flush(wd); | mywrite_flush(wd); | ||||
| write_windowmanagers(wd, &mainvar->wm); | ListBase *lbarray[MAX_LIBARRAY]; | ||||
| write_screens(wd, &mainvar->screen); | int a = set_listbasepointers(mainvar, lbarray); | ||||
| write_movieclips(wd, &mainvar->movieclip); | while (a--) { | ||||
| write_masks(wd, &mainvar->mask); | ID *id = lbarray[a]->first; | ||||
| write_scenes(wd, &mainvar->scene); | |||||
| write_curves(wd, &mainvar->curve); | if (id && GS(id->name) == ID_LI) { | ||||
| write_mballs(wd, &mainvar->mball); | continue; /* Libraries are handled separately below. */ | ||||
| write_images(wd, &mainvar->image); | } | ||||
| write_cameras(wd, &mainvar->camera); | |||||
| write_lamps(wd, &mainvar->lamp); | for (; id; id = id->next) { | ||||
| write_lattices(wd, &mainvar->latt); | switch ((ID_Type)GS(id->name)) { | ||||
| write_vfonts(wd, &mainvar->vfont); | case ID_WM: | ||||
| write_keys(wd, &mainvar->key); | write_windowmanager(wd, (wmWindowManager *)id); | ||||
| write_worlds(wd, &mainvar->world); | break; | ||||
| write_texts(wd, &mainvar->text); | case ID_SCR: | ||||
| write_speakers(wd, &mainvar->speaker); | write_screen(wd, (bScreen *)id); | ||||
| write_sounds(wd, &mainvar->sound); | break; | ||||
| write_groups(wd, &mainvar->group); | case ID_MC: | ||||
| write_armatures(wd, &mainvar->armature); | write_movieclip(wd, (MovieClip *)id); | ||||
| write_actions(wd, &mainvar->action); | break; | ||||
| write_objects(wd, &mainvar->object); | case ID_MSK: | ||||
| write_materials(wd, &mainvar->mat); | write_mask(wd, (Mask *)id); | ||||
| write_textures(wd, &mainvar->tex); | break; | ||||
| write_meshes(wd, &mainvar->mesh); | case ID_SCE: | ||||
| write_particlesettings(wd, &mainvar->particle); | write_scene(wd, (Scene *)id); | ||||
| write_nodetrees(wd, &mainvar->nodetree); | break; | ||||
| write_brushes(wd, &mainvar->brush); | case ID_CU: | ||||
| write_palettes(wd, &mainvar->palettes); | write_curve(wd,(Curve *)id); | ||||
| write_paintcurves(wd, &mainvar->paintcurves); | break; | ||||
| write_gpencils(wd, &mainvar->gpencil); | case ID_MB: | ||||
| write_linestyles(wd, &mainvar->linestyle); | write_mball(wd, (MetaBall *)id); | ||||
| write_cachefiles(wd, &mainvar->cachefiles); | break; | ||||
| case ID_IM: | |||||
| write_image(wd, (Image *)id); | |||||
| break; | |||||
| case ID_CA: | |||||
| write_camera(wd, (Camera *)id); | |||||
| break; | |||||
| case ID_LA: | |||||
| write_lamp(wd, (Lamp *)id); | |||||
| break; | |||||
| case ID_LT: | |||||
| write_lattice(wd, (Lattice *)id); | |||||
| break; | |||||
| case ID_VF: | |||||
| write_vfont(wd, (VFont *)id); | |||||
| break; | |||||
| case ID_KE: | |||||
| write_key(wd, (Key *)id); | |||||
| break; | |||||
| case ID_WO: | |||||
| write_world(wd, (World *)id); | |||||
| break; | |||||
| case ID_TXT: | |||||
| write_text(wd, (Text *)id); | |||||
| break; | |||||
| case ID_SPK: | |||||
| write_speaker(wd, (Speaker *)id); | |||||
| break; | |||||
| case ID_SO: | |||||
| write_sound(wd, (bSound *)id); | |||||
| break; | |||||
| case ID_GR: | |||||
| write_group(wd, (Group *)id); | |||||
| break; | |||||
| case ID_AR: | |||||
| write_armature(wd, (bArmature *)id); | |||||
| break; | |||||
| case ID_AC: | |||||
| write_action(wd, (bAction *)id); | |||||
| break; | |||||
| case ID_OB: | |||||
| write_object(wd, (Object *)id); | |||||
| break; | |||||
| case ID_MA: | |||||
| write_material(wd, (Material *)id); | |||||
| break; | |||||
| case ID_TE: | |||||
| write_texture(wd, (Tex *)id); | |||||
| break; | |||||
| case ID_ME: | |||||
| write_mesh(wd, (Mesh *)id); | |||||
| break; | |||||
| case ID_PA: | |||||
| write_particlesettings(wd, (ParticleSettings *)id); | |||||
| break; | |||||
| case ID_NT: | |||||
| write_nodetree(wd, (bNodeTree *)id); | |||||
| break; | |||||
| case ID_BR: | |||||
| write_brush(wd, (Brush *)id); | |||||
| break; | |||||
| case ID_PAL: | |||||
| write_palette(wd, (Palette *)id); | |||||
| break; | |||||
| case ID_PC: | |||||
| write_paintcurve(wd, (PaintCurve *)id); | |||||
| break; | |||||
| case ID_GD: | |||||
| write_gpencil(wd, (bGPdata *)id); | |||||
| break; | |||||
| case ID_LS: | |||||
| write_linestyle(wd, (FreestyleLineStyle *)id); | |||||
| break; | |||||
| case ID_CF: | |||||
| write_cachefile(wd, (CacheFile *)id); | |||||
| break; | |||||
| case ID_LI: | |||||
| /* Do nothing, handled below - and should never be reached. */ | |||||
| BLI_assert(0); | |||||
| break; | |||||
| case ID_IP: | |||||
| /* Do nothing, deprecated. */ | |||||
| break; | |||||
| } | |||||
campbellbarton: should add assert for default case, nice to error incase people forget adding new datablocks. | |||||
| } | |||||
| mywrite_flush(wd); | |||||
| } | |||||
| /* Special handling, operating over split Mains... */ | |||||
| write_libraries(wd, mainvar->next); | write_libraries(wd, mainvar->next); | ||||
| /* So changes above don't cause a 'DNA1' to be detected as changed on undo. */ | /* So changes above don't cause a 'DNA1' to be detected as changed on undo. */ | ||||
| mywrite_flush(wd); | mywrite_flush(wd); | ||||
| if (write_flags & G_FILE_USERPREFS) { | if (write_flags & G_FILE_USERPREFS) { | ||||
| write_userdef(wd); | write_userdef(wd); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 183 Lines • Show Last 20 Lines | |||||
should add assert for default case, nice to error incase people forget adding new datablocks.