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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-05-04 19:42:49 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-05-04 19:42:49 +0400
commit1fd397d2d6ce5f9036c606963060eaf5f49d72c4 (patch)
tree1d7de6cee0d166587857679d606f0574a87d9a79 /source/blender/blenloader
parent65b5362c74acbba58c3098715660e441ab25141b (diff)
Split do_versions into separate files for pre-2.50 versions and 2.5x versions
This should make it easier to navigate through readfile.c and also hopefully will prevent corereview to fail parsing this file.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/CMakeLists.txt2
-rw-r--r--source/blender/blenloader/intern/readfile.c6017
-rw-r--r--source/blender/blenloader/intern/readfile.h18
-rw-r--r--source/blender/blenloader/intern/versioning_250.c2677
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c3570
5 files changed, 6290 insertions, 5994 deletions
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 35271f7b873..a0fe042e7fb 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -44,6 +44,8 @@ set(SRC
intern/readfile.c
intern/runtime.c
intern/undofile.c
+ intern/versioning_250.c
+ intern/versioning_legacy.c
intern/writefile.c
BLO_readfile.h
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index df71a9f6494..cab45f58e2e 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -328,6 +328,11 @@ static void oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int n
entry->nr= nr;
}
+void blo_do_versions_oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int nr)
+{
+ oldnewmap_insert(onm, oldaddr, newaddr, nr);
+}
+
static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr)
{
int i;
@@ -1177,6 +1182,11 @@ static void *newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */
return oldnewmap_liblookup(fd->libmap, adr, lib);
}
+void *blo_do_versions_newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */
+{
+ return newlibadr(fd, lib, adr);
+}
+
static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */
{
ID *id= newlibadr(fd, lib, adr);
@@ -1187,6 +1197,11 @@ static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user
return id;
}
+void *blo_do_versions_newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */
+{
+ return newlibadr_us(fd, lib, adr);
+}
+
static void change_idid_adr_fd(FileData *fd, void *old, void *new)
{
int i;
@@ -2202,7 +2217,7 @@ static void do_versions_socket_default_value(bNodeSocket *sock)
}
}
-static void do_versions_nodetree_default_value(bNodeTree *ntree)
+void blo_do_versions_nodetree_default_value(bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
@@ -2225,7 +2240,7 @@ static void lib_nodetree_init_types_cb(void *UNUSED(data), ID *UNUSED(id), bNode
ntreeInitTypes(ntree);
/* need to do this here instead of in do_versions, otherwise next function can crash */
- do_versions_nodetree_default_value(ntree);
+ blo_do_versions_nodetree_default_value(ntree);
/* XXX could be replaced by do_versions for new nodes */
for (node=ntree->nodes.first; node; node=node->next)
@@ -5713,7 +5728,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
/* for the saved 2.50 files without regiondata */
/* and as patch for 2.48 and older */
-static void view3d_split_250(View3D *v3d, ListBase *regions)
+void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
{
ARegion *ar;
@@ -5799,7 +5814,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
}
/* add local view3d too */
else if (sa->spacetype==SPACE_VIEW3D)
- view3d_split_250(sa->spacedata.first, &sa->regionbase);
+ blo_do_versions_view3d_split_250(sa->spacedata.first, &sa->regionbase);
for (sl= sa->spacedata.first; sl; sl= sl->next) {
link_list(fd, &(sl->regionbase));
@@ -5839,7 +5854,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
if (v3d->drawtype == OB_RENDER)
v3d->drawtype = OB_WIRE;
- view3d_split_250(v3d, &sl->regionbase);
+ blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
}
else if (sl->spacetype==SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo*)sl;
@@ -6494,1012 +6509,7 @@ static void link_global(FileData *fd, BlendFileData *bfd)
}
}
-static void vcol_to_fcol(Mesh *me)
-{
- MFace *mface;
- unsigned int *mcol, *mcoln, *mcolmain;
- int a;
-
- if (me->totface==0 || me->mcol==NULL) return;
-
- mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln");
- mcol = (unsigned int *)me->mcol;
- mface= me->mface;
- for (a=me->totface; a>0; a--, mface++) {
- mcoln[0]= mcol[mface->v1];
- mcoln[1]= mcol[mface->v2];
- mcoln[2]= mcol[mface->v3];
- mcoln[3]= mcol[mface->v4];
- mcoln+= 4;
- }
-
- MEM_freeN(me->mcol);
- me->mcol= (MCol *)mcolmain;
-}
-
-static int map_223_keybd_code_to_224_keybd_code(int code)
-{
- switch (code) {
- case 312: return 311; /* F12KEY */
- case 159: return 161; /* PADSLASHKEY */
- case 161: return 150; /* PAD0 */
- case 154: return 151; /* PAD1 */
- case 150: return 152; /* PAD2 */
- case 155: return 153; /* PAD3 */
- case 151: return 154; /* PAD4 */
- case 156: return 155; /* PAD5 */
- case 152: return 156; /* PAD6 */
- case 157: return 157; /* PAD7 */
- case 153: return 158; /* PAD8 */
- case 158: return 159; /* PAD9 */
- default: return code;
- }
-}
-
-static void do_version_bone_head_tail_237(Bone *bone)
-{
- Bone *child;
- float vec[3];
-
- /* head */
- copy_v3_v3(bone->arm_head, bone->arm_mat[3]);
-
- /* tail is in current local coord system */
- copy_v3_v3(vec, bone->arm_mat[1]);
- mul_v3_fl(vec, bone->length);
- add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
-
- for (child= bone->childbase.first; child; child= child->next)
- do_version_bone_head_tail_237(child);
-}
-
-static void bone_version_238(ListBase *lb)
-{
- Bone *bone;
-
- for (bone= lb->first; bone; bone= bone->next) {
- if (bone->rad_tail==0.0f && bone->rad_head==0.0f) {
- bone->rad_head= 0.25f*bone->length;
- bone->rad_tail= 0.1f*bone->length;
-
- bone->dist-= bone->rad_head;
- if (bone->dist<=0.0f) bone->dist= 0.0f;
- }
- bone_version_238(&bone->childbase);
- }
-}
-
-static void bone_version_239(ListBase *lb)
-{
- Bone *bone;
-
- for (bone= lb->first; bone; bone= bone->next) {
- if (bone->layer==0)
- bone->layer= 1;
- bone_version_239(&bone->childbase);
- }
-}
-
-static void ntree_version_241(bNodeTree *ntree)
-{
- bNode *node;
-
- if (ntree->type==NTREE_COMPOSIT) {
- for (node= ntree->nodes.first; node; node= node->next) {
- if (node->type==CMP_NODE_BLUR) {
- if (node->storage==NULL) {
- NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch");
- nbd->sizex= node->custom1;
- nbd->sizey= node->custom2;
- nbd->filtertype= R_FILTER_QUAD;
- node->storage= nbd;
- }
- }
- else if (node->type==CMP_NODE_VECBLUR) {
- if (node->storage==NULL) {
- NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch");
- nbd->samples= node->custom1;
- nbd->maxspeed= node->custom2;
- nbd->fac= 1.0f;
- node->storage= nbd;
- }
- }
- }
- }
-}
-
-static void ntree_version_242(bNodeTree *ntree)
-{
- bNode *node;
-
- if (ntree->type==NTREE_COMPOSIT) {
- for (node= ntree->nodes.first; node; node= node->next) {
- if (node->type==CMP_NODE_HUE_SAT) {
- if (node->storage) {
- NodeHueSat *nhs= node->storage;
- if (nhs->val==0.0f) nhs->val= 1.0f;
- }
- }
- }
- }
- else if (ntree->type==NTREE_SHADER) {
- for (node= ntree->nodes.first; node; node= node->next)
- if (node->type == SH_NODE_GEOMETRY && node->storage == NULL)
- node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
- }
-
-}
-
-static void customdata_version_242(Mesh *me)
-{
- CustomDataLayer *layer;
- MTFace *mtf;
- MCol *mcol;
- TFace *tf;
- int a, mtfacen, mcoln;
-
- if (!me->vdata.totlayer) {
- CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert);
-
- if (me->msticky)
- CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_ASSIGN, me->msticky, me->totvert);
- if (me->dvert)
- CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert);
- }
-
- if (!me->edata.totlayer)
- CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge);
-
- if (!me->fdata.totlayer) {
- CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface);
-
- if (me->tface) {
- if (me->mcol)
- MEM_freeN(me->mcol);
-
- me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
- me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface);
-
- mtf= me->mtface;
- mcol= me->mcol;
- tf= me->tface;
-
- for (a=0; a < me->totface; a++, mtf++, tf++, mcol+=4) {
- memcpy(mcol, tf->col, sizeof(tf->col));
- memcpy(mtf->uv, tf->uv, sizeof(tf->uv));
-
- mtf->flag= tf->flag;
- mtf->unwrap= tf->unwrap;
- mtf->mode= tf->mode;
- mtf->tile= tf->tile;
- mtf->tpage= tf->tpage;
- mtf->transp= tf->transp;
- }
-
- MEM_freeN(me->tface);
- me->tface= NULL;
- }
- else if (me->mcol) {
- me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface);
- }
- }
-
- if (me->tface) {
- MEM_freeN(me->tface);
- me->tface= NULL;
- }
-
- for (a=0, mtfacen=0, mcoln=0; a < me->fdata.totlayer; a++) {
- layer= &me->fdata.layers[a];
-
- if (layer->type == CD_MTFACE) {
- if (layer->name[0] == 0) {
- if (mtfacen == 0) strcpy(layer->name, "UVMap");
- else BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen);
- }
- mtfacen++;
- }
- else if (layer->type == CD_MCOL) {
- if (layer->name[0] == 0) {
- if (mcoln == 0) strcpy(layer->name, "Col");
- else BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln);
- }
- mcoln++;
- }
- }
-
- mesh_update_customdata_pointers(me, TRUE);
-}
-
-/*only copy render texface layer from active*/
-static void customdata_version_243(Mesh *me)
-{
- CustomDataLayer *layer;
- int a;
-
- for (a=0; a < me->fdata.totlayer; a++) {
- layer= &me->fdata.layers[a];
- layer->active_rnd = layer->active;
- }
-}
-
-/* struct NodeImageAnim moved to ImageUser, and we make it default available */
-static void do_version_ntree_242_2(bNodeTree *ntree)
-{
- bNode *node;
-
- if (ntree->type==NTREE_COMPOSIT) {
- for (node= ntree->nodes.first; node; node= node->next) {
- if (ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
- /* only image had storage */
- if (node->storage) {
- NodeImageAnim *nia= node->storage;
- ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "ima user node");
-
- iuser->frames= nia->frames;
- iuser->sfra= nia->sfra;
- iuser->offset= nia->nr-1;
- iuser->cycl= nia->cyclic;
- iuser->fie_ima= 2;
- iuser->ok= 1;
-
- node->storage= iuser;
- MEM_freeN(nia);
- }
- else {
- ImageUser *iuser= node->storage= MEM_callocN(sizeof(ImageUser), "node image user");
- iuser->sfra= 1;
- iuser->fie_ima= 2;
- iuser->ok= 1;
- }
- }
- }
- }
-}
-
-static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree)
-{
- bNode *node;
- NodeTwoFloats *ntf;
- ID *nodeid;
- Image *image;
- ImageUser *iuser;
-
- if (ntree->type==NTREE_COMPOSIT) {
- for (node= ntree->nodes.first; node; node= node->next) {
- if (node->type == CMP_NODE_ALPHAOVER) {
- if (!node->storage) {
- ntf= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats");
- node->storage= ntf;
- if (node->custom1)
- ntf->x= 1.0f;
- }
- }
-
- /* fix for temporary flag changes during 245 cycle */
- nodeid= newlibadr(fd, lib, node->id);
- if (node->storage && nodeid && GS(nodeid->name) == ID_IM) {
- image= (Image*)nodeid;
- iuser= node->storage;
- if (iuser->flag & IMA_OLD_PREMUL) {
- iuser->flag &= ~IMA_OLD_PREMUL;
- iuser->flag |= IMA_DO_PREMUL;
- }
- if (iuser->flag & IMA_DO_PREMUL) {
- image->flag &= ~IMA_OLD_PREMUL;
- image->flag |= IMA_DO_PREMUL;
- }
- }
- }
- }
-}
-
-static void idproperties_fix_groups_lengths_recurse(IDProperty *prop)
-{
- IDProperty *loop;
- int i;
-
- for (loop=prop->data.group.first, i=0; loop; loop=loop->next, i++) {
- if (loop->type == IDP_GROUP) idproperties_fix_groups_lengths_recurse(loop);
- }
-
- if (prop->len != i) {
- printf("Found and fixed bad id property group length.\n");
- prop->len = i;
- }
-}
-
-static void idproperties_fix_group_lengths(ListBase idlist)
-{
- ID *id;
-
- for (id=idlist.first; id; id=id->next) {
- if (id->properties) {
- idproperties_fix_groups_lengths_recurse(id->properties);
- }
- }
-}
-
-static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me)
-{
- Material *ma;
- MFace *mf;
- MTFace *tf;
- int a, b, texalpha;
-
- /* verify we have a tface layer */
- for (b=0; b<me->fdata.totlayer; b++)
- if (me->fdata.layers[b].type == CD_MTFACE)
- break;
-
- if (b == me->fdata.totlayer)
- return;
-
- /* if we do, set alpha sort if the game engine did it before */
- for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
- if (mf->mat_nr < me->totcol) {
- ma= newlibadr(fd, lib, me->mat[mf->mat_nr]);
- texalpha = 0;
-
- /* we can't read from this if it comes from a library,
- * because direct_link might not have happened on it,
- * so ma->mtex is not pointing to valid memory yet */
- if (ma && ma->id.lib)
- ma= NULL;
-
- for (b=0; ma && b<MAX_MTEX; b++)
- if (ma->mtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA)
- texalpha = 1;
- }
- else {
- ma= NULL;
- texalpha = 0;
- }
-
- for (b=0; b<me->fdata.totlayer; b++) {
- if (me->fdata.layers[b].type == CD_MTFACE) {
- tf = ((MTFace*)me->fdata.layers[b].data) + a;
-
- tf->mode &= ~TF_ALPHASORT;
- if (ma && (ma->mode & MA_ZTRANSP))
- if (ELEM(tf->transp, TF_ALPHA, TF_ADD) || (texalpha && (tf->transp != TF_CLIP)))
- tf->mode |= TF_ALPHASORT;
- }
- }
- }
-}
-
-/* 2.50 patch */
-static void area_add_header_region(ScrArea *sa, ListBase *lb)
-{
- ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
-
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_HEADER;
- if (sa->headertype==HEADERDOWN)
- ar->alignment= RGN_ALIGN_BOTTOM;
- else
- ar->alignment= RGN_ALIGN_TOP;
-
- /* initialize view2d data for header region, to allow panning */
- /* is copy from ui_view2d.c */
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
- ar->v2d.keepofs = V2D_LOCKOFS_Y;
- ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
- ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y;
- ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
-}
-
-static void sequencer_init_preview_region(ARegion* ar)
-{
- // XXX a bit ugly still, copied from space_sequencer
- /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
- ar->regiontype= RGN_TYPE_PREVIEW;
- ar->alignment= RGN_ALIGN_TOP;
- ar->flag |= RGN_FLAG_HIDDEN;
- ar->v2d.keepzoom= V2D_KEEPASPECT | V2D_KEEPZOOM;
- ar->v2d.minzoom= 0.00001f;
- ar->v2d.maxzoom= 100000.0f;
- ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */
- ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */
- ar->v2d.tot.xmax = 960.0f;
- ar->v2d.tot.ymax = 540.0f;
- ar->v2d.min[0]= 0.0f;
- ar->v2d.min[1]= 0.0f;
- ar->v2d.max[0]= 12000.0f;
- ar->v2d.max[1]= 12000.0f;
- ar->v2d.cur= ar->v2d.tot;
- ar->v2d.align= V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
- ar->v2d.keeptot= V2D_KEEPTOT_FREE;
-}
-
-/* 2.50 patch */
-static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
-{
- ARegion *ar;
- ARegion *ar_main;
-
- if (sl) {
- /* first channels for ipo action nla... */
- switch (sl->spacetype) {
- case SPACE_IPO:
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_CHANNELS;
- ar->alignment= RGN_ALIGN_LEFT;
- ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
-
- // for some reason, this doesn't seem to go auto like for NLA...
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_RIGHT;
- ar->v2d.scroll= V2D_SCROLL_RIGHT;
- ar->v2d.flag = RGN_FLAG_HIDDEN;
- break;
-
- case SPACE_ACTION:
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_CHANNELS;
- ar->alignment= RGN_ALIGN_LEFT;
- ar->v2d.scroll= V2D_SCROLL_BOTTOM;
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
- break;
-
- case SPACE_NLA:
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_CHANNELS;
- ar->alignment= RGN_ALIGN_LEFT;
- ar->v2d.scroll= V2D_SCROLL_BOTTOM;
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
- // for some reason, some files still don't get this auto
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_RIGHT;
- ar->v2d.scroll= V2D_SCROLL_RIGHT;
- ar->v2d.flag = RGN_FLAG_HIDDEN;
- break;
-
- case SPACE_NODE:
- ar= MEM_callocN(sizeof(ARegion), "nodetree area for node");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_LEFT;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
- /* temporarily hide it */
- ar->flag = RGN_FLAG_HIDDEN;
- break;
- case SPACE_FILE:
- ar= MEM_callocN(sizeof(ARegion), "nodetree area for node");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_CHANNELS;
- ar->alignment= RGN_ALIGN_LEFT;
-
- ar= MEM_callocN(sizeof(ARegion), "ui area for file");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_TOP;
- break;
- case SPACE_SEQ:
- ar_main = (ARegion*)lb->first;
- for (; ar_main; ar_main = ar_main->next) {
- if (ar_main->regiontype == RGN_TYPE_WINDOW)
- break;
- }
- ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
- BLI_insertlinkbefore(lb, ar_main, ar);
- sequencer_init_preview_region(ar);
- break;
- case SPACE_VIEW3D:
- /* toolbar */
- ar= MEM_callocN(sizeof(ARegion), "toolbar for view3d");
-
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_TOOLS;
- ar->alignment= RGN_ALIGN_LEFT;
- ar->flag = RGN_FLAG_HIDDEN;
-
- /* tool properties */
- ar= MEM_callocN(sizeof(ARegion), "tool properties for view3d");
-
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_TOOL_PROPS;
- ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
- ar->flag = RGN_FLAG_HIDDEN;
-
- /* buttons/list view */
- ar= MEM_callocN(sizeof(ARegion), "buttons for view3d");
-
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_RIGHT;
- ar->flag = RGN_FLAG_HIDDEN;
-#if 0
- case SPACE_BUTS:
- /* context UI region */
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_RIGHT;
-
- break;
-#endif
- }
- }
-
- /* main region */
- ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
-
- BLI_addtail(lb, ar);
- ar->winrct= sa->totrct;
-
- ar->regiontype= RGN_TYPE_WINDOW;
-
- if (sl) {
- /* if active spacetype has view2d data, copy that over to main region */
- /* and we split view3d */
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- view3d_split_250((View3D *)sl, lb);
- break;
-
- case SPACE_OUTLINER:
- {
- SpaceOops *soops= (SpaceOops *)sl;
-
- memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
-
- ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O);
- ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
- ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT);
- ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
- ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
- //ar->v2d.flag |= V2D_IS_INITIALISED;
- }
- break;
- case SPACE_TIME:
- {
- SpaceTime *stime= (SpaceTime *)sl;
- memcpy(&ar->v2d, &stime->v2d, sizeof(View2D));
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
- ar->v2d.keepofs |= V2D_LOCKOFS_Y;
- ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
- ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0;
- ar->v2d.min[1]= ar->v2d.max[1]= 20.0;
- }
- break;
- case SPACE_IPO:
- {
- SpaceIpo *sipo= (SpaceIpo *)sl;
- memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D));
-
- /* init mainarea view2d */
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
-
- ar->v2d.min[0]= FLT_MIN;
- ar->v2d.min[1]= FLT_MIN;
-
- ar->v2d.max[0]= MAXFRAMEF;
- ar->v2d.max[1]= FLT_MAX;
-
- //ar->v2d.flag |= V2D_IS_INITIALISED;
- break;
- }
- case SPACE_NLA:
- {
- SpaceNla *snla= (SpaceNla *)sl;
- memcpy(&ar->v2d, &snla->v2d, sizeof(View2D));
-
- ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f;
- ar->v2d.tot.ymax = 0.0f;
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
- ar->v2d.align = V2D_ALIGN_NO_POS_Y;
- ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
- break;
- }
- case SPACE_ACTION:
- {
- SpaceAction *saction= (SpaceAction *)sl;
-
- /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
- ar->v2d.tot.xmin = -20.0f;
- ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f;
- ar->v2d.tot.xmax = (float)((sa->winx > 120)? (sa->winx) : 120);
- ar->v2d.tot.ymax = 0.0f;
-
- ar->v2d.cur= ar->v2d.tot;
-
- ar->v2d.min[0]= 0.0f;
- ar->v2d.min[1]= 0.0f;
-
- ar->v2d.max[0]= MAXFRAMEF;
- ar->v2d.max[1]= FLT_MAX;
-
- ar->v2d.minzoom= 0.01f;
- ar->v2d.maxzoom= 50;
- ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
- ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
- ar->v2d.align= V2D_ALIGN_NO_POS_Y;
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
- /* for old files with ShapeKey editors open + an action set, clear the action as
- * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
- * only shows ShapeKey-rooted actions only)
- */
- if (saction->mode == SACTCONT_SHAPEKEY)
- saction->action = NULL;
- break;
- }
- case SPACE_SEQ:
- {
- SpaceSeq *sseq= (SpaceSeq *)sl;
- memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D));
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
- ar->v2d.align= V2D_ALIGN_NO_NEG_Y;
- ar->v2d.flag |= V2D_IS_INITIALISED;
- break;
- }
- case SPACE_NODE:
- {
- SpaceNode *snode= (SpaceNode *)sl;
- memcpy(&ar->v2d, &snode->v2d, sizeof(View2D));
-
- ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT;
- break;
- }
- case SPACE_BUTS:
- {
- SpaceButs *sbuts= (SpaceButs *)sl;
- memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D));
-
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- break;
- }
- case SPACE_FILE:
- {
- // SpaceFile *sfile= (SpaceFile *)sl;
- ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0;
- ar->v2d.tot.xmax = ar->winx;
- ar->v2d.tot.ymax = ar->winy;
- ar->v2d.cur = ar->v2d.tot;
- ar->regiontype= RGN_TYPE_WINDOW;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O);
- ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
- break;
- }
- case SPACE_TEXT:
- {
- SpaceText *st= (SpaceText *)sl;
- st->flags |= ST_FIND_WRAP;
- }
- //case SPACE_XXX: // FIXME... add other ones
- // memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
- // break;
- }
- }
-}
-
-static void do_versions_windowmanager_2_50(bScreen *screen)
-{
- ScrArea *sa;
- SpaceLink *sl;
-
- /* add regions */
- for (sa= screen->areabase.first; sa; sa= sa->next) {
-
- /* we keep headertype variable to convert old files only */
- if (sa->headertype)
- area_add_header_region(sa, &sa->regionbase);
-
- area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase);
-
- /* space imageselect is deprecated */
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_IMASEL)
- sl->spacetype= SPACE_EMPTY; /* spacedata then matches */
- }
-
- /* space sound is deprecated */
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_SOUND)
- sl->spacetype= SPACE_EMPTY; /* spacedata then matches */
- }
-
- /* it seems to be possible in 2.5 to have this saved, filewindow probably */
- sa->butspacetype= sa->spacetype;
-
- /* pushed back spaces also need regions! */
- if (sa->spacedata.first) {
- sl= sa->spacedata.first;
- for (sl= sl->next; sl; sl= sl->next) {
- if (sa->headertype)
- area_add_header_region(sa, &sl->regionbase);
- area_add_window_regions(sa, sl, &sl->regionbase);
- }
- }
- }
-}
-
-static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name)
-{
-
- BLI_addtail(lb, id);
- id->us= 1;
- id->flag= LIB_FAKEUSER;
- *( (short *)id->name )= ID_GD;
-
- new_id(lb, id, name);
- /* alphabetic insterion: is in new_id */
-
- if (G.debug & G_DEBUG)
- printf("Converted GPencil to ID: %s\n", id->name+2);
-}
-
-static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
-{
- ScrArea *sa;
- SpaceLink *sl;
-
- /* add regions */
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
- if (v3d->gpd) {
- versions_gpencil_add_main(&main->gpencil, (ID *)v3d->gpd, "GPencil View3D");
- v3d->gpd= NULL;
- }
- }
- else if (sl->spacetype==SPACE_NODE) {
- SpaceNode *snode= (SpaceNode *)sl;
- if (snode->gpd) {
- versions_gpencil_add_main(&main->gpencil, (ID *)snode->gpd, "GPencil Node");
- snode->gpd= NULL;
- }
- }
- else if (sl->spacetype==SPACE_SEQ) {
- SpaceSeq *sseq= (SpaceSeq *)sl;
- if (sseq->gpd) {
- versions_gpencil_add_main(&main->gpencil, (ID *)sseq->gpd, "GPencil Node");
- sseq->gpd= NULL;
- }
- }
- else if (sl->spacetype==SPACE_IMAGE) {
- SpaceImage *sima= (SpaceImage *)sl;
-#if 0 /* see comment on r28002 */
- if (sima->gpd) {
- versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image");
- sima->gpd= NULL;
- }
-#else
- sima->gpd= NULL;
-#endif
- }
- }
- }
-}
-
/* deprecated, only keep this for readfile.c */
-static PartEff *do_version_give_parteff_245(Object *ob)
-{
- PartEff *paf;
-
- paf= ob->effect.first;
- while (paf) {
- if (paf->type==EFF_PARTICLE) return paf;
- paf= paf->next;
- }
- return NULL;
-}
-static void do_version_free_effect_245(Effect *eff)
-{
- PartEff *paf;
-
- if (eff->type==EFF_PARTICLE) {
- paf= (PartEff *)eff;
- if (paf->keys) MEM_freeN(paf->keys);
- }
- MEM_freeN(eff);
-}
-static void do_version_free_effects_245(ListBase *lb)
-{
- Effect *eff;
-
- eff= lb->first;
- while (eff) {
- BLI_remlink(lb, eff);
- do_version_free_effect_245(eff);
- eff= lb->first;
- }
-}
-
-static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype)
-{
- MTex *mtex;
- float varfac, colfac;
- int a, neg;
-
- if (!mtex_array)
- return;
-
- for (a=0; a<MAX_MTEX; a++) {
- if (mtex_array[a]) {
- mtex= mtex_array[a];
-
- neg= mtex->maptoneg;
- varfac= mtex->varfac;
- colfac= mtex->colfac;
-
- if (neg & MAP_DISP) mtex->dispfac= -mtex->dispfac;
- if (neg & MAP_NORM) mtex->norfac= -mtex->norfac;
- if (neg & MAP_WARP) mtex->warpfac= -mtex->warpfac;
-
- mtex->colspecfac= (neg & MAP_COLSPEC)? -colfac: colfac;
- mtex->mirrfac= (neg & MAP_COLMIR)? -colfac: colfac;
- mtex->alphafac= (neg & MAP_ALPHA)? -varfac: varfac;
- mtex->difffac= (neg & MAP_REF)? -varfac: varfac;
- mtex->specfac= (neg & MAP_SPEC)? -varfac: varfac;
- mtex->emitfac= (neg & MAP_EMIT)? -varfac: varfac;
- mtex->hardfac= (neg & MAP_HAR)? -varfac: varfac;
- mtex->raymirrfac= (neg & MAP_RAYMIRR)? -varfac: varfac;
- mtex->translfac= (neg & MAP_TRANSLU)? -varfac: varfac;
- mtex->ambfac= (neg & MAP_AMB)? -varfac: varfac;
- mtex->colemitfac= (neg & MAP_EMISSION_COL)? -colfac: colfac;
- mtex->colreflfac= (neg & MAP_REFLECTION_COL)? -colfac: colfac;
- mtex->coltransfac= (neg & MAP_TRANSMISSION_COL)? -colfac: colfac;
- mtex->densfac= (neg & MAP_DENSITY)? -varfac: varfac;
- mtex->scatterfac= (neg & MAP_SCATTERING)? -varfac: varfac;
- mtex->reflfac= (neg & MAP_REFLECTION)? -varfac: varfac;
-
- mtex->timefac= (neg & MAP_PA_TIME)? -varfac: varfac;
- mtex->lengthfac= (neg & MAP_PA_LENGTH)? -varfac: varfac;
- mtex->clumpfac= (neg & MAP_PA_CLUMP)? -varfac: varfac;
- mtex->kinkfac= (neg & MAP_PA_KINK)? -varfac: varfac;
- mtex->roughfac= (neg & MAP_PA_ROUGH)? -varfac: varfac;
- mtex->padensfac= (neg & MAP_PA_DENS)? -varfac: varfac;
- mtex->lifefac= (neg & MAP_PA_LIFE)? -varfac: varfac;
- mtex->sizefac= (neg & MAP_PA_SIZE)? -varfac: varfac;
- mtex->ivelfac= (neg & MAP_PA_IVEL)? -varfac: varfac;
-
- mtex->shadowfac= (neg & LAMAP_SHAD)? -colfac: colfac;
-
- mtex->zenupfac= (neg & WOMAP_ZENUP)? -colfac: colfac;
- mtex->zendownfac= (neg & WOMAP_ZENDOWN)? -colfac: colfac;
- mtex->blendfac= (neg & WOMAP_BLEND)? -varfac: varfac;
-
- if (idtype == ID_MA)
- mtex->colfac= (neg & MAP_COL)? -colfac: colfac;
- else if (idtype == ID_LA)
- mtex->colfac= (neg & LAMAP_COL)? -colfac: colfac;
- else if (idtype == ID_WO)
- mtex->colfac= (neg & WOMAP_HORIZ)? -colfac: colfac;
- }
- }
-}
-
-static void do_version_mdef_250(Main *main)
-{
- Object *ob;
- ModifierData *md;
- MeshDeformModifierData *mmd;
-
- for (ob= main->object.first; ob; ob=ob->id.next) {
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type == eModifierType_MeshDeform) {
- mmd= (MeshDeformModifierData*)md;
-
- if (mmd->bindcos) {
- /* make bindcos NULL in order to trick older versions
- * into thinking that the mesh was not bound yet */
- mmd->bindcagecos= mmd->bindcos;
- mmd->bindcos= NULL;
-
- modifier_mdef_compact_influences(md);
- }
- }
- }
- }
-}
-
-static void do_version_constraints_radians_degrees_250(ListBase *lb)
-{
- bConstraint *con;
-
- for (con=lb->first; con; con=con->next) {
- if (con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) {
- bRigidBodyJointConstraint *data = con->data;
- data->axX *= (float)(M_PI/180.0);
- data->axY *= (float)(M_PI/180.0);
- data->axZ *= (float)(M_PI/180.0);
- }
- else if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data = con->data;
- data->poleangle *= (float)(M_PI/180.0);
- }
- else if (con->type==CONSTRAINT_TYPE_ROTLIMIT) {
- bRotLimitConstraint *data = con->data;
-
- data->xmin *= (float)(M_PI/180.0);
- data->xmax *= (float)(M_PI/180.0);
- data->ymin *= (float)(M_PI/180.0);
- data->ymax *= (float)(M_PI/180.0);
- data->zmin *= (float)(M_PI/180.0);
- data->zmax *= (float)(M_PI/180.0);
- }
- }
-}
-
-/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */
-static void do_version_old_trackto_to_constraints(Object *ob)
-{
- /* create new trackto constraint from the relationship */
- if (ob->track) {
- bConstraint *con= add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
- bTrackToConstraint *data = con->data;
-
- /* copy tracking settings from the object */
- data->tar = ob->track;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
-
- /* clear old track setting */
- ob->track = NULL;
-}
-
-static void do_versions_seq_unique_name_all_strips(
- Scene * sce, ListBase *seqbasep)
-{
- Sequence * seq = seqbasep->first;
-
- while (seq) {
- seqbase_unique_name_recursive(&sce->ed->seqbase, seq);
- if (seq->seqbase.first) {
- do_versions_seq_unique_name_all_strips(
- sce, &seq->seqbase);
- }
- seq=seq->next;
- }
-}
-
-
-static void do_version_bone_roll_256(Bone *bone)
-{
- Bone *child;
- float submat[3][3];
-
- copy_m3_m4(submat, bone->arm_mat);
- mat3_to_vec_roll(submat, NULL, &bone->arm_roll);
-
- for (child = bone->childbase.first; child; child = child->next)
- do_version_bone_roll_256(child);
-}
-
-static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree)
-{
- bNodeSocket *sock;
- for (sock=ntree->inputs.first; sock; sock=sock->next)
- sock->flag |= SOCK_DYNAMIC;
- for (sock=ntree->outputs.first; sock; sock=sock->next)
- sock->flag |= SOCK_DYNAMIC;
-}
-
void convert_tface_mt(FileData *fd, Main *main)
{
Main *gmain;
@@ -7796,4990 +6806,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (G.debug & G_DEBUG)
printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision);
-
- if (main->versionfile == 100) {
- /* tex->extend and tex->imageflag have changed: */
- Tex *tex = main->tex.first;
- while (tex) {
- if (tex->id.flag & LIB_NEEDLINK) {
-
- if (tex->extend==0) {
- if (tex->xrepeat || tex->yrepeat) tex->extend= TEX_REPEAT;
- else {
- tex->extend= TEX_EXTEND;
- tex->xrepeat= tex->yrepeat= 1;
- }
- }
-
- }
- tex= tex->id.next;
- }
- }
- if (main->versionfile <= 101) {
- /* frame mapping */
- Scene *sce = main->scene.first;
- while (sce) {
- sce->r.framapto= 100;
- sce->r.images= 100;
- sce->r.framelen= 1.0;
- sce= sce->id.next;
- }
- }
- if (main->versionfile <= 102) {
- /* init halo's at 1.0 */
- Material *ma = main->mat.first;
- while (ma) {
- ma->add= 1.0;
- ma= ma->id.next;
- }
- }
- if (main->versionfile <= 103) {
- /* new variable in object: colbits */
- Object *ob = main->object.first;
- int a;
- while (ob) {
- ob->colbits= 0;
- if (ob->totcol) {
- for (a=0; a<ob->totcol; a++) {
- if (ob->mat[a]) ob->colbits |= (1<<a);
- }
- }
- ob= ob->id.next;
- }
- }
- if (main->versionfile <= 104) {
- /* timeoffs moved */
- Object *ob = main->object.first;
- while (ob) {
- if (ob->transflag & 1) {
- ob->transflag -= 1;
- //ob->ipoflag |= OB_OFFS_OB;
- }
- ob= ob->id.next;
- }
- }
- if (main->versionfile <= 105) {
- Object *ob = main->object.first;
- while (ob) {
- ob->dupon= 1; ob->dupoff= 0;
- ob->dupsta= 1; ob->dupend= 100;
- ob= ob->id.next;
- }
- }
- if (main->versionfile <= 106) {
- /* mcol changed */
- Mesh *me = main->mesh.first;
- while (me) {
- if (me->mcol) vcol_to_fcol(me);
- me= me->id.next;
- }
-
- }
- if (main->versionfile <= 107) {
- Object *ob;
- Scene *sce = main->scene.first;
- while (sce) {
- sce->r.mode |= R_GAMMA;
- sce= sce->id.next;
- }
- ob= main->object.first;
- while (ob) {
- //ob->ipoflag |= OB_OFFS_PARENT;
- if (ob->dt==0) ob->dt= OB_SOLID;
- ob= ob->id.next;
- }
-
- }
- if (main->versionfile <= 109) {
- /* new variable: gridlines */
- bScreen *sc = main->screen.first;
- while (sc) {
- ScrArea *sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl= sa->spacedata.first;
- while (sl) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
-
- if (v3d->gridlines==0) v3d->gridlines= 20;
- }
- sl= sl->next;
- }
- sa= sa->next;
- }
- sc= sc->id.next;
- }
- }
- if (main->versionfile <= 113) {
- Material *ma = main->mat.first;
- while (ma) {
- if (ma->flaresize==0.0f) ma->flaresize= 1.0f;
- ma->subsize= 1.0f;
- ma->flareboost= 1.0f;
- ma= ma->id.next;
- }
- }
-
- if (main->versionfile <= 134) {
- Tex *tex = main->tex.first;
- while (tex) {
- if ((tex->rfac == 0.0f) &&
- (tex->gfac == 0.0f) &&
- (tex->bfac == 0.0f)) {
- tex->rfac = 1.0f;
- tex->gfac = 1.0f;
- tex->bfac = 1.0f;
- tex->filtersize = 1.0f;
- }
- tex = tex->id.next;
- }
- }
- if (main->versionfile <= 140) {
- /* r-g-b-fac in texture */
- Tex *tex = main->tex.first;
- while (tex) {
- if ((tex->rfac == 0.0f) &&
- (tex->gfac == 0.0f) &&
- (tex->bfac == 0.0f)) {
- tex->rfac = 1.0f;
- tex->gfac = 1.0f;
- tex->bfac = 1.0f;
- tex->filtersize = 1.0f;
- }
- tex = tex->id.next;
- }
- }
- if (main->versionfile <= 153) {
- Scene *sce = main->scene.first;
- while (sce) {
- if (sce->r.blurfac==0.0f) sce->r.blurfac= 1.0f;
- sce= sce->id.next;
- }
- }
- if (main->versionfile <= 163) {
- Scene *sce = main->scene.first;
- while (sce) {
- if (sce->r.frs_sec==0) sce->r.frs_sec= 25;
- sce= sce->id.next;
- }
- }
- if (main->versionfile <= 164) {
- Mesh *me= main->mesh.first;
- while (me) {
- me->smoothresh= 30;
- me= me->id.next;
- }
- }
- if (main->versionfile <= 165) {
- Mesh *me= main->mesh.first;
- TFace *tface;
- int nr;
- char *cp;
-
- while (me) {
- if (me->tface) {
- nr= me->totface;
- tface= me->tface;
- while (nr--) {
- cp= (char *)&tface->col[0];
- if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
- if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
- if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
- cp= (char *)&tface->col[1];
- if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
- if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
- if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
- cp= (char *)&tface->col[2];
- if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
- if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
- if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
- cp= (char *)&tface->col[3];
- if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
- if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
- if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
-
- tface++;
- }
- }
- me= me->id.next;
- }
- }
-
- if (main->versionfile <= 169) {
- Mesh *me= main->mesh.first;
- while (me) {
- if (me->subdiv==0) me->subdiv= 1;
- me= me->id.next;
- }
- }
-
- if (main->versionfile <= 169) {
- bScreen *sc= main->screen.first;
- while (sc) {
- ScrArea *sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl= sa->spacedata.first;
- while (sl) {
- if (sl->spacetype==SPACE_IPO) {
- SpaceIpo *sipo= (SpaceIpo*) sl;
- sipo->v2d.max[0]= 15000.0;
- }
- sl= sl->next;
- }
- sa= sa->next;
- }
- sc= sc->id.next;
- }
- }
-
- if (main->versionfile <= 170) {
- Object *ob = main->object.first;
- PartEff *paf;
- while (ob) {
- paf = do_version_give_parteff_245(ob);
- if (paf) {
- if (paf->staticstep == 0) {
- paf->staticstep= 5;
- }
- }
- ob = ob->id.next;
- }
- }
-
- if (main->versionfile <= 171) {
- bScreen *sc= main->screen.first;
- while (sc) {
- ScrArea *sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl= sa->spacedata.first;
- while (sl) {
- if (sl->spacetype==SPACE_TEXT) {
- SpaceText *st= (SpaceText*) sl;
- st->lheight= 12;
- }
- sl= sl->next;
- }
- sa= sa->next;
- }
- sc= sc->id.next;
- }
- }
-
- if (main->versionfile <= 173) {
- int a, b;
- Mesh *me= main->mesh.first;
- while (me) {
- if (me->tface) {
- TFace *tface= me->tface;
- for (a=0; a<me->totface; a++, tface++) {
- for (b=0; b<4; b++) {
- tface->uv[b][0]/= 32767.0f;
- tface->uv[b][1]/= 32767.0f;
- }
- }
- }
- me= me->id.next;
- }
- }
-
- if (main->versionfile <= 191) {
- Object *ob= main->object.first;
- Material *ma = main->mat.first;
-
- /* let faces have default add factor of 0.0 */
- while (ma) {
- if (!(ma->mode & MA_HALO)) ma->add = 0.0;
- ma = ma->id.next;
- }
-
- while (ob) {
- ob->mass= 1.0f;
- ob->damping= 0.1f;
- /*ob->quat[1]= 1.0f;*/ /* quats arnt used yet */
- ob= ob->id.next;
- }
- }
-
- if (main->versionfile <= 193) {
- Object *ob= main->object.first;
- while (ob) {
- ob->inertia= 1.0f;
- ob->rdamping= 0.1f;
- ob= ob->id.next;
- }
- }
-
- if (main->versionfile <= 196) {
- Mesh *me= main->mesh.first;
- int a, b;
- while (me) {
- if (me->tface) {
- TFace *tface= me->tface;
- for (a=0; a<me->totface; a++, tface++) {
- for (b=0; b<4; b++) {
- tface->mode |= TF_DYNAMIC;
- tface->mode &= ~TF_INVISIBLE;
- }
- }
- }
- me= me->id.next;
- }
- }
-
- if (main->versionfile <= 200) {
- Object *ob= main->object.first;
- while (ob) {
- ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
- /* 64 is do_fh */
- ob->gameflag &= ~(OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
- ob = ob->id.next;
- }
- }
-
- if (main->versionfile <= 201) {
- /* add-object + end-object are joined to edit-object actuator */
- Object *ob = main->object.first;
- bProperty *prop;
- bActuator *act;
- bIpoActuator *ia;
- bEditObjectActuator *eoa;
- bAddObjectActuator *aoa;
- while (ob) {
- act = ob->actuators.first;
- while (act) {
- if (act->type==ACT_IPO) {
- ia= act->data;
- prop= get_ob_property(ob, ia->name);
- if (prop) {
- ia->type= ACT_IPO_FROM_PROP;
- }
- }
- else if (act->type==ACT_ADD_OBJECT) {
- aoa= act->data;
- eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
- eoa->type= ACT_EDOB_ADD_OBJECT;
- eoa->ob= aoa->ob;
- eoa->time= aoa->time;
- MEM_freeN(aoa);
- act->data= eoa;
- act->type= act->otype= ACT_EDIT_OBJECT;
- }
- else if (act->type==ACT_END_OBJECT) {
- eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
- eoa->type= ACT_EDOB_END_OBJECT;
- act->data= eoa;
- act->type= act->otype= ACT_EDIT_OBJECT;
- }
- act= act->next;
- }
- ob = ob->id.next;
- }
- }
-
- if (main->versionfile <= 202) {
- /* add-object and end-object are joined to edit-object
- * actuator */
- Object *ob= main->object.first;
- bActuator *act;
- bObjectActuator *oa;
- while (ob) {
- act= ob->actuators.first;
- while (act) {
- if (act->type==ACT_OBJECT) {
- oa= act->data;
- oa->flag &= ~(ACT_TORQUE_LOCAL|ACT_DROT_LOCAL); /* this actuator didn't do local/glob rot before */
- }
- act= act->next;
- }
- ob= ob->id.next;
- }
- }
-
- if (main->versionfile <= 204) {
- /* patches for new physics */
- Object *ob= main->object.first;
- bActuator *act;
- bObjectActuator *oa;
- bSound *sound;
- while (ob) {
-
- /* please check this for demo20 files like
- * original Egypt levels etc. converted
- * rotation factor of 50 is not workable */
- act= ob->actuators.first;
- while (act) {
- if (act->type==ACT_OBJECT) {
- oa= act->data;
-
- oa->forceloc[0]*= 25.0f;
- oa->forceloc[1]*= 25.0f;
- oa->forceloc[2]*= 25.0f;
-
- oa->forcerot[0]*= 10.0f;
- oa->forcerot[1]*= 10.0f;
- oa->forcerot[2]*= 10.0f;
- }
- act= act->next;
- }
- ob= ob->id.next;
- }
-
- sound = main->sound.first;
- while (sound) {
- if (sound->volume < 0.01f) {
- sound->volume = 1.0f;
- }
- sound = sound->id.next;
- }
- }
- if (main->versionfile <= 205) {
- /* patches for new physics */
- Object *ob= main->object.first;
- bActuator *act;
- bSensor *sens;
- bEditObjectActuator *oa;
- bRaySensor *rs;
- bCollisionSensor *cs;
- while (ob) {
- /* Set anisotropic friction off for old objects,
- * values to 1.0. */
- ob->gameflag &= ~OB_ANISOTROPIC_FRICTION;
- ob->anisotropicFriction[0] = 1.0;
- ob->anisotropicFriction[1] = 1.0;
- ob->anisotropicFriction[2] = 1.0;
-
- act= ob->actuators.first;
- while (act) {
- if (act->type==ACT_EDIT_OBJECT) {
- /* Zero initial velocity for newly
- * added objects */
- oa= act->data;
- oa->linVelocity[0] = 0.0;
- oa->linVelocity[1] = 0.0;
- oa->linVelocity[2] = 0.0;
- oa->localflag = 0;
- }
- act= act->next;
- }
-
- sens= ob->sensors.first;
- while (sens) {
- /* Extra fields for radar sensors. */
- if (sens->type == SENS_RADAR) {
- bRadarSensor *s = sens->data;
- s->range = 10000.0;
- }
-
- /* Pulsing: defaults for new sensors. */
- if (sens->type != SENS_ALWAYS) {
- sens->pulse = 0;
- sens->freq = 0;
- }
- else {
- sens->pulse = 1;
- }
-
- /* Invert: off. */
- sens->invert = 0;
-
- /* Collision and ray: default = trigger
- * on property. The material field can
- * remain empty. */
- if (sens->type == SENS_COLLISION) {
- cs = (bCollisionSensor*) sens->data;
- cs->mode = 0;
- }
- if (sens->type == SENS_RAY) {
- rs = (bRaySensor*) sens->data;
- rs->mode = 0;
- }
- sens = sens->next;
- }
- ob= ob->id.next;
- }
- /* have to check the exact multiplier */
- }
-
- if (main->versionfile <= 211) {
- /* Render setting: per scene, the applicable gamma value
- * can be set. Default is 1.0, which means no
- * correction. */
- bActuator *act;
- bObjectActuator *oa;
- Object *ob;
-
- /* added alpha in obcolor */
- ob= main->object.first;
- while (ob) {
- ob->col[3]= 1.0;
- ob= ob->id.next;
- }
-
- /* added alpha in obcolor */
- ob= main->object.first;
- while (ob) {
- act= ob->actuators.first;
- while (act) {
- if (act->type==ACT_OBJECT) {
- /* multiply velocity with 50 in old files */
- oa= act->data;
- if (fabsf(oa->linearvelocity[0]) >= 0.01f)
- oa->linearvelocity[0] *= 50.0f;
- if (fabsf(oa->linearvelocity[1]) >= 0.01f)
- oa->linearvelocity[1] *= 50.0f;
- if (fabsf(oa->linearvelocity[2]) >= 0.01f)
- oa->linearvelocity[2] *= 50.0f;
- if (fabsf(oa->angularvelocity[0])>=0.01f)
- oa->angularvelocity[0] *= 50.0f;
- if (fabsf(oa->angularvelocity[1])>=0.01f)
- oa->angularvelocity[1] *= 50.0f;
- if (fabsf(oa->angularvelocity[2])>=0.01f)
- oa->angularvelocity[2] *= 50.0f;
- }
- act= act->next;
- }
- ob= ob->id.next;
- }
- }
-
- if (main->versionfile <= 212) {
-
- bSound* sound;
- bProperty *prop;
- Object *ob;
- Mesh *me;
-
- sound = main->sound.first;
- while (sound) {
- sound->max_gain = 1.0;
- sound->min_gain = 0.0;
- sound->distance = 1.0;
-
- if (sound->attenuation > 0.0f)
- sound->flags |= SOUND_FLAGS_3D;
- else
- sound->flags &= ~SOUND_FLAGS_3D;
-
- sound = sound->id.next;
- }
-
- ob = main->object.first;
-
- while (ob) {
- prop= ob->prop.first;
- while (prop) {
- if (prop->type == GPROP_TIME) {
- // convert old GPROP_TIME values from int to float
- *((float *)&prop->data) = (float) prop->data;
- }
-
- prop= prop->next;
- }
- ob = ob->id.next;
- }
-
- /* me->subdiv changed to reflect the actual reparametization
- * better, and smeshes were removed - if it was a smesh make
- * it a subsurf, and reset the subdiv level because subsurf
- * takes a lot more work to calculate.
- */
- for (me= main->mesh.first; me; me= me->id.next) {
- if (me->flag&ME_SMESH) {
- me->flag&= ~ME_SMESH;
- me->flag|= ME_SUBSURF;
-
- me->subdiv= 1;
- }
- else {
- if (me->subdiv<2)
- me->subdiv= 1;
- else
- me->subdiv--;
- }
- }
- }
-
- if (main->versionfile <= 220) {
- Object *ob;
- Mesh *me;
-
- ob = main->object.first;
-
- /* adapt form factor in order to get the 'old' physics
- * behavior back...*/
-
- while (ob) {
- /* in future, distinguish between different
- * object bounding shapes */
- ob->formfactor = 0.4f;
- /* patch form factor, note that inertia equiv radius
- * of a rotation symmetrical obj */
- if (ob->inertia != 1.0f) {
- ob->formfactor /= ob->inertia * ob->inertia;
- }
- ob = ob->id.next;
- }
-
- /* Began using alpha component of vertex colors, but
- * old file vertex colors are undefined, reset them
- * to be fully opaque. -zr
- */
- for (me= main->mesh.first; me; me= me->id.next) {
- if (me->mcol) {
- int i;
-
- for (i=0; i<me->totface*4; i++) {
- MCol *mcol= &me->mcol[i];
- mcol->a= 255;
- }
- }
- if (me->tface) {
- int i, j;
-
- for (i=0; i<me->totface; i++) {
- TFace *tf= &((TFace*) me->tface)[i];
-
- for (j=0; j<4; j++) {
- char *col= (char*) &tf->col[j];
-
- col[0]= 255;
- }
- }
- }
- }
- }
- if (main->versionfile <= 221) {
- Scene *sce= main->scene.first;
-
- // new variables for std-alone player and runtime
- while (sce) {
-
- sce->r.xplay= 640;
- sce->r.yplay= 480;
- sce->r.freqplay= 60;
-
- sce= sce->id.next;
- }
-
- }
- if (main->versionfile <= 222) {
- Scene *sce= main->scene.first;
-
- // new variables for std-alone player and runtime
- while (sce) {
-
- sce->r.depth= 32;
-
- sce= sce->id.next;
- }
- }
-
-
- if (main->versionfile <= 223) {
- VFont *vf;
- Image *ima;
- Object *ob;
-
- for (vf= main->vfont.first; vf; vf= vf->id.next) {
- if (strcmp(vf->name+strlen(vf->name)-6, ".Bfont")==0) {
- strcpy(vf->name, FO_BUILTIN_NAME);
- }
- }
-
- /* Old textures animate at 25 FPS */
- for (ima = main->image.first; ima; ima=ima->id.next) {
- ima->animspeed = 25;
- }
-
- /* Zr remapped some keyboard codes to be linear (stupid zr) */
- for (ob= main->object.first; ob; ob= ob->id.next) {
- bSensor *sens;
-
- for (sens= ob->sensors.first; sens; sens= sens->next) {
- if (sens->type==SENS_KEYBOARD) {
- bKeyboardSensor *ks= sens->data;
-
- ks->key= map_223_keybd_code_to_224_keybd_code(ks->key);
- ks->qual= map_223_keybd_code_to_224_keybd_code(ks->qual);
- ks->qual2= map_223_keybd_code_to_224_keybd_code(ks->qual2);
- }
- }
- }
- }
- if (main->versionfile <= 224) {
- bSound* sound;
- Scene *sce;
- Mesh *me;
- bScreen *sc;
-
- for (sound=main->sound.first; sound; sound=sound->id.next) {
- if (sound->packedfile) {
- if (sound->newpackedfile == NULL) {
- sound->newpackedfile = sound->packedfile;
- }
- sound->packedfile = NULL;
- }
- }
- /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */
- for (me=main->mesh.first; me; me=me->id.next) {
- if ((me->flag & ME_SUBSURF) && (me->subdivr==0))
- me->subdivr=me->subdiv;
- }
-
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- sce->r.stereomode = 1; // no stereo
- }
-
- /* some oldfile patch, moved from set_func_space */
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
-
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
-
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_IPO) {
- SpaceSeq *sseq= (SpaceSeq*) sl;
- sseq->v2d.keeptot= 0;
- }
- }
- }
- }
-
- }
-
-
- if (main->versionfile <= 225) {
- World *wo;
- /* Use Sumo for old games */
- for (wo = main->world.first; wo; wo= wo->id.next) {
- wo->physicsEngine = 2;
- }
- }
-
- if (main->versionfile <= 227) {
- Scene *sce;
- Material *ma;
- bScreen *sc;
- Object *ob;
-
- /* As of now, this insures that the transition from the old Track system
- * to the new full constraint Track is painless for everyone. - theeth
- */
- ob = main->object.first;
-
- while (ob) {
- ListBase *list;
- list = &ob->constraints;
-
- /* check for already existing TrackTo constraint
- * set their track and up flag correctly */
-
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon=curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first;
- pchan; pchan=pchan->next) {
- for (curcon = pchan->constraints.first;
- curcon; curcon=curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
- }
- }
-
- /* Change Ob->Track in real TrackTo constraint */
- do_version_old_trackto_to_constraints(ob);
-
- ob = ob->id.next;
- }
-
-
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- sce->audio.mixrate = 44100;
- sce->audio.flag |= AUDIO_SCRUB;
- sce->r.mode |= R_ENVMAP;
- }
- // init new shader vars
- for (ma= main->mat.first; ma; ma= ma->id.next) {
- ma->refrac= 4.0f;
- ma->roughness= 0.5f;
- ma->param[0]= 0.5f;
- ma->param[1]= 0.1f;
- ma->param[2]= 0.1f;
- ma->param[3]= 0.05f;
- }
- // patch for old wrong max view2d settings, allows zooming out more
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
-
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
-
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_ACTION) {
- SpaceAction *sac= (SpaceAction *) sl;
- sac->v2d.max[0]= 32000;
- }
- else if (sl->spacetype==SPACE_NLA) {
- SpaceNla *sla= (SpaceNla *) sl;
- sla->v2d.max[0]= 32000;
- }
- }
- }
- }
- }
- if (main->versionfile <= 228) {
- Scene *sce;
- bScreen *sc;
- Object *ob;
-
-
- /* As of now, this insures that the transition from the old Track system
- * to the new full constraint Track is painless for everyone.*/
- ob = main->object.first;
-
- while (ob) {
- ListBase *list;
- list = &ob->constraints;
-
- /* check for already existing TrackTo constraint
- * set their track and up flag correctly */
-
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon=curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first;
- pchan; pchan=pchan->next) {
- for (curcon = pchan->constraints.first;
- curcon; curcon=curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
- }
- }
-
- ob = ob->id.next;
- }
-
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- sce->r.mode |= R_ENVMAP;
- }
-
- // convert old mainb values for new button panels
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
-
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
-
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_BUTS) {
- SpaceButs *sbuts= (SpaceButs *) sl;
-
- sbuts->v2d.maxzoom= 1.2f;
- sbuts->align= 1; /* horizontal default */
-
- if (sbuts->mainb==BUTS_LAMP) {
- sbuts->mainb= CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
- }
- else if (sbuts->mainb==BUTS_MAT) {
- sbuts->mainb= CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
- }
- else if (sbuts->mainb==BUTS_TEX) {
- sbuts->mainb= CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
- }
- else if (sbuts->mainb==BUTS_ANIM) {
- sbuts->mainb= CONTEXT_OBJECT;
- }
- else if (sbuts->mainb==BUTS_WORLD) {
- sbuts->mainb= CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
- }
- else if (sbuts->mainb==BUTS_RENDER) {
- sbuts->mainb= CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
- }
- else if (sbuts->mainb==BUTS_GAME) {
- sbuts->mainb= CONTEXT_LOGIC;
- }
- else if (sbuts->mainb==BUTS_FPAINT) {
- sbuts->mainb= CONTEXT_EDITING;
- }
- else if (sbuts->mainb==BUTS_RADIO) {
- sbuts->mainb= CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
- }
- else if (sbuts->mainb==BUTS_CONSTRAINT) {
- sbuts->mainb= CONTEXT_OBJECT;
- }
- else if (sbuts->mainb==BUTS_SCRIPT) {
- sbuts->mainb= CONTEXT_OBJECT;
- }
- else if (sbuts->mainb==BUTS_EDIT) {
- sbuts->mainb= CONTEXT_EDITING;
- }
- else sbuts->mainb= CONTEXT_SCENE;
- }
- }
- }
- }
- }
- /* ton: made this 230 instead of 229,
- * to be sure (tuho files) and this is a reliable check anyway
- * nevertheless, we might need to think over a fitness (initialize)
- * check apart from the do_versions() */
-
- if (main->versionfile <= 230) {
- bScreen *sc;
-
- // new variable blockscale, for panels in any area
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
-
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
-
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->blockscale==0.0f) sl->blockscale= 0.7f;
- /* added: 5x better zoom in for action */
- if (sl->spacetype==SPACE_ACTION) {
- SpaceAction *sac= (SpaceAction *)sl;
- sac->v2d.maxzoom= 50;
- }
- }
- }
- }
- }
- if (main->versionfile <= 231) {
- /* new bit flags for showing/hiding grid floor and axes */
- bScreen *sc = main->screen.first;
- while (sc) {
- ScrArea *sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl= sa->spacedata.first;
- while (sl) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
-
- if (v3d->gridflag==0) {
- v3d->gridflag |= V3D_SHOW_X;
- v3d->gridflag |= V3D_SHOW_Y;
- v3d->gridflag |= V3D_SHOW_FLOOR;
- v3d->gridflag &= ~V3D_SHOW_Z;
- }
- }
- sl= sl->next;
- }
- sa= sa->next;
- }
- sc= sc->id.next;
- }
- }
- if (main->versionfile <= 231) {
- Material *ma= main->mat.first;
- bScreen *sc = main->screen.first;
- Scene *sce;
- Lamp *la;
- World *wrld;
-
- /* introduction of raytrace */
- while (ma) {
- if (ma->fresnel_tra_i==0.0f) ma->fresnel_tra_i= 1.25f;
- if (ma->fresnel_mir_i==0.0f) ma->fresnel_mir_i= 1.25f;
-
- ma->ang= 1.0;
- ma->ray_depth= 2;
- ma->ray_depth_tra= 2;
- ma->fresnel_tra= 0.0;
- ma->fresnel_mir= 0.0;
-
- ma= ma->id.next;
- }
- sce= main->scene.first;
- while (sce) {
- if (sce->r.gauss==0.0f) sce->r.gauss= 1.0f;
- sce= sce->id.next;
- }
- la= main->lamp.first;
- while (la) {
- if (la->k==0.0f) la->k= 1.0;
- if (la->ray_samp==0) la->ray_samp= 1;
- if (la->ray_sampy==0) la->ray_sampy= 1;
- if (la->ray_sampz==0) la->ray_sampz= 1;
- if (la->area_size==0.0f) la->area_size= 1.0f;
- if (la->area_sizey==0.0f) la->area_sizey= 1.0f;
- if (la->area_sizez==0.0f) la->area_sizez= 1.0f;
- la= la->id.next;
- }
- wrld= main->world.first;
- while (wrld) {
- if (wrld->range==0.0f) {
- wrld->range= 1.0f/wrld->exposure;
- }
- wrld= wrld->id.next;
- }
-
- /* new bit flags for showing/hiding grid floor and axes */
-
- while (sc) {
- ScrArea *sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl= sa->spacedata.first;
- while (sl) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
-
- if (v3d->gridflag==0) {
- v3d->gridflag |= V3D_SHOW_X;
- v3d->gridflag |= V3D_SHOW_Y;
- v3d->gridflag |= V3D_SHOW_FLOOR;
- v3d->gridflag &= ~V3D_SHOW_Z;
- }
- }
- sl= sl->next;
- }
- sa= sa->next;
- }
- sc= sc->id.next;
- }
- }
- if (main->versionfile <= 232) {
- Tex *tex= main->tex.first;
- World *wrld= main->world.first;
- bScreen *sc;
- Scene *sce;
-
- while (tex) {
- if ((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) {
- tex->flag |= TEX_CHECKER_ODD;
- }
- /* copied from kernel texture.c */
- if (tex->ns_outscale==0.0f) {
- /* musgrave */
- tex->mg_H = 1.0f;
- tex->mg_lacunarity = 2.0f;
- tex->mg_octaves = 2.0f;
- tex->mg_offset = 1.0f;
- tex->mg_gain = 1.0f;
- tex->ns_outscale = 1.0f;
- /* distnoise */
- tex->dist_amount = 1.0f;
- /* voronoi */
- tex->vn_w1 = 1.0f;
- tex->vn_mexp = 2.5f;
- }
- tex= tex->id.next;
- }
-
- while (wrld) {
- if (wrld->aodist==0.0f) {
- wrld->aodist= 10.0f;
- wrld->aobias= 0.05f;
- }
- if (wrld->aosamp==0) wrld->aosamp= 5;
- if (wrld->aoenergy==0.0f) wrld->aoenergy= 1.0f;
- wrld= wrld->id.next;
- }
-
-
- // new variable blockscale, for panels in any area, do again because new
- // areas didnt initialize it to 0.7 yet
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->blockscale==0.0f) sl->blockscale= 0.7f;
-
- /* added: 5x better zoom in for nla */
- if (sl->spacetype==SPACE_NLA) {
- SpaceNla *snla= (SpaceNla *)sl;
- snla->v2d.maxzoom= 50;
- }
- }
- }
- }
- sce= main->scene.first;
- while (sce) {
- if (sce->r.ocres==0) sce->r.ocres= 64;
- sce= sce->id.next;
- }
-
- }
- if (main->versionfile <= 233) {
- bScreen *sc;
- Material *ma= main->mat.first;
- /* Object *ob= main->object.first; */
-
- while (ma) {
- if (ma->rampfac_col==0.0f) ma->rampfac_col= 1.0;
- if (ma->rampfac_spec==0.0f) ma->rampfac_spec= 1.0;
- if (ma->pr_lamp==0) ma->pr_lamp= 3;
- ma= ma->id.next;
- }
-
- /* this should have been done loooong before! */
-#if 0 /* deprecated in 2.5+ */
- while (ob) {
- if (ob->ipowin==0) ob->ipowin= ID_OB;
- ob= ob->id.next;
- }
-#endif
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D *)sl;
- v3d->flag |= V3D_SELECT_OUTLINE;
- }
- }
- }
- }
- }
-
-
-
-
- if (main->versionfile <= 234) {
- World *wo;
- bScreen *sc;
-
- // force sumo engine to be active
- for (wo = main->world.first; wo; wo= wo->id.next) {
- if (wo->physicsEngine==0) wo->physicsEngine = 2;
- }
-
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D *)sl;
- v3d->flag |= V3D_ZBUF_SELECT;
- }
- else if (sl->spacetype==SPACE_TEXT) {
- SpaceText *st= (SpaceText *)sl;
- if (st->tabnumber==0) st->tabnumber= 2;
- }
- }
- }
- }
- }
- if (main->versionfile <= 235) {
- Tex *tex= main->tex.first;
- Scene *sce= main->scene.first;
- Sequence *seq;
- Editing *ed;
-
- while (tex) {
- if (tex->nabla==0.0f) tex->nabla= 0.025f;
- tex= tex->id.next;
- }
- while (sce) {
- ed= sce->ed;
- if (ed) {
- SEQ_BEGIN (sce->ed, seq)
- {
- if (seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE)
- seq->flag |= SEQ_MAKE_PREMUL;
- }
- SEQ_END
- }
-
- sce= sce->id.next;
- }
- }
- if (main->versionfile <= 236) {
- Object *ob;
- Camera *cam= main->camera.first;
- Material *ma;
- bScreen *sc;
-
- while (cam) {
- if (cam->ortho_scale==0.0f) {
- cam->ortho_scale= 256.0f/cam->lens;
- if (cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n");
- }
- cam= cam->id.next;
- }
- /* set manipulator type */
- /* force oops draw if depgraph was set*/
- /* set time line var */
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D *)sl;
- if (v3d->twtype==0) v3d->twtype= V3D_MANIP_TRANSLATE;
- }
- }
- }
- }
- // init new shader vars
- for (ma= main->mat.first; ma; ma= ma->id.next) {
- if (ma->darkness==0.0f) {
- ma->rms=0.1f;
- ma->darkness=1.0f;
- }
- }
-
- /* softbody init new vars */
- for (ob= main->object.first; ob; ob= ob->id.next) {
- if (ob->soft) {
- if (ob->soft->defgoal==0.0f) ob->soft->defgoal= 0.7f;
- if (ob->soft->physics_speed==0.0f) ob->soft->physics_speed= 1.0f;
-
- if (ob->soft->interval==0) {
- ob->soft->interval= 2;
- ob->soft->sfra= 1;
- ob->soft->efra= 100;
- }
- }
- if (ob->soft && ob->soft->vertgroup==0) {
- bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL");
- if (locGroup) {
- /* retrieve index for that group */
- ob->soft->vertgroup = 1 + BLI_findindex(&ob->defbase, locGroup);
- }
- }
- }
- }
- if (main->versionfile <= 237) {
- bArmature *arm;
- bConstraint *con;
- Object *ob;
- Bone *bone;
-
- // armature recode checks
- for (arm= main->armature.first; arm; arm= arm->id.next) {
- where_is_armature(arm);
-
- for (bone= arm->bonebase.first; bone; bone= bone->next)
- do_version_bone_head_tail_237(bone);
- }
- for (ob= main->object.first; ob; ob= ob->id.next) {
- if (ob->parent) {
- Object *parent= newlibadr(fd, lib, ob->parent);
- if (parent && parent->type==OB_LATTICE)
- ob->partype = PARSKEL;
- }
-
- // btw. armature_rebuild_pose is further only called on leave editmode
- if (ob->type==OB_ARMATURE) {
- if (ob->pose)
- ob->pose->flag |= POSE_RECALC;
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // cannot call stuff now (pointers!), done in setup_app_data
-
- /* new generic xray option */
- arm= newlibadr(fd, lib, ob->data);
- if (arm->flag & ARM_DRAWXRAY) {
- ob->dtx |= OB_DRAWXRAY;
- }
- }
- else if (ob->type==OB_MESH) {
- Mesh *me = newlibadr(fd, lib, ob->data);
-
- if ((me->flag&ME_SUBSURF)) {
- SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf);
-
- smd->levels = MAX2(1, me->subdiv);
- smd->renderLevels = MAX2(1, me->subdivr);
- smd->subdivType = me->subsurftype;
-
- smd->modifier.mode = 0;
- if (me->subdiv!=0)
- smd->modifier.mode |= 1;
- if (me->subdivr!=0)
- smd->modifier.mode |= 2;
- if (me->flag&ME_OPT_EDGES)
- smd->flags |= eSubsurfModifierFlag_ControlEdges;
-
- BLI_addtail(&ob->modifiers, smd);
-
- modifier_unique_name(&ob->modifiers, (ModifierData*)smd);
- }
- }
-
- // follow path constraint needs to set the 'path' option in curves...
- for (con=ob->constraints.first; con; con= con->next) {
- if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
- bFollowPathConstraint *data = con->data;
- Object *obc= newlibadr(fd, lib, data->tar);
-
- if (obc && obc->type==OB_CURVE) {
- Curve *cu= newlibadr(fd, lib, obc->data);
- if (cu) cu->flag |= CU_PATH;
- }
- }
- }
- }
- }
- if (main->versionfile <= 238) {
- Lattice *lt;
- Object *ob;
- bArmature *arm;
- Mesh *me;
- Key *key;
- Scene *sce= main->scene.first;
-
- while (sce) {
- if (sce->toolsettings == NULL) {
- sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct");
- sce->toolsettings->cornertype=0;
- sce->toolsettings->degr = 90;
- sce->toolsettings->step = 9;
- sce->toolsettings->turn = 1;
- sce->toolsettings->extr_offs = 1;
- sce->toolsettings->doublimit = 0.001f;
- sce->toolsettings->segments = 32;
- sce->toolsettings->rings = 32;
- sce->toolsettings->vertices = 32;
- }
- sce= sce->id.next;
- }
-
- for (lt=main->latt.first; lt; lt=lt->id.next) {
- if (lt->fu==0.0f && lt->fv==0.0f && lt->fw==0.0f) {
- calc_lat_fudu(lt->flag, lt->pntsu, &lt->fu, &lt->du);
- calc_lat_fudu(lt->flag, lt->pntsv, &lt->fv, &lt->dv);
- calc_lat_fudu(lt->flag, lt->pntsw, &lt->fw, &lt->dw);
- }
- }
-
- for (ob=main->object.first; ob; ob= ob->id.next) {
- ModifierData *md;
- PartEff *paf;
-
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type==eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData*) md;
-
- smd->flags &= ~(eSubsurfModifierFlag_Incremental|eSubsurfModifierFlag_DebugIncr);
- }
- }
-
- if ((ob->softflag&OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) {
- if (ob->softflag&OB_SB_POSTDEF) {
- md = ob->modifiers.first;
-
- while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
- md = md->next;
- }
-
- BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(eModifierType_Softbody));
- }
- else {
- BLI_addhead(&ob->modifiers, modifier_new(eModifierType_Softbody));
- }
-
- ob->softflag &= ~OB_SB_ENABLE;
- }
- if (ob->pose) {
- bPoseChannel *pchan;
- bConstraint *con;
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- // note, pchan->bone is also lib-link stuff
- if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) {
- pchan->limitmin[0]= pchan->limitmin[1]= pchan->limitmin[2]= -180.0f;
- pchan->limitmax[0]= pchan->limitmax[1]= pchan->limitmax[2]= 180.0f;
-
- for (con= pchan->constraints.first; con; con= con->next) {
- if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data = (bKinematicConstraint*)con->data;
- data->weight = 1.0f;
- data->orientweight = 1.0f;
- data->flag &= ~CONSTRAINT_IK_ROT;
-
- /* enforce conversion from old IK_TOPARENT to rootbone index */
- data->rootbone= -1;
-
- /* update_pose_etc handles rootbone==-1 */
- ob->pose->flag |= POSE_RECALC;
- }
- }
- }
- }
- }
-
- paf = do_version_give_parteff_245(ob);
- if (paf) {
- if (paf->disp == 0)
- paf->disp = 100;
- if (paf->speedtex == 0)
- paf->speedtex = 8;
- if (paf->omat == 0)
- paf->omat = 1;
- }
- }
-
- for (arm=main->armature.first; arm; arm= arm->id.next) {
- bone_version_238(&arm->bonebase);
- arm->deformflag |= ARM_DEF_VGROUP;
- }
-
- for (me=main->mesh.first; me; me= me->id.next) {
- if (!me->medge) {
- make_edges(me, 1); /* 1 = use mface->edcode */
- }
- else {
- mesh_strip_loose_faces(me);
- }
- }
-
- for (key= main->key.first; key; key= key->id.next) {
- KeyBlock *kb;
- int index = 1;
-
- for (kb= key->block.first; kb; kb= kb->next) {
- if (kb==key->refkey) {
- if (kb->name[0]==0)
- strcpy(kb->name, "Basis");
- }
- else {
- if (kb->name[0]==0) {
- BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index);
- }
- index++;
- }
- }
- }
- }
- if (main->versionfile <= 239) {
- bArmature *arm;
- Object *ob;
- Scene *sce= main->scene.first;
- Camera *cam= main->camera.first;
- Material *ma= main->mat.first;
- int set_passepartout= 0;
-
- /* deformflag is local in modifier now */
- for (ob=main->object.first; ob; ob= ob->id.next) {
- ModifierData *md;
-
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type==eModifierType_Armature) {
- ArmatureModifierData *amd = (ArmatureModifierData*) md;
- if (amd->object && amd->deformflag==0) {
- Object *oba= newlibadr(fd, lib, amd->object);
- arm= newlibadr(fd, lib, oba->data);
- amd->deformflag= arm->deformflag;
- }
- }
- }
- }
-
- /* updating stepsize for ghost drawing */
- for (arm= main->armature.first; arm; arm= arm->id.next) {
- if (arm->ghostsize==0) arm->ghostsize=1;
- bone_version_239(&arm->bonebase);
- if (arm->layer==0) arm->layer= 1;
- }
-
- for (;sce;sce= sce->id.next) {
- /* make 'innervert' the default subdivide type, for backwards compat */
- sce->toolsettings->cornertype=1;
-
- if (sce->r.scemode & R_PASSEPARTOUT) {
- set_passepartout= 1;
- sce->r.scemode &= ~R_PASSEPARTOUT;
- }
- /* gauss is filter variable now */
- if (sce->r.mode & R_GAUSS) {
- sce->r.filtertype= R_FILTER_GAUSS;
- sce->r.mode &= ~R_GAUSS;
- }
- }
-
- for (;cam; cam= cam->id.next) {
- if (set_passepartout)
- cam->flag |= CAM_SHOWPASSEPARTOUT;
-
- /* make sure old cameras have title safe on */
- if (!(cam->flag & CAM_SHOWTITLESAFE))
- cam->flag |= CAM_SHOWTITLESAFE;
-
- /* set an appropriate camera passepartout alpha */
- if (!(cam->passepartalpha)) cam->passepartalpha = 0.2f;
- }
-
- for (; ma; ma= ma->id.next) {
- if (ma->strand_sta==0.0f) {
- ma->strand_sta= ma->strand_end= 1.0f;
- ma->mode |= MA_TANGENT_STR;
- }
- if (ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF;
- }
- }
-
- if (main->versionfile <= 241) {
- Object *ob;
- Tex *tex;
- Scene *sce;
- World *wo;
- Lamp *la;
- Material *ma;
- bArmature *arm;
- bNodeTree *ntree;
-
- for (wo = main->world.first; wo; wo= wo->id.next) {
- /* Migrate to Bullet for games, except for the NaN versions */
- /* People can still explicitly choose for Sumo (after 2.42 is out) */
- if (main->versionfile > 225)
- wo->physicsEngine = WOPHY_BULLET;
- if (WO_AODIST == wo->aomode)
- wo->aocolor= WO_AOPLAIN;
- }
-
- /* updating layers still */
- for (arm= main->armature.first; arm; arm= arm->id.next) {
- bone_version_239(&arm->bonebase);
- if (arm->layer==0) arm->layer= 1;
- }
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->audio.mixrate==0) sce->audio.mixrate= 44100;
-
- if (sce->r.xparts<2) sce->r.xparts= 4;
- if (sce->r.yparts<2) sce->r.yparts= 4;
- /* adds default layer */
- if (sce->r.layers.first==NULL)
- scene_add_render_layer(sce, NULL);
- else {
- SceneRenderLayer *srl;
- /* new layer flag for sky, was default for solid */
- for (srl= sce->r.layers.first; srl; srl= srl->next) {
- if (srl->layflag & SCE_LAY_SOLID)
- srl->layflag |= SCE_LAY_SKY;
- srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR);
- }
- }
-
- /* node version changes */
- if (sce->nodetree)
- ntree_version_241(sce->nodetree);
-
- /* uv calculation options moved to toolsettings */
- if (sce->toolsettings->uvcalc_radius == 0.0f) {
- sce->toolsettings->uvcalc_radius = 1.0f;
- sce->toolsettings->uvcalc_cubesize = 1.0f;
- sce->toolsettings->uvcalc_mapdir = 1;
- sce->toolsettings->uvcalc_mapalign = 1;
- sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES;
- sce->toolsettings->unwrapper = 1;
- }
-
- if (sce->r.mode & R_PANORAMA) {
- /* all these checks to ensure saved files with svn version keep working... */
- if (sce->r.xsch < sce->r.ysch) {
- Object *obc= newlibadr(fd, lib, sce->camera);
- if (obc && obc->type==OB_CAMERA) {
- Camera *cam= newlibadr(fd, lib, obc->data);
- if (cam->lens>=10.0f) {
- sce->r.xsch*= sce->r.xparts;
- cam->lens*= (float)sce->r.ysch/(float)sce->r.xsch;
- }
- }
- }
- }
- }
-
- for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
- ntree_version_241(ntree);
-
- for (la= main->lamp.first; la; la= la->id.next)
- if (la->buffers==0)
- la->buffers= 1;
-
- for (tex= main->tex.first; tex; tex= tex->id.next) {
- if (tex->env && tex->env->viewscale==0.0f)
- tex->env->viewscale= 1.0f;
-// tex->imaflag |= TEX_GAUSS_MIP;
- }
-
- /* for empty drawsize and drawtype */
- for (ob=main->object.first; ob; ob= ob->id.next) {
- if (ob->empty_drawsize==0.0f) {
- ob->empty_drawtype = OB_ARROWS;
- ob->empty_drawsize = 1.0;
- }
- }
-
- for (ma= main->mat.first; ma; ma= ma->id.next) {
- /* stucci returns intensity from now on */
- int a;
- for (a=0; a<MAX_MTEX; a++) {
- if (ma->mtex[a] && ma->mtex[a]->tex) {
- tex= newlibadr(fd, lib, ma->mtex[a]->tex);
- if (tex && tex->type==TEX_STUCCI)
- ma->mtex[a]->mapto &= ~(MAP_COL|MAP_SPEC|MAP_REF);
- }
- }
- /* transmissivity defaults */
- if (ma->tx_falloff==0.0f) ma->tx_falloff= 1.0f;
- }
-
- /* during 2.41 images with this name were used for viewer node output, lets fix that */
- if (main->versionfile == 241) {
- Image *ima;
- for (ima= main->image.first; ima; ima= ima->id.next)
- if (strcmp(ima->name, "Compositor")==0) {
- strcpy(ima->id.name+2, "Viewer Node");
- strcpy(ima->name, "Viewer Node");
- }
- }
- }
-
- if (main->versionfile <= 242) {
- Scene *sce;
- bScreen *sc;
- Object *ob;
- Curve *cu;
- Material *ma;
- Mesh *me;
- Group *group;
- Nurb *nu;
- BezTriple *bezt;
- BPoint *bp;
- bNodeTree *ntree;
- int a;
-
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl;
-
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
- if (v3d->gridsubdiv == 0)
- v3d->gridsubdiv = 10;
- }
- }
- sa = sa->next;
- }
- }
-
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->toolsettings->select_thresh == 0.0f)
- sce->toolsettings->select_thresh= 0.01f;
- if (sce->toolsettings->clean_thresh == 0.0f)
- sce->toolsettings->clean_thresh = 0.1f;
-
- if (sce->r.threads==0) {
- if (sce->r.mode & R_THREADS)
- sce->r.threads= 2;
- else
- sce->r.threads= 1;
- }
- if (sce->nodetree)
- ntree_version_242(sce->nodetree);
- }
-
- for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
- ntree_version_242(ntree);
-
- /* add default radius values to old curve points */
- for (cu= main->curve.first; cu; cu= cu->id.next) {
- for (nu= cu->nurb.first; nu; nu= nu->next) {
- if (nu) {
- if (nu->bezt) {
- for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) {
- if (!bezt->radius) bezt->radius= 1.0;
- }
- }
- else if (nu->bp) {
- for (bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
- if (!bp->radius) bp->radius= 1.0;
- }
- }
- }
- }
- }
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- ModifierData *md;
- ListBase *list;
- list = &ob->constraints;
-
- /* check for already existing MinMax (floor) constraint
- * and update the sticky flagging */
-
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon=curcon->next) {
- switch (curcon->type) {
- case CONSTRAINT_TYPE_MINMAX:
- {
- bMinMaxConstraint *data = curcon->data;
- if (data->sticky==1)
- data->flag |= MINMAX_STICKY;
- else
- data->flag &= ~MINMAX_STICKY;
- }
- break;
- case CONSTRAINT_TYPE_ROTLIKE:
- {
- bRotateLikeConstraint *data = curcon->data;
-
- /* version patch from buttons_object.c */
- if (data->flag==0)
- data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
- }
- break;
- }
- }
- }
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) {
- switch (curcon->type) {
- case CONSTRAINT_TYPE_MINMAX:
- {
- bMinMaxConstraint *data = curcon->data;
- if (data->sticky==1)
- data->flag |= MINMAX_STICKY;
- else
- data->flag &= ~MINMAX_STICKY;
- }
- break;
- case CONSTRAINT_TYPE_KINEMATIC:
- {
- bKinematicConstraint *data = curcon->data;
- if (!(data->flag & CONSTRAINT_IK_POS)) {
- data->flag |= CONSTRAINT_IK_POS;
- data->flag |= CONSTRAINT_IK_STRETCH;
- }
- }
- break;
- case CONSTRAINT_TYPE_ROTLIKE:
- {
- bRotateLikeConstraint *data = curcon->data;
-
- /* version patch from buttons_object.c */
- if (data->flag==0)
- data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
- }
- break;
- }
- }
- }
- }
- }
-
- /* copy old object level track settings to curve modifers */
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type==eModifierType_Curve) {
- CurveModifierData *cmd = (CurveModifierData*) md;
-
- if (cmd->defaxis == 0) cmd->defaxis = ob->trackflag+1;
- }
- }
-
- }
-
- for (ma = main->mat.first; ma; ma= ma->id.next) {
- if (ma->shad_alpha==0.0f)
- ma->shad_alpha= 1.0f;
- if (ma->nodetree)
- ntree_version_242(ma->nodetree);
- }
-
- for (me=main->mesh.first; me; me=me->id.next)
- customdata_version_242(me);
-
- for (group= main->group.first; group; group= group->id.next)
- if (group->layer==0)
- group->layer= (1<<20)-1;
-
- /* now, subversion control! */
- if (main->subversionfile < 3) {
- Image *ima;
- Tex *tex;
-
- /* Image refactor initialize */
- for (ima= main->image.first; ima; ima= ima->id.next) {
- ima->source= IMA_SRC_FILE;
- ima->type= IMA_TYPE_IMAGE;
-
- ima->gen_x= 256; ima->gen_y= 256;
- ima->gen_type= 1;
-
- if (0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name)-2)) {
- ima->source= IMA_SRC_VIEWER;
- ima->type= IMA_TYPE_COMPOSITE;
- }
- if (0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name)-2)) {
- ima->source= IMA_SRC_VIEWER;
- ima->type= IMA_TYPE_R_RESULT;
- }
-
- }
- for (tex= main->tex.first; tex; tex= tex->id.next) {
- if (tex->type==TEX_IMAGE && tex->ima) {
- ima= newlibadr(fd, lib, tex->ima);
- if (tex->imaflag & TEX_ANIM5_)
- ima->source= IMA_SRC_MOVIE;
- if (tex->imaflag & TEX_FIELDS_)
- ima->flag |= IMA_FIELDS;
- if (tex->imaflag & TEX_STD_FIELD_)
- ima->flag |= IMA_STD_FIELD;
- }
- tex->iuser.frames= tex->frames;
- tex->iuser.fie_ima= (char)tex->fie_ima;
- tex->iuser.offset= tex->offset;
- tex->iuser.sfra= tex->sfra;
- tex->iuser.cycl= (tex->imaflag & TEX_ANIMCYCLIC_)!=0;
- }
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->nodetree)
- do_version_ntree_242_2(sce->nodetree);
- }
- for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
- do_version_ntree_242_2(ntree);
- for (ma = main->mat.first; ma; ma= ma->id.next)
- if (ma->nodetree)
- do_version_ntree_242_2(ma->nodetree);
-
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_IMAGE)
- ((SpaceImage *)sl)->iuser.fie_ima= 2;
- else if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D *)sl;
- BGpic *bgpic;
- for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next)
- bgpic->iuser.fie_ima= 2;
- }
- }
- }
- }
- }
-
- if (main->subversionfile < 4) {
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- sce->r.bake_mode= 1; /* prevent to include render stuff here */
- sce->r.bake_filter= 2;
- sce->r.bake_osa= 5;
- sce->r.bake_flag= R_BAKE_CLEAR;
- }
- }
-
- if (main->subversionfile < 5) {
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- /* improved triangle to quad conversion settings */
- if (sce->toolsettings->jointrilimit==0.0f)
- sce->toolsettings->jointrilimit= 0.8f;
- }
- }
- }
- if (main->versionfile <= 243) {
- Object *ob= main->object.first;
- Material *ma;
-
- for (ma=main->mat.first; ma; ma= ma->id.next) {
- if (ma->sss_scale==0.0f) {
- ma->sss_radius[0]= 1.0f;
- ma->sss_radius[1]= 1.0f;
- ma->sss_radius[2]= 1.0f;
- ma->sss_col[0]= 0.8f;
- ma->sss_col[1]= 0.8f;
- ma->sss_col[2]= 0.8f;
- ma->sss_error= 0.05f;
- ma->sss_scale= 0.1f;
- ma->sss_ior= 1.3f;
- ma->sss_colfac= 1.0f;
- ma->sss_texfac= 0.0f;
- }
- if (ma->sss_front==0 && ma->sss_back==0) {
- ma->sss_front= 1.0f;
- ma->sss_back= 1.0f;
- }
- if (ma->sss_col[0]==0 && ma->sss_col[1]==0 && ma->sss_col[2]==0) {
- ma->sss_col[0]= ma->r;
- ma->sss_col[1]= ma->g;
- ma->sss_col[2]= ma->b;
- }
- }
-
- for (; ob; ob= ob->id.next) {
- bDeformGroup *curdef;
-
- for (curdef= ob->defbase.first; curdef; curdef=curdef->next) {
- /* replace an empty-string name with unique name */
- if (curdef->name[0] == '\0') {
- defgroup_unique_name(curdef, ob);
- }
- }
-
- if (main->versionfile < 243 || main->subversionfile < 1) {
- ModifierData *md;
-
- /* translate old mirror modifier axis values to new flags */
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type==eModifierType_Mirror) {
- MirrorModifierData *mmd = (MirrorModifierData*) md;
-
- switch (mmd->axis) {
- case 0:
- mmd->flag |= MOD_MIR_AXIS_X;
- break;
- case 1:
- mmd->flag |= MOD_MIR_AXIS_Y;
- break;
- case 2:
- mmd->flag |= MOD_MIR_AXIS_Z;
- break;
- }
-
- mmd->axis = 0;
- }
- }
- }
- }
-
- /* render layer added, this is not the active layer */
- if (main->versionfile <= 243 || main->subversionfile < 2) {
- Mesh *me;
- for (me=main->mesh.first; me; me=me->id.next)
- customdata_version_243(me);
- }
-
- }
-
- if (main->versionfile <= 244) {
- Scene *sce;
- bScreen *sc;
- Lamp *la;
- World *wrld;
-
- if (main->versionfile != 244 || main->subversionfile < 2) {
- for (sce= main->scene.first; sce; sce= sce->id.next)
- sce->r.mode |= R_SSS;
-
- /* correct older action editors - incorrect scrolling */
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl;
-
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_ACTION) {
- SpaceAction *saction= (SpaceAction*) sl;
-
- saction->v2d.tot.ymin = -1000.0;
- saction->v2d.tot.ymax = 0.0;
-
- saction->v2d.cur.ymin = -75.0;
- saction->v2d.cur.ymax = 5.0;
- }
- }
- sa = sa->next;
- }
- }
- }
- if (main->versionfile != 244 || main->subversionfile < 3) {
- /* constraints recode version patch used to be here. Moved to 245 now... */
-
-
- for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
- if (wrld->mode & WO_AMB_OCC)
- wrld->ao_samp_method = WO_AOSAMP_CONSTANT;
- else
- wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
-
- wrld->ao_adapt_thresh = 0.005f;
- }
-
- for (la=main->lamp.first; la; la= la->id.next) {
- if (la->type == LA_AREA)
- la->ray_samp_method = LA_SAMP_CONSTANT;
- else
- la->ray_samp_method = LA_SAMP_HALTON;
-
- la->adapt_thresh = 0.001f;
- }
- }
- }
- if (main->versionfile <= 245) {
- Scene *sce;
- Object *ob;
- Image *ima;
- Lamp *la;
- Material *ma;
- ParticleSettings *part;
- World *wrld;
- Mesh *me;
- bNodeTree *ntree;
- Tex *tex;
- ModifierData *md;
- ParticleSystem *psys;
-
- /* unless the file was created 2.44.3 but not 2.45, update the constraints */
- if ( !(main->versionfile==244 && main->subversionfile==3) &&
- ((main->versionfile<245) || (main->versionfile==245 && main->subversionfile==0)) )
- {
- for (ob = main->object.first; ob; ob= ob->id.next) {
- ListBase *list;
- list = &ob->constraints;
-
- /* fix up constraints due to constraint recode changes (originally at 2.44.3) */
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon=curcon->next) {
- /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
- if (curcon->flag & 0x20) {
- curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
- curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
- }
-
- switch (curcon->type) {
- case CONSTRAINT_TYPE_LOCLIMIT:
- {
- bLocLimitConstraint *data= (bLocLimitConstraint *)curcon->data;
-
- /* old limit without parent option for objects */
- if (data->flag2)
- curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
- }
- break;
- }
- }
- }
-
- /* correctly initialize constinv matrix */
- unit_m4(ob->constinv);
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- /* make sure constraints are all up to date */
- for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) {
- /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
- if (curcon->flag & 0x20) {
- curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
- curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
- }
-
- switch (curcon->type) {
- case CONSTRAINT_TYPE_ACTION:
- {
- bActionConstraint *data= (bActionConstraint *)curcon->data;
-
- /* 'data->local' used to mean that target was in local-space */
- if (data->local)
- curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
- }
- break;
- }
- }
-
- /* correctly initialize constinv matrix */
- unit_m4(pchan->constinv);
- }
- }
- }
- }
- }
-
- /* fix all versions before 2.45 */
- if (main->versionfile != 245) {
-
- /* repair preview from 242 - 244*/
- for (ima= main->image.first; ima; ima= ima->id.next) {
- ima->preview = NULL;
- }
- }
-
- /* add point caches */
- for (ob=main->object.first; ob; ob=ob->id.next) {
- if (ob->soft && !ob->soft->pointcache)
- ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches);
-
- for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- if (psys->pointcache) {
- if (psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) {
- printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n");
- psys->pointcache->flag &= ~PTCACHE_BAKED;
- }
- }
- else
- psys->pointcache= BKE_ptcache_add(&psys->ptcaches);
- }
-
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type==eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData*) md;
- if (!clmd->point_cache)
- clmd->point_cache= BKE_ptcache_add(&clmd->ptcaches);
- }
- }
- }
-
- /* Copy over old per-level multires vertex data
- * into a single vertex array in struct Multires */
- for (me = main->mesh.first; me; me=me->id.next) {
- if (me->mr && !me->mr->verts) {
- MultiresLevel *lvl = me->mr->levels.last;
- if (lvl) {
- me->mr->verts = lvl->verts;
- lvl->verts = NULL;
- /* Don't need the other vert arrays */
- for (lvl = lvl->prev; lvl; lvl = lvl->prev) {
- MEM_freeN(lvl->verts);
- lvl->verts = NULL;
- }
- }
- }
- }
-
- if (main->versionfile != 245 || main->subversionfile < 1) {
- for (la=main->lamp.first; la; la= la->id.next) {
- if (la->mode & LA_QUAD) la->falloff_type = LA_FALLOFF_SLIDERS;
- else la->falloff_type = LA_FALLOFF_INVLINEAR;
-
- if (la->curfalloff == NULL) {
- la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- curvemapping_initialize(la->curfalloff);
- }
- }
- }
-
- for (ma=main->mat.first; ma; ma= ma->id.next) {
- if (ma->samp_gloss_mir == 0) {
- ma->gloss_mir = ma->gloss_tra= 1.0f;
- ma->aniso_gloss_mir = 1.0f;
- ma->samp_gloss_mir = ma->samp_gloss_tra= 18;
- ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005f;
- ma->dist_mir = 0.0f;
- ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
- }
-
- if (ma->strand_min == 0.0f)
- ma->strand_min= 1.0f;
- }
-
- for (part=main->particle.first; part; part=part->id.next) {
- if (part->ren_child_nbr==0)
- part->ren_child_nbr= part->child_nbr;
-
- if (part->simplify_refsize==0) {
- part->simplify_refsize= 1920;
- part->simplify_rate= 1.0f;
- part->simplify_transition= 0.1f;
- part->simplify_viewport= 0.8f;
- }
- }
-
- for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
- if (wrld->ao_approx_error == 0.0f)
- wrld->ao_approx_error= 0.25f;
- }
-
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->nodetree)
- ntree_version_245(fd, lib, sce->nodetree);
-
- if (sce->r.simplify_shadowsamples == 0) {
- sce->r.simplify_subsurf= 6;
- sce->r.simplify_particles= 1.0f;
- sce->r.simplify_shadowsamples= 16;
- sce->r.simplify_aosss= 1.0f;
- }
-
- if (sce->r.cineongamma == 0) {
- sce->r.cineonblack= 95;
- sce->r.cineonwhite= 685;
- sce->r.cineongamma= 1.7f;
- }
- }
-
- for (ntree=main->nodetree.first; ntree; ntree= ntree->id.next)
- ntree_version_245(fd, lib, ntree);
-
- /* fix for temporary flag changes during 245 cycle */
- for (ima= main->image.first; ima; ima= ima->id.next) {
- if (ima->flag & IMA_OLD_PREMUL) {
- ima->flag &= ~IMA_OLD_PREMUL;
- ima->flag |= IMA_DO_PREMUL;
- }
- }
-
- for (tex=main->tex.first; tex; tex=tex->id.next) {
- if (tex->iuser.flag & IMA_OLD_PREMUL) {
- tex->iuser.flag &= ~IMA_OLD_PREMUL;
- tex->iuser.flag |= IMA_DO_PREMUL;
-
- }
-
- ima= newlibadr(fd, lib, tex->ima);
- if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) {
- ima->flag &= ~IMA_OLD_PREMUL;
- ima->flag |= IMA_DO_PREMUL;
- }
- }
- }
-
- /* sanity check for skgen
- * */
- {
- Scene *sce;
- for (sce=main->scene.first; sce; sce = sce->id.next) {
- if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] ||
- sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
- sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
- {
- sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
- sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
- sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
- }
- }
- }
-
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) {
- Image *ima;
-
- /* initialize 1:1 Aspect */
- for (ima= main->image.first; ima; ima= ima->id.next) {
- ima->aspx = ima->aspy = 1.0f;
- }
-
- }
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 4)) {
- bArmature *arm;
- ModifierData *md;
- Object *ob;
-
- for (arm= main->armature.first; arm; arm= arm->id.next)
- arm->deformflag |= ARM_DEF_B_BONE_REST;
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type==eModifierType_Armature)
- ((ArmatureModifierData*)md)->deformflag |= ARM_DEF_B_BONE_REST;
- }
- }
- }
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 5)) {
- /* foreground color needs to be something other then black */
- Scene *sce;
- for (sce= main->scene.first; sce; sce=sce->id.next) {
- sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
- sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */
- sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */
- }
- }
-
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 6)) {
- Scene *sce;
- /* fix frs_sec_base */
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->r.frs_sec_base == 0) {
- sce->r.frs_sec_base = 1;
- }
- }
- }
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) {
- Object *ob;
- bPoseChannel *pchan;
- bConstraint *con;
- bConstraintTarget *ct;
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- if (ob->pose) {
- for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- for (con=pchan->constraints.first; con; con=con->next) {
- if (con->type == CONSTRAINT_TYPE_PYTHON) {
- bPythonConstraint *data= (bPythonConstraint *)con->data;
- if (data->tar) {
- /* version patching needs to be done */
- ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget");
-
- ct->tar = data->tar;
- BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget));
- ct->space = con->tarspace;
-
- BLI_addtail(&data->targets, ct);
- data->tarnum++;
-
- /* clear old targets to avoid problems */
- data->tar = NULL;
- data->subtarget[0]= '\0';
- }
- }
- else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
- bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data;
-
- /* new headtail functionality makes Bone-Tip function obsolete */
- if (data->flag & LOCLIKE_TIP)
- con->headtail = 1.0f;
- }
- }
- }
- }
-
- for (con=ob->constraints.first; con; con=con->next) {
- if (con->type==CONSTRAINT_TYPE_PYTHON) {
- bPythonConstraint *data= (bPythonConstraint *)con->data;
- if (data->tar) {
- /* version patching needs to be done */
- ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget");
-
- ct->tar = data->tar;
- BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget));
- ct->space = con->tarspace;
-
- BLI_addtail(&data->targets, ct);
- data->tarnum++;
-
- /* clear old targets to avoid problems */
- data->tar = NULL;
- data->subtarget[0]= '\0';
- }
- }
- else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
- bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data;
-
- /* new headtail functionality makes Bone-Tip function obsolete */
- if (data->flag & LOCLIKE_TIP)
- con->headtail = 1.0f;
- }
- }
-
- if (ob->soft && ob->soft->keys) {
- SoftBody *sb = ob->soft;
- int k;
-
- for (k=0; k<sb->totkey; k++) {
- if (sb->keys[k])
- MEM_freeN(sb->keys[k]);
- }
-
- MEM_freeN(sb->keys);
-
- sb->keys = NULL;
- sb->totkey = 0;
- }
- }
- }
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) {
- Scene *sce;
- Object *ob;
- PartEff *paf=NULL;
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- if (ob->soft && ob->soft->keys) {
- SoftBody *sb = ob->soft;
- int k;
-
- for (k=0; k<sb->totkey; k++) {
- if (sb->keys[k])
- MEM_freeN(sb->keys[k]);
- }
-
- MEM_freeN(sb->keys);
-
- sb->keys = NULL;
- sb->totkey = 0;
- }
-
- /* convert old particles to new system */
- if ((paf = do_version_give_parteff_245(ob))) {
- ParticleSystem *psys;
- ModifierData *md;
- ParticleSystemModifierData *psmd;
- ParticleSettings *part;
-
- /* create new particle system */
- psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
- psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
-
- part = psys->part = psys_new_settings("ParticleSettings", main);
-
- /* needed for proper libdata lookup */
- oldnewmap_insert(fd->libmap, psys->part, psys->part, 0);
- part->id.lib= ob->id.lib;
-
- part->id.us--;
- part->id.flag |= (ob->id.flag & LIB_NEEDLINK);
-
- psys->totpart=0;
- psys->flag= PSYS_ENABLED|PSYS_CURRENT;
-
- BLI_addtail(&ob->particlesystem, psys);
-
- md= modifier_new(eModifierType_ParticleSystem);
- BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
- psmd= (ParticleSystemModifierData*) md;
- psmd->psys=psys;
- BLI_addtail(&ob->modifiers, md);
-
- /* convert settings from old particle system */
- /* general settings */
- part->totpart = MIN2(paf->totpart, 100000);
- part->sta = paf->sta;
- part->end = paf->end;
- part->lifetime = paf->lifetime;
- part->randlife = paf->randlife;
- psys->seed = paf->seed;
- part->disp = paf->disp;
- part->omat = paf->mat[0];
- part->hair_step = paf->totkey;
-
- part->eff_group = paf->group;
-
- /* old system didn't interpolate between keypoints at render time */
- part->draw_step = part->ren_step = 0;
-
- /* physics */
- part->normfac = paf->normfac * 25.0f;
- part->obfac = paf->obfac;
- part->randfac = paf->randfac * 25.0f;
- part->dampfac = paf->damp;
- copy_v3_v3(part->acc, paf->force);
-
- /* flags */
- if (paf->stype & PAF_VECT) {
- if (paf->flag & PAF_STATIC) {
- /* new hair lifetime is always 100.0f */
- float fac = paf->lifetime / 100.0f;
-
- part->draw_as = PART_DRAW_PATH;
- part->type = PART_HAIR;
- psys->recalc |= PSYS_RECALC_REDO;
-
- part->normfac *= fac;
- part->randfac *= fac;
- }
- else {
- part->draw_as = PART_DRAW_LINE;
- part->draw |= PART_DRAW_VEL_LENGTH;
- part->draw_line[1] = 0.04f;
- }
- }
-
- part->rotmode = PART_ROT_VEL;
-
- part->flag |= (paf->flag & PAF_BSPLINE) ? PART_HAIR_BSPLINE : 0;
- part->flag |= (paf->flag & PAF_TRAND) ? PART_TRAND : 0;
- part->flag |= (paf->flag & PAF_EDISTR) ? PART_EDISTR : 0;
- part->flag |= (paf->flag & PAF_UNBORN) ? PART_UNBORN : 0;
- part->flag |= (paf->flag & PAF_DIED) ? PART_DIED : 0;
- part->from |= (paf->flag & PAF_FACE) ? PART_FROM_FACE : 0;
- part->draw |= (paf->flag & PAF_SHOWE) ? PART_DRAW_EMITTER : 0;
-
- psys->vgroup[PSYS_VG_DENSITY] = paf->vertgroup;
- psys->vgroup[PSYS_VG_VEL] = paf->vertgroup_v;
- psys->vgroup[PSYS_VG_LENGTH] = paf->vertgroup_v;
-
- /* dupliobjects */
- if (ob->transflag & OB_DUPLIVERTS) {
- Object *dup = main->object.first;
-
- for (; dup; dup= dup->id.next) {
- if (ob == newlibadr(fd, lib, dup->parent)) {
- part->dup_ob = dup;
- ob->transflag |= OB_DUPLIPARTS;
- ob->transflag &= ~OB_DUPLIVERTS;
-
- part->draw_as = PART_DRAW_OB;
-
- /* needed for proper libdata lookup */
- oldnewmap_insert(fd->libmap, dup, dup, 0);
- }
- }
- }
-
-
- {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
- if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE)
- part->type = PART_FLUID;
- }
-
- do_version_free_effects_245(&ob->effect);
-
- printf("Old particle system converted to new system.\n");
- }
- }
-
- for (sce= main->scene.first; sce; sce=sce->id.next) {
- ParticleEditSettings *pset= &sce->toolsettings->particle;
- int a;
-
- if (pset->brush[0].size == 0) {
- pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
- pset->emitterdist= 0.25f;
- pset->totrekey= 5;
- pset->totaddkey= 5;
- pset->brushtype= PE_BRUSH_NONE;
-
- for (a=0; a<PE_TOT_BRUSH; a++) {
- pset->brush[a].strength= 50;
- pset->brush[a].size= 50;
- pset->brush[a].step= 10;
- }
-
- pset->brush[PE_BRUSH_CUT].strength= 100;
- }
- }
- }
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 9)) {
- Material *ma;
- int a;
-
- for (ma=main->mat.first; ma; ma= ma->id.next)
- if (ma->mode & MA_NORMAP_TANG)
- for (a=0; a<MAX_MTEX; a++)
- if (ma->mtex[a] && ma->mtex[a]->tex)
- ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT;
- }
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) {
- Object *ob;
-
- /* dupliface scale */
- for (ob= main->object.first; ob; ob= ob->id.next)
- ob->dupfacesca = 1.0f;
- }
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) {
- Object *ob;
- bActionStrip *strip;
-
- /* nla-strips - scale */
- for (ob= main->object.first; ob; ob= ob->id.next) {
- for (strip= ob->nlastrips.first; strip; strip= strip->next) {
- float length, actlength, repeat;
-
- if (strip->flag & ACTSTRIP_USESTRIDE)
- repeat= 1.0f;
- else
- repeat= strip->repeat;
-
- length = strip->end-strip->start;
- if (length == 0.0f) length= 1.0f;
- actlength = strip->actend-strip->actstart;
-
- strip->scale = length / (repeat * actlength);
- if (strip->scale == 0.0f) strip->scale= 1.0f;
- }
- if (ob->soft) {
- ob->soft->inpush = ob->soft->inspring;
- ob->soft->shearstiff = 1.0f;
- }
- }
- }
-
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) {
- Scene *sce;
- Sequence *seq;
-
- for (sce=main->scene.first; sce; sce=sce->id.next) {
- SEQ_BEGIN (sce->ed, seq)
- {
- if (seq->blend_mode == 0)
- seq->blend_opacity = 100.0f;
- }
- SEQ_END
- }
- }
-
- /*fix broken group lengths in id properties*/
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 15)) {
- idproperties_fix_group_lengths(main->scene);
- idproperties_fix_group_lengths(main->library);
- idproperties_fix_group_lengths(main->object);
- idproperties_fix_group_lengths(main->mesh);
- idproperties_fix_group_lengths(main->curve);
- idproperties_fix_group_lengths(main->mball);
- idproperties_fix_group_lengths(main->mat);
- idproperties_fix_group_lengths(main->tex);
- idproperties_fix_group_lengths(main->image);
- idproperties_fix_group_lengths(main->latt);
- idproperties_fix_group_lengths(main->lamp);
- idproperties_fix_group_lengths(main->camera);
- idproperties_fix_group_lengths(main->ipo);
- idproperties_fix_group_lengths(main->key);
- idproperties_fix_group_lengths(main->world);
- idproperties_fix_group_lengths(main->screen);
- idproperties_fix_group_lengths(main->script);
- idproperties_fix_group_lengths(main->vfont);
- idproperties_fix_group_lengths(main->text);
- idproperties_fix_group_lengths(main->sound);
- idproperties_fix_group_lengths(main->group);
- idproperties_fix_group_lengths(main->armature);
- idproperties_fix_group_lengths(main->action);
- idproperties_fix_group_lengths(main->nodetree);
- idproperties_fix_group_lengths(main->brush);
- idproperties_fix_group_lengths(main->particle);
- }
-
- /* sun/sky */
- if (main->versionfile < 246) {
- Object *ob;
- bActuator *act;
-
- /* dRot actuator change direction in 2.46 */
- for (ob = main->object.first; ob; ob= ob->id.next) {
- for (act= ob->actuators.first; act; act= act->next) {
- if (act->type == ACT_OBJECT) {
- bObjectActuator *ba= act->data;
-
- ba->drot[0] = -ba->drot[0];
- ba->drot[1] = -ba->drot[1];
- ba->drot[2] = -ba->drot[2];
- }
- }
- }
- }
-
- // convert fluids to modifier
- if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
- Object *ob;
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- if (ob->fluidsimSettings) {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim);
- BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd);
-
- MEM_freeN(fluidmd->fss);
- fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings);
- fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo);
- MEM_freeN(ob->fluidsimSettings);
-
- fluidmd->fss->lastgoodframe = INT_MAX;
- fluidmd->fss->flag = 0;
- fluidmd->fss->meshVelocities = NULL;
- }
- }
- }
-
-
- if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
- Mesh *me;
-
- for (me=main->mesh.first; me; me= me->id.next)
- alphasort_version_246(fd, lib, me);
- }
-
- if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
- Object *ob;
- for (ob = main->object.first; ob; ob= ob->id.next) {
- if (ob->pd && (ob->pd->forcefield == PFIELD_WIND))
- ob->pd->f_noise = 0.0f;
- }
- }
-
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) {
- Object *ob;
- for (ob = main->object.first; ob; ob= ob->id.next) {
- ob->gameflag |= OB_COLLISION;
- ob->margin = 0.06f;
- }
- }
-
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) {
- Object *ob;
- for (ob = main->object.first; ob; ob= ob->id.next) {
- // Starting from subversion 3, ACTOR is a separate feature.
- // Before it was conditioning all the other dynamic flags
- if (!(ob->gameflag & OB_ACTOR))
- ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
- /* suitable default for older files */
- }
- }
-
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) {
- Lamp *la= main->lamp.first;
- for (; la; la= la->id.next) {
- la->skyblendtype= MA_RAMP_ADD;
- la->skyblendfac= 1.0f;
- }
- }
-
- /* set the curve radius interpolation to 2.47 default - easy */
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) {
- Curve *cu;
- Nurb *nu;
-
- for (cu= main->curve.first; cu; cu= cu->id.next) {
- for (nu= cu->nurb.first; nu; nu= nu->next) {
- if (nu) {
- nu->radius_interp = 3;
-
- /* resolu and resolv are now used differently for surfaces
- * rather than using the resolution to define the entire number of divisions,
- * use it for the number of divisions per segment
- */
- if (nu->pntsv > 1) {
- nu->resolu = MAX2( 1, (int)(((float)nu->resolu / (float)nu->pntsu)+0.5f) );
- nu->resolv = MAX2( 1, (int)(((float)nu->resolv / (float)nu->pntsv)+0.5f) );
- }
- }
- }
- }
- }
- /* direction constraint actuators were always local in previous version */
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) {
- bActuator *act;
- Object *ob;
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- for (act= ob->actuators.first; act; act= act->next) {
- if (act->type == ACT_CONSTRAINT) {
- bConstraintActuator *coa = act->data;
- if (coa->type == ACT_CONST_TYPE_DIST) {
- coa->flag |= ACT_CONST_LOCAL;
- }
- }
- }
- }
- }
-
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) {
- Lamp *la= main->lamp.first;
- for (; la; la= la->id.next) {
- la->sky_exposure= 1.0f;
- }
- }
-
- /* BGE message actuators needed OB prefix, very confusing */
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) {
- bActuator *act;
- Object *ob;
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- for (act= ob->actuators.first; act; act= act->next) {
- if (act->type == ACT_MESSAGE) {
- bMessageActuator *msgAct = (bMessageActuator *) act->data;
- if (BLI_strnlen(msgAct->toPropName, 3) > 2) {
- /* strip first 2 chars, would have only worked if these were OB anyway */
- memmove(msgAct->toPropName, msgAct->toPropName + 2, sizeof(msgAct->toPropName) - 2);
- }
- else {
- msgAct->toPropName[0] = '\0';
- }
- }
- }
- }
- }
-
- if (main->versionfile < 248) {
- Lamp *la;
-
- for (la=main->lamp.first; la; la= la->id.next) {
- if (la->atm_turbidity == 0.0f) {
- la->sun_effect_type = 0;
- la->horizon_brightness = 1.0f;
- la->spread = 1.0f;
- la->sun_brightness = 1.0f;
- la->sun_size = 1.0f;
- la->backscattered_light = 1.0f;
- la->atm_turbidity = 2.0f;
- la->atm_inscattering_factor = 1.0f;
- la->atm_extinction_factor = 1.0f;
- la->atm_distance_factor = 1.0f;
- la->sun_intensity = 1.0f;
- }
- }
- }
-
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) {
- Scene *sce;
-
- /* Note, these will need to be added for painting */
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- sce->toolsettings->imapaint.seam_bleed = 2;
- sce->toolsettings->imapaint.normal_angle = 80;
-
- /* initialize skeleton generation toolsettings */
- sce->toolsettings->skgen_resolution = 250;
- sce->toolsettings->skgen_threshold_internal = 0.1f;
- sce->toolsettings->skgen_threshold_external = 0.1f;
- sce->toolsettings->skgen_angle_limit = 30.0f;
- sce->toolsettings->skgen_length_ratio = 1.3f;
- sce->toolsettings->skgen_length_limit = 1.5f;
- sce->toolsettings->skgen_correlation_limit = 0.98f;
- sce->toolsettings->skgen_symmetry_limit = 0.1f;
- sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
- sce->toolsettings->skgen_postpro_passes = 3;
- sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_SUB_CORRELATION|SKGEN_HARMONIC;
- sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
- sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
- sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
-
-
- sce->toolsettings->skgen_retarget_angle_weight = 1.0f;
- sce->toolsettings->skgen_retarget_length_weight = 1.0f;
- sce->toolsettings->skgen_retarget_distance_weight = 1.0f;
-
- /* Skeleton Sketching */
- sce->toolsettings->bone_sketching = 0;
- sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW;
- }
- }
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
- bScreen *sc;
-
- /* adjust default settings for Animation Editors */
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
-
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
-
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- switch (sl->spacetype) {
- case SPACE_ACTION:
- {
- SpaceAction *sact= (SpaceAction *)sl;
-
- sact->mode= SACTCONT_DOPESHEET;
- sact->autosnap= SACTSNAP_FRAME;
- }
- break;
- case SPACE_IPO:
- {
- SpaceIpo *sipo= (SpaceIpo *)sl;
- sipo->autosnap= SACTSNAP_FRAME;
- }
- break;
- case SPACE_NLA:
- {
- SpaceNla *snla= (SpaceNla *)sl;
- snla->autosnap= SACTSNAP_FRAME;
- }
- break;
- }
- }
- }
- }
- }
-
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
- Object *ob;
-
- /* Adjustments needed after Bullets update */
- for (ob = main->object.first; ob; ob= ob->id.next) {
- ob->damping *= 0.635f;
- ob->rdamping = 0.1f + (0.8f * ob->rdamping);
- }
- }
-
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) {
- Scene *sce;
- World *wrld;
-
- /* Dome (Fisheye) default parameters */
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- sce->r.domeangle = 180;
- sce->r.domemode = 1;
- sce->r.domeres = 4;
- sce->r.domeresbuf = 1.0f;
- sce->r.dometilt = 0;
- }
- /* DBVT culling by default */
- for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
- wrld->mode |= WO_DBVT_CULLING;
- wrld->occlusionRes = 128;
- }
- }
-
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) {
- Object *ob;
- World *wrld;
- for (ob = main->object.first; ob; ob= ob->id.next) {
- ob->m_contactProcessingThreshold = 1.0f; //pad3 is used for m_contactProcessingThreshold
- if (ob->parent) {
- /* check if top parent has compound shape set and if yes, set this object
- * to compound shaper as well (was the behavior before, now it's optional) */
- Object *parent= newlibadr(fd, lib, ob->parent);
- while (parent && parent != ob && parent->parent != NULL) {
- parent = newlibadr(fd, lib, parent->parent);
- }
- if (parent) {
- if (parent->gameflag & OB_CHILD)
- ob->gameflag |= OB_CHILD;
- }
- }
- }
- for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
- wrld->ticrate = 60;
- wrld->maxlogicstep = 5;
- wrld->physubstep = 1;
- wrld->maxphystep = 5;
- }
- }
-
- // correct introduce of seed for wind force
- if (main->versionfile < 249 && main->subversionfile < 1) {
- Object *ob;
- for (ob = main->object.first; ob; ob= ob->id.next) {
- if (ob->pd)
- ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128;
- }
-
- }
-
- if (main->versionfile < 249 && main->subversionfile < 2) {
- Scene *sce= main->scene.first;
- Sequence *seq;
- Editing *ed;
-
- while (sce) {
- ed= sce->ed;
- if (ed) {
- SEQP_BEGIN (ed, seq)
- {
- if (seq->strip && seq->strip->proxy) {
- seq->strip->proxy->quality =90;
- }
- }
- SEQ_END
- }
-
- sce= sce->id.next;
- }
-
- }
-
- if (main->versionfile < 250) {
- bScreen *screen;
- Scene *scene;
- Base *base;
- Material *ma;
- Camera *cam;
- Mesh *me;
- Curve *cu;
- Scene *sce;
- Tex *tx;
- ParticleSettings *part;
- Object *ob;
- //PTCacheID *pid;
- //ListBase pidlist;
-
- bSound *sound;
- Sequence *seq;
- bActuator *act;
- int a;
-
- for (sound = main->sound.first; sound; sound = sound->id.next) {
- if (sound->newpackedfile) {
- sound->packedfile = sound->newpackedfile;
- sound->newpackedfile = NULL;
- }
- }
-
- for (ob = main->object.first; ob; ob= ob->id.next) {
- for (act= ob->actuators.first; act; act= act->next) {
- if (act->type == ACT_SOUND) {
- bSoundActuator *sAct = (bSoundActuator*) act->data;
- if (sAct->sound) {
- sound = newlibadr(fd, lib, sAct->sound);
- sAct->flag = sound->flags & SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0;
- sAct->pitch = sound->pitch;
- sAct->volume = sound->volume;
- sAct->sound3D.reference_distance = sound->distance;
- sAct->sound3D.max_gain = sound->max_gain;
- sAct->sound3D.min_gain = sound->min_gain;
- sAct->sound3D.rolloff_factor = sound->attenuation;
- }
- else {
- sAct->sound3D.reference_distance = 1.0f;
- sAct->volume = 1.0f;
- sAct->sound3D.max_gain = 1.0f;
- sAct->sound3D.rolloff_factor = 1.0f;
- }
- sAct->sound3D.cone_inner_angle = 360.0f;
- sAct->sound3D.cone_outer_angle = 360.0f;
- sAct->sound3D.max_distance = FLT_MAX;
- }
- }
- }
-
- for (scene = main->scene.first; scene; scene = scene->id.next) {
- if (scene->ed && scene->ed->seqbasep) {
- SEQ_BEGIN (scene->ed, seq)
- {
- if (seq->type == SEQ_HD_SOUND) {
- char str[FILE_MAX];
- BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(str, main->name);
- seq->sound = sound_new_file(main, str);
- }
- /* don't know, if anybody used that
- * this way, but just in case, upgrade
- * to new way... */
- if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) &&
- !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR))
- {
-
- BLI_snprintf(seq->strip->proxy->dir,
- FILE_MAXDIR, "%s/BL_proxy",
- seq->strip->dir);
- }
- }
- SEQ_END
- }
- }
-
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- do_versions_windowmanager_2_50(screen);
- do_versions_gpencil_2_50(main, screen);
- }
-
- /* shader, composite and texture node trees have id.name empty, put something in
- * to have them show in RNA viewer and accessible otherwise.
- */
- for (ma= main->mat.first; ma; ma= ma->id.next) {
- if (ma->nodetree && ma->nodetree->id.name[0] == '\0')
- strcpy(ma->nodetree->id.name, "NTShader Nodetree");
-
- /* which_output 0 is now "not specified" */
- for (a=0; a<MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- tx= newlibadr(fd, lib, ma->mtex[a]->tex);
- if (tx && tx->use_nodes)
- ma->mtex[a]->which_output++;
- }
- }
- }
- /* and composite trees */
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->nodetree && sce->nodetree->id.name[0] == '\0')
- strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
-
- /* move to cameras */
- if (sce->r.mode & R_PANORAMA) {
- for (base=sce->base.first; base; base=base->next) {
- ob= newlibadr(fd, lib, base->object);
-
- if (ob->type == OB_CAMERA && !ob->id.lib) {
- cam= newlibadr(fd, lib, ob->data);
- cam->flag |= CAM_PANORAMA;
- }
- }
-
- sce->r.mode &= ~R_PANORAMA;
- }
- }
- /* and texture trees */
- for (tx= main->tex.first; tx; tx= tx->id.next) {
- bNode *node;
-
- if (tx->nodetree) {
- if (tx->nodetree->id.name[0] == '\0')
- strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
-
- /* which_output 0 is now "not specified" */
- for (node=tx->nodetree->nodes.first; node; node=node->next)
- if (node->type == TEX_NODE_OUTPUT)
- node->custom1++;
- }
- }
-
- /* copy standard draw flag to meshes(used to be global, is not available here) */
- for (me= main->mesh.first; me; me= me->id.next) {
- me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
- }
-
- /* particle draw and render types */
- for (part= main->particle.first; part; part= part->id.next) {
- if (part->draw_as) {
- if (part->draw_as == PART_DRAW_DOT) {
- part->ren_as = PART_DRAW_HALO;
- part->draw_as = PART_DRAW_REND;
- }
- else if (part->draw_as <= PART_DRAW_AXIS) {
- part->ren_as = PART_DRAW_HALO;
- }
- else {
- part->ren_as = part->draw_as;
- part->draw_as = PART_DRAW_REND;
- }
- }
- part->path_end = 1.0f;
- part->clength = 1.0f;
- }
- /* set old pointcaches to have disk cache flag */
- for (ob = main->object.first; ob; ob= ob->id.next) {
-
- //BKE_ptcache_ids_from_object(&pidlist, ob);
-
- //for (pid=pidlist.first; pid; pid=pid->next)
- // pid->cache->flag |= PTCACHE_DISK_CACHE;
-
- //BLI_freelistN(&pidlist);
- }
-
- /* type was a mixed flag & enum. move the 2d flag elsewhere */
- for (cu = main->curve.first; cu; cu= cu->id.next) {
- Nurb *nu;
-
- for (nu= cu->nurb.first; nu; nu= nu->next) {
- nu->flag |= (nu->type & CU_2D);
- nu->type &= CU_TYPE;
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) {
- Object *ob;
- Material *ma;
- Tex *tex;
- Scene *sce;
- ToolSettings *ts;
- //PTCacheID *pid;
- //ListBase pidlist;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- //BKE_ptcache_ids_from_object(&pidlist, ob);
-
- //for (pid=pidlist.first; pid; pid=pid->next) {
- // if (pid->ptcaches->first == NULL)
- // pid->ptcaches->first = pid->ptcaches->last = pid->cache;
- //}
-
- //BLI_freelistN(&pidlist);
-
- if (ob->type == OB_MESH) {
- Mesh *me = newlibadr(fd, lib, ob->data);
- void *olddata = ob->data;
- ob->data = me;
-
- /* XXX - library meshes crash on loading most yoFrankie levels,
- * the multires pointer gets invalid - Campbell */
- if (me && me->id.lib==NULL && me->mr && me->mr->level_count > 1) {
- multires_load_old(ob, me);
- }
-
- ob->data = olddata;
- }
-
- if (ob->totcol && ob->matbits == NULL) {
- int a;
-
- ob->matbits= MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits");
- for (a=0; a<ob->totcol; a++)
- ob->matbits[a]= ob->colbits & (1<<a);
- }
- }
-
- /* texture filter */
- for (tex = main->tex.first; tex; tex = tex->id.next) {
- if (tex->afmax == 0)
- tex->afmax= 8;
- }
-
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- int a;
- if (ma->mode & MA_WIRE) {
- ma->material_type= MA_TYPE_WIRE;
- ma->mode &= ~MA_WIRE;
- }
- if (ma->mode & MA_HALO) {
- ma->material_type= MA_TYPE_HALO;
- ma->mode &= ~MA_HALO;
- }
-
- if (ma->mode & (MA_ZTRANSP|MA_RAYTRANSP)) {
- ma->mode |= MA_TRANSP;
- }
- else {
- /* ma->mode |= MA_ZTRANSP; */ /* leave ztransp as is even if its not used [#28113] */
- ma->mode &= ~MA_TRANSP;
- }
-
- /* set new bump for unused slots */
- for (a=0; a<MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- tex= ma->mtex[a]->tex;
- if (!tex) {
- ma->mtex[a]->texflag |= MTEX_3TAP_BUMP;
- ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE;
- }
- else {
- tex= (Tex*)newlibadr(fd, ma->id.lib, tex);
- if (tex && tex->type == 0) { /* invalid type */
- ma->mtex[a]->texflag |= MTEX_3TAP_BUMP;
- ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE;
- }
- }
- }
- }
-
- /* volume rendering settings */
- if (ma->vol.stepsize < 0.0001f) {
- ma->vol.density = 1.0f;
- ma->vol.emission = 0.0f;
- ma->vol.scattering = 1.0f;
- ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f;
- ma->vol.density_scale = 1.0f;
- ma->vol.depth_cutoff = 0.01f;
- ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED;
- ma->vol.stepsize = 0.2f;
- ma->vol.shade_type = MA_VOL_SHADE_SHADED;
- ma->vol.shadeflag |= MA_VOL_PRECACHESHADING;
- ma->vol.precache_resolution = 50;
- }
- }
-
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- ts= sce->toolsettings;
- if (ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
- ts->normalsize= 0.1f;
- ts->selectmode= SCE_SELECT_VERTEX;
-
- /* autokeying - setting should be taken from the user-prefs
- * but the userprefs version may not have correct flags set
- * (i.e. will result in blank box when enabled)
- */
- ts->autokey_mode= U.autokey_mode;
- if (ts->autokey_mode == 0)
- ts->autokey_mode= 2; /* 'add/replace' but not on */
- ts->uv_selectmode= UV_SELECT_VERTEX;
- ts->vgroup_weight= 1.0f;
- }
-
- /* Game Settings */
- //Dome
- sce->gm.dome.angle = sce->r.domeangle;
- sce->gm.dome.mode = sce->r.domemode;
- sce->gm.dome.res = sce->r.domeres;
- sce->gm.dome.resbuf = sce->r.domeresbuf;
- sce->gm.dome.tilt = sce->r.dometilt;
- sce->gm.dome.warptext = sce->r.dometext;
-
- //Stand Alone
- sce->gm.playerflag |= (sce->r.fullscreen?GAME_PLAYER_FULLSCREEN:0);
- sce->gm.xplay = sce->r.xplay;
- sce->gm.yplay = sce->r.yplay;
- sce->gm.freqplay = sce->r.freqplay;
- sce->gm.depth = sce->r.depth;
- sce->gm.attrib = sce->r.attrib;
-
- //Stereo
- sce->gm.stereomode = sce->r.stereomode;
- /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/
- if (sce->gm.stereomode == 1) { //1 = STEREO_NOSTEREO
- sce->gm.stereoflag = STEREO_NOSTEREO;
- sce->gm.stereomode = STEREO_ANAGLYPH;
- }
- else if (sce->gm.stereomode == 8) { //8 = STEREO_DOME
- sce->gm.stereoflag = STEREO_DOME;
- sce->gm.stereomode = STEREO_ANAGLYPH;
- }
- else
- sce->gm.stereoflag = STEREO_ENABLED;
-
- //Framing
- sce->gm.framing = sce->framing;
- sce->gm.xplay = sce->r.xplay;
- sce->gm.yplay = sce->r.yplay;
- sce->gm.freqplay= sce->r.freqplay;
- sce->gm.depth= sce->r.depth;
-
- //Physic (previously stored in world)
- sce->gm.gravity =9.8f;
- sce->gm.physicsEngine= WOPHY_BULLET;// Bullet by default
- sce->gm.mode = WO_DBVT_CULLING; // DBVT culling by default
- sce->gm.occlusionRes = 128;
- sce->gm.ticrate = 60;
- sce->gm.maxlogicstep = 5;
- sce->gm.physubstep = 1;
- sce->gm.maxphystep = 5;
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) {
- Scene *sce;
- Object *ob;
-
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- if (fd->fileflags & G_FILE_ENABLE_ALL_FRAMES)
- sce->gm.flag |= GAME_ENABLE_ALL_FRAMES;
- if (fd->fileflags & G_FILE_SHOW_DEBUG_PROPS)
- sce->gm.flag |= GAME_SHOW_DEBUG_PROPS;
- if (fd->fileflags & G_FILE_SHOW_FRAMERATE)
- sce->gm.flag |= GAME_SHOW_FRAMERATE;
- if (fd->fileflags & G_FILE_SHOW_PHYSICS)
- sce->gm.flag |= GAME_SHOW_PHYSICS;
- if (fd->fileflags & G_FILE_GLSL_NO_SHADOWS)
- sce->gm.flag |= GAME_GLSL_NO_SHADOWS;
- if (fd->fileflags & G_FILE_GLSL_NO_SHADERS)
- sce->gm.flag |= GAME_GLSL_NO_SHADERS;
- if (fd->fileflags & G_FILE_GLSL_NO_RAMPS)
- sce->gm.flag |= GAME_GLSL_NO_RAMPS;
- if (fd->fileflags & G_FILE_GLSL_NO_NODES)
- sce->gm.flag |= GAME_GLSL_NO_NODES;
- if (fd->fileflags & G_FILE_GLSL_NO_EXTRA_TEX)
- sce->gm.flag |= GAME_GLSL_NO_EXTRA_TEX;
- if (fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS)
- sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS;
-
- if (fd->fileflags & G_FILE_GAME_MAT_GLSL)
- sce->gm.matmode= GAME_MAT_GLSL;
- else if (fd->fileflags & G_FILE_GAME_MAT)
- sce->gm.matmode= GAME_MAT_MULTITEX;
- else
- sce->gm.matmode= GAME_MAT_TEXFACE;
-
- sce->gm.flag |= GAME_DISPLAY_LISTS;
- }
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->flag & 8192) // OB_POSEMODE = 8192
- ob->mode |= OB_MODE_POSE;
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) {
- Scene *sce;
- Object *ob;
- Material *ma;
- Lamp *la;
- World *wo;
- Tex *tex;
- ParticleSettings *part;
- int do_gravity = 0;
-
- for (sce = main->scene.first; sce; sce = sce->id.next)
- if (sce->unit.scale_length == 0.0f)
- sce->unit.scale_length= 1.0f;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- /* fluid-sim stuff */
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
- if (fluidmd) fluidmd->fss->fmd = fluidmd;
-
- /* rotation modes were added, but old objects would now default to being 'quaternion based' */
- ob->rotmode= ROT_MODE_EUL;
- }
-
- for (ma = main->mat.first; ma; ma=ma->id.next) {
- if (ma->vol.reflection == 0.f) {
- ma->vol.reflection = 1.f;
- ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f;
- ma->vol.reflection_col[0] = ma->vol.reflection_col[1] = ma->vol.reflection_col[2] = 1.0f;
- }
-
- do_version_mtex_factor_2_50(ma->mtex, ID_MA);
- }
-
- for (la = main->lamp.first; la; la=la->id.next)
- do_version_mtex_factor_2_50(la->mtex, ID_LA);
-
- for (wo = main->world.first; wo; wo=wo->id.next)
- do_version_mtex_factor_2_50(wo->mtex, ID_WO);
-
- for (tex = main->tex.first; tex; tex=tex->id.next)
- if (tex->vd)
- if (tex->vd->extend == 0)
- tex->vd->extend = TEX_CLIP;
-
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->audio.main == 0.0f)
- sce->audio.main = 1.0f;
-
- sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
- sce->r.ffcodecdata.audio_volume = sce->audio.main;
- sce->audio.distance_model = 2;
- sce->audio.doppler_factor = 1.0f;
- sce->audio.speed_of_sound = 343.3f;
- }
-
- /* Add default gravity to scenes */
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
- len_v3(sce->physics_settings.gravity) == 0.0f)
- {
- sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
- sce->physics_settings.gravity[2] = -9.81f;
- sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY;
- do_gravity = 1;
- }
- }
-
- /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */
- if (do_gravity) for (part= main->particle.first; part; part= part->id.next)
- part->effector_weights->global_gravity = part->acc[2]/-9.81f;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- if (do_gravity) {
- for (md= ob->modifiers.first; md; md= md->next) {
- ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
- if (clmd)
- clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81f;
- }
-
- if (ob->soft)
- ob->soft->effector_weights->global_gravity = ob->soft->grav/9.81f;
- }
-
- /* Normal wind shape is plane */
- if (ob->pd) {
- if (ob->pd->forcefield == PFIELD_WIND)
- ob->pd->shape = PFIELD_SHAPE_PLANE;
-
- if (ob->pd->flag & PFIELD_PLANAR)
- ob->pd->shape = PFIELD_SHAPE_PLANE;
- else if (ob->pd->flag & PFIELD_SURFACE)
- ob->pd->shape = PFIELD_SHAPE_SURFACE;
-
- ob->pd->flag |= PFIELD_DO_LOCATION;
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) {
- Object *ob;
- Lamp *la;
-
- /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */
- for (ob= main->object.first; ob; ob= ob->id.next) {
- /* new variables for all objects */
- ob->quat[0]= 1.0f;
- ob->rotAxis[1]= 1.0f;
-
- /* bones */
- if (ob->pose) {
- bPoseChannel *pchan;
-
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- /* just need to initalise rotation axis properly... */
- pchan->rotAxis[1]= 1.0f;
- }
- }
- }
-
- for (la = main->lamp.first; la; la=la->id.next)
- la->compressthresh= 0.05f;
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) {
- Mesh *me;
- Nurb *nu;
- Lattice *lt;
- Curve *cu;
- Key *key;
- float *data;
- int a, tot;
-
- /* shape keys are no longer applied to the mesh itself, but rather
- * to the derivedmesh/displist, so here we ensure that the basis
- * shape key is always set in the mesh coordinates. */
-
- for (me= main->mesh.first; me; me= me->id.next) {
- if ((key = newlibadr(fd, lib, me->key)) && key->refkey) {
- data= key->refkey->data;
- tot= MIN2(me->totvert, key->refkey->totelem);
-
- for (a=0; a<tot; a++, data+=3)
- copy_v3_v3(me->mvert[a].co, data);
- }
- }
-
- for (lt= main->latt.first; lt; lt= lt->id.next) {
- if ((key = newlibadr(fd, lib, lt->key)) && key->refkey) {
- data= key->refkey->data;
- tot= MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem);
-
- for (a=0; a<tot; a++, data+=3)
- copy_v3_v3(lt->def[a].vec, data);
- }
- }
-
- for (cu= main->curve.first; cu; cu= cu->id.next) {
- if ((key = newlibadr(fd, lib, cu->key)) && key->refkey) {
- data= key->refkey->data;
-
- for (nu=cu->nurb.first; nu; nu=nu->next) {
- if (nu->bezt) {
- BezTriple *bezt = nu->bezt;
-
- for (a=0; a<nu->pntsu; a++, bezt++) {
- copy_v3_v3(bezt->vec[0], data); data+=3;
- copy_v3_v3(bezt->vec[1], data); data+=3;
- copy_v3_v3(bezt->vec[2], data); data+=3;
- bezt->alfa= *data; data++;
- }
- }
- else if (nu->bp) {
- BPoint *bp = nu->bp;
-
- for (a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
- copy_v3_v3(bp->vec, data); data+=3;
- bp->alfa= *data; data++;
- }
- }
- }
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) {
- {
- Scene *sce= main->scene.first;
- while (sce) {
- if (sce->r.frame_step==0)
- sce->r.frame_step= 1;
- if (sce->r.mblur_samples==0)
- sce->r.mblur_samples = sce->r.osa;
-
- if (sce->ed && sce->ed->seqbase.first) {
- do_versions_seq_unique_name_all_strips(
- sce, &sce->ed->seqbase);
- }
-
- sce= sce->id.next;
- }
- }
- {
- /* ensure all nodes have unique names */
- bNodeTree *ntree= main->nodetree.first;
- while (ntree) {
- bNode *node=ntree->nodes.first;
-
- while (node) {
- nodeUniqueName(ntree, node);
- node= node->next;
- }
-
- ntree= ntree->id.next;
- }
- }
- {
- Object *ob=main->object.first;
- while (ob) {
- /* shaded mode disabled for now */
- if (ob->dt == OB_MATERIAL) ob->dt = OB_TEXTURE;
- ob=ob->id.next;
- }
- }
-
- {
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->drawtype == OB_MATERIAL) v3d->drawtype = OB_SOLID;
- }
- }
- }
- }
- }
-
- /* only convert old 2.50 files with color management */
- if (main->versionfile == 250) {
- Scene *sce=main->scene.first;
- Material *ma=main->mat.first;
- World *wo=main->world.first;
- Tex *tex=main->tex.first;
- int i, convert=0;
-
- /* convert to new color management system:
- * while previously colors were stored as srgb,
- * now they are stored as linear internally,
- * with screen gamma correction in certain places in the UI. */
-
- /* don't know what scene is active, so we'll convert if any scene has it enabled... */
- while (sce) {
- if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- convert=1;
- sce=sce->id.next;
- }
-
- if (convert) {
- while (ma) {
- if (ma->ramp_col) {
- ColorBand *band = (ColorBand *)ma->ramp_col;
- for (i=0; i<band->tot; i++) {
- CBData *data = band->data + i;
- srgb_to_linearrgb_v3_v3(&data->r, &data->r);
- }
- }
- if (ma->ramp_spec) {
- ColorBand *band = (ColorBand *)ma->ramp_spec;
- for (i=0; i<band->tot; i++) {
- CBData *data = band->data + i;
- srgb_to_linearrgb_v3_v3(&data->r, &data->r);
- }
- }
-
- srgb_to_linearrgb_v3_v3(&ma->r, &ma->r);
- srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr);
- srgb_to_linearrgb_v3_v3(&ma->mirr, &ma->mirr);
- srgb_to_linearrgb_v3_v3(ma->sss_col, ma->sss_col);
- ma=ma->id.next;
- }
-
- while (tex) {
- if (tex->coba) {
- ColorBand *band = (ColorBand *)tex->coba;
- for (i=0; i<band->tot; i++) {
- CBData *data = band->data + i;
- srgb_to_linearrgb_v3_v3(&data->r, &data->r);
- }
- }
- tex=tex->id.next;
- }
-
- while (wo) {
- srgb_to_linearrgb_v3_v3(&wo->ambr, &wo->ambr);
- srgb_to_linearrgb_v3_v3(&wo->horr, &wo->horr);
- srgb_to_linearrgb_v3_v3(&wo->zenr, &wo->zenr);
- wo=wo->id.next;
- }
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) {
- Scene *sce;
- Mesh *me;
- Object *ob;
-
- for (sce=main->scene.first; sce; sce=sce->id.next)
- if (!sce->toolsettings->particle.selectmode)
- sce->toolsettings->particle.selectmode= SCE_SELECT_PATH;
-
- if (main->versionfile == 250 && main->subversionfile > 1) {
- for (me=main->mesh.first; me; me=me->id.next)
- multires_load_old_250(me);
-
- for (ob=main->object.first; ob; ob=ob->id.next) {
- MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(ob, eModifierType_Multires);
-
- if (mmd) {
- mmd->totlvl--;
- mmd->lvl--;
- mmd->sculptlvl= mmd->lvl;
- mmd->renderlvl= mmd->lvl;
- }
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10)) {
- Object *ob;
-
- /* properly initialize hair clothsim data on old files */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md= ob->modifiers.first; md; md= md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
- if (clmd->sim_parms->velocity_smooth < 0.01f)
- clmd->sim_parms->velocity_smooth = 0.f;
- }
- }
- }
- }
-
- /* fix bad area setup in subversion 10 */
- if (main->versionfile == 250 && main->subversionfile == 10) {
- /* fix for new view type in sequencer */
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
-
- /* remove all preview window in wrong spaces */
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype!=SPACE_SEQ) {
- ARegion *ar;
- ListBase *regionbase;
-
- if (sl == sa->spacedata.first) {
- regionbase = &sa->regionbase;
- }
- else {
- regionbase = &sl->regionbase;
- }
-
-
- for ( ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_PREVIEW)
- break;
- }
-
- if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) {
- SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ);
- BKE_area_region_free(st, ar);
- BLI_freelinkN(regionbase, ar);
- }
- }
- }
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11)) {
- {
- /* fix for new view type in sequencer */
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
-
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_SEQ) {
- ARegion *ar;
- ARegion *ar_main;
- ListBase *regionbase;
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- if (sl == sa->spacedata.first) {
- regionbase = &sa->regionbase;
- }
- else {
- regionbase = &sl->regionbase;
- }
-
- if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE;
- if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
-
- ar_main = (ARegion*)regionbase->first;
- for (; ar_main; ar_main = ar_main->next) {
- if (ar_main->regiontype == RGN_TYPE_WINDOW)
- break;
- }
- ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
- BLI_insertlinkbefore(regionbase, ar_main, ar);
- sequencer_init_preview_region(ar);
- }
- }
- }
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) {
- Scene *sce;
- Object *ob;
- Brush *brush;
- Material *ma;
-
- /* game engine changes */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- sce->gm.eyeseparation = 0.10f;
- }
-
- /* anim viz changes */
- for (ob= main->object.first; ob; ob= ob->id.next) {
- /* initialize object defaults */
- animviz_settings_init(&ob->avs);
-
- /* if armature, copy settings for pose from armature data
- * performing initialization where appropriate
- */
- if (ob->pose && ob->data) {
- bArmature *arm= newlibadr(fd, lib, ob->data);
- if (arm) { /* XXX - why does this fail in some cases? */
- bAnimVizSettings *avs= &ob->pose->avs;
-
- /* ghosting settings ---------------- */
- /* ranges */
- avs->ghost_bc= avs->ghost_ac= arm->ghostep;
-
- avs->ghost_sf= arm->ghostsf;
- avs->ghost_ef= arm->ghostef;
- if ((avs->ghost_sf == avs->ghost_ef) && (avs->ghost_sf == 0)) {
- avs->ghost_sf= 1;
- avs->ghost_ef= 100;
- }
-
- /* type */
- if (arm->ghostep == 0)
- avs->ghost_type= GHOST_TYPE_NONE;
- else
- avs->ghost_type= arm->ghosttype + 1;
-
- /* stepsize */
- avs->ghost_step= arm->ghostsize;
- if (avs->ghost_step == 0)
- avs->ghost_step= 1;
-
- /* path settings --------------------- */
- /* ranges */
- avs->path_bc= arm->pathbc;
- avs->path_ac= arm->pathac;
- if ((avs->path_bc == avs->path_ac) && (avs->path_bc == 0))
- avs->path_bc= avs->path_ac= 10;
-
- avs->path_sf= arm->pathsf;
- avs->path_ef= arm->pathef;
- if ((avs->path_sf == avs->path_ef) && (avs->path_sf == 0)) {
- avs->path_sf= 1;
- avs->path_ef= 250;
- }
-
- /* flags */
- if (arm->pathflag & ARM_PATH_FNUMS)
- avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS;
- if (arm->pathflag & ARM_PATH_KFRAS)
- avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS;
- if (arm->pathflag & ARM_PATH_KFNOS)
- avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS;
-
- /* bake flags */
- if (arm->pathflag & ARM_PATH_HEADS)
- avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS;
-
- /* type */
- if (arm->pathflag & ARM_PATH_ACFRA)
- avs->path_type = MOTIONPATH_TYPE_ACFRA;
-
- /* stepsize */
- avs->path_step= arm->pathsize;
- if (avs->path_step == 0)
- avs->path_step= 1;
- }
- else
- animviz_settings_init(&ob->pose->avs);
- }
- }
-
- /* brush texture changes */
- for (brush= main->brush.first; brush; brush= brush->id.next) {
- default_mtex(&brush->mtex);
- }
-
- for (ma= main->mat.first; ma; ma= ma->id.next) {
- if (ma->vol.ms_spread < 0.0001f) {
- ma->vol.ms_spread = 0.2f;
- ma->vol.ms_diff = 1.f;
- ma->vol.ms_intensity = 1.f;
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) {
- /* NOTE: if you do more conversion, be sure to do it outside of this and
- * increase subversion again, otherwise it will not be correct */
- Object *ob;
-
- /* convert degrees to radians for internal use */
- for (ob=main->object.first; ob; ob=ob->id.next) {
- bPoseChannel *pchan;
-
- do_version_constraints_radians_degrees_250(&ob->constraints);
-
- if (ob->pose) {
- for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- pchan->limitmin[0] *= (float)(M_PI/180.0);
- pchan->limitmin[1] *= (float)(M_PI/180.0);
- pchan->limitmin[2] *= (float)(M_PI/180.0);
- pchan->limitmax[0] *= (float)(M_PI/180.0);
- pchan->limitmax[1] *= (float)(M_PI/180.0);
- pchan->limitmax[2] *= (float)(M_PI/180.0);
-
- do_version_constraints_radians_degrees_250(&pchan->constraints);
- }
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 14)) {
- /* fix for bad View2D extents for Animation Editors */
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- ListBase *regionbase;
- ARegion *ar;
-
- if (sl == sa->spacedata.first)
- regionbase = &sa->regionbase;
- else
- regionbase = &sl->regionbase;
-
- if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
- for (ar = (ARegion*)regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f;
- ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
- }
- }
- }
- }
- }
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 15)) {
- World *wo;
- Material *ma;
-
- /* ambient default from 0.5f to 1.0f */
- for (ma= main->mat.first; ma; ma=ma->id.next)
- ma->amb *= 2.0f;
-
- for (wo= main->world.first; wo; wo=wo->id.next) {
- /* ao splitting into ao/env/indirect */
- wo->ao_env_energy= wo->aoenergy;
- wo->aoenergy= 1.0f;
-
- if (wo->ao_indirect_bounces == 0)
- wo->ao_indirect_bounces= 1;
- else
- wo->mode |= WO_INDIRECT_LIGHT;
-
- if (wo->aomix == WO_AOSUB)
- wo->ao_env_energy= -wo->ao_env_energy;
- else if (wo->aomix == WO_AOADDSUB)
- wo->mode |= WO_AMB_OCC;
-
- wo->aomix= WO_AOMUL;
-
- /* ambient default from 0.5f to 1.0f */
- mul_v3_fl(&wo->ambr, 0.5f);
- wo->ao_env_energy *= 0.5f;
- }
- }
-
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) {
- Scene *sce;
- Sequence *seq;
- Material *ma;
-
- /* initialize to sane default so toggling on border shows something */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f &&
- sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f) {
- sce->r.border.xmin = 0.0f;
- sce->r.border.ymin = 0.0f;
- sce->r.border.xmax = 1.0f;
- sce->r.border.ymax = 1.0f;
- }
-
- if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
- sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
-
- SEQ_BEGIN (sce->ed, seq)
- {
- seq->volume = 1.0f;
- }
- SEQ_END
- }
-
- /* particle brush strength factor was changed from int to float */
- for (sce= main->scene.first; sce; sce=sce->id.next) {
- ParticleEditSettings *pset= &sce->toolsettings->particle;
- int a;
-
- for (a=0; a<PE_TOT_BRUSH; a++)
- pset->brush[a].strength /= 100.0f;
- }
-
- for (ma = main->mat.first; ma; ma=ma->id.next)
- if (ma->mode & MA_TRACEBLE)
- ma->shade_flag |= MA_APPROX_OCCLUSION;
-
- /* sequencer changes */
- {
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_SEQ) {
- ARegion *ar_preview;
- ListBase *regionbase;
-
- if (sl == sa->spacedata.first) {
- regionbase = &sa->regionbase;
- }
- else {
- regionbase = &sl->regionbase;
- }
-
- ar_preview = (ARegion*)regionbase->first;
- for (; ar_preview; ar_preview = ar_preview->next) {
- if (ar_preview->regiontype == RGN_TYPE_PREVIEW)
- break;
- }
- if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) {
- sequencer_init_preview_region(ar_preview);
- }
- }
- }
- }
- }
- } /* sequencer changes */
- }
-
- if (main->versionfile <= 251) { /* 2.5.1 had no subversions */
- bScreen *sc;
-
- /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE.
- * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated.
- * Here we clear it for old files so they don't come in with V3D_RENDER_OVERRIDE set,
- * which would cause cameras, lamps, etc to become invisible */
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D* v3d = (View3D *)sl;
- v3d->flag2 &= ~V3D_RENDER_OVERRIDE;
- }
- }
- }
- }
- }
-
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 1)) {
- Brush *brush;
- Object *ob;
- Scene *scene;
- bNodeTree *ntree;
-
- for (brush= main->brush.first; brush; brush= brush->id.next) {
- if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH;
- }
-
- /* properly initialize active flag for fluidsim modifiers */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md= ob->modifiers.first; md; md= md->next) {
- if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fmd = (FluidsimModifierData *)md;
- fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
- fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME;
- }
- }
- }
-
- /* adjustment to color balance node values */
- for (scene= main->scene.first; scene; scene= scene->id.next) {
- if (scene->nodetree) {
- bNode *node=scene->nodetree->nodes.first;
-
- while (node) {
- if (node->type == CMP_NODE_COLORBALANCE) {
- NodeColorBalance *n= (NodeColorBalance *)node->storage;
- n->lift[0] += 1.f;
- n->lift[1] += 1.f;
- n->lift[2] += 1.f;
- }
- node= node->next;
- }
- }
- }
- /* check inside node groups too */
- for (ntree= main->nodetree.first; ntree; ntree=ntree->id.next) {
- bNode *node=ntree->nodes.first;
-
- while (node) {
- if (node->type == CMP_NODE_COLORBALANCE) {
- NodeColorBalance *n= (NodeColorBalance *)node->storage;
- n->lift[0] += 1.f;
- n->lift[1] += 1.f;
- n->lift[2] += 1.f;
- }
- node= node->next;
- }
- }
- }
-
- /* old-track -> constraints (this time we're really doing it!) */
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 2)) {
- Object *ob;
-
- for (ob = main->object.first; ob; ob = ob->id.next)
- do_version_old_trackto_to_constraints(ob);
- }
-
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
- bScreen *sc;
-
- /* Image editor scopes */
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
- scopes_new(&sima->scopes);
- }
- }
- }
- }
- }
-
-
- if (main->versionfile < 253) {
- Object *ob;
- Scene *scene;
- bScreen *sc;
- Tex *tex;
- Brush *brush;
-
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode= (SpaceNode *)sl;
- ListBase *regionbase;
- ARegion *ar;
-
- if (sl == sa->spacedata.first)
- regionbase = &sa->regionbase;
- else
- regionbase = &sl->regionbase;
-
- if (snode->v2d.minzoom > 0.09f)
- snode->v2d.minzoom= 0.09f;
- if (snode->v2d.maxzoom < 2.31f)
- snode->v2d.maxzoom= 2.31f;
-
- for (ar= regionbase->first; ar; ar= ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.minzoom > 0.09f)
- ar->v2d.minzoom= 0.09f;
- if (ar->v2d.maxzoom < 2.31f)
- ar->v2d.maxzoom= 2.31f;
- }
- }
- }
- else if (sl->spacetype == SPACE_TIME) {
- SpaceTime *stime= (SpaceTime *)sl;
-
- /* enable all cache display */
- stime->cache_display |= TIME_CACHE_DISPLAY;
- stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
- stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
- }
- }
- }
- }
-
- do_version_mdef_250(main);
-
- /* parent type to modifier */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->parent) {
- Object *parent= (Object *)newlibadr(fd, lib, ob->parent);
- if (parent) { /* parent may not be in group */
- if (parent->type==OB_ARMATURE && ob->partype==PARSKEL) {
- ArmatureModifierData *amd;
- bArmature *arm= (bArmature *)newlibadr(fd, lib, parent->data);
-
- amd = (ArmatureModifierData*) modifier_new(eModifierType_Armature);
- amd->object = ob->parent;
- BLI_addtail((ListBase*)&ob->modifiers, amd);
- amd->deformflag= arm->deformflag;
- ob->partype = PAROBJECT;
- }
- else if (parent->type==OB_LATTICE && ob->partype==PARSKEL) {
- LatticeModifierData *lmd;
-
- lmd = (LatticeModifierData*) modifier_new(eModifierType_Lattice);
- lmd->object = ob->parent;
- BLI_addtail((ListBase*)&ob->modifiers, lmd);
- ob->partype = PAROBJECT;
- }
- else if (parent->type==OB_CURVE && ob->partype==PARCURVE) {
- CurveModifierData *cmd;
-
- cmd = (CurveModifierData*) modifier_new(eModifierType_Curve);
- cmd->object = ob->parent;
- BLI_addtail((ListBase*)&ob->modifiers, cmd);
- ob->partype = PAROBJECT;
- }
- }
- }
- }
-
- /* initialize scene active layer */
- for (scene= main->scene.first; scene; scene=scene->id.next) {
- int i;
- for (i=0; i<20; i++) {
- if (scene->lay & (1<<i)) {
- scene->layact= 1<<i;
- break;
- }
- }
- }
-
- for (tex= main->tex.first; tex; tex= tex->id.next) {
- /* if youre picky, this isn't correct until we do a version bump
- * since you could set saturation to be 0.0*/
- if (tex->saturation==0.0f)
- tex->saturation= 1.0f;
- }
-
- {
- Curve *cu;
- for (cu= main->curve.first; cu; cu= cu->id.next) {
- cu->smallcaps_scale= 0.75f;
- }
- }
-
- for (scene= main->scene.first; scene; scene=scene->id.next) {
- if (scene) {
- Sequence *seq;
- SEQ_BEGIN (scene->ed, seq)
- {
- if (seq->sat==0.0f) {
- seq->sat= 1.0f;
- }
- }
- SEQ_END
- }
- }
-
- /* GSOC 2010 Sculpt - New settings for Brush */
-
- for (brush= main->brush.first; brush; brush= brush->id.next) {
- /* Sanity Check */
-
- // infinite number of dabs
- if (brush->spacing == 0)
- brush->spacing = 10;
-
- // will have no effect
- if (brush->alpha == 0)
- brush->alpha = 0.5f;
-
- // bad radius
- if (brush->unprojected_radius == 0)
- brush->unprojected_radius = 0.125f;
-
- // unusable size
- if (brush->size == 0)
- brush->size = 35;
-
- // can't see overlay
- if (brush->texture_overlay_alpha == 0)
- brush->texture_overlay_alpha = 33;
-
- // same as draw brush
- if (brush->crease_pinch_factor == 0)
- brush->crease_pinch_factor = 0.5f;
-
- // will sculpt no vertexes
- if (brush->plane_trim == 0)
- brush->plane_trim = 0.5f;
-
- // same as smooth stroke off
- if (brush->smooth_stroke_radius == 0)
- brush->smooth_stroke_radius= 75;
-
- // will keep cursor in one spot
- if (brush->smooth_stroke_radius == 1)
- brush->smooth_stroke_factor= 0.9f;
-
- // same as dots
- if (brush->rate == 0)
- brush->rate = 0.1f;
-
- /* New Settings */
- if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
- brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space
-
- // spacing was originally in pixels, convert it to percentage for new version
- // size should not be zero due to sanity check above
- brush->spacing = (int)(100*((float)brush->spacing) / ((float)brush->size));
-
- if (brush->add_col[0] == 0 &&
- brush->add_col[1] == 0 &&
- brush->add_col[2] == 0)
- {
- brush->add_col[0] = 1.00f;
- brush->add_col[1] = 0.39f;
- brush->add_col[2] = 0.39f;
- }
-
- if (brush->sub_col[0] == 0 &&
- brush->sub_col[1] == 0 &&
- brush->sub_col[2] == 0)
- {
- brush->sub_col[0] = 0.39f;
- brush->sub_col[1] = 0.39f;
- brush->sub_col[2] = 1.00f;
- }
- }
- }
- }
-
- /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */
- if (main->versionfile < 253) {
- Scene *sce;
- for (sce= main->scene.first; sce; sce= sce->id.next) {
- if (sce->toolsettings->sculpt_paint_unified_alpha == 0)
- sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
-
- if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0)
- sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f;
-
- if (sce->toolsettings->sculpt_paint_unified_size == 0)
- sce->toolsettings->sculpt_paint_unified_size = 35;
- }
- }
-
- if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) {
- Object *ob;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md= ob->modifiers.first; md; md= md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
-
- if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
- smd->domain->vorticity = 2.0f;
- smd->domain->time_scale = 1.0f;
-
- if (!(smd->domain->flags & (1<<4)))
- continue;
-
- /* delete old MOD_SMOKE_INITVELOCITY flag */
- smd->domain->flags &= ~(1<<4);
-
- /* for now just add it to all flow objects in the scene */
- {
- Object *ob2;
- for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) {
- ModifierData *md2;
- for (md2= ob2->modifiers.first; md2; md2= md2->next) {
- if (md2->type == eModifierType_Smoke) {
- SmokeModifierData *smd2 = (SmokeModifierData *)md2;
-
- if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) {
- smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY;
- }
- }
- }
- }
- }
-
- }
- else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
- smd->flow->vel_multi = 1.0f;
- }
-
- }
- }
- }
- }
-
- if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 1)) {
- Brush *br;
- ParticleSettings *part;
- bScreen *sc;
- Object *ob;
-
- for (br= main->brush.first; br; br= br->id.next) {
- if (br->ob_mode==0)
- br->ob_mode= OB_MODE_ALL_PAINT;
- }
-
- for (part = main->particle.first; part; part = part->id.next) {
- if (part->boids)
- part->boids->pitch = 1.0f;
-
- part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
- part->kink_amp_clump = 1.f; /* keep old files looking similar */
- }
-
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- ScrArea *sa;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype == SPACE_INFO) {
- SpaceInfo *sinfo= (SpaceInfo *)sl;
- ARegion *ar;
-
- sinfo->rpt_mask= INFO_RPT_OP;
-
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- ar->v2d.scroll = (V2D_SCROLL_RIGHT);
- ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */
- ar->v2d.keepofs = V2D_LOCKOFS_X;
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
- ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS;
- ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
- }
- }
- }
- }
- }
- }
-
- /* fix rotation actuators for objects so they use real angles (radians)
- * since before blender went opensource this strange scalar was used: (1 / 0.02) * 2 * math.pi/360 */
- for (ob= main->object.first; ob; ob= ob->id.next) {
- bActuator *act= ob->actuators.first;
- while (act) {
- if (act->type==ACT_OBJECT) {
- /* multiply velocity with 50 in old files */
- bObjectActuator *oa= act->data;
- mul_v3_fl(oa->drot, 0.8726646259971648f);
- }
- act= act->next;
- }
- }
- }
-
- // init facing axis property of steering actuators
- {
- Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- bActuator *act;
- for (act= ob->actuators.first; act; act= act->next) {
- if (act->type==ACT_STEERING) {
- bSteeringActuator* stact = act->data;
- if (stact->facingaxis==0) {
- stact->facingaxis=1;
- }
- }
- }
- }
- }
-
- if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) {
- Object *ob;
-
- /* ocean res is now squared, reset old ones - will be massive */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md= ob->modifiers.first; md; md= md->next) {
- if (md->type == eModifierType_Ocean) {
- OceanModifierData *omd = (OceanModifierData *)md;
- omd->resolution = 7;
- omd->oceancache = NULL;
- }
- }
- }
- }
-
- if (main->versionfile < 256) {
- bScreen *sc;
- ScrArea *sa;
- Key *key;
-
- /* Fix for sample line scope initializing with no height */
- for (sc= main->screen.first; sc; sc= sc->id.next) {
- sa= sc->areabase.first;
- while (sa) {
- SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_IMAGE) {
- SpaceImage *sima= (SpaceImage *)sl;
- if (sima->sample_line_hist.height == 0 )
- sima->sample_line_hist.height = 100;
- }
- }
- sa= sa->next;
- }
- }
-
- /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in
- * 2.4x would never reveal this to users as a dummy value always ended up getting used
- * instead
- */
- for (key = main->key.first; key; key = key->id.next) {
- KeyBlock *kb;
-
- for (kb = key->block.first; kb; kb = kb->next) {
- if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0))
- kb->slidermax = kb->slidermin + 1.0f;
- }
- }
- }
-
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) {
- /* fix for bones that didn't have arm_roll before */
- bArmature* arm;
- Bone* bone;
- Object *ob;
-
- for (arm = main->armature.first; arm; arm = arm->id.next)
- for (bone = arm->bonebase.first; bone; bone = bone->next)
- do_version_bone_roll_256(bone);
-
- /* fix for objects which have zero dquat's
- * since this is multiplied with the quat rather than added */
- for (ob= main->object.first; ob; ob= ob->id.next) {
- if (is_zero_v4(ob->dquat)) {
- unit_qt(ob->dquat);
- }
- if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) {
- unit_axis_angle(ob->drotAxis, &ob->drotAngle);
- }
- }
- }
-
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) {
- bNodeTree *ntree;
-
- /* node sockets are not exposed automatically any more,
- * this mimics the old behavior by adding all unlinked sockets to groups.
- */
- for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
- /* XXX Only setting a flag here. Actual adding of group sockets
- * is done in lib_verify_nodetree, because at this point the internal
- * nodes may not be up-to-date! (missing lib-link)
- */
- ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE;
- }
- }
-
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <3)) {
- bScreen *sc;
- Brush *brush;
- Object *ob;
- ParticleSettings *part;
- Material *mat;
- int tex_nr, transp_tex;
-
- for (mat = main->mat.first; mat; mat = mat->id.next) {
- if (!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)) {
-
- transp_tex= 0;
-
- for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
- if (!mat->mtex[tex_nr]) continue;
- if (mat->mtex[tex_nr]->mapto & MAP_ALPHA) transp_tex= 1;
- }
-
- /* weak! material alpha could be animated */
- if (mat->alpha < 1.0f || mat->fresnel_tra > 0.0f || transp_tex) {
- mat->mode |= MA_TRANSP;
- mat->mode &= ~(MA_ZTRANSP|MA_RAYTRANSP);
- }
- }
- }
-
- /* redraws flag in SpaceTime has been moved to Screen level */
- for (sc = main->screen.first; sc; sc= sc->id.next) {
- if (sc->redraws_flag == 0) {
- /* just initialize to default? */
- // XXX: we could also have iterated through areas, and taken them from the first timeline available...
- sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
- }
- }
-
- for (brush= main->brush.first; brush; brush= brush->id.next) {
- if (brush->height == 0)
- brush->height= 0.4f;
- }
-
- /* replace 'rim material' option for in offset*/
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md= ob->modifiers.first; md; md= md->next) {
- if (md->type == eModifierType_Solidify) {
- SolidifyModifierData *smd = (SolidifyModifierData *)md;
- if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
- smd->mat_ofs_rim= 1;
- smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
- }
- }
- }
- }
-
- /* particle draw color from material */
- for (part = main->particle.first; part; part = part->id.next) {
- if (part->draw & PART_DRAW_MAT_COL)
- part->draw_col = PART_DRAW_COL_MAT;
- }
- }
-
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)) {
- Mesh *me;
-
- for (me= main->mesh.first; me; me= me->id.next)
- mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL);
- }
-
- if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) {
- /* update blur area sizes from 0..1 range to 0..100 percentage */
- Scene *scene;
- bNode *node;
- for (scene=main->scene.first; scene; scene=scene->id.next)
- if (scene->nodetree)
- for (node=scene->nodetree->nodes.first; node; node=node->next)
- if (node->type==CMP_NODE_BLUR) {
- NodeBlurData *nbd= node->storage;
- nbd->percentx *= 100.0f;
- nbd->percenty *= 100.0f;
- }
- }
-
- if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)) {
- /* screen view2d settings were not properly initialized [#27164]
- * v2d->scroll caused the bug but best reset other values too which are in old blend files only.
- * need to make less ugly - possibly an iterator? */
- bScreen *screen;
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- ScrArea *sa;
- /* add regions */
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl= sa->spacedata.first;
- if (sl->spacetype==SPACE_IMAGE) {
- ARegion *ar;
- for (ar=sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- View2D *v2d= &ar->v2d;
- v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
- }
- }
- }
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_IMAGE) {
- ARegion *ar;
- for (ar=sl->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- View2D *v2d= &ar->v2d;
- v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
- }
- }
- }
- }
- }
- }
-
- {
- /* Initialize texture point density curve falloff */
- Tex *tex;
- for (tex= main->tex.first; tex; tex= tex->id.next) {
- if (tex->pd) {
- if (tex->pd->falloff_speed_scale == 0.0f)
- tex->pd->falloff_speed_scale = 100.0f;
-
- if (!tex->pd->falloff_curve) {
- tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
-
- tex->pd->falloff_curve->preset = CURVE_PRESET_LINE;
- tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
- curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
- curvemapping_changed(tex->pd->falloff_curve, 0);
- }
- }
- }
- }
-
- {
- /* add default value for behind strength of camera actuator */
- Object *ob;
- bActuator *act;
- for (ob = main->object.first; ob; ob= ob->id.next) {
- for (act= ob->actuators.first; act; act= act->next) {
- if (act->type == ACT_CAMERA) {
- bCameraActuator *ba= act->data;
-
- ba->damping = 1.0/32.0;
- }
- }
- }
- }
-
- {
- ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
- /* Initialize particle billboard scale */
- part->bb_size[0] = part->bb_size[1] = 1.0f;
- }
- }
- }
-
- if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)) {
- {
- Scene *scene;
- Sequence *seq;
-
- for (scene=main->scene.first; scene; scene=scene->id.next) {
- scene->r.ffcodecdata.audio_channels = 2;
- scene->audio.volume = 1.0f;
- SEQ_BEGIN (scene->ed, seq)
- {
- seq->pitch = 1.0f;
- }
- SEQ_END
- }
- }
- {
- bScreen *screen;
- for (screen= main->screen.first; screen; screen= screen->id.next) {
- ScrArea *sa;
- /* add regions */
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- SpaceLink *sl= sa->spacedata.first;
- if (sl->spacetype==SPACE_SEQ) {
- ARegion *ar;
- for (ar=sa->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.min[1] == 4.0f)
- ar->v2d.min[1]= 0.5f;
- }
- }
- }
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_SEQ) {
- ARegion *ar;
- for (ar=sl->regionbase.first; ar; ar= ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.min[1] == 4.0f)
- ar->v2d.min[1]= 0.5f;
- }
- }
- }
- }
- }
- }
- }
- {
- /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve
- *
- * We're only patching F-Curves in Actions here, since it is assumed that most
- * drivers out there won't be using this (and if they are, they're in the minority).
- * While we should aim to fix everything ideally, in practice it's far too hard
- * to get to every animdata block, not to mention the performance hit that'd have
- */
- bAction *act;
- FCurve *fcu;
-
- for (act = main->action.first; act; act = act->id.next) {
- for (fcu = act->curves.first; fcu; fcu = fcu->next) {
- BezTriple *bezt;
- unsigned int i = 0;
-
- /* only need to touch curves that had this flag set */
- if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
- continue;
- if ((fcu->totvert == 0) || (fcu->bezt == NULL))
- continue;
-
- /* only change auto-handles to auto-clamped */
- for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
- if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM;
- if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM;
- }
-
- fcu->flag &= ~FCURVE_AUTO_HANDLES;
- }
- }
- }
- {
- /* convert fcurve and shape action actuators to action actuators */
- Object *ob;
- bActuator *act;
- bIpoActuator *ia;
- bActionActuator *aa;
-
- for (ob= main->object.first; ob; ob= ob->id.next) {
- for (act= ob->actuators.first; act; act= act->next) {
- if (act->type == ACT_IPO) {
- // Create the new actuator
- ia= act->data;
- aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version");
-
- // Copy values
- aa->type = ia->type;
- aa->flag = ia->flag;
- aa->sta = ia->sta;
- aa->end = ia->end;
- BLI_strncpy(aa->name, ia->name, sizeof(aa->name));
- BLI_strncpy(aa->frameProp, ia->frameProp, sizeof(aa->frameProp));
- if (ob->adt)
- aa->act = ob->adt->action;
-
- // Get rid of the old actuator
- MEM_freeN(ia);
-
- // Assign the new actuator
- act->data = aa;
- act->type= act->otype= ACT_ACTION;
-
- }
- else if (act->type == ACT_SHAPEACTION) {
- act->type = act->otype = ACT_ACTION;
- }
- }
- }
- }
- }
-
- if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)) {
- {
- /* Convert default socket values from bNodeStack */
- Scene *sce;
- Material *mat;
- Tex *tex;
- bNodeTree *ntree;
- for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
- do_versions_nodetree_default_value(ntree);
- ntree->update |= NTREE_UPDATE;
- }
- for (sce=main->scene.first; sce; sce=sce->id.next)
- if (sce->nodetree) {
- do_versions_nodetree_default_value(sce->nodetree);
- sce->nodetree->update |= NTREE_UPDATE;
- }
- for (mat=main->mat.first; mat; mat=mat->id.next)
- if (mat->nodetree) {
- do_versions_nodetree_default_value(mat->nodetree);
- mat->nodetree->update |= NTREE_UPDATE;
- }
- for (tex=main->tex.first; tex; tex=tex->id.next)
- if (tex->nodetree) {
- do_versions_nodetree_default_value(tex->nodetree);
- tex->nodetree->update |= NTREE_UPDATE;
- }
- }
-
- /* add SOCK_DYNAMIC flag to existing group sockets */
- {
- bNodeTree *ntree;
- /* only need to do this for trees in main, local trees are not used as groups */
- for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
- do_versions_nodetree_dynamic_sockets(ntree);
- ntree->update |= NTREE_UPDATE;
- }
- }
-
- {
- /* Initialize group tree nodetypes.
- * These are used to distinguish tree types and
- * associate them with specific node types for polling.
- */
- bNodeTree *ntree;
- /* all node trees in main->nodetree are considered groups */
- for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
- ntree->nodetype = NODE_GROUP;
- }
- }
-
- if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 4)) {
- {
- /* Adaptive time step for particle systems */
- ParticleSettings *part;
- for (part = main->particle.first; part; part = part->id.next) {
- part->courant_target = 0.2f;
- part->time_flag &= ~PART_TIME_AUTOSF;
- }
- }
-
- {
- /* set defaults for obstacle avoidance, recast data */
- Scene *sce;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- if (sce->gm.levelHeight == 0.f)
- sce->gm.levelHeight = 2.f;
-
- if (sce->gm.recastData.cellsize == 0.0f)
- sce->gm.recastData.cellsize = 0.3f;
- if (sce->gm.recastData.cellheight == 0.0f)
- sce->gm.recastData.cellheight = 0.2f;
- if (sce->gm.recastData.agentmaxslope == 0.0f)
- sce->gm.recastData.agentmaxslope = (float)M_PI/4;
- if (sce->gm.recastData.agentmaxclimb == 0.0f)
- sce->gm.recastData.agentmaxclimb = 0.9f;
- if (sce->gm.recastData.agentheight == 0.0f)
- sce->gm.recastData.agentheight = 2.0f;
- if (sce->gm.recastData.agentradius == 0.0f)
- sce->gm.recastData.agentradius = 0.6f;
- if (sce->gm.recastData.edgemaxlen == 0.0f)
- sce->gm.recastData.edgemaxlen = 12.0f;
- if (sce->gm.recastData.edgemaxerror == 0.0f)
- sce->gm.recastData.edgemaxerror = 1.3f;
- if (sce->gm.recastData.regionminsize == 0.0f)
- sce->gm.recastData.regionminsize = 8.f;
- if (sce->gm.recastData.regionmergesize == 0.0f)
- sce->gm.recastData.regionmergesize = 20.f;
- if (sce->gm.recastData.vertsperpoly<3)
- sce->gm.recastData.vertsperpoly = 6;
- if (sce->gm.recastData.detailsampledist == 0.0f)
- sce->gm.recastData.detailsampledist = 6.0f;
- if (sce->gm.recastData.detailsamplemaxerror == 0.0f)
- sce->gm.recastData.detailsamplemaxerror = 1.0f;
- }
- }
- }
+ blo_do_versions_pre250(fd, lib, main);
+ blo_do_versions_250(fd, lib, main);
if (main->versionfile < 260) {
{
@@ -14185,7 +8214,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
expand_doit(fd, mainvar, ob->mat[a]);
}
- paf = do_version_give_parteff_245(ob);
+ paf = blo_do_version_give_parteff_245(ob);
if (paf && paf->group)
expand_doit(fd, mainvar, paf->group);
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 511ded0ecdc..9be375977e9 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -39,6 +39,10 @@ struct OldNewMap;
struct MemFile;
struct bheadsort;
struct ReportList;
+struct Object;
+struct PartEff;
+struct View3D;
+struct bNodeTree;
typedef struct FileData {
// linked list of BHeadN's
@@ -133,5 +137,19 @@ BHead *blo_prevbhead(FileData *fd, BHead *thisblock);
char *bhead_id_name(FileData *fd, BHead *bhead);
+/* do versions stuff */
+
+void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm, void *oldaddr, void *newaddr, int nr);
+void *blo_do_versions_newlibadr(struct FileData *fd, void *lib, void *adr);
+void *blo_do_versions_newlibadr_us(struct FileData *fd, void *lib, void *adr);
+
+struct PartEff *blo_do_version_give_parteff_245(struct Object *ob);
+void blo_do_version_old_trackto_to_constraints(struct Object *ob);
+void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions);
+void blo_do_versions_nodetree_default_value(struct bNodeTree *ntree);
+
+void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *main);
+void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *main);
+
#endif
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
new file mode 100644
index 00000000000..c6bab33f364
--- /dev/null
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -0,0 +1,2677 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/blenloader/intern/readfile_250.c
+ * \ingroup blenloader
+ */
+
+#ifndef WIN32
+# include <unistd.h> // for read close
+#else
+# include <io.h> // for open close read
+# include "winsock2.h"
+# include "BLI_winstuff.h"
+#endif
+
+/* allow readfile to use deprecated functionality */
+#define DNA_DEPRECATED_ALLOW
+
+#include "DNA_anim_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_actuator_types.h"
+#include "DNA_brush_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_cloth_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_node_types.h"
+#include "DNA_object_fluidsim.h" // NT
+#include "DNA_object_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_sdna_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_smoke_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_space_types.h"
+#include "DNA_world_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_edgehash.h"
+
+#include "BKE_anim.h"
+#include "BKE_armature.h"
+#include "BKE_colortools.h"
+#include "BKE_global.h" // for G
+#include "BKE_library.h" // for which_libbase
+#include "BKE_main.h" // for Main
+#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_modifier.h"
+#include "BKE_multires.h"
+#include "BKE_particle.h"
+#include "BKE_pointcache.h"
+#include "BKE_screen.h"
+#include "BKE_sequencer.h"
+#include "BKE_texture.h" // for open_plugin_tex
+#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
+#include "BKE_sound.h"
+
+#include "NOD_socket.h"
+
+//XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes
+//XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie
+//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo
+#include "BLO_readfile.h"
+#include "BLO_undofile.h"
+
+#include "RE_engine.h"
+
+#include "readfile.h"
+
+#include "PIL_time.h"
+
+#include <errno.h>
+
+/* 2.50 patch */
+static void area_add_header_region(ScrArea *sa, ListBase *lb)
+{
+ ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_HEADER;
+ if (sa->headertype==HEADERDOWN)
+ ar->alignment= RGN_ALIGN_BOTTOM;
+ else
+ ar->alignment= RGN_ALIGN_TOP;
+
+ /* initialize view2d data for header region, to allow panning */
+ /* is copy from ui_view2d.c */
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
+ ar->v2d.keepofs = V2D_LOCKOFS_Y;
+ ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
+ ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y;
+ ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
+}
+
+static void sequencer_init_preview_region(ARegion* ar)
+{
+ // XXX a bit ugly still, copied from space_sequencer
+ /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
+ ar->regiontype= RGN_TYPE_PREVIEW;
+ ar->alignment= RGN_ALIGN_TOP;
+ ar->flag |= RGN_FLAG_HIDDEN;
+ ar->v2d.keepzoom= V2D_KEEPASPECT | V2D_KEEPZOOM;
+ ar->v2d.minzoom= 0.00001f;
+ ar->v2d.maxzoom= 100000.0f;
+ ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */
+ ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */
+ ar->v2d.tot.xmax = 960.0f;
+ ar->v2d.tot.ymax = 540.0f;
+ ar->v2d.min[0]= 0.0f;
+ ar->v2d.min[1]= 0.0f;
+ ar->v2d.max[0]= 12000.0f;
+ ar->v2d.max[1]= 12000.0f;
+ ar->v2d.cur= ar->v2d.tot;
+ ar->v2d.align= V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
+ ar->v2d.keeptot= V2D_KEEPTOT_FREE;
+}
+
+static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
+{
+ ARegion *ar;
+ ARegion *ar_main;
+
+ if (sl) {
+ /* first channels for ipo action nla... */
+ switch (sl->spacetype) {
+ case SPACE_IPO:
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_CHANNELS;
+ ar->alignment= RGN_ALIGN_LEFT;
+ ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+
+ // for some reason, this doesn't seem to go auto like for NLA...
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_UI;
+ ar->alignment= RGN_ALIGN_RIGHT;
+ ar->v2d.scroll= V2D_SCROLL_RIGHT;
+ ar->v2d.flag = RGN_FLAG_HIDDEN;
+ break;
+
+ case SPACE_ACTION:
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_CHANNELS;
+ ar->alignment= RGN_ALIGN_LEFT;
+ ar->v2d.scroll= V2D_SCROLL_BOTTOM;
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+ break;
+
+ case SPACE_NLA:
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_CHANNELS;
+ ar->alignment= RGN_ALIGN_LEFT;
+ ar->v2d.scroll= V2D_SCROLL_BOTTOM;
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+
+ // for some reason, some files still don't get this auto
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_UI;
+ ar->alignment= RGN_ALIGN_RIGHT;
+ ar->v2d.scroll= V2D_SCROLL_RIGHT;
+ ar->v2d.flag = RGN_FLAG_HIDDEN;
+ break;
+
+ case SPACE_NODE:
+ ar= MEM_callocN(sizeof(ARegion), "nodetree area for node");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_UI;
+ ar->alignment= RGN_ALIGN_LEFT;
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+ /* temporarily hide it */
+ ar->flag = RGN_FLAG_HIDDEN;
+ break;
+ case SPACE_FILE:
+ ar= MEM_callocN(sizeof(ARegion), "nodetree area for node");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_CHANNELS;
+ ar->alignment= RGN_ALIGN_LEFT;
+
+ ar= MEM_callocN(sizeof(ARegion), "ui area for file");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_UI;
+ ar->alignment= RGN_ALIGN_TOP;
+ break;
+ case SPACE_SEQ:
+ ar_main = (ARegion*)lb->first;
+ for (; ar_main; ar_main = ar_main->next) {
+ if (ar_main->regiontype == RGN_TYPE_WINDOW)
+ break;
+ }
+ ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
+ BLI_insertlinkbefore(lb, ar_main, ar);
+ sequencer_init_preview_region(ar);
+ break;
+ case SPACE_VIEW3D:
+ /* toolbar */
+ ar= MEM_callocN(sizeof(ARegion), "toolbar for view3d");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_TOOLS;
+ ar->alignment= RGN_ALIGN_LEFT;
+ ar->flag = RGN_FLAG_HIDDEN;
+
+ /* tool properties */
+ ar= MEM_callocN(sizeof(ARegion), "tool properties for view3d");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_TOOL_PROPS;
+ ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
+ ar->flag = RGN_FLAG_HIDDEN;
+
+ /* buttons/list view */
+ ar= MEM_callocN(sizeof(ARegion), "buttons for view3d");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_UI;
+ ar->alignment= RGN_ALIGN_RIGHT;
+ ar->flag = RGN_FLAG_HIDDEN;
+#if 0
+ case SPACE_BUTS:
+ /* context UI region */
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype= RGN_TYPE_UI;
+ ar->alignment= RGN_ALIGN_RIGHT;
+
+ break;
+#endif
+ }
+ }
+
+ /* main region */
+ ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
+
+ BLI_addtail(lb, ar);
+ ar->winrct= sa->totrct;
+
+ ar->regiontype= RGN_TYPE_WINDOW;
+
+ if (sl) {
+ /* if active spacetype has view2d data, copy that over to main region */
+ /* and we split view3d */
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D:
+ blo_do_versions_view3d_split_250((View3D *)sl, lb);
+ break;
+
+ case SPACE_OUTLINER:
+ {
+ SpaceOops *soops= (SpaceOops *)sl;
+
+ memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
+
+ ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O);
+ ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
+ ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT);
+ ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
+ ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
+ }
+ break;
+ case SPACE_TIME:
+ {
+ SpaceTime *stime= (SpaceTime *)sl;
+ memcpy(&ar->v2d, &stime->v2d, sizeof(View2D));
+
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
+ ar->v2d.keepofs |= V2D_LOCKOFS_Y;
+ ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
+ ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0;
+ ar->v2d.min[1]= ar->v2d.max[1]= 20.0;
+ }
+ break;
+ case SPACE_IPO:
+ {
+ SpaceIpo *sipo= (SpaceIpo *)sl;
+ memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D));
+
+ /* init mainarea view2d */
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
+
+ ar->v2d.min[0]= FLT_MIN;
+ ar->v2d.min[1]= FLT_MIN;
+
+ ar->v2d.max[0]= MAXFRAMEF;
+ ar->v2d.max[1]= FLT_MAX;
+
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
+ break;
+ }
+ case SPACE_NLA:
+ {
+ SpaceNla *snla= (SpaceNla *)sl;
+ memcpy(&ar->v2d, &snla->v2d, sizeof(View2D));
+
+ ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f;
+ ar->v2d.tot.ymax = 0.0f;
+
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
+ ar->v2d.align = V2D_ALIGN_NO_POS_Y;
+ ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
+ break;
+ }
+ case SPACE_ACTION:
+ {
+ SpaceAction *saction= (SpaceAction *)sl;
+
+ /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
+ ar->v2d.tot.xmin = -20.0f;
+ ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f;
+ ar->v2d.tot.xmax = (float)((sa->winx > 120)? (sa->winx) : 120);
+ ar->v2d.tot.ymax = 0.0f;
+
+ ar->v2d.cur= ar->v2d.tot;
+
+ ar->v2d.min[0]= 0.0f;
+ ar->v2d.min[1]= 0.0f;
+
+ ar->v2d.max[0]= MAXFRAMEF;
+ ar->v2d.max[1]= FLT_MAX;
+
+ ar->v2d.minzoom= 0.01f;
+ ar->v2d.maxzoom= 50;
+ ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
+ ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
+ ar->v2d.align= V2D_ALIGN_NO_POS_Y;
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+
+ /* for old files with ShapeKey editors open + an action set, clear the action as
+ * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
+ * only shows ShapeKey-rooted actions only)
+ */
+ if (saction->mode == SACTCONT_SHAPEKEY)
+ saction->action = NULL;
+ break;
+ }
+ case SPACE_SEQ:
+ {
+ SpaceSeq *sseq= (SpaceSeq *)sl;
+ memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D));
+
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
+ ar->v2d.align= V2D_ALIGN_NO_NEG_Y;
+ ar->v2d.flag |= V2D_IS_INITIALISED;
+ break;
+ }
+ case SPACE_NODE:
+ {
+ SpaceNode *snode= (SpaceNode *)sl;
+ memcpy(&ar->v2d, &snode->v2d, sizeof(View2D));
+
+ ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+ ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT;
+ break;
+ }
+ case SPACE_BUTS:
+ {
+ SpaceButs *sbuts= (SpaceButs *)sl;
+ memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D));
+
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+ break;
+ }
+ case SPACE_FILE:
+ {
+ // SpaceFile *sfile= (SpaceFile *)sl;
+ ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0;
+ ar->v2d.tot.xmax = ar->winx;
+ ar->v2d.tot.ymax = ar->winy;
+ ar->v2d.cur = ar->v2d.tot;
+ ar->regiontype= RGN_TYPE_WINDOW;
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O);
+ ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
+ break;
+ }
+ case SPACE_TEXT:
+ {
+ SpaceText *st= (SpaceText *)sl;
+ st->flags |= ST_FIND_WRAP;
+ }
+ //case SPACE_XXX: // FIXME... add other ones
+ // memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
+ // break;
+ }
+ }
+}
+
+static void do_versions_windowmanager_2_50(bScreen *screen)
+{
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ /* add regions */
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+
+ /* we keep headertype variable to convert old files only */
+ if (sa->headertype)
+ area_add_header_region(sa, &sa->regionbase);
+
+ area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase);
+
+ /* space imageselect is deprecated */
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_IMASEL)
+ sl->spacetype= SPACE_EMPTY; /* spacedata then matches */
+ }
+
+ /* space sound is deprecated */
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_SOUND)
+ sl->spacetype= SPACE_EMPTY; /* spacedata then matches */
+ }
+
+ /* it seems to be possible in 2.5 to have this saved, filewindow probably */
+ sa->butspacetype= sa->spacetype;
+
+ /* pushed back spaces also need regions! */
+ if (sa->spacedata.first) {
+ sl= sa->spacedata.first;
+ for (sl= sl->next; sl; sl= sl->next) {
+ if (sa->headertype)
+ area_add_header_region(sa, &sl->regionbase);
+ area_add_window_regions(sa, sl, &sl->regionbase);
+ }
+ }
+ }
+}
+
+static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name)
+{
+
+ BLI_addtail(lb, id);
+ id->us= 1;
+ id->flag= LIB_FAKEUSER;
+ *( (short *)id->name )= ID_GD;
+
+ new_id(lb, id, name);
+ /* alphabetic insterion: is in new_id */
+
+ if (G.debug & G_DEBUG)
+ printf("Converted GPencil to ID: %s\n", id->name+2);
+}
+
+static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
+{
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ /* add regions */
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D*) sl;
+ if (v3d->gpd) {
+ versions_gpencil_add_main(&main->gpencil, (ID *)v3d->gpd, "GPencil View3D");
+ v3d->gpd= NULL;
+ }
+ }
+ else if (sl->spacetype==SPACE_NODE) {
+ SpaceNode *snode= (SpaceNode *)sl;
+ if (snode->gpd) {
+ versions_gpencil_add_main(&main->gpencil, (ID *)snode->gpd, "GPencil Node");
+ snode->gpd= NULL;
+ }
+ }
+ else if (sl->spacetype==SPACE_SEQ) {
+ SpaceSeq *sseq= (SpaceSeq *)sl;
+ if (sseq->gpd) {
+ versions_gpencil_add_main(&main->gpencil, (ID *)sseq->gpd, "GPencil Node");
+ sseq->gpd= NULL;
+ }
+ }
+ else if (sl->spacetype==SPACE_IMAGE) {
+ SpaceImage *sima= (SpaceImage *)sl;
+#if 0 /* see comment on r28002 */
+ if (sima->gpd) {
+ versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image");
+ sima->gpd= NULL;
+ }
+#else
+ sima->gpd= NULL;
+#endif
+ }
+ }
+ }
+}
+
+static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype)
+{
+ MTex *mtex;
+ float varfac, colfac;
+ int a, neg;
+
+ if (!mtex_array)
+ return;
+
+ for (a=0; a<MAX_MTEX; a++) {
+ if (mtex_array[a]) {
+ mtex= mtex_array[a];
+
+ neg= mtex->maptoneg;
+ varfac= mtex->varfac;
+ colfac= mtex->colfac;
+
+ if (neg & MAP_DISP) mtex->dispfac= -mtex->dispfac;
+ if (neg & MAP_NORM) mtex->norfac= -mtex->norfac;
+ if (neg & MAP_WARP) mtex->warpfac= -mtex->warpfac;
+
+ mtex->colspecfac= (neg & MAP_COLSPEC)? -colfac: colfac;
+ mtex->mirrfac= (neg & MAP_COLMIR)? -colfac: colfac;
+ mtex->alphafac= (neg & MAP_ALPHA)? -varfac: varfac;
+ mtex->difffac= (neg & MAP_REF)? -varfac: varfac;
+ mtex->specfac= (neg & MAP_SPEC)? -varfac: varfac;
+ mtex->emitfac= (neg & MAP_EMIT)? -varfac: varfac;
+ mtex->hardfac= (neg & MAP_HAR)? -varfac: varfac;
+ mtex->raymirrfac= (neg & MAP_RAYMIRR)? -varfac: varfac;
+ mtex->translfac= (neg & MAP_TRANSLU)? -varfac: varfac;
+ mtex->ambfac= (neg & MAP_AMB)? -varfac: varfac;
+ mtex->colemitfac= (neg & MAP_EMISSION_COL)? -colfac: colfac;
+ mtex->colreflfac= (neg & MAP_REFLECTION_COL)? -colfac: colfac;
+ mtex->coltransfac= (neg & MAP_TRANSMISSION_COL)? -colfac: colfac;
+ mtex->densfac= (neg & MAP_DENSITY)? -varfac: varfac;
+ mtex->scatterfac= (neg & MAP_SCATTERING)? -varfac: varfac;
+ mtex->reflfac= (neg & MAP_REFLECTION)? -varfac: varfac;
+
+ mtex->timefac= (neg & MAP_PA_TIME)? -varfac: varfac;
+ mtex->lengthfac= (neg & MAP_PA_LENGTH)? -varfac: varfac;
+ mtex->clumpfac= (neg & MAP_PA_CLUMP)? -varfac: varfac;
+ mtex->kinkfac= (neg & MAP_PA_KINK)? -varfac: varfac;
+ mtex->roughfac= (neg & MAP_PA_ROUGH)? -varfac: varfac;
+ mtex->padensfac= (neg & MAP_PA_DENS)? -varfac: varfac;
+ mtex->lifefac= (neg & MAP_PA_LIFE)? -varfac: varfac;
+ mtex->sizefac= (neg & MAP_PA_SIZE)? -varfac: varfac;
+ mtex->ivelfac= (neg & MAP_PA_IVEL)? -varfac: varfac;
+
+ mtex->shadowfac= (neg & LAMAP_SHAD)? -colfac: colfac;
+
+ mtex->zenupfac= (neg & WOMAP_ZENUP)? -colfac: colfac;
+ mtex->zendownfac= (neg & WOMAP_ZENDOWN)? -colfac: colfac;
+ mtex->blendfac= (neg & WOMAP_BLEND)? -varfac: varfac;
+
+ if (idtype == ID_MA)
+ mtex->colfac= (neg & MAP_COL)? -colfac: colfac;
+ else if (idtype == ID_LA)
+ mtex->colfac= (neg & LAMAP_COL)? -colfac: colfac;
+ else if (idtype == ID_WO)
+ mtex->colfac= (neg & WOMAP_HORIZ)? -colfac: colfac;
+ }
+ }
+}
+
+static void do_version_mdef_250(Main *main)
+{
+ Object *ob;
+ ModifierData *md;
+ MeshDeformModifierData *mmd;
+
+ for (ob= main->object.first; ob; ob=ob->id.next) {
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type == eModifierType_MeshDeform) {
+ mmd= (MeshDeformModifierData*)md;
+
+ if (mmd->bindcos) {
+ /* make bindcos NULL in order to trick older versions
+ * into thinking that the mesh was not bound yet */
+ mmd->bindcagecos= mmd->bindcos;
+ mmd->bindcos= NULL;
+
+ modifier_mdef_compact_influences(md);
+ }
+ }
+ }
+ }
+}
+
+static void do_version_constraints_radians_degrees_250(ListBase *lb)
+{
+ bConstraint *con;
+
+ for (con=lb->first; con; con=con->next) {
+ if (con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) {
+ bRigidBodyJointConstraint *data = con->data;
+ data->axX *= (float)(M_PI/180.0);
+ data->axY *= (float)(M_PI/180.0);
+ data->axZ *= (float)(M_PI/180.0);
+ }
+ else if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
+ bKinematicConstraint *data = con->data;
+ data->poleangle *= (float)(M_PI/180.0);
+ }
+ else if (con->type==CONSTRAINT_TYPE_ROTLIMIT) {
+ bRotLimitConstraint *data = con->data;
+
+ data->xmin *= (float)(M_PI/180.0);
+ data->xmax *= (float)(M_PI/180.0);
+ data->ymin *= (float)(M_PI/180.0);
+ data->ymax *= (float)(M_PI/180.0);
+ data->zmin *= (float)(M_PI/180.0);
+ data->zmax *= (float)(M_PI/180.0);
+ }
+ }
+}
+
+/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */
+static void do_versions_seq_unique_name_all_strips(
+ Scene * sce, ListBase *seqbasep)
+{
+ Sequence * seq = seqbasep->first;
+
+ while (seq) {
+ seqbase_unique_name_recursive(&sce->ed->seqbase, seq);
+ if (seq->seqbase.first) {
+ do_versions_seq_unique_name_all_strips(
+ sce, &seq->seqbase);
+ }
+ seq=seq->next;
+ }
+}
+
+static void do_version_bone_roll_256(Bone *bone)
+{
+ Bone *child;
+ float submat[3][3];
+
+ copy_m3_m4(submat, bone->arm_mat);
+ mat3_to_vec_roll(submat, NULL, &bone->arm_roll);
+
+ for (child = bone->childbase.first; child; child = child->next)
+ do_version_bone_roll_256(child);
+}
+
+static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree)
+{
+ bNodeSocket *sock;
+ for (sock=ntree->inputs.first; sock; sock=sock->next)
+ sock->flag |= SOCK_DYNAMIC;
+ for (sock=ntree->outputs.first; sock; sock=sock->next)
+ sock->flag |= SOCK_DYNAMIC;
+}
+
+void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
+{
+ /* WATCH IT!!!: pointers from libdata have not been converted */
+
+ if (G.debug & G_DEBUG)
+ printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision);
+
+ if (main->versionfile < 250) {
+ bScreen *screen;
+ Scene *scene;
+ Base *base;
+ Material *ma;
+ Camera *cam;
+ Mesh *me;
+ Curve *cu;
+ Scene *sce;
+ Tex *tx;
+ ParticleSettings *part;
+ Object *ob;
+ //PTCacheID *pid;
+ //ListBase pidlist;
+
+ bSound *sound;
+ Sequence *seq;
+ bActuator *act;
+ int a;
+
+ for (sound = main->sound.first; sound; sound = sound->id.next) {
+ if (sound->newpackedfile) {
+ sound->packedfile = sound->newpackedfile;
+ sound->newpackedfile = NULL;
+ }
+ }
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_SOUND) {
+ bSoundActuator *sAct = (bSoundActuator*) act->data;
+ if (sAct->sound) {
+ sound = blo_do_versions_newlibadr(fd, lib, sAct->sound);
+ sAct->flag = sound->flags & SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0;
+ sAct->pitch = sound->pitch;
+ sAct->volume = sound->volume;
+ sAct->sound3D.reference_distance = sound->distance;
+ sAct->sound3D.max_gain = sound->max_gain;
+ sAct->sound3D.min_gain = sound->min_gain;
+ sAct->sound3D.rolloff_factor = sound->attenuation;
+ }
+ else {
+ sAct->sound3D.reference_distance = 1.0f;
+ sAct->volume = 1.0f;
+ sAct->sound3D.max_gain = 1.0f;
+ sAct->sound3D.rolloff_factor = 1.0f;
+ }
+ sAct->sound3D.cone_inner_angle = 360.0f;
+ sAct->sound3D.cone_outer_angle = 360.0f;
+ sAct->sound3D.max_distance = FLT_MAX;
+ }
+ }
+ }
+
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ if (scene->ed && scene->ed->seqbasep) {
+ SEQ_BEGIN (scene->ed, seq)
+ {
+ if (seq->type == SEQ_HD_SOUND) {
+ char str[FILE_MAX];
+ BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(str, main->name);
+ seq->sound = sound_new_file(main, str);
+ }
+ /* don't know, if anybody used that
+ * this way, but just in case, upgrade
+ * to new way... */
+ if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) &&
+ !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR))
+ {
+
+ BLI_snprintf(seq->strip->proxy->dir,
+ FILE_MAXDIR, "%s/BL_proxy",
+ seq->strip->dir);
+ }
+ }
+ SEQ_END
+ }
+ }
+
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ do_versions_windowmanager_2_50(screen);
+ do_versions_gpencil_2_50(main, screen);
+ }
+
+ /* shader, composite and texture node trees have id.name empty, put something in
+ * to have them show in RNA viewer and accessible otherwise.
+ */
+ for (ma= main->mat.first; ma; ma= ma->id.next) {
+ if (ma->nodetree && ma->nodetree->id.name[0] == '\0')
+ strcpy(ma->nodetree->id.name, "NTShader Nodetree");
+
+ /* which_output 0 is now "not specified" */
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a]) {
+ tx= blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex);
+ if (tx && tx->use_nodes)
+ ma->mtex[a]->which_output++;
+ }
+ }
+ }
+ /* and composite trees */
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->nodetree && sce->nodetree->id.name[0] == '\0')
+ strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
+
+ /* move to cameras */
+ if (sce->r.mode & R_PANORAMA) {
+ for (base=sce->base.first; base; base=base->next) {
+ ob= blo_do_versions_newlibadr(fd, lib, base->object);
+
+ if (ob->type == OB_CAMERA && !ob->id.lib) {
+ cam= blo_do_versions_newlibadr(fd, lib, ob->data);
+ cam->flag |= CAM_PANORAMA;
+ }
+ }
+
+ sce->r.mode &= ~R_PANORAMA;
+ }
+ }
+ /* and texture trees */
+ for (tx= main->tex.first; tx; tx= tx->id.next) {
+ bNode *node;
+
+ if (tx->nodetree) {
+ if (tx->nodetree->id.name[0] == '\0')
+ strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
+
+ /* which_output 0 is now "not specified" */
+ for (node=tx->nodetree->nodes.first; node; node=node->next)
+ if (node->type == TEX_NODE_OUTPUT)
+ node->custom1++;
+ }
+ }
+
+ /* copy standard draw flag to meshes(used to be global, is not available here) */
+ for (me= main->mesh.first; me; me= me->id.next) {
+ me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
+ }
+
+ /* particle draw and render types */
+ for (part= main->particle.first; part; part= part->id.next) {
+ if (part->draw_as) {
+ if (part->draw_as == PART_DRAW_DOT) {
+ part->ren_as = PART_DRAW_HALO;
+ part->draw_as = PART_DRAW_REND;
+ }
+ else if (part->draw_as <= PART_DRAW_AXIS) {
+ part->ren_as = PART_DRAW_HALO;
+ }
+ else {
+ part->ren_as = part->draw_as;
+ part->draw_as = PART_DRAW_REND;
+ }
+ }
+ part->path_end = 1.0f;
+ part->clength = 1.0f;
+ }
+ /* set old pointcaches to have disk cache flag */
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+
+ //BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ //for (pid=pidlist.first; pid; pid=pid->next)
+ // pid->cache->flag |= PTCACHE_DISK_CACHE;
+
+ //BLI_freelistN(&pidlist);
+ }
+
+ /* type was a mixed flag & enum. move the 2d flag elsewhere */
+ for (cu = main->curve.first; cu; cu= cu->id.next) {
+ Nurb *nu;
+
+ for (nu= cu->nurb.first; nu; nu= nu->next) {
+ nu->flag |= (nu->type & CU_2D);
+ nu->type &= CU_TYPE;
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) {
+ Object *ob;
+ Material *ma;
+ Tex *tex;
+ Scene *sce;
+ ToolSettings *ts;
+ //PTCacheID *pid;
+ //ListBase pidlist;
+
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ //BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ //for (pid=pidlist.first; pid; pid=pid->next) {
+ // if (pid->ptcaches->first == NULL)
+ // pid->ptcaches->first = pid->ptcaches->last = pid->cache;
+ //}
+
+ //BLI_freelistN(&pidlist);
+
+ if (ob->type == OB_MESH) {
+ Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
+ void *olddata = ob->data;
+ ob->data = me;
+
+ /* XXX - library meshes crash on loading most yoFrankie levels,
+ * the multires pointer gets invalid - Campbell */
+ if (me && me->id.lib==NULL && me->mr && me->mr->level_count > 1) {
+ multires_load_old(ob, me);
+ }
+
+ ob->data = olddata;
+ }
+
+ if (ob->totcol && ob->matbits == NULL) {
+ int a;
+
+ ob->matbits= MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits");
+ for (a=0; a<ob->totcol; a++)
+ ob->matbits[a]= ob->colbits & (1<<a);
+ }
+ }
+
+ /* texture filter */
+ for (tex = main->tex.first; tex; tex = tex->id.next) {
+ if (tex->afmax == 0)
+ tex->afmax= 8;
+ }
+
+ for (ma = main->mat.first; ma; ma = ma->id.next) {
+ int a;
+ if (ma->mode & MA_WIRE) {
+ ma->material_type= MA_TYPE_WIRE;
+ ma->mode &= ~MA_WIRE;
+ }
+ if (ma->mode & MA_HALO) {
+ ma->material_type= MA_TYPE_HALO;
+ ma->mode &= ~MA_HALO;
+ }
+
+ if (ma->mode & (MA_ZTRANSP|MA_RAYTRANSP)) {
+ ma->mode |= MA_TRANSP;
+ }
+ else {
+ /* ma->mode |= MA_ZTRANSP; */ /* leave ztransp as is even if its not used [#28113] */
+ ma->mode &= ~MA_TRANSP;
+ }
+
+ /* set new bump for unused slots */
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a]) {
+ tex= ma->mtex[a]->tex;
+ if (!tex) {
+ ma->mtex[a]->texflag |= MTEX_3TAP_BUMP;
+ ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE;
+ }
+ else {
+ tex= (Tex*)blo_do_versions_newlibadr(fd, ma->id.lib, tex);
+ if (tex && tex->type == 0) { /* invalid type */
+ ma->mtex[a]->texflag |= MTEX_3TAP_BUMP;
+ ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE;
+ }
+ }
+ }
+ }
+
+ /* volume rendering settings */
+ if (ma->vol.stepsize < 0.0001f) {
+ ma->vol.density = 1.0f;
+ ma->vol.emission = 0.0f;
+ ma->vol.scattering = 1.0f;
+ ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f;
+ ma->vol.density_scale = 1.0f;
+ ma->vol.depth_cutoff = 0.01f;
+ ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED;
+ ma->vol.stepsize = 0.2f;
+ ma->vol.shade_type = MA_VOL_SHADE_SHADED;
+ ma->vol.shadeflag |= MA_VOL_PRECACHESHADING;
+ ma->vol.precache_resolution = 50;
+ }
+ }
+
+ for (sce = main->scene.first; sce; sce = sce->id.next) {
+ ts= sce->toolsettings;
+ if (ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
+ ts->normalsize= 0.1f;
+ ts->selectmode= SCE_SELECT_VERTEX;
+
+ /* autokeying - setting should be taken from the user-prefs
+ * but the userprefs version may not have correct flags set
+ * (i.e. will result in blank box when enabled)
+ */
+ ts->autokey_mode= U.autokey_mode;
+ if (ts->autokey_mode == 0)
+ ts->autokey_mode= 2; /* 'add/replace' but not on */
+ ts->uv_selectmode= UV_SELECT_VERTEX;
+ ts->vgroup_weight= 1.0f;
+ }
+
+ /* Game Settings */
+ //Dome
+ sce->gm.dome.angle = sce->r.domeangle;
+ sce->gm.dome.mode = sce->r.domemode;
+ sce->gm.dome.res = sce->r.domeres;
+ sce->gm.dome.resbuf = sce->r.domeresbuf;
+ sce->gm.dome.tilt = sce->r.dometilt;
+ sce->gm.dome.warptext = sce->r.dometext;
+
+ //Stand Alone
+ sce->gm.playerflag |= (sce->r.fullscreen?GAME_PLAYER_FULLSCREEN:0);
+ sce->gm.xplay = sce->r.xplay;
+ sce->gm.yplay = sce->r.yplay;
+ sce->gm.freqplay = sce->r.freqplay;
+ sce->gm.depth = sce->r.depth;
+ sce->gm.attrib = sce->r.attrib;
+
+ //Stereo
+ sce->gm.stereomode = sce->r.stereomode;
+ /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/
+ if (sce->gm.stereomode == 1) { //1 = STEREO_NOSTEREO
+ sce->gm.stereoflag = STEREO_NOSTEREO;
+ sce->gm.stereomode = STEREO_ANAGLYPH;
+ }
+ else if (sce->gm.stereomode == 8) { //8 = STEREO_DOME
+ sce->gm.stereoflag = STEREO_DOME;
+ sce->gm.stereomode = STEREO_ANAGLYPH;
+ }
+ else
+ sce->gm.stereoflag = STEREO_ENABLED;
+
+ //Framing
+ sce->gm.framing = sce->framing;
+ sce->gm.xplay = sce->r.xplay;
+ sce->gm.yplay = sce->r.yplay;
+ sce->gm.freqplay= sce->r.freqplay;
+ sce->gm.depth= sce->r.depth;
+
+ //Physic (previously stored in world)
+ sce->gm.gravity =9.8f;
+ sce->gm.physicsEngine= WOPHY_BULLET;// Bullet by default
+ sce->gm.mode = WO_DBVT_CULLING; // DBVT culling by default
+ sce->gm.occlusionRes = 128;
+ sce->gm.ticrate = 60;
+ sce->gm.maxlogicstep = 5;
+ sce->gm.physubstep = 1;
+ sce->gm.maxphystep = 5;
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) {
+ Scene *sce;
+ Object *ob;
+
+ for (sce = main->scene.first; sce; sce = sce->id.next) {
+ if (fd->fileflags & G_FILE_ENABLE_ALL_FRAMES)
+ sce->gm.flag |= GAME_ENABLE_ALL_FRAMES;
+ if (fd->fileflags & G_FILE_SHOW_DEBUG_PROPS)
+ sce->gm.flag |= GAME_SHOW_DEBUG_PROPS;
+ if (fd->fileflags & G_FILE_SHOW_FRAMERATE)
+ sce->gm.flag |= GAME_SHOW_FRAMERATE;
+ if (fd->fileflags & G_FILE_SHOW_PHYSICS)
+ sce->gm.flag |= GAME_SHOW_PHYSICS;
+ if (fd->fileflags & G_FILE_GLSL_NO_SHADOWS)
+ sce->gm.flag |= GAME_GLSL_NO_SHADOWS;
+ if (fd->fileflags & G_FILE_GLSL_NO_SHADERS)
+ sce->gm.flag |= GAME_GLSL_NO_SHADERS;
+ if (fd->fileflags & G_FILE_GLSL_NO_RAMPS)
+ sce->gm.flag |= GAME_GLSL_NO_RAMPS;
+ if (fd->fileflags & G_FILE_GLSL_NO_NODES)
+ sce->gm.flag |= GAME_GLSL_NO_NODES;
+ if (fd->fileflags & G_FILE_GLSL_NO_EXTRA_TEX)
+ sce->gm.flag |= GAME_GLSL_NO_EXTRA_TEX;
+ if (fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS)
+ sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS;
+
+ if (fd->fileflags & G_FILE_GAME_MAT_GLSL)
+ sce->gm.matmode= GAME_MAT_GLSL;
+ else if (fd->fileflags & G_FILE_GAME_MAT)
+ sce->gm.matmode= GAME_MAT_MULTITEX;
+ else
+ sce->gm.matmode= GAME_MAT_TEXFACE;
+
+ sce->gm.flag |= GAME_DISPLAY_LISTS;
+ }
+
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ if (ob->flag & 8192) // OB_POSEMODE = 8192
+ ob->mode |= OB_MODE_POSE;
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) {
+ Scene *sce;
+ Object *ob;
+ Material *ma;
+ Lamp *la;
+ World *wo;
+ Tex *tex;
+ ParticleSettings *part;
+ int do_gravity = 0;
+
+ for (sce = main->scene.first; sce; sce = sce->id.next)
+ if (sce->unit.scale_length == 0.0f)
+ sce->unit.scale_length= 1.0f;
+
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ /* fluid-sim stuff */
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
+ if (fluidmd) fluidmd->fss->fmd = fluidmd;
+
+ /* rotation modes were added, but old objects would now default to being 'quaternion based' */
+ ob->rotmode= ROT_MODE_EUL;
+ }
+
+ for (ma = main->mat.first; ma; ma=ma->id.next) {
+ if (ma->vol.reflection == 0.f) {
+ ma->vol.reflection = 1.f;
+ ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f;
+ ma->vol.reflection_col[0] = ma->vol.reflection_col[1] = ma->vol.reflection_col[2] = 1.0f;
+ }
+
+ do_version_mtex_factor_2_50(ma->mtex, ID_MA);
+ }
+
+ for (la = main->lamp.first; la; la=la->id.next)
+ do_version_mtex_factor_2_50(la->mtex, ID_LA);
+
+ for (wo = main->world.first; wo; wo=wo->id.next)
+ do_version_mtex_factor_2_50(wo->mtex, ID_WO);
+
+ for (tex = main->tex.first; tex; tex=tex->id.next)
+ if (tex->vd)
+ if (tex->vd->extend == 0)
+ tex->vd->extend = TEX_CLIP;
+
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->audio.main == 0.0f)
+ sce->audio.main = 1.0f;
+
+ sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
+ sce->r.ffcodecdata.audio_volume = sce->audio.main;
+ sce->audio.distance_model = 2;
+ sce->audio.doppler_factor = 1.0f;
+ sce->audio.speed_of_sound = 343.3f;
+ }
+
+ /* Add default gravity to scenes */
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
+ len_v3(sce->physics_settings.gravity) == 0.0f)
+ {
+ sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
+ sce->physics_settings.gravity[2] = -9.81f;
+ sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY;
+ do_gravity = 1;
+ }
+ }
+
+ /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */
+ if (do_gravity) for (part= main->particle.first; part; part= part->id.next)
+ part->effector_weights->global_gravity = part->acc[2]/-9.81f;
+
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ if (do_gravity) {
+ for (md= ob->modifiers.first; md; md= md->next) {
+ ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
+ if (clmd)
+ clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81f;
+ }
+
+ if (ob->soft)
+ ob->soft->effector_weights->global_gravity = ob->soft->grav/9.81f;
+ }
+
+ /* Normal wind shape is plane */
+ if (ob->pd) {
+ if (ob->pd->forcefield == PFIELD_WIND)
+ ob->pd->shape = PFIELD_SHAPE_PLANE;
+
+ if (ob->pd->flag & PFIELD_PLANAR)
+ ob->pd->shape = PFIELD_SHAPE_PLANE;
+ else if (ob->pd->flag & PFIELD_SURFACE)
+ ob->pd->shape = PFIELD_SHAPE_SURFACE;
+
+ ob->pd->flag |= PFIELD_DO_LOCATION;
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) {
+ Object *ob;
+ Lamp *la;
+
+ /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ /* new variables for all objects */
+ ob->quat[0]= 1.0f;
+ ob->rotAxis[1]= 1.0f;
+
+ /* bones */
+ if (ob->pose) {
+ bPoseChannel *pchan;
+
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ /* just need to initalise rotation axis properly... */
+ pchan->rotAxis[1]= 1.0f;
+ }
+ }
+ }
+
+ for (la = main->lamp.first; la; la=la->id.next)
+ la->compressthresh= 0.05f;
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) {
+ Mesh *me;
+ Nurb *nu;
+ Lattice *lt;
+ Curve *cu;
+ Key *key;
+ float *data;
+ int a, tot;
+
+ /* shape keys are no longer applied to the mesh itself, but rather
+ * to the derivedmesh/displist, so here we ensure that the basis
+ * shape key is always set in the mesh coordinates. */
+
+ for (me= main->mesh.first; me; me= me->id.next) {
+ if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) {
+ data= key->refkey->data;
+ tot= MIN2(me->totvert, key->refkey->totelem);
+
+ for (a=0; a<tot; a++, data+=3)
+ copy_v3_v3(me->mvert[a].co, data);
+ }
+ }
+
+ for (lt= main->latt.first; lt; lt= lt->id.next) {
+ if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) {
+ data= key->refkey->data;
+ tot= MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem);
+
+ for (a=0; a<tot; a++, data+=3)
+ copy_v3_v3(lt->def[a].vec, data);
+ }
+ }
+
+ for (cu= main->curve.first; cu; cu= cu->id.next) {
+ if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) {
+ data= key->refkey->data;
+
+ for (nu=cu->nurb.first; nu; nu=nu->next) {
+ if (nu->bezt) {
+ BezTriple *bezt = nu->bezt;
+
+ for (a=0; a<nu->pntsu; a++, bezt++) {
+ copy_v3_v3(bezt->vec[0], data); data+=3;
+ copy_v3_v3(bezt->vec[1], data); data+=3;
+ copy_v3_v3(bezt->vec[2], data); data+=3;
+ bezt->alfa= *data; data++;
+ }
+ }
+ else if (nu->bp) {
+ BPoint *bp = nu->bp;
+
+ for (a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
+ copy_v3_v3(bp->vec, data); data+=3;
+ bp->alfa= *data; data++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) {
+ {
+ Scene *sce= main->scene.first;
+ while (sce) {
+ if (sce->r.frame_step==0)
+ sce->r.frame_step= 1;
+ if (sce->r.mblur_samples==0)
+ sce->r.mblur_samples = sce->r.osa;
+
+ if (sce->ed && sce->ed->seqbase.first) {
+ do_versions_seq_unique_name_all_strips(
+ sce, &sce->ed->seqbase);
+ }
+
+ sce= sce->id.next;
+ }
+ }
+ {
+ /* ensure all nodes have unique names */
+ bNodeTree *ntree= main->nodetree.first;
+ while (ntree) {
+ bNode *node=ntree->nodes.first;
+
+ while (node) {
+ nodeUniqueName(ntree, node);
+ node= node->next;
+ }
+
+ ntree= ntree->id.next;
+ }
+ }
+ {
+ Object *ob=main->object.first;
+ while (ob) {
+ /* shaded mode disabled for now */
+ if (ob->dt == OB_MATERIAL) ob->dt = OB_TEXTURE;
+ ob=ob->id.next;
+ }
+ }
+
+ {
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->drawtype == OB_MATERIAL) v3d->drawtype = OB_SOLID;
+ }
+ }
+ }
+ }
+ }
+
+ /* only convert old 2.50 files with color management */
+ if (main->versionfile == 250) {
+ Scene *sce=main->scene.first;
+ Material *ma=main->mat.first;
+ World *wo=main->world.first;
+ Tex *tex=main->tex.first;
+ int i, convert=0;
+
+ /* convert to new color management system:
+ * while previously colors were stored as srgb,
+ * now they are stored as linear internally,
+ * with screen gamma correction in certain places in the UI. */
+
+ /* don't know what scene is active, so we'll convert if any scene has it enabled... */
+ while (sce) {
+ if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ convert=1;
+ sce=sce->id.next;
+ }
+
+ if (convert) {
+ while (ma) {
+ if (ma->ramp_col) {
+ ColorBand *band = (ColorBand *)ma->ramp_col;
+ for (i=0; i<band->tot; i++) {
+ CBData *data = band->data + i;
+ srgb_to_linearrgb_v3_v3(&data->r, &data->r);
+ }
+ }
+ if (ma->ramp_spec) {
+ ColorBand *band = (ColorBand *)ma->ramp_spec;
+ for (i=0; i<band->tot; i++) {
+ CBData *data = band->data + i;
+ srgb_to_linearrgb_v3_v3(&data->r, &data->r);
+ }
+ }
+
+ srgb_to_linearrgb_v3_v3(&ma->r, &ma->r);
+ srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr);
+ srgb_to_linearrgb_v3_v3(&ma->mirr, &ma->mirr);
+ srgb_to_linearrgb_v3_v3(ma->sss_col, ma->sss_col);
+ ma=ma->id.next;
+ }
+
+ while (tex) {
+ if (tex->coba) {
+ ColorBand *band = (ColorBand *)tex->coba;
+ for (i=0; i<band->tot; i++) {
+ CBData *data = band->data + i;
+ srgb_to_linearrgb_v3_v3(&data->r, &data->r);
+ }
+ }
+ tex=tex->id.next;
+ }
+
+ while (wo) {
+ srgb_to_linearrgb_v3_v3(&wo->ambr, &wo->ambr);
+ srgb_to_linearrgb_v3_v3(&wo->horr, &wo->horr);
+ srgb_to_linearrgb_v3_v3(&wo->zenr, &wo->zenr);
+ wo=wo->id.next;
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) {
+ Scene *sce;
+ Mesh *me;
+ Object *ob;
+
+ for (sce=main->scene.first; sce; sce=sce->id.next)
+ if (!sce->toolsettings->particle.selectmode)
+ sce->toolsettings->particle.selectmode= SCE_SELECT_PATH;
+
+ if (main->versionfile == 250 && main->subversionfile > 1) {
+ for (me=main->mesh.first; me; me=me->id.next)
+ multires_load_old_250(me);
+
+ for (ob=main->object.first; ob; ob=ob->id.next) {
+ MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(ob, eModifierType_Multires);
+
+ if (mmd) {
+ mmd->totlvl--;
+ mmd->lvl--;
+ mmd->sculptlvl= mmd->lvl;
+ mmd->renderlvl= mmd->lvl;
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10)) {
+ Object *ob;
+
+ /* properly initialize hair clothsim data on old files */
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md= ob->modifiers.first; md; md= md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+ if (clmd->sim_parms->velocity_smooth < 0.01f)
+ clmd->sim_parms->velocity_smooth = 0.f;
+ }
+ }
+ }
+ }
+
+ /* fix bad area setup in subversion 10 */
+ if (main->versionfile == 250 && main->subversionfile == 10) {
+ /* fix for new view type in sequencer */
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+
+ /* remove all preview window in wrong spaces */
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype!=SPACE_SEQ) {
+ ARegion *ar;
+ ListBase *regionbase;
+
+ if (sl == sa->spacedata.first) {
+ regionbase = &sa->regionbase;
+ }
+ else {
+ regionbase = &sl->regionbase;
+ }
+
+
+ for ( ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_PREVIEW)
+ break;
+ }
+
+ if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) {
+ SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ);
+ BKE_area_region_free(st, ar);
+ BLI_freelinkN(regionbase, ar);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11)) {
+ {
+ /* fix for new view type in sequencer */
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_SEQ) {
+ ARegion *ar;
+ ARegion *ar_main;
+ ListBase *regionbase;
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ if (sl == sa->spacedata.first) {
+ regionbase = &sa->regionbase;
+ }
+ else {
+ regionbase = &sl->regionbase;
+ }
+
+ if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE;
+ if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+
+ ar_main = (ARegion*)regionbase->first;
+ for (; ar_main; ar_main = ar_main->next) {
+ if (ar_main->regiontype == RGN_TYPE_WINDOW)
+ break;
+ }
+ ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
+ BLI_insertlinkbefore(regionbase, ar_main, ar);
+ sequencer_init_preview_region(ar);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) {
+ Scene *sce;
+ Object *ob;
+ Brush *brush;
+ Material *ma;
+
+ /* game engine changes */
+ for (sce = main->scene.first; sce; sce = sce->id.next) {
+ sce->gm.eyeseparation = 0.10f;
+ }
+
+ /* anim viz changes */
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ /* initialize object defaults */
+ animviz_settings_init(&ob->avs);
+
+ /* if armature, copy settings for pose from armature data
+ * performing initialization where appropriate
+ */
+ if (ob->pose && ob->data) {
+ bArmature *arm= blo_do_versions_newlibadr(fd, lib, ob->data);
+ if (arm) { /* XXX - why does this fail in some cases? */
+ bAnimVizSettings *avs= &ob->pose->avs;
+
+ /* ghosting settings ---------------- */
+ /* ranges */
+ avs->ghost_bc= avs->ghost_ac= arm->ghostep;
+
+ avs->ghost_sf= arm->ghostsf;
+ avs->ghost_ef= arm->ghostef;
+ if ((avs->ghost_sf == avs->ghost_ef) && (avs->ghost_sf == 0)) {
+ avs->ghost_sf= 1;
+ avs->ghost_ef= 100;
+ }
+
+ /* type */
+ if (arm->ghostep == 0)
+ avs->ghost_type= GHOST_TYPE_NONE;
+ else
+ avs->ghost_type= arm->ghosttype + 1;
+
+ /* stepsize */
+ avs->ghost_step= arm->ghostsize;
+ if (avs->ghost_step == 0)
+ avs->ghost_step= 1;
+
+ /* path settings --------------------- */
+ /* ranges */
+ avs->path_bc= arm->pathbc;
+ avs->path_ac= arm->pathac;
+ if ((avs->path_bc == avs->path_ac) && (avs->path_bc == 0))
+ avs->path_bc= avs->path_ac= 10;
+
+ avs->path_sf= arm->pathsf;
+ avs->path_ef= arm->pathef;
+ if ((avs->path_sf == avs->path_ef) && (avs->path_sf == 0)) {
+ avs->path_sf= 1;
+ avs->path_ef= 250;
+ }
+
+ /* flags */
+ if (arm->pathflag & ARM_PATH_FNUMS)
+ avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS;
+ if (arm->pathflag & ARM_PATH_KFRAS)
+ avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS;
+ if (arm->pathflag & ARM_PATH_KFNOS)
+ avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS;
+
+ /* bake flags */
+ if (arm->pathflag & ARM_PATH_HEADS)
+ avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS;
+
+ /* type */
+ if (arm->pathflag & ARM_PATH_ACFRA)
+ avs->path_type = MOTIONPATH_TYPE_ACFRA;
+
+ /* stepsize */
+ avs->path_step= arm->pathsize;
+ if (avs->path_step == 0)
+ avs->path_step= 1;
+ }
+ else
+ animviz_settings_init(&ob->pose->avs);
+ }
+ }
+
+ /* brush texture changes */
+ for (brush= main->brush.first; brush; brush= brush->id.next) {
+ default_mtex(&brush->mtex);
+ }
+
+ for (ma= main->mat.first; ma; ma= ma->id.next) {
+ if (ma->vol.ms_spread < 0.0001f) {
+ ma->vol.ms_spread = 0.2f;
+ ma->vol.ms_diff = 1.f;
+ ma->vol.ms_intensity = 1.f;
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) {
+ /* NOTE: if you do more conversion, be sure to do it outside of this and
+ * increase subversion again, otherwise it will not be correct */
+ Object *ob;
+
+ /* convert degrees to radians for internal use */
+ for (ob=main->object.first; ob; ob=ob->id.next) {
+ bPoseChannel *pchan;
+
+ do_version_constraints_radians_degrees_250(&ob->constraints);
+
+ if (ob->pose) {
+ for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ pchan->limitmin[0] *= (float)(M_PI/180.0);
+ pchan->limitmin[1] *= (float)(M_PI/180.0);
+ pchan->limitmin[2] *= (float)(M_PI/180.0);
+ pchan->limitmax[0] *= (float)(M_PI/180.0);
+ pchan->limitmax[1] *= (float)(M_PI/180.0);
+ pchan->limitmax[2] *= (float)(M_PI/180.0);
+
+ do_version_constraints_radians_degrees_250(&pchan->constraints);
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 14)) {
+ /* fix for bad View2D extents for Animation Editors */
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ ListBase *regionbase;
+ ARegion *ar;
+
+ if (sl == sa->spacedata.first)
+ regionbase = &sa->regionbase;
+ else
+ regionbase = &sl->regionbase;
+
+ if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
+ for (ar = (ARegion*)regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f;
+ ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 15)) {
+ World *wo;
+ Material *ma;
+
+ /* ambient default from 0.5f to 1.0f */
+ for (ma= main->mat.first; ma; ma=ma->id.next)
+ ma->amb *= 2.0f;
+
+ for (wo= main->world.first; wo; wo=wo->id.next) {
+ /* ao splitting into ao/env/indirect */
+ wo->ao_env_energy= wo->aoenergy;
+ wo->aoenergy= 1.0f;
+
+ if (wo->ao_indirect_bounces == 0)
+ wo->ao_indirect_bounces= 1;
+ else
+ wo->mode |= WO_INDIRECT_LIGHT;
+
+ if (wo->aomix == WO_AOSUB)
+ wo->ao_env_energy= -wo->ao_env_energy;
+ else if (wo->aomix == WO_AOADDSUB)
+ wo->mode |= WO_AMB_OCC;
+
+ wo->aomix= WO_AOMUL;
+
+ /* ambient default from 0.5f to 1.0f */
+ mul_v3_fl(&wo->ambr, 0.5f);
+ wo->ao_env_energy *= 0.5f;
+ }
+ }
+
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) {
+ Scene *sce;
+ Sequence *seq;
+ Material *ma;
+
+ /* initialize to sane default so toggling on border shows something */
+ for (sce = main->scene.first; sce; sce = sce->id.next) {
+ if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f &&
+ sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f) {
+ sce->r.border.xmin = 0.0f;
+ sce->r.border.ymin = 0.0f;
+ sce->r.border.xmax = 1.0f;
+ sce->r.border.ymax = 1.0f;
+ }
+
+ if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
+ sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
+
+ SEQ_BEGIN (sce->ed, seq)
+ {
+ seq->volume = 1.0f;
+ }
+ SEQ_END
+ }
+
+ /* particle brush strength factor was changed from int to float */
+ for (sce= main->scene.first; sce; sce=sce->id.next) {
+ ParticleEditSettings *pset= &sce->toolsettings->particle;
+ int a;
+
+ for (a=0; a<PE_TOT_BRUSH; a++)
+ pset->brush[a].strength /= 100.0f;
+ }
+
+ for (ma = main->mat.first; ma; ma=ma->id.next)
+ if (ma->mode & MA_TRACEBLE)
+ ma->shade_flag |= MA_APPROX_OCCLUSION;
+
+ /* sequencer changes */
+ {
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_SEQ) {
+ ARegion *ar_preview;
+ ListBase *regionbase;
+
+ if (sl == sa->spacedata.first) {
+ regionbase = &sa->regionbase;
+ }
+ else {
+ regionbase = &sl->regionbase;
+ }
+
+ ar_preview = (ARegion*)regionbase->first;
+ for (; ar_preview; ar_preview = ar_preview->next) {
+ if (ar_preview->regiontype == RGN_TYPE_PREVIEW)
+ break;
+ }
+ if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) {
+ sequencer_init_preview_region(ar_preview);
+ }
+ }
+ }
+ }
+ }
+ } /* sequencer changes */
+ }
+
+ if (main->versionfile <= 251) { /* 2.5.1 had no subversions */
+ bScreen *sc;
+
+ /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE.
+ * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated.
+ * Here we clear it for old files so they don't come in with V3D_RENDER_OVERRIDE set,
+ * which would cause cameras, lamps, etc to become invisible */
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D* v3d = (View3D *)sl;
+ v3d->flag2 &= ~V3D_RENDER_OVERRIDE;
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 1)) {
+ Brush *brush;
+ Object *ob;
+ Scene *scene;
+ bNodeTree *ntree;
+
+ for (brush= main->brush.first; brush; brush= brush->id.next) {
+ if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH;
+ }
+
+ /* properly initialize active flag for fluidsim modifiers */
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md= ob->modifiers.first; md; md= md->next) {
+ if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fmd = (FluidsimModifierData *)md;
+ fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
+ fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME;
+ }
+ }
+ }
+
+ /* adjustment to color balance node values */
+ for (scene= main->scene.first; scene; scene= scene->id.next) {
+ if (scene->nodetree) {
+ bNode *node=scene->nodetree->nodes.first;
+
+ while (node) {
+ if (node->type == CMP_NODE_COLORBALANCE) {
+ NodeColorBalance *n= (NodeColorBalance *)node->storage;
+ n->lift[0] += 1.f;
+ n->lift[1] += 1.f;
+ n->lift[2] += 1.f;
+ }
+ node= node->next;
+ }
+ }
+ }
+ /* check inside node groups too */
+ for (ntree= main->nodetree.first; ntree; ntree=ntree->id.next) {
+ bNode *node=ntree->nodes.first;
+
+ while (node) {
+ if (node->type == CMP_NODE_COLORBALANCE) {
+ NodeColorBalance *n= (NodeColorBalance *)node->storage;
+ n->lift[0] += 1.f;
+ n->lift[1] += 1.f;
+ n->lift[2] += 1.f;
+ }
+ node= node->next;
+ }
+ }
+ }
+
+ /* old-track -> constraints (this time we're really doing it!) */
+ if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 2)) {
+ Object *ob;
+
+ for (ob = main->object.first; ob; ob = ob->id.next)
+ blo_do_version_old_trackto_to_constraints(ob);
+ }
+
+ if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
+ bScreen *sc;
+
+ /* Image editor scopes */
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+ scopes_new(&sima->scopes);
+ }
+ }
+ }
+ }
+ }
+
+
+ if (main->versionfile < 253) {
+ Object *ob;
+ Scene *scene;
+ bScreen *sc;
+ Tex *tex;
+ Brush *brush;
+
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode= (SpaceNode *)sl;
+ ListBase *regionbase;
+ ARegion *ar;
+
+ if (sl == sa->spacedata.first)
+ regionbase = &sa->regionbase;
+ else
+ regionbase = &sl->regionbase;
+
+ if (snode->v2d.minzoom > 0.09f)
+ snode->v2d.minzoom= 0.09f;
+ if (snode->v2d.maxzoom < 2.31f)
+ snode->v2d.maxzoom= 2.31f;
+
+ for (ar= regionbase->first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->v2d.minzoom > 0.09f)
+ ar->v2d.minzoom= 0.09f;
+ if (ar->v2d.maxzoom < 2.31f)
+ ar->v2d.maxzoom= 2.31f;
+ }
+ }
+ }
+ else if (sl->spacetype == SPACE_TIME) {
+ SpaceTime *stime= (SpaceTime *)sl;
+
+ /* enable all cache display */
+ stime->cache_display |= TIME_CACHE_DISPLAY;
+ stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
+ stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
+ }
+ }
+ }
+ }
+
+ do_version_mdef_250(main);
+
+ /* parent type to modifier */
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ if (ob->parent) {
+ Object *parent= (Object *)blo_do_versions_newlibadr(fd, lib, ob->parent);
+ if (parent) { /* parent may not be in group */
+ if (parent->type==OB_ARMATURE && ob->partype==PARSKEL) {
+ ArmatureModifierData *amd;
+ bArmature *arm= (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data);
+
+ amd = (ArmatureModifierData*) modifier_new(eModifierType_Armature);
+ amd->object = ob->parent;
+ BLI_addtail((ListBase*)&ob->modifiers, amd);
+ amd->deformflag= arm->deformflag;
+ ob->partype = PAROBJECT;
+ }
+ else if (parent->type==OB_LATTICE && ob->partype==PARSKEL) {
+ LatticeModifierData *lmd;
+
+ lmd = (LatticeModifierData*) modifier_new(eModifierType_Lattice);
+ lmd->object = ob->parent;
+ BLI_addtail((ListBase*)&ob->modifiers, lmd);
+ ob->partype = PAROBJECT;
+ }
+ else if (parent->type==OB_CURVE && ob->partype==PARCURVE) {
+ CurveModifierData *cmd;
+
+ cmd = (CurveModifierData*) modifier_new(eModifierType_Curve);
+ cmd->object = ob->parent;
+ BLI_addtail((ListBase*)&ob->modifiers, cmd);
+ ob->partype = PAROBJECT;
+ }
+ }
+ }
+ }
+
+ /* initialize scene active layer */
+ for (scene= main->scene.first; scene; scene=scene->id.next) {
+ int i;
+ for (i=0; i<20; i++) {
+ if (scene->lay & (1<<i)) {
+ scene->layact= 1<<i;
+ break;
+ }
+ }
+ }
+
+ for (tex= main->tex.first; tex; tex= tex->id.next) {
+ /* if youre picky, this isn't correct until we do a version bump
+ * since you could set saturation to be 0.0*/
+ if (tex->saturation==0.0f)
+ tex->saturation= 1.0f;
+ }
+
+ {
+ Curve *cu;
+ for (cu= main->curve.first; cu; cu= cu->id.next) {
+ cu->smallcaps_scale= 0.75f;
+ }
+ }
+
+ for (scene= main->scene.first; scene; scene=scene->id.next) {
+ if (scene) {
+ Sequence *seq;
+ SEQ_BEGIN (scene->ed, seq)
+ {
+ if (seq->sat==0.0f) {
+ seq->sat= 1.0f;
+ }
+ }
+ SEQ_END
+ }
+ }
+
+ /* GSOC 2010 Sculpt - New settings for Brush */
+
+ for (brush= main->brush.first; brush; brush= brush->id.next) {
+ /* Sanity Check */
+
+ // infinite number of dabs
+ if (brush->spacing == 0)
+ brush->spacing = 10;
+
+ // will have no effect
+ if (brush->alpha == 0)
+ brush->alpha = 0.5f;
+
+ // bad radius
+ if (brush->unprojected_radius == 0)
+ brush->unprojected_radius = 0.125f;
+
+ // unusable size
+ if (brush->size == 0)
+ brush->size = 35;
+
+ // can't see overlay
+ if (brush->texture_overlay_alpha == 0)
+ brush->texture_overlay_alpha = 33;
+
+ // same as draw brush
+ if (brush->crease_pinch_factor == 0)
+ brush->crease_pinch_factor = 0.5f;
+
+ // will sculpt no vertexes
+ if (brush->plane_trim == 0)
+ brush->plane_trim = 0.5f;
+
+ // same as smooth stroke off
+ if (brush->smooth_stroke_radius == 0)
+ brush->smooth_stroke_radius= 75;
+
+ // will keep cursor in one spot
+ if (brush->smooth_stroke_radius == 1)
+ brush->smooth_stroke_factor= 0.9f;
+
+ // same as dots
+ if (brush->rate == 0)
+ brush->rate = 0.1f;
+
+ /* New Settings */
+ if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
+ brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space
+
+ // spacing was originally in pixels, convert it to percentage for new version
+ // size should not be zero due to sanity check above
+ brush->spacing = (int)(100*((float)brush->spacing) / ((float)brush->size));
+
+ if (brush->add_col[0] == 0 &&
+ brush->add_col[1] == 0 &&
+ brush->add_col[2] == 0)
+ {
+ brush->add_col[0] = 1.00f;
+ brush->add_col[1] = 0.39f;
+ brush->add_col[2] = 0.39f;
+ }
+
+ if (brush->sub_col[0] == 0 &&
+ brush->sub_col[1] == 0 &&
+ brush->sub_col[2] == 0)
+ {
+ brush->sub_col[0] = 0.39f;
+ brush->sub_col[1] = 0.39f;
+ brush->sub_col[2] = 1.00f;
+ }
+ }
+ }
+ }
+
+ /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */
+ if (main->versionfile < 253) {
+ Scene *sce;
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->toolsettings->sculpt_paint_unified_alpha == 0)
+ sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
+
+ if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0)
+ sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f;
+
+ if (sce->toolsettings->sculpt_paint_unified_size == 0)
+ sce->toolsettings->sculpt_paint_unified_size = 35;
+ }
+ }
+
+ if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) {
+ Object *ob;
+
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md= ob->modifiers.first; md; md= md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+ smd->domain->vorticity = 2.0f;
+ smd->domain->time_scale = 1.0f;
+
+ if (!(smd->domain->flags & (1<<4)))
+ continue;
+
+ /* delete old MOD_SMOKE_INITVELOCITY flag */
+ smd->domain->flags &= ~(1<<4);
+
+ /* for now just add it to all flow objects in the scene */
+ {
+ Object *ob2;
+ for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) {
+ ModifierData *md2;
+ for (md2= ob2->modifiers.first; md2; md2= md2->next) {
+ if (md2->type == eModifierType_Smoke) {
+ SmokeModifierData *smd2 = (SmokeModifierData *)md2;
+
+ if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) {
+ smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY;
+ }
+ }
+ }
+ }
+ }
+
+ }
+ else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
+ smd->flow->vel_multi = 1.0f;
+ }
+
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 1)) {
+ Brush *br;
+ ParticleSettings *part;
+ bScreen *sc;
+ Object *ob;
+
+ for (br= main->brush.first; br; br= br->id.next) {
+ if (br->ob_mode==0)
+ br->ob_mode= OB_MODE_ALL_PAINT;
+ }
+
+ for (part = main->particle.first; part; part = part->id.next) {
+ if (part->boids)
+ part->boids->pitch = 1.0f;
+
+ part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
+ part->kink_amp_clump = 1.f; /* keep old files looking similar */
+ }
+
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype == SPACE_INFO) {
+ SpaceInfo *sinfo= (SpaceInfo *)sl;
+ ARegion *ar;
+
+ sinfo->rpt_mask= INFO_RPT_OP;
+
+ for (ar= sa->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT);
+ ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */
+ ar->v2d.keepofs = V2D_LOCKOFS_X;
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
+ ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS;
+ ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* fix rotation actuators for objects so they use real angles (radians)
+ * since before blender went opensource this strange scalar was used: (1 / 0.02) * 2 * math.pi/360 */
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ bActuator *act= ob->actuators.first;
+ while (act) {
+ if (act->type==ACT_OBJECT) {
+ /* multiply velocity with 50 in old files */
+ bObjectActuator *oa= act->data;
+ mul_v3_fl(oa->drot, 0.8726646259971648f);
+ }
+ act= act->next;
+ }
+ }
+ }
+
+ // init facing axis property of steering actuators
+ {
+ Object *ob;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ bActuator *act;
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type==ACT_STEERING) {
+ bSteeringActuator* stact = act->data;
+ if (stact->facingaxis==0) {
+ stact->facingaxis=1;
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) {
+ Object *ob;
+
+ /* ocean res is now squared, reset old ones - will be massive */
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md= ob->modifiers.first; md; md= md->next) {
+ if (md->type == eModifierType_Ocean) {
+ OceanModifierData *omd = (OceanModifierData *)md;
+ omd->resolution = 7;
+ omd->oceancache = NULL;
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 256) {
+ bScreen *sc;
+ ScrArea *sa;
+ Key *key;
+
+ /* Fix for sample line scope initializing with no height */
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_IMAGE) {
+ SpaceImage *sima= (SpaceImage *)sl;
+ if (sima->sample_line_hist.height == 0 )
+ sima->sample_line_hist.height = 100;
+ }
+ }
+ sa= sa->next;
+ }
+ }
+
+ /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in
+ * 2.4x would never reveal this to users as a dummy value always ended up getting used
+ * instead
+ */
+ for (key = main->key.first; key; key = key->id.next) {
+ KeyBlock *kb;
+
+ for (kb = key->block.first; kb; kb = kb->next) {
+ if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0))
+ kb->slidermax = kb->slidermin + 1.0f;
+ }
+ }
+ }
+
+ if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) {
+ /* fix for bones that didn't have arm_roll before */
+ bArmature* arm;
+ Bone* bone;
+ Object *ob;
+
+ for (arm = main->armature.first; arm; arm = arm->id.next)
+ for (bone = arm->bonebase.first; bone; bone = bone->next)
+ do_version_bone_roll_256(bone);
+
+ /* fix for objects which have zero dquat's
+ * since this is multiplied with the quat rather than added */
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ if (is_zero_v4(ob->dquat)) {
+ unit_qt(ob->dquat);
+ }
+ if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) {
+ unit_axis_angle(ob->drotAxis, &ob->drotAngle);
+ }
+ }
+ }
+
+ if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) {
+ bNodeTree *ntree;
+
+ /* node sockets are not exposed automatically any more,
+ * this mimics the old behavior by adding all unlinked sockets to groups.
+ */
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+ /* XXX Only setting a flag here. Actual adding of group sockets
+ * is done in lib_verify_nodetree, because at this point the internal
+ * nodes may not be up-to-date! (missing lib-link)
+ */
+ ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE;
+ }
+ }
+
+ if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <3)) {
+ bScreen *sc;
+ Brush *brush;
+ Object *ob;
+ ParticleSettings *part;
+ Material *mat;
+ int tex_nr, transp_tex;
+
+ for (mat = main->mat.first; mat; mat = mat->id.next) {
+ if (!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)) {
+
+ transp_tex= 0;
+
+ for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
+ if (!mat->mtex[tex_nr]) continue;
+ if (mat->mtex[tex_nr]->mapto & MAP_ALPHA) transp_tex= 1;
+ }
+
+ /* weak! material alpha could be animated */
+ if (mat->alpha < 1.0f || mat->fresnel_tra > 0.0f || transp_tex) {
+ mat->mode |= MA_TRANSP;
+ mat->mode &= ~(MA_ZTRANSP|MA_RAYTRANSP);
+ }
+ }
+ }
+
+ /* redraws flag in SpaceTime has been moved to Screen level */
+ for (sc = main->screen.first; sc; sc= sc->id.next) {
+ if (sc->redraws_flag == 0) {
+ /* just initialize to default? */
+ // XXX: we could also have iterated through areas, and taken them from the first timeline available...
+ sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
+ }
+ }
+
+ for (brush= main->brush.first; brush; brush= brush->id.next) {
+ if (brush->height == 0)
+ brush->height= 0.4f;
+ }
+
+ /* replace 'rim material' option for in offset*/
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md= ob->modifiers.first; md; md= md->next) {
+ if (md->type == eModifierType_Solidify) {
+ SolidifyModifierData *smd = (SolidifyModifierData *)md;
+ if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
+ smd->mat_ofs_rim= 1;
+ smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
+ }
+ }
+ }
+ }
+
+ /* particle draw color from material */
+ for (part = main->particle.first; part; part = part->id.next) {
+ if (part->draw & PART_DRAW_MAT_COL)
+ part->draw_col = PART_DRAW_COL_MAT;
+ }
+ }
+
+ if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)) {
+ Mesh *me;
+
+ for (me= main->mesh.first; me; me= me->id.next)
+ mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL);
+ }
+
+ if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) {
+ /* update blur area sizes from 0..1 range to 0..100 percentage */
+ Scene *scene;
+ bNode *node;
+ for (scene=main->scene.first; scene; scene=scene->id.next)
+ if (scene->nodetree)
+ for (node=scene->nodetree->nodes.first; node; node=node->next)
+ if (node->type==CMP_NODE_BLUR) {
+ NodeBlurData *nbd= node->storage;
+ nbd->percentx *= 100.0f;
+ nbd->percenty *= 100.0f;
+ }
+ }
+
+ if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)) {
+ /* screen view2d settings were not properly initialized [#27164]
+ * v2d->scroll caused the bug but best reset other values too which are in old blend files only.
+ * need to make less ugly - possibly an iterator? */
+ bScreen *screen;
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ ScrArea *sa;
+ /* add regions */
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl= sa->spacedata.first;
+ if (sl->spacetype==SPACE_IMAGE) {
+ ARegion *ar;
+ for (ar=sa->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ View2D *v2d= &ar->v2d;
+ v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
+ }
+ }
+ }
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_IMAGE) {
+ ARegion *ar;
+ for (ar=sl->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ View2D *v2d= &ar->v2d;
+ v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ {
+ /* Initialize texture point density curve falloff */
+ Tex *tex;
+ for (tex= main->tex.first; tex; tex= tex->id.next) {
+ if (tex->pd) {
+ if (tex->pd->falloff_speed_scale == 0.0f)
+ tex->pd->falloff_speed_scale = 100.0f;
+
+ if (!tex->pd->falloff_curve) {
+ tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
+
+ tex->pd->falloff_curve->preset = CURVE_PRESET_LINE;
+ tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+ curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
+ curvemapping_changed(tex->pd->falloff_curve, 0);
+ }
+ }
+ }
+ }
+
+ {
+ /* add default value for behind strength of camera actuator */
+ Object *ob;
+ bActuator *act;
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_CAMERA) {
+ bCameraActuator *ba= act->data;
+
+ ba->damping = 1.0/32.0;
+ }
+ }
+ }
+ }
+
+ {
+ ParticleSettings *part;
+ for (part = main->particle.first; part; part = part->id.next) {
+ /* Initialize particle billboard scale */
+ part->bb_size[0] = part->bb_size[1] = 1.0f;
+ }
+ }
+ }
+
+ if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)) {
+ {
+ Scene *scene;
+ Sequence *seq;
+
+ for (scene=main->scene.first; scene; scene=scene->id.next) {
+ scene->r.ffcodecdata.audio_channels = 2;
+ scene->audio.volume = 1.0f;
+ SEQ_BEGIN (scene->ed, seq)
+ {
+ seq->pitch = 1.0f;
+ }
+ SEQ_END
+ }
+ }
+ {
+ bScreen *screen;
+ for (screen= main->screen.first; screen; screen= screen->id.next) {
+ ScrArea *sa;
+ /* add regions */
+ for (sa= screen->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl= sa->spacedata.first;
+ if (sl->spacetype==SPACE_SEQ) {
+ ARegion *ar;
+ for (ar=sa->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->v2d.min[1] == 4.0f)
+ ar->v2d.min[1]= 0.5f;
+ }
+ }
+ }
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_SEQ) {
+ ARegion *ar;
+ for (ar=sl->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->v2d.min[1] == 4.0f)
+ ar->v2d.min[1]= 0.5f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ {
+ /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve
+ *
+ * We're only patching F-Curves in Actions here, since it is assumed that most
+ * drivers out there won't be using this (and if they are, they're in the minority).
+ * While we should aim to fix everything ideally, in practice it's far too hard
+ * to get to every animdata block, not to mention the performance hit that'd have
+ */
+ bAction *act;
+ FCurve *fcu;
+
+ for (act = main->action.first; act; act = act->id.next) {
+ for (fcu = act->curves.first; fcu; fcu = fcu->next) {
+ BezTriple *bezt;
+ unsigned int i = 0;
+
+ /* only need to touch curves that had this flag set */
+ if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
+ continue;
+ if ((fcu->totvert == 0) || (fcu->bezt == NULL))
+ continue;
+
+ /* only change auto-handles to auto-clamped */
+ for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM;
+ if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM;
+ }
+
+ fcu->flag &= ~FCURVE_AUTO_HANDLES;
+ }
+ }
+ }
+ {
+ /* convert fcurve and shape action actuators to action actuators */
+ Object *ob;
+ bActuator *act;
+ bIpoActuator *ia;
+ bActionActuator *aa;
+
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_IPO) {
+ // Create the new actuator
+ ia= act->data;
+ aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version");
+
+ // Copy values
+ aa->type = ia->type;
+ aa->flag = ia->flag;
+ aa->sta = ia->sta;
+ aa->end = ia->end;
+ BLI_strncpy(aa->name, ia->name, sizeof(aa->name));
+ BLI_strncpy(aa->frameProp, ia->frameProp, sizeof(aa->frameProp));
+ if (ob->adt)
+ aa->act = ob->adt->action;
+
+ // Get rid of the old actuator
+ MEM_freeN(ia);
+
+ // Assign the new actuator
+ act->data = aa;
+ act->type= act->otype= ACT_ACTION;
+
+ }
+ else if (act->type == ACT_SHAPEACTION) {
+ act->type = act->otype = ACT_ACTION;
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)) {
+ {
+ /* Convert default socket values from bNodeStack */
+ Scene *sce;
+ Material *mat;
+ Tex *tex;
+ bNodeTree *ntree;
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+ blo_do_versions_nodetree_default_value(ntree);
+ ntree->update |= NTREE_UPDATE;
+ }
+ for (sce=main->scene.first; sce; sce=sce->id.next)
+ if (sce->nodetree) {
+ blo_do_versions_nodetree_default_value(sce->nodetree);
+ sce->nodetree->update |= NTREE_UPDATE;
+ }
+ for (mat=main->mat.first; mat; mat=mat->id.next)
+ if (mat->nodetree) {
+ blo_do_versions_nodetree_default_value(mat->nodetree);
+ mat->nodetree->update |= NTREE_UPDATE;
+ }
+ for (tex=main->tex.first; tex; tex=tex->id.next)
+ if (tex->nodetree) {
+ blo_do_versions_nodetree_default_value(tex->nodetree);
+ tex->nodetree->update |= NTREE_UPDATE;
+ }
+ }
+
+ /* add SOCK_DYNAMIC flag to existing group sockets */
+ {
+ bNodeTree *ntree;
+ /* only need to do this for trees in main, local trees are not used as groups */
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+ do_versions_nodetree_dynamic_sockets(ntree);
+ ntree->update |= NTREE_UPDATE;
+ }
+ }
+
+ {
+ /* Initialize group tree nodetypes.
+ * These are used to distinguish tree types and
+ * associate them with specific node types for polling.
+ */
+ bNodeTree *ntree;
+ /* all node trees in main->nodetree are considered groups */
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
+ ntree->nodetype = NODE_GROUP;
+ }
+ }
+
+ if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 4)) {
+ {
+ /* Adaptive time step for particle systems */
+ ParticleSettings *part;
+ for (part = main->particle.first; part; part = part->id.next) {
+ part->courant_target = 0.2f;
+ part->time_flag &= ~PART_TIME_AUTOSF;
+ }
+ }
+
+ {
+ /* set defaults for obstacle avoidance, recast data */
+ Scene *sce;
+ for (sce = main->scene.first; sce; sce = sce->id.next) {
+ if (sce->gm.levelHeight == 0.f)
+ sce->gm.levelHeight = 2.f;
+
+ if (sce->gm.recastData.cellsize == 0.0f)
+ sce->gm.recastData.cellsize = 0.3f;
+ if (sce->gm.recastData.cellheight == 0.0f)
+ sce->gm.recastData.cellheight = 0.2f;
+ if (sce->gm.recastData.agentmaxslope == 0.0f)
+ sce->gm.recastData.agentmaxslope = (float)M_PI/4;
+ if (sce->gm.recastData.agentmaxclimb == 0.0f)
+ sce->gm.recastData.agentmaxclimb = 0.9f;
+ if (sce->gm.recastData.agentheight == 0.0f)
+ sce->gm.recastData.agentheight = 2.0f;
+ if (sce->gm.recastData.agentradius == 0.0f)
+ sce->gm.recastData.agentradius = 0.6f;
+ if (sce->gm.recastData.edgemaxlen == 0.0f)
+ sce->gm.recastData.edgemaxlen = 12.0f;
+ if (sce->gm.recastData.edgemaxerror == 0.0f)
+ sce->gm.recastData.edgemaxerror = 1.3f;
+ if (sce->gm.recastData.regionminsize == 0.0f)
+ sce->gm.recastData.regionminsize = 8.f;
+ if (sce->gm.recastData.regionmergesize == 0.0f)
+ sce->gm.recastData.regionmergesize = 20.f;
+ if (sce->gm.recastData.vertsperpoly<3)
+ sce->gm.recastData.vertsperpoly = 6;
+ if (sce->gm.recastData.detailsampledist == 0.0f)
+ sce->gm.recastData.detailsampledist = 6.0f;
+ if (sce->gm.recastData.detailsamplemaxerror == 0.0f)
+ sce->gm.recastData.detailsamplemaxerror = 1.0f;
+ }
+ }
+ }
+
+ /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
+ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
+
+ /* don't forget to set version number in blender.c! */
+}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
new file mode 100644
index 00000000000..fc238204251
--- /dev/null
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -0,0 +1,3570 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/blenloader/intern/readfile_pre250.c
+ * \ingroup blenloader
+ */
+
+
+//#include "zlib.h"
+
+#include <limits.h>
+//#include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
+//#include <stdlib.h> // for getenv atoi
+//#include <stddef.h> // for offsetof
+//#include <fcntl.h> // for open
+//#include <string.h> // for strrchr strncmp strstr
+//#include <math.h> // for fabs
+//#include <stdarg.h> /* for va_start/end */
+
+#ifndef WIN32
+# include <unistd.h> // for read close
+#else
+# include <io.h> // for open close read
+# include "winsock2.h"
+# include "BLI_winstuff.h"
+#endif
+
+/* allow readfile to use deprecated functionality */
+#define DNA_DEPRECATED_ALLOW
+
+#include "DNA_armature_types.h"
+#include "DNA_actuator_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_effect_types.h"
+#include "DNA_group_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_nla_types.h"
+#include "DNA_node_types.h"
+#include "DNA_object_fluidsim.h" // NT
+#include "DNA_object_types.h"
+#include "DNA_property_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_sensor_types.h"
+#include "DNA_sdna_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_space_types.h"
+#include "DNA_vfont_types.h"
+#include "DNA_world_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_edgehash.h"
+
+#include "BKE_armature.h"
+#include "BKE_colortools.h"
+#include "BKE_constraint.h"
+#include "BKE_deform.h"
+#include "BKE_fcurve.h"
+#include "BKE_global.h" // for G
+#include "BKE_image.h"
+#include "BKE_lattice.h"
+#include "BKE_main.h" // for Main
+#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_modifier.h"
+#include "BKE_particle.h"
+#include "BKE_pointcache.h"
+#include "BKE_property.h" // for get_ob_property
+#include "BKE_scene.h"
+#include "BKE_sequencer.h"
+#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
+
+#include "IMB_imbuf.h" // for proxy / timecode versioning stuff
+
+#include "NOD_socket.h"
+
+//XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes
+//XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie
+//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo
+#include "BLO_readfile.h"
+#include "BLO_undofile.h"
+
+#include "RE_engine.h"
+
+#include "readfile.h"
+
+#include "PIL_time.h"
+
+#include <errno.h>
+
+static void vcol_to_fcol(Mesh *me)
+{
+ MFace *mface;
+ unsigned int *mcol, *mcoln, *mcolmain;
+ int a;
+
+ if (me->totface==0 || me->mcol==NULL) return;
+
+ mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln");
+ mcol = (unsigned int *)me->mcol;
+ mface= me->mface;
+ for (a=me->totface; a>0; a--, mface++) {
+ mcoln[0]= mcol[mface->v1];
+ mcoln[1]= mcol[mface->v2];
+ mcoln[2]= mcol[mface->v3];
+ mcoln[3]= mcol[mface->v4];
+ mcoln+= 4;
+ }
+
+ MEM_freeN(me->mcol);
+ me->mcol= (MCol *)mcolmain;
+}
+
+static int map_223_keybd_code_to_224_keybd_code(int code)
+{
+ switch (code) {
+ case 312: return 311; /* F12KEY */
+ case 159: return 161; /* PADSLASHKEY */
+ case 161: return 150; /* PAD0 */
+ case 154: return 151; /* PAD1 */
+ case 150: return 152; /* PAD2 */
+ case 155: return 153; /* PAD3 */
+ case 151: return 154; /* PAD4 */
+ case 156: return 155; /* PAD5 */
+ case 152: return 156; /* PAD6 */
+ case 157: return 157; /* PAD7 */
+ case 153: return 158; /* PAD8 */
+ case 158: return 159; /* PAD9 */
+ default: return code;
+ }
+}
+
+static void do_version_bone_head_tail_237(Bone *bone)
+{
+ Bone *child;
+ float vec[3];
+
+ /* head */
+ copy_v3_v3(bone->arm_head, bone->arm_mat[3]);
+
+ /* tail is in current local coord system */
+ copy_v3_v3(vec, bone->arm_mat[1]);
+ mul_v3_fl(vec, bone->length);
+ add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
+
+ for (child= bone->childbase.first; child; child= child->next)
+ do_version_bone_head_tail_237(child);
+}
+
+static void bone_version_238(ListBase *lb)
+{
+ Bone *bone;
+
+ for (bone= lb->first; bone; bone= bone->next) {
+ if (bone->rad_tail==0.0f && bone->rad_head==0.0f) {
+ bone->rad_head= 0.25f*bone->length;
+ bone->rad_tail= 0.1f*bone->length;
+
+ bone->dist-= bone->rad_head;
+ if (bone->dist<=0.0f) bone->dist= 0.0f;
+ }
+ bone_version_238(&bone->childbase);
+ }
+}
+
+static void bone_version_239(ListBase *lb)
+{
+ Bone *bone;
+
+ for (bone= lb->first; bone; bone= bone->next) {
+ if (bone->layer==0)
+ bone->layer= 1;
+ bone_version_239(&bone->childbase);
+ }
+}
+
+static void ntree_version_241(bNodeTree *ntree)
+{
+ bNode *node;
+
+ if (ntree->type==NTREE_COMPOSIT) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->type==CMP_NODE_BLUR) {
+ if (node->storage==NULL) {
+ NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch");
+ nbd->sizex= node->custom1;
+ nbd->sizey= node->custom2;
+ nbd->filtertype= R_FILTER_QUAD;
+ node->storage= nbd;
+ }
+ }
+ else if (node->type==CMP_NODE_VECBLUR) {
+ if (node->storage==NULL) {
+ NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch");
+ nbd->samples= node->custom1;
+ nbd->maxspeed= node->custom2;
+ nbd->fac= 1.0f;
+ node->storage= nbd;
+ }
+ }
+ }
+ }
+}
+
+static void ntree_version_242(bNodeTree *ntree)
+{
+ bNode *node;
+
+ if (ntree->type==NTREE_COMPOSIT) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->type==CMP_NODE_HUE_SAT) {
+ if (node->storage) {
+ NodeHueSat *nhs= node->storage;
+ if (nhs->val==0.0f) nhs->val= 1.0f;
+ }
+ }
+ }
+ }
+ else if (ntree->type==NTREE_SHADER) {
+ for (node= ntree->nodes.first; node; node= node->next)
+ if (node->type == SH_NODE_GEOMETRY && node->storage == NULL)
+ node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
+ }
+
+}
+
+static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree)
+{
+ bNode *node;
+ NodeTwoFloats *ntf;
+ ID *nodeid;
+ Image *image;
+ ImageUser *iuser;
+
+ if (ntree->type==NTREE_COMPOSIT) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->type == CMP_NODE_ALPHAOVER) {
+ if (!node->storage) {
+ ntf= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats");
+ node->storage= ntf;
+ if (node->custom1)
+ ntf->x= 1.0f;
+ }
+ }
+
+ /* fix for temporary flag changes during 245 cycle */
+ nodeid= blo_do_versions_newlibadr(fd, lib, node->id);
+ if (node->storage && nodeid && GS(nodeid->name) == ID_IM) {
+ image= (Image*)nodeid;
+ iuser= node->storage;
+ if (iuser->flag & IMA_OLD_PREMUL) {
+ iuser->flag &= ~IMA_OLD_PREMUL;
+ iuser->flag |= IMA_DO_PREMUL;
+ }
+ if (iuser->flag & IMA_DO_PREMUL) {
+ image->flag &= ~IMA_OLD_PREMUL;
+ image->flag |= IMA_DO_PREMUL;
+ }
+ }
+ }
+ }
+}
+
+static void idproperties_fix_groups_lengths_recurse(IDProperty *prop)
+{
+ IDProperty *loop;
+ int i;
+
+ for (loop=prop->data.group.first, i=0; loop; loop=loop->next, i++) {
+ if (loop->type == IDP_GROUP) idproperties_fix_groups_lengths_recurse(loop);
+ }
+
+ if (prop->len != i) {
+ printf("Found and fixed bad id property group length.\n");
+ prop->len = i;
+ }
+}
+
+static void idproperties_fix_group_lengths(ListBase idlist)
+{
+ ID *id;
+
+ for (id=idlist.first; id; id=id->next) {
+ if (id->properties) {
+ idproperties_fix_groups_lengths_recurse(id->properties);
+ }
+ }
+}
+
+static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me)
+{
+ Material *ma;
+ MFace *mf;
+ MTFace *tf;
+ int a, b, texalpha;
+
+ /* verify we have a tface layer */
+ for (b=0; b<me->fdata.totlayer; b++)
+ if (me->fdata.layers[b].type == CD_MTFACE)
+ break;
+
+ if (b == me->fdata.totlayer)
+ return;
+
+ /* if we do, set alpha sort if the game engine did it before */
+ for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
+ if (mf->mat_nr < me->totcol) {
+ ma= blo_do_versions_newlibadr(fd, lib, me->mat[mf->mat_nr]);
+ texalpha = 0;
+
+ /* we can't read from this if it comes from a library,
+ * because direct_link might not have happened on it,
+ * so ma->mtex is not pointing to valid memory yet */
+ if (ma && ma->id.lib)
+ ma= NULL;
+
+ for (b=0; ma && b<MAX_MTEX; b++)
+ if (ma->mtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA)
+ texalpha = 1;
+ }
+ else {
+ ma= NULL;
+ texalpha = 0;
+ }
+
+ for (b=0; b<me->fdata.totlayer; b++) {
+ if (me->fdata.layers[b].type == CD_MTFACE) {
+ tf = ((MTFace*)me->fdata.layers[b].data) + a;
+
+ tf->mode &= ~TF_ALPHASORT;
+ if (ma && (ma->mode & MA_ZTRANSP))
+ if (ELEM(tf->transp, TF_ALPHA, TF_ADD) || (texalpha && (tf->transp != TF_CLIP)))
+ tf->mode |= TF_ALPHASORT;
+ }
+ }
+ }
+}
+
+static void customdata_version_242(Mesh *me)
+{
+ CustomDataLayer *layer;
+ MTFace *mtf;
+ MCol *mcol;
+ TFace *tf;
+ int a, mtfacen, mcoln;
+
+ if (!me->vdata.totlayer) {
+ CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert);
+
+ if (me->msticky)
+ CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_ASSIGN, me->msticky, me->totvert);
+ if (me->dvert)
+ CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert);
+ }
+
+ if (!me->edata.totlayer)
+ CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge);
+
+ if (!me->fdata.totlayer) {
+ CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface);
+
+ if (me->tface) {
+ if (me->mcol)
+ MEM_freeN(me->mcol);
+
+ me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
+ me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface);
+
+ mtf= me->mtface;
+ mcol= me->mcol;
+ tf= me->tface;
+
+ for (a=0; a < me->totface; a++, mtf++, tf++, mcol+=4) {
+ memcpy(mcol, tf->col, sizeof(tf->col));
+ memcpy(mtf->uv, tf->uv, sizeof(tf->uv));
+
+ mtf->flag= tf->flag;
+ mtf->unwrap= tf->unwrap;
+ mtf->mode= tf->mode;
+ mtf->tile= tf->tile;
+ mtf->tpage= tf->tpage;
+ mtf->transp= tf->transp;
+ }
+
+ MEM_freeN(me->tface);
+ me->tface= NULL;
+ }
+ else if (me->mcol) {
+ me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface);
+ }
+ }
+
+ if (me->tface) {
+ MEM_freeN(me->tface);
+ me->tface= NULL;
+ }
+
+ for (a=0, mtfacen=0, mcoln=0; a < me->fdata.totlayer; a++) {
+ layer= &me->fdata.layers[a];
+
+ if (layer->type == CD_MTFACE) {
+ if (layer->name[0] == 0) {
+ if (mtfacen == 0) strcpy(layer->name, "UVMap");
+ else BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen);
+ }
+ mtfacen++;
+ }
+ else if (layer->type == CD_MCOL) {
+ if (layer->name[0] == 0) {
+ if (mcoln == 0) strcpy(layer->name, "Col");
+ else BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln);
+ }
+ mcoln++;
+ }
+ }
+
+ mesh_update_customdata_pointers(me, TRUE);
+}
+
+/*only copy render texface layer from active*/
+static void customdata_version_243(Mesh *me)
+{
+ CustomDataLayer *layer;
+ int a;
+
+ for (a=0; a < me->fdata.totlayer; a++) {
+ layer= &me->fdata.layers[a];
+ layer->active_rnd = layer->active;
+ }
+}
+
+/* struct NodeImageAnim moved to ImageUser, and we make it default available */
+static void do_version_ntree_242_2(bNodeTree *ntree)
+{
+ bNode *node;
+
+ if (ntree->type==NTREE_COMPOSIT) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
+ /* only image had storage */
+ if (node->storage) {
+ NodeImageAnim *nia= node->storage;
+ ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "ima user node");
+
+ iuser->frames= nia->frames;
+ iuser->sfra= nia->sfra;
+ iuser->offset= nia->nr-1;
+ iuser->cycl= nia->cyclic;
+ iuser->fie_ima= 2;
+ iuser->ok= 1;
+
+ node->storage= iuser;
+ MEM_freeN(nia);
+ }
+ else {
+ ImageUser *iuser= node->storage= MEM_callocN(sizeof(ImageUser), "node image user");
+ iuser->sfra= 1;
+ iuser->fie_ima= 2;
+ iuser->ok= 1;
+ }
+ }
+ }
+ }
+}
+
+static void do_version_free_effect_245(Effect *eff)
+{
+ PartEff *paf;
+
+ if (eff->type==EFF_PARTICLE) {
+ paf= (PartEff *)eff;
+ if (paf->keys) MEM_freeN(paf->keys);
+ }
+ MEM_freeN(eff);
+}
+
+static void do_version_free_effects_245(ListBase *lb)
+{
+ Effect *eff;
+
+ eff= lb->first;
+ while (eff) {
+ BLI_remlink(lb, eff);
+ do_version_free_effect_245(eff);
+ eff= lb->first;
+ }
+}
+
+PartEff *blo_do_version_give_parteff_245(Object *ob)
+{
+ PartEff *paf;
+
+ paf= ob->effect.first;
+ while (paf) {
+ if (paf->type==EFF_PARTICLE) return paf;
+ paf= paf->next;
+ }
+ return NULL;
+}
+
+/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */
+void blo_do_version_old_trackto_to_constraints(Object *ob)
+{
+ /* create new trackto constraint from the relationship */
+ if (ob->track) {
+ bConstraint *con= add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
+ bTrackToConstraint *data = con->data;
+
+ /* copy tracking settings from the object */
+ data->tar = ob->track;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+
+ /* clear old track setting */
+ ob->track = NULL;
+}
+
+void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
+{
+ /* WATCH IT!!!: pointers from libdata have not been converted */
+
+ if (G.debug & G_DEBUG)
+ printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision);
+
+ if (main->versionfile == 100) {
+ /* tex->extend and tex->imageflag have changed: */
+ Tex *tex = main->tex.first;
+ while (tex) {
+ if (tex->id.flag & LIB_NEEDLINK) {
+
+ if (tex->extend==0) {
+ if (tex->xrepeat || tex->yrepeat) tex->extend= TEX_REPEAT;
+ else {
+ tex->extend= TEX_EXTEND;
+ tex->xrepeat= tex->yrepeat= 1;
+ }
+ }
+
+ }
+ tex= tex->id.next;
+ }
+ }
+ if (main->versionfile <= 101) {
+ /* frame mapping */
+ Scene *sce = main->scene.first;
+ while (sce) {
+ sce->r.framapto= 100;
+ sce->r.images= 100;
+ sce->r.framelen= 1.0;
+ sce= sce->id.next;
+ }
+ }
+ if (main->versionfile <= 102) {
+ /* init halo's at 1.0 */
+ Material *ma = main->mat.first;
+ while (ma) {
+ ma->add= 1.0;
+ ma= ma->id.next;
+ }
+ }
+ if (main->versionfile <= 103) {
+ /* new variable in object: colbits */
+ Object *ob = main->object.first;
+ int a;
+ while (ob) {
+ ob->colbits= 0;
+ if (ob->totcol) {
+ for (a=0; a<ob->totcol; a++) {
+ if (ob->mat[a]) ob->colbits |= (1<<a);
+ }
+ }
+ ob= ob->id.next;
+ }
+ }
+ if (main->versionfile <= 104) {
+ /* timeoffs moved */
+ Object *ob = main->object.first;
+ while (ob) {
+ if (ob->transflag & 1) {
+ ob->transflag -= 1;
+ //ob->ipoflag |= OB_OFFS_OB;
+ }
+ ob= ob->id.next;
+ }
+ }
+ if (main->versionfile <= 105) {
+ Object *ob = main->object.first;
+ while (ob) {
+ ob->dupon= 1; ob->dupoff= 0;
+ ob->dupsta= 1; ob->dupend= 100;
+ ob= ob->id.next;
+ }
+ }
+ if (main->versionfile <= 106) {
+ /* mcol changed */
+ Mesh *me = main->mesh.first;
+ while (me) {
+ if (me->mcol) vcol_to_fcol(me);
+ me= me->id.next;
+ }
+
+ }
+ if (main->versionfile <= 107) {
+ Object *ob;
+ Scene *sce = main->scene.first;
+ while (sce) {
+ sce->r.mode |= R_GAMMA;
+ sce= sce->id.next;
+ }
+ ob= main->object.first;
+ while (ob) {
+ //ob->ipoflag |= OB_OFFS_PARENT;
+ if (ob->dt==0) ob->dt= OB_SOLID;
+ ob= ob->id.next;
+ }
+
+ }
+ if (main->versionfile <= 109) {
+ /* new variable: gridlines */
+ bScreen *sc = main->screen.first;
+ while (sc) {
+ ScrArea *sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl= sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D*) sl;
+
+ if (v3d->gridlines==0) v3d->gridlines= 20;
+ }
+ sl= sl->next;
+ }
+ sa= sa->next;
+ }
+ sc= sc->id.next;
+ }
+ }
+ if (main->versionfile <= 113) {
+ Material *ma = main->mat.first;
+ while (ma) {
+ if (ma->flaresize==0.0f) ma->flaresize= 1.0f;
+ ma->subsize= 1.0f;
+ ma->flareboost= 1.0f;
+ ma= ma->id.next;
+ }
+ }
+
+ if (main->versionfile <= 134) {
+ Tex *tex = main->tex.first;
+ while (tex) {
+ if ((tex->rfac == 0.0f) &&
+ (tex->gfac == 0.0f) &&
+ (tex->bfac == 0.0f)) {
+ tex->rfac = 1.0f;
+ tex->gfac = 1.0f;
+ tex->bfac = 1.0f;
+ tex->filtersize = 1.0f;
+ }
+ tex = tex->id.next;
+ }
+ }
+ if (main->versionfile <= 140) {
+ /* r-g-b-fac in texture */
+ Tex *tex = main->tex.first;
+ while (tex) {
+ if ((tex->rfac == 0.0f) &&
+ (tex->gfac == 0.0f) &&
+ (tex->bfac == 0.0f)) {
+ tex->rfac = 1.0f;
+ tex->gfac = 1.0f;
+ tex->bfac = 1.0f;
+ tex->filtersize = 1.0f;
+ }
+ tex = tex->id.next;
+ }
+ }
+ if (main->versionfile <= 153) {
+ Scene *sce = main->scene.first;
+ while (sce) {
+ if (sce->r.blurfac==0.0f) sce->r.blurfac= 1.0f;
+ sce= sce->id.next;
+ }
+ }
+ if (main->versionfile <= 163) {
+ Scene *sce = main->scene.first;
+ while (sce) {
+ if (sce->r.frs_sec==0) sce->r.frs_sec= 25;
+ sce= sce->id.next;
+ }
+ }
+ if (main->versionfile <= 164) {
+ Mesh *me= main->mesh.first;
+ while (me) {
+ me->smoothresh= 30;
+ me= me->id.next;
+ }
+ }
+ if (main->versionfile <= 165) {
+ Mesh *me= main->mesh.first;
+ TFace *tface;
+ int nr;
+ char *cp;
+
+ while (me) {
+ if (me->tface) {
+ nr= me->totface;
+ tface= me->tface;
+ while (nr--) {
+ cp= (char *)&tface->col[0];
+ if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
+ if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
+ if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
+ cp= (char *)&tface->col[1];
+ if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
+ if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
+ if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
+ cp= (char *)&tface->col[2];
+ if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
+ if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
+ if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
+ cp= (char *)&tface->col[3];
+ if (cp[1]>126) cp[1]= 255; else cp[1]*=2;
+ if (cp[2]>126) cp[2]= 255; else cp[2]*=2;
+ if (cp[3]>126) cp[3]= 255; else cp[3]*=2;
+
+ tface++;
+ }
+ }
+ me= me->id.next;
+ }
+ }
+
+ if (main->versionfile <= 169) {
+ Mesh *me= main->mesh.first;
+ while (me) {
+ if (me->subdiv==0) me->subdiv= 1;
+ me= me->id.next;
+ }
+ }
+
+ if (main->versionfile <= 169) {
+ bScreen *sc= main->screen.first;
+ while (sc) {
+ ScrArea *sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl= sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype==SPACE_IPO) {
+ SpaceIpo *sipo= (SpaceIpo*) sl;
+ sipo->v2d.max[0]= 15000.0;
+ }
+ sl= sl->next;
+ }
+ sa= sa->next;
+ }
+ sc= sc->id.next;
+ }
+ }
+
+ if (main->versionfile <= 170) {
+ Object *ob = main->object.first;
+ PartEff *paf;
+ while (ob) {
+ paf = blo_do_version_give_parteff_245(ob);
+ if (paf) {
+ if (paf->staticstep == 0) {
+ paf->staticstep= 5;
+ }
+ }
+ ob = ob->id.next;
+ }
+ }
+
+ if (main->versionfile <= 171) {
+ bScreen *sc= main->screen.first;
+ while (sc) {
+ ScrArea *sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl= sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype==SPACE_TEXT) {
+ SpaceText *st= (SpaceText*) sl;
+ st->lheight= 12;
+ }
+ sl= sl->next;
+ }
+ sa= sa->next;
+ }
+ sc= sc->id.next;
+ }
+ }
+
+ if (main->versionfile <= 173) {
+ int a, b;
+ Mesh *me= main->mesh.first;
+ while (me) {
+ if (me->tface) {
+ TFace *tface= me->tface;
+ for (a=0; a<me->totface; a++, tface++) {
+ for (b=0; b<4; b++) {
+ tface->uv[b][0]/= 32767.0f;
+ tface->uv[b][1]/= 32767.0f;
+ }
+ }
+ }
+ me= me->id.next;
+ }
+ }
+
+ if (main->versionfile <= 191) {
+ Object *ob= main->object.first;
+ Material *ma = main->mat.first;
+
+ /* let faces have default add factor of 0.0 */
+ while (ma) {
+ if (!(ma->mode & MA_HALO)) ma->add = 0.0;
+ ma = ma->id.next;
+ }
+
+ while (ob) {
+ ob->mass= 1.0f;
+ ob->damping= 0.1f;
+ /*ob->quat[1]= 1.0f;*/ /* quats arnt used yet */
+ ob= ob->id.next;
+ }
+ }
+
+ if (main->versionfile <= 193) {
+ Object *ob= main->object.first;
+ while (ob) {
+ ob->inertia= 1.0f;
+ ob->rdamping= 0.1f;
+ ob= ob->id.next;
+ }
+ }
+
+ if (main->versionfile <= 196) {
+ Mesh *me= main->mesh.first;
+ int a, b;
+ while (me) {
+ if (me->tface) {
+ TFace *tface= me->tface;
+ for (a=0; a<me->totface; a++, tface++) {
+ for (b=0; b<4; b++) {
+ tface->mode |= TF_DYNAMIC;
+ tface->mode &= ~TF_INVISIBLE;
+ }
+ }
+ }
+ me= me->id.next;
+ }
+ }
+
+ if (main->versionfile <= 200) {
+ Object *ob= main->object.first;
+ while (ob) {
+ ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
+ /* 64 is do_fh */
+ ob->gameflag &= ~(OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
+ ob = ob->id.next;
+ }
+ }
+
+ if (main->versionfile <= 201) {
+ /* add-object + end-object are joined to edit-object actuator */
+ Object *ob = main->object.first;
+ bProperty *prop;
+ bActuator *act;
+ bIpoActuator *ia;
+ bEditObjectActuator *eoa;
+ bAddObjectActuator *aoa;
+ while (ob) {
+ act = ob->actuators.first;
+ while (act) {
+ if (act->type==ACT_IPO) {
+ ia= act->data;
+ prop= get_ob_property(ob, ia->name);
+ if (prop) {
+ ia->type= ACT_IPO_FROM_PROP;
+ }
+ }
+ else if (act->type==ACT_ADD_OBJECT) {
+ aoa= act->data;
+ eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
+ eoa->type= ACT_EDOB_ADD_OBJECT;
+ eoa->ob= aoa->ob;
+ eoa->time= aoa->time;
+ MEM_freeN(aoa);
+ act->data= eoa;
+ act->type= act->otype= ACT_EDIT_OBJECT;
+ }
+ else if (act->type==ACT_END_OBJECT) {
+ eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
+ eoa->type= ACT_EDOB_END_OBJECT;
+ act->data= eoa;
+ act->type= act->otype= ACT_EDIT_OBJECT;
+ }
+ act= act->next;
+ }
+ ob = ob->id.next;
+ }
+ }
+
+ if (main->versionfile <= 202) {
+ /* add-object and end-object are joined to edit-object
+ * actuator */
+ Object *ob= main->object.first;
+ bActuator *act;
+ bObjectActuator *oa;
+ while (ob) {
+ act= ob->actuators.first;
+ while (act) {
+ if (act->type==ACT_OBJECT) {
+ oa= act->data;
+ oa->flag &= ~(ACT_TORQUE_LOCAL|ACT_DROT_LOCAL); /* this actuator didn't do local/glob rot before */
+ }
+ act= act->next;
+ }
+ ob= ob->id.next;
+ }
+ }
+
+ if (main->versionfile <= 204) {
+ /* patches for new physics */
+ Object *ob= main->object.first;
+ bActuator *act;
+ bObjectActuator *oa;
+ bSound *sound;
+ while (ob) {
+
+ /* please check this for demo20 files like
+ * original Egypt levels etc. converted
+ * rotation factor of 50 is not workable */
+ act= ob->actuators.first;
+ while (act) {
+ if (act->type==ACT_OBJECT) {
+ oa= act->data;
+
+ oa->forceloc[0]*= 25.0f;
+ oa->forceloc[1]*= 25.0f;
+ oa->forceloc[2]*= 25.0f;
+
+ oa->forcerot[0]*= 10.0f;
+ oa->forcerot[1]*= 10.0f;
+ oa->forcerot[2]*= 10.0f;
+ }
+ act= act->next;
+ }
+ ob= ob->id.next;
+ }
+
+ sound = main->sound.first;
+ while (sound) {
+ if (sound->volume < 0.01f) {
+ sound->volume = 1.0f;
+ }
+ sound = sound->id.next;
+ }
+ }
+
+ if (main->versionfile <= 205) {
+ /* patches for new physics */
+ Object *ob= main->object.first;
+ bActuator *act;
+ bSensor *sens;
+ bEditObjectActuator *oa;
+ bRaySensor *rs;
+ bCollisionSensor *cs;
+ while (ob) {
+ /* Set anisotropic friction off for old objects,
+ * values to 1.0. */
+ ob->gameflag &= ~OB_ANISOTROPIC_FRICTION;
+ ob->anisotropicFriction[0] = 1.0;
+ ob->anisotropicFriction[1] = 1.0;
+ ob->anisotropicFriction[2] = 1.0;
+
+ act= ob->actuators.first;
+ while (act) {
+ if (act->type==ACT_EDIT_OBJECT) {
+ /* Zero initial velocity for newly
+ * added objects */
+ oa= act->data;
+ oa->linVelocity[0] = 0.0;
+ oa->linVelocity[1] = 0.0;
+ oa->linVelocity[2] = 0.0;
+ oa->localflag = 0;
+ }
+ act= act->next;
+ }
+
+ sens= ob->sensors.first;
+ while (sens) {
+ /* Extra fields for radar sensors. */
+ if (sens->type == SENS_RADAR) {
+ bRadarSensor *s = sens->data;
+ s->range = 10000.0;
+ }
+
+ /* Pulsing: defaults for new sensors. */
+ if (sens->type != SENS_ALWAYS) {
+ sens->pulse = 0;
+ sens->freq = 0;
+ }
+ else {
+ sens->pulse = 1;
+ }
+
+ /* Invert: off. */
+ sens->invert = 0;
+
+ /* Collision and ray: default = trigger
+ * on property. The material field can
+ * remain empty. */
+ if (sens->type == SENS_COLLISION) {
+ cs = (bCollisionSensor*) sens->data;
+ cs->mode = 0;
+ }
+ if (sens->type == SENS_RAY) {
+ rs = (bRaySensor*) sens->data;
+ rs->mode = 0;
+ }
+ sens = sens->next;
+ }
+ ob= ob->id.next;
+ }
+ /* have to check the exact multiplier */
+ }
+
+ if (main->versionfile <= 211) {
+ /* Render setting: per scene, the applicable gamma value
+ * can be set. Default is 1.0, which means no
+ * correction. */
+ bActuator *act;
+ bObjectActuator *oa;
+ Object *ob;
+
+ /* added alpha in obcolor */
+ ob= main->object.first;
+ while (ob) {
+ ob->col[3]= 1.0;
+ ob= ob->id.next;
+ }
+
+ /* added alpha in obcolor */
+ ob= main->object.first;
+ while (ob) {
+ act= ob->actuators.first;
+ while (act) {
+ if (act->type==ACT_OBJECT) {
+ /* multiply velocity with 50 in old files */
+ oa= act->data;
+ if (fabsf(oa->linearvelocity[0]) >= 0.01f)
+ oa->linearvelocity[0] *= 50.0f;
+ if (fabsf(oa->linearvelocity[1]) >= 0.01f)
+ oa->linearvelocity[1] *= 50.0f;
+ if (fabsf(oa->linearvelocity[2]) >= 0.01f)
+ oa->linearvelocity[2] *= 50.0f;
+ if (fabsf(oa->angularvelocity[0])>=0.01f)
+ oa->angularvelocity[0] *= 50.0f;
+ if (fabsf(oa->angularvelocity[1])>=0.01f)
+ oa->angularvelocity[1] *= 50.0f;
+ if (fabsf(oa->angularvelocity[2])>=0.01f)
+ oa->angularvelocity[2] *= 50.0f;
+ }
+ act= act->next;
+ }
+ ob= ob->id.next;
+ }
+ }
+
+ if (main->versionfile <= 212) {
+
+ bSound* sound;
+ bProperty *prop;
+ Object *ob;
+ Mesh *me;
+
+ sound = main->sound.first;
+ while (sound) {
+ sound->max_gain = 1.0;
+ sound->min_gain = 0.0;
+ sound->distance = 1.0;
+
+ if (sound->attenuation > 0.0f)
+ sound->flags |= SOUND_FLAGS_3D;
+ else
+ sound->flags &= ~SOUND_FLAGS_3D;
+
+ sound = sound->id.next;
+ }
+
+ ob = main->object.first;
+
+ while (ob) {
+ prop= ob->prop.first;
+ while (prop) {
+ if (prop->type == GPROP_TIME) {
+ // convert old GPROP_TIME values from int to float
+ *((float *)&prop->data) = (float) prop->data;
+ }
+
+ prop= prop->next;
+ }
+ ob = ob->id.next;
+ }
+
+ /* me->subdiv changed to reflect the actual reparametization
+ * better, and smeshes were removed - if it was a smesh make
+ * it a subsurf, and reset the subdiv level because subsurf
+ * takes a lot more work to calculate.
+ */
+ for (me= main->mesh.first; me; me= me->id.next) {
+ if (me->flag&ME_SMESH) {
+ me->flag&= ~ME_SMESH;
+ me->flag|= ME_SUBSURF;
+
+ me->subdiv= 1;
+ }
+ else {
+ if (me->subdiv<2)
+ me->subdiv= 1;
+ else
+ me->subdiv--;
+ }
+ }
+ }
+
+ if (main->versionfile <= 220) {
+ Object *ob;
+ Mesh *me;
+
+ ob = main->object.first;
+
+ /* adapt form factor in order to get the 'old' physics
+ * behavior back...*/
+
+ while (ob) {
+ /* in future, distinguish between different
+ * object bounding shapes */
+ ob->formfactor = 0.4f;
+ /* patch form factor, note that inertia equiv radius
+ * of a rotation symmetrical obj */
+ if (ob->inertia != 1.0f) {
+ ob->formfactor /= ob->inertia * ob->inertia;
+ }
+ ob = ob->id.next;
+ }
+
+ /* Began using alpha component of vertex colors, but
+ * old file vertex colors are undefined, reset them
+ * to be fully opaque. -zr
+ */
+ for (me= main->mesh.first; me; me= me->id.next) {
+ if (me->mcol) {
+ int i;
+
+ for (i=0; i<me->totface*4; i++) {
+ MCol *mcol= &me->mcol[i];
+ mcol->a= 255;
+ }
+ }
+ if (me->tface) {
+ int i, j;
+
+ for (i=0; i<me->totface; i++) {
+ TFace *tf= &((TFace*) me->tface)[i];
+
+ for (j=0; j<4; j++) {
+ char *col= (char*) &tf->col[j];
+
+ col[0]= 255;
+ }
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 221) {
+ Scene *sce= main->scene.first;
+
+ // new variables for std-alone player and runtime
+ while (sce) {
+
+ sce->r.xplay= 640;
+ sce->r.yplay= 480;
+ sce->r.freqplay= 60;
+
+ sce= sce->id.next;
+ }
+
+ }
+ if (main->versionfile <= 222) {
+ Scene *sce= main->scene.first;
+
+ // new variables for std-alone player and runtime
+ while (sce) {
+
+ sce->r.depth= 32;
+
+ sce= sce->id.next;
+ }
+ }
+
+
+ if (main->versionfile <= 223) {
+ VFont *vf;
+ Image *ima;
+ Object *ob;
+
+ for (vf= main->vfont.first; vf; vf= vf->id.next) {
+ if (strcmp(vf->name+strlen(vf->name)-6, ".Bfont")==0) {
+ strcpy(vf->name, FO_BUILTIN_NAME);
+ }
+ }
+
+ /* Old textures animate at 25 FPS */
+ for (ima = main->image.first; ima; ima=ima->id.next) {
+ ima->animspeed = 25;
+ }
+
+ /* Zr remapped some keyboard codes to be linear (stupid zr) */
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ bSensor *sens;
+
+ for (sens= ob->sensors.first; sens; sens= sens->next) {
+ if (sens->type==SENS_KEYBOARD) {
+ bKeyboardSensor *ks= sens->data;
+
+ ks->key= map_223_keybd_code_to_224_keybd_code(ks->key);
+ ks->qual= map_223_keybd_code_to_224_keybd_code(ks->qual);
+ ks->qual2= map_223_keybd_code_to_224_keybd_code(ks->qual2);
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 224) {
+ bSound* sound;
+ Scene *sce;
+ Mesh *me;
+ bScreen *sc;
+
+ for (sound=main->sound.first; sound; sound=sound->id.next) {
+ if (sound->packedfile) {
+ if (sound->newpackedfile == NULL) {
+ sound->newpackedfile = sound->packedfile;
+ }
+ sound->packedfile = NULL;
+ }
+ }
+ /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */
+ for (me=main->mesh.first; me; me=me->id.next) {
+ if ((me->flag & ME_SUBSURF) && (me->subdivr==0))
+ me->subdivr=me->subdiv;
+ }
+
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ sce->r.stereomode = 1; // no stereo
+ }
+
+ /* some oldfile patch, moved from set_func_space */
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_IPO) {
+ SpaceSeq *sseq= (SpaceSeq*) sl;
+ sseq->v2d.keeptot= 0;
+ }
+ }
+ }
+ }
+
+ }
+
+
+ if (main->versionfile <= 225) {
+ World *wo;
+ /* Use Sumo for old games */
+ for (wo = main->world.first; wo; wo= wo->id.next) {
+ wo->physicsEngine = 2;
+ }
+ }
+
+ if (main->versionfile <= 227) {
+ Scene *sce;
+ Material *ma;
+ bScreen *sc;
+ Object *ob;
+
+ /* As of now, this insures that the transition from the old Track system
+ * to the new full constraint Track is painless for everyone. - theeth
+ */
+ ob = main->object.first;
+
+ while (ob) {
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* check for already existing TrackTo constraint
+ * set their track and up flag correctly */
+
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon=curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first;
+ pchan; pchan=pchan->next) {
+ for (curcon = pchan->constraints.first;
+ curcon; curcon=curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+ }
+ }
+
+ /* Change Ob->Track in real TrackTo constraint */
+ blo_do_version_old_trackto_to_constraints(ob);
+
+ ob = ob->id.next;
+ }
+
+
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ sce->audio.mixrate = 44100;
+ sce->audio.flag |= AUDIO_SCRUB;
+ sce->r.mode |= R_ENVMAP;
+ }
+ // init new shader vars
+ for (ma= main->mat.first; ma; ma= ma->id.next) {
+ ma->refrac= 4.0f;
+ ma->roughness= 0.5f;
+ ma->param[0]= 0.5f;
+ ma->param[1]= 0.1f;
+ ma->param[2]= 0.1f;
+ ma->param[3]= 0.05f;
+ }
+ // patch for old wrong max view2d settings, allows zooming out more
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_ACTION) {
+ SpaceAction *sac= (SpaceAction *) sl;
+ sac->v2d.max[0]= 32000;
+ }
+ else if (sl->spacetype==SPACE_NLA) {
+ SpaceNla *sla= (SpaceNla *) sl;
+ sla->v2d.max[0]= 32000;
+ }
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 228) {
+ Scene *sce;
+ bScreen *sc;
+ Object *ob;
+
+
+ /* As of now, this insures that the transition from the old Track system
+ * to the new full constraint Track is painless for everyone.*/
+ ob = main->object.first;
+
+ while (ob) {
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* check for already existing TrackTo constraint
+ * set their track and up flag correctly */
+
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon=curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first;
+ pchan; pchan=pchan->next) {
+ for (curcon = pchan->constraints.first;
+ curcon; curcon=curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+ }
+ }
+
+ ob = ob->id.next;
+ }
+
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ sce->r.mode |= R_ENVMAP;
+ }
+
+ // convert old mainb values for new button panels
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_BUTS) {
+ SpaceButs *sbuts= (SpaceButs *) sl;
+
+ sbuts->v2d.maxzoom= 1.2f;
+ sbuts->align= 1; /* horizontal default */
+
+ if (sbuts->mainb==BUTS_LAMP) {
+ sbuts->mainb= CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
+ }
+ else if (sbuts->mainb==BUTS_MAT) {
+ sbuts->mainb= CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
+ }
+ else if (sbuts->mainb==BUTS_TEX) {
+ sbuts->mainb= CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
+ }
+ else if (sbuts->mainb==BUTS_ANIM) {
+ sbuts->mainb= CONTEXT_OBJECT;
+ }
+ else if (sbuts->mainb==BUTS_WORLD) {
+ sbuts->mainb= CONTEXT_SCENE;
+ //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
+ }
+ else if (sbuts->mainb==BUTS_RENDER) {
+ sbuts->mainb= CONTEXT_SCENE;
+ //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
+ }
+ else if (sbuts->mainb==BUTS_GAME) {
+ sbuts->mainb= CONTEXT_LOGIC;
+ }
+ else if (sbuts->mainb==BUTS_FPAINT) {
+ sbuts->mainb= CONTEXT_EDITING;
+ }
+ else if (sbuts->mainb==BUTS_RADIO) {
+ sbuts->mainb= CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
+ }
+ else if (sbuts->mainb==BUTS_CONSTRAINT) {
+ sbuts->mainb= CONTEXT_OBJECT;
+ }
+ else if (sbuts->mainb==BUTS_SCRIPT) {
+ sbuts->mainb= CONTEXT_OBJECT;
+ }
+ else if (sbuts->mainb==BUTS_EDIT) {
+ sbuts->mainb= CONTEXT_EDITING;
+ }
+ else sbuts->mainb= CONTEXT_SCENE;
+ }
+ }
+ }
+ }
+ }
+ /* ton: made this 230 instead of 229,
+ * to be sure (tuho files) and this is a reliable check anyway
+ * nevertheless, we might need to think over a fitness (initialize)
+ * check apart from the do_versions() */
+
+ if (main->versionfile <= 230) {
+ bScreen *sc;
+
+ // new variable blockscale, for panels in any area
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->blockscale==0.0f) sl->blockscale= 0.7f;
+ /* added: 5x better zoom in for action */
+ if (sl->spacetype==SPACE_ACTION) {
+ SpaceAction *sac= (SpaceAction *)sl;
+ sac->v2d.maxzoom= 50;
+ }
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 231) {
+ /* new bit flags for showing/hiding grid floor and axes */
+ bScreen *sc = main->screen.first;
+ while (sc) {
+ ScrArea *sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl= sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D*) sl;
+
+ if (v3d->gridflag==0) {
+ v3d->gridflag |= V3D_SHOW_X;
+ v3d->gridflag |= V3D_SHOW_Y;
+ v3d->gridflag |= V3D_SHOW_FLOOR;
+ v3d->gridflag &= ~V3D_SHOW_Z;
+ }
+ }
+ sl= sl->next;
+ }
+ sa= sa->next;
+ }
+ sc= sc->id.next;
+ }
+ }
+ if (main->versionfile <= 231) {
+ Material *ma= main->mat.first;
+ bScreen *sc = main->screen.first;
+ Scene *sce;
+ Lamp *la;
+ World *wrld;
+
+ /* introduction of raytrace */
+ while (ma) {
+ if (ma->fresnel_tra_i==0.0f) ma->fresnel_tra_i= 1.25f;
+ if (ma->fresnel_mir_i==0.0f) ma->fresnel_mir_i= 1.25f;
+
+ ma->ang= 1.0;
+ ma->ray_depth= 2;
+ ma->ray_depth_tra= 2;
+ ma->fresnel_tra= 0.0;
+ ma->fresnel_mir= 0.0;
+
+ ma= ma->id.next;
+ }
+ sce= main->scene.first;
+ while (sce) {
+ if (sce->r.gauss==0.0f) sce->r.gauss= 1.0f;
+ sce= sce->id.next;
+ }
+ la= main->lamp.first;
+ while (la) {
+ if (la->k==0.0f) la->k= 1.0;
+ if (la->ray_samp==0) la->ray_samp= 1;
+ if (la->ray_sampy==0) la->ray_sampy= 1;
+ if (la->ray_sampz==0) la->ray_sampz= 1;
+ if (la->area_size==0.0f) la->area_size= 1.0f;
+ if (la->area_sizey==0.0f) la->area_sizey= 1.0f;
+ if (la->area_sizez==0.0f) la->area_sizez= 1.0f;
+ la= la->id.next;
+ }
+ wrld= main->world.first;
+ while (wrld) {
+ if (wrld->range==0.0f) {
+ wrld->range= 1.0f/wrld->exposure;
+ }
+ wrld= wrld->id.next;
+ }
+
+ /* new bit flags for showing/hiding grid floor and axes */
+
+ while (sc) {
+ ScrArea *sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl= sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D*) sl;
+
+ if (v3d->gridflag==0) {
+ v3d->gridflag |= V3D_SHOW_X;
+ v3d->gridflag |= V3D_SHOW_Y;
+ v3d->gridflag |= V3D_SHOW_FLOOR;
+ v3d->gridflag &= ~V3D_SHOW_Z;
+ }
+ }
+ sl= sl->next;
+ }
+ sa= sa->next;
+ }
+ sc= sc->id.next;
+ }
+ }
+ if (main->versionfile <= 232) {
+ Tex *tex= main->tex.first;
+ World *wrld= main->world.first;
+ bScreen *sc;
+ Scene *sce;
+
+ while (tex) {
+ if ((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) {
+ tex->flag |= TEX_CHECKER_ODD;
+ }
+ /* copied from kernel texture.c */
+ if (tex->ns_outscale==0.0f) {
+ /* musgrave */
+ tex->mg_H = 1.0f;
+ tex->mg_lacunarity = 2.0f;
+ tex->mg_octaves = 2.0f;
+ tex->mg_offset = 1.0f;
+ tex->mg_gain = 1.0f;
+ tex->ns_outscale = 1.0f;
+ /* distnoise */
+ tex->dist_amount = 1.0f;
+ /* voronoi */
+ tex->vn_w1 = 1.0f;
+ tex->vn_mexp = 2.5f;
+ }
+ tex= tex->id.next;
+ }
+
+ while (wrld) {
+ if (wrld->aodist==0.0f) {
+ wrld->aodist= 10.0f;
+ wrld->aobias= 0.05f;
+ }
+ if (wrld->aosamp==0) wrld->aosamp= 5;
+ if (wrld->aoenergy==0.0f) wrld->aoenergy= 1.0f;
+ wrld= wrld->id.next;
+ }
+
+
+ // new variable blockscale, for panels in any area, do again because new
+ // areas didnt initialize it to 0.7 yet
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->blockscale==0.0f) sl->blockscale= 0.7f;
+
+ /* added: 5x better zoom in for nla */
+ if (sl->spacetype==SPACE_NLA) {
+ SpaceNla *snla= (SpaceNla *)sl;
+ snla->v2d.maxzoom= 50;
+ }
+ }
+ }
+ }
+ sce= main->scene.first;
+ while (sce) {
+ if (sce->r.ocres==0) sce->r.ocres= 64;
+ sce= sce->id.next;
+ }
+
+ }
+ if (main->versionfile <= 233) {
+ bScreen *sc;
+ Material *ma= main->mat.first;
+ /* Object *ob= main->object.first; */
+
+ while (ma) {
+ if (ma->rampfac_col==0.0f) ma->rampfac_col= 1.0;
+ if (ma->rampfac_spec==0.0f) ma->rampfac_spec= 1.0;
+ if (ma->pr_lamp==0) ma->pr_lamp= 3;
+ ma= ma->id.next;
+ }
+
+ /* this should have been done loooong before! */
+#if 0 /* deprecated in 2.5+ */
+ while (ob) {
+ if (ob->ipowin==0) ob->ipowin= ID_OB;
+ ob= ob->id.next;
+ }
+#endif
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D *)sl;
+ v3d->flag |= V3D_SELECT_OUTLINE;
+ }
+ }
+ }
+ }
+ }
+
+
+
+
+ if (main->versionfile <= 234) {
+ World *wo;
+ bScreen *sc;
+
+ // force sumo engine to be active
+ for (wo = main->world.first; wo; wo= wo->id.next) {
+ if (wo->physicsEngine==0) wo->physicsEngine = 2;
+ }
+
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D *)sl;
+ v3d->flag |= V3D_ZBUF_SELECT;
+ }
+ else if (sl->spacetype==SPACE_TEXT) {
+ SpaceText *st= (SpaceText *)sl;
+ if (st->tabnumber==0) st->tabnumber= 2;
+ }
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 235) {
+ Tex *tex= main->tex.first;
+ Scene *sce= main->scene.first;
+ Sequence *seq;
+ Editing *ed;
+
+ while (tex) {
+ if (tex->nabla==0.0f) tex->nabla= 0.025f;
+ tex= tex->id.next;
+ }
+ while (sce) {
+ ed= sce->ed;
+ if (ed) {
+ SEQ_BEGIN (sce->ed, seq)
+ {
+ if (seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE)
+ seq->flag |= SEQ_MAKE_PREMUL;
+ }
+ SEQ_END
+ }
+
+ sce= sce->id.next;
+ }
+ }
+ if (main->versionfile <= 236) {
+ Object *ob;
+ Camera *cam= main->camera.first;
+ Material *ma;
+ bScreen *sc;
+
+ while (cam) {
+ if (cam->ortho_scale==0.0f) {
+ cam->ortho_scale= 256.0f/cam->lens;
+ if (cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n");
+ }
+ cam= cam->id.next;
+ }
+ /* set manipulator type */
+ /* force oops draw if depgraph was set*/
+ /* set time line var */
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D *)sl;
+ if (v3d->twtype==0) v3d->twtype= V3D_MANIP_TRANSLATE;
+ }
+ }
+ }
+ }
+ // init new shader vars
+ for (ma= main->mat.first; ma; ma= ma->id.next) {
+ if (ma->darkness==0.0f) {
+ ma->rms=0.1f;
+ ma->darkness=1.0f;
+ }
+ }
+
+ /* softbody init new vars */
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ if (ob->soft) {
+ if (ob->soft->defgoal==0.0f) ob->soft->defgoal= 0.7f;
+ if (ob->soft->physics_speed==0.0f) ob->soft->physics_speed= 1.0f;
+
+ if (ob->soft->interval==0) {
+ ob->soft->interval= 2;
+ ob->soft->sfra= 1;
+ ob->soft->efra= 100;
+ }
+ }
+ if (ob->soft && ob->soft->vertgroup==0) {
+ bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL");
+ if (locGroup) {
+ /* retrieve index for that group */
+ ob->soft->vertgroup = 1 + BLI_findindex(&ob->defbase, locGroup);
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 237) {
+ bArmature *arm;
+ bConstraint *con;
+ Object *ob;
+ Bone *bone;
+
+ // armature recode checks
+ for (arm= main->armature.first; arm; arm= arm->id.next) {
+ where_is_armature(arm);
+
+ for (bone= arm->bonebase.first; bone; bone= bone->next)
+ do_version_bone_head_tail_237(bone);
+ }
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ if (ob->parent) {
+ Object *parent= blo_do_versions_newlibadr(fd, lib, ob->parent);
+ if (parent && parent->type==OB_LATTICE)
+ ob->partype = PARSKEL;
+ }
+
+ // btw. armature_rebuild_pose is further only called on leave editmode
+ if (ob->type==OB_ARMATURE) {
+ if (ob->pose)
+ ob->pose->flag |= POSE_RECALC;
+ ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // cannot call stuff now (pointers!), done in setup_app_data
+
+ /* new generic xray option */
+ arm= blo_do_versions_newlibadr(fd, lib, ob->data);
+ if (arm->flag & ARM_DRAWXRAY) {
+ ob->dtx |= OB_DRAWXRAY;
+ }
+ }
+ else if (ob->type==OB_MESH) {
+ Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
+
+ if ((me->flag&ME_SUBSURF)) {
+ SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf);
+
+ smd->levels = MAX2(1, me->subdiv);
+ smd->renderLevels = MAX2(1, me->subdivr);
+ smd->subdivType = me->subsurftype;
+
+ smd->modifier.mode = 0;
+ if (me->subdiv!=0)
+ smd->modifier.mode |= 1;
+ if (me->subdivr!=0)
+ smd->modifier.mode |= 2;
+ if (me->flag&ME_OPT_EDGES)
+ smd->flags |= eSubsurfModifierFlag_ControlEdges;
+
+ BLI_addtail(&ob->modifiers, smd);
+
+ modifier_unique_name(&ob->modifiers, (ModifierData*)smd);
+ }
+ }
+
+ // follow path constraint needs to set the 'path' option in curves...
+ for (con=ob->constraints.first; con; con= con->next) {
+ if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
+ bFollowPathConstraint *data = con->data;
+ Object *obc= blo_do_versions_newlibadr(fd, lib, data->tar);
+
+ if (obc && obc->type==OB_CURVE) {
+ Curve *cu= blo_do_versions_newlibadr(fd, lib, obc->data);
+ if (cu) cu->flag |= CU_PATH;
+ }
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 238) {
+ Lattice *lt;
+ Object *ob;
+ bArmature *arm;
+ Mesh *me;
+ Key *key;
+ Scene *sce= main->scene.first;
+
+ while (sce) {
+ if (sce->toolsettings == NULL) {
+ sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct");
+ sce->toolsettings->cornertype=0;
+ sce->toolsettings->degr = 90;
+ sce->toolsettings->step = 9;
+ sce->toolsettings->turn = 1;
+ sce->toolsettings->extr_offs = 1;
+ sce->toolsettings->doublimit = 0.001f;
+ sce->toolsettings->segments = 32;
+ sce->toolsettings->rings = 32;
+ sce->toolsettings->vertices = 32;
+ }
+ sce= sce->id.next;
+ }
+
+ for (lt=main->latt.first; lt; lt=lt->id.next) {
+ if (lt->fu==0.0f && lt->fv==0.0f && lt->fw==0.0f) {
+ calc_lat_fudu(lt->flag, lt->pntsu, &lt->fu, &lt->du);
+ calc_lat_fudu(lt->flag, lt->pntsv, &lt->fv, &lt->dv);
+ calc_lat_fudu(lt->flag, lt->pntsw, &lt->fw, &lt->dw);
+ }
+ }
+
+ for (ob=main->object.first; ob; ob= ob->id.next) {
+ ModifierData *md;
+ PartEff *paf;
+
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Subsurf) {
+ SubsurfModifierData *smd = (SubsurfModifierData*) md;
+
+ smd->flags &= ~(eSubsurfModifierFlag_Incremental|eSubsurfModifierFlag_DebugIncr);
+ }
+ }
+
+ if ((ob->softflag&OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) {
+ if (ob->softflag&OB_SB_POSTDEF) {
+ md = ob->modifiers.first;
+
+ while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
+ md = md->next;
+ }
+
+ BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(eModifierType_Softbody));
+ }
+ else {
+ BLI_addhead(&ob->modifiers, modifier_new(eModifierType_Softbody));
+ }
+
+ ob->softflag &= ~OB_SB_ENABLE;
+ }
+ if (ob->pose) {
+ bPoseChannel *pchan;
+ bConstraint *con;
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ // note, pchan->bone is also lib-link stuff
+ if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) {
+ pchan->limitmin[0]= pchan->limitmin[1]= pchan->limitmin[2]= -180.0f;
+ pchan->limitmax[0]= pchan->limitmax[1]= pchan->limitmax[2]= 180.0f;
+
+ for (con= pchan->constraints.first; con; con= con->next) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+ bKinematicConstraint *data = (bKinematicConstraint*)con->data;
+ data->weight = 1.0f;
+ data->orientweight = 1.0f;
+ data->flag &= ~CONSTRAINT_IK_ROT;
+
+ /* enforce conversion from old IK_TOPARENT to rootbone index */
+ data->rootbone= -1;
+
+ /* update_pose_etc handles rootbone==-1 */
+ ob->pose->flag |= POSE_RECALC;
+ }
+ }
+ }
+ }
+ }
+
+ paf = blo_do_version_give_parteff_245(ob);
+ if (paf) {
+ if (paf->disp == 0)
+ paf->disp = 100;
+ if (paf->speedtex == 0)
+ paf->speedtex = 8;
+ if (paf->omat == 0)
+ paf->omat = 1;
+ }
+ }
+
+ for (arm=main->armature.first; arm; arm= arm->id.next) {
+ bone_version_238(&arm->bonebase);
+ arm->deformflag |= ARM_DEF_VGROUP;
+ }
+
+ for (me=main->mesh.first; me; me= me->id.next) {
+ if (!me->medge) {
+ make_edges(me, 1); /* 1 = use mface->edcode */
+ }
+ else {
+ mesh_strip_loose_faces(me);
+ }
+ }
+
+ for (key= main->key.first; key; key= key->id.next) {
+ KeyBlock *kb;
+ int index = 1;
+
+ for (kb= key->block.first; kb; kb= kb->next) {
+ if (kb==key->refkey) {
+ if (kb->name[0]==0)
+ strcpy(kb->name, "Basis");
+ }
+ else {
+ if (kb->name[0]==0) {
+ BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index);
+ }
+ index++;
+ }
+ }
+ }
+ }
+ if (main->versionfile <= 239) {
+ bArmature *arm;
+ Object *ob;
+ Scene *sce= main->scene.first;
+ Camera *cam= main->camera.first;
+ Material *ma= main->mat.first;
+ int set_passepartout= 0;
+
+ /* deformflag is local in modifier now */
+ for (ob=main->object.first; ob; ob= ob->id.next) {
+ ModifierData *md;
+
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Armature) {
+ ArmatureModifierData *amd = (ArmatureModifierData*) md;
+ if (amd->object && amd->deformflag==0) {
+ Object *oba= blo_do_versions_newlibadr(fd, lib, amd->object);
+ arm= blo_do_versions_newlibadr(fd, lib, oba->data);
+ amd->deformflag= arm->deformflag;
+ }
+ }
+ }
+ }
+
+ /* updating stepsize for ghost drawing */
+ for (arm= main->armature.first; arm; arm= arm->id.next) {
+ if (arm->ghostsize==0) arm->ghostsize=1;
+ bone_version_239(&arm->bonebase);
+ if (arm->layer==0) arm->layer= 1;
+ }
+
+ for (;sce;sce= sce->id.next) {
+ /* make 'innervert' the default subdivide type, for backwards compat */
+ sce->toolsettings->cornertype=1;
+
+ if (sce->r.scemode & R_PASSEPARTOUT) {
+ set_passepartout= 1;
+ sce->r.scemode &= ~R_PASSEPARTOUT;
+ }
+ /* gauss is filter variable now */
+ if (sce->r.mode & R_GAUSS) {
+ sce->r.filtertype= R_FILTER_GAUSS;
+ sce->r.mode &= ~R_GAUSS;
+ }
+ }
+
+ for (;cam; cam= cam->id.next) {
+ if (set_passepartout)
+ cam->flag |= CAM_SHOWPASSEPARTOUT;
+
+ /* make sure old cameras have title safe on */
+ if (!(cam->flag & CAM_SHOWTITLESAFE))
+ cam->flag |= CAM_SHOWTITLESAFE;
+
+ /* set an appropriate camera passepartout alpha */
+ if (!(cam->passepartalpha)) cam->passepartalpha = 0.2f;
+ }
+
+ for (; ma; ma= ma->id.next) {
+ if (ma->strand_sta==0.0f) {
+ ma->strand_sta= ma->strand_end= 1.0f;
+ ma->mode |= MA_TANGENT_STR;
+ }
+ if (ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF;
+ }
+ }
+
+ if (main->versionfile <= 241) {
+ Object *ob;
+ Tex *tex;
+ Scene *sce;
+ World *wo;
+ Lamp *la;
+ Material *ma;
+ bArmature *arm;
+ bNodeTree *ntree;
+
+ for (wo = main->world.first; wo; wo= wo->id.next) {
+ /* Migrate to Bullet for games, except for the NaN versions */
+ /* People can still explicitly choose for Sumo (after 2.42 is out) */
+ if (main->versionfile > 225)
+ wo->physicsEngine = WOPHY_BULLET;
+ if (WO_AODIST == wo->aomode)
+ wo->aocolor= WO_AOPLAIN;
+ }
+
+ /* updating layers still */
+ for (arm= main->armature.first; arm; arm= arm->id.next) {
+ bone_version_239(&arm->bonebase);
+ if (arm->layer==0) arm->layer= 1;
+ }
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->audio.mixrate==0) sce->audio.mixrate= 44100;
+
+ if (sce->r.xparts<2) sce->r.xparts= 4;
+ if (sce->r.yparts<2) sce->r.yparts= 4;
+ /* adds default layer */
+ if (sce->r.layers.first==NULL)
+ scene_add_render_layer(sce, NULL);
+ else {
+ SceneRenderLayer *srl;
+ /* new layer flag for sky, was default for solid */
+ for (srl= sce->r.layers.first; srl; srl= srl->next) {
+ if (srl->layflag & SCE_LAY_SOLID)
+ srl->layflag |= SCE_LAY_SKY;
+ srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR);
+ }
+ }
+
+ /* node version changes */
+ if (sce->nodetree)
+ ntree_version_241(sce->nodetree);
+
+ /* uv calculation options moved to toolsettings */
+ if (sce->toolsettings->uvcalc_radius == 0.0f) {
+ sce->toolsettings->uvcalc_radius = 1.0f;
+ sce->toolsettings->uvcalc_cubesize = 1.0f;
+ sce->toolsettings->uvcalc_mapdir = 1;
+ sce->toolsettings->uvcalc_mapalign = 1;
+ sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES;
+ sce->toolsettings->unwrapper = 1;
+ }
+
+ if (sce->r.mode & R_PANORAMA) {
+ /* all these checks to ensure saved files with svn version keep working... */
+ if (sce->r.xsch < sce->r.ysch) {
+ Object *obc= blo_do_versions_newlibadr(fd, lib, sce->camera);
+ if (obc && obc->type==OB_CAMERA) {
+ Camera *cam= blo_do_versions_newlibadr(fd, lib, obc->data);
+ if (cam->lens>=10.0f) {
+ sce->r.xsch*= sce->r.xparts;
+ cam->lens*= (float)sce->r.ysch/(float)sce->r.xsch;
+ }
+ }
+ }
+ }
+ }
+
+ for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
+ ntree_version_241(ntree);
+
+ for (la= main->lamp.first; la; la= la->id.next)
+ if (la->buffers==0)
+ la->buffers= 1;
+
+ for (tex= main->tex.first; tex; tex= tex->id.next) {
+ if (tex->env && tex->env->viewscale==0.0f)
+ tex->env->viewscale= 1.0f;
+// tex->imaflag |= TEX_GAUSS_MIP;
+ }
+
+ /* for empty drawsize and drawtype */
+ for (ob=main->object.first; ob; ob= ob->id.next) {
+ if (ob->empty_drawsize==0.0f) {
+ ob->empty_drawtype = OB_ARROWS;
+ ob->empty_drawsize = 1.0;
+ }
+ }
+
+ for (ma= main->mat.first; ma; ma= ma->id.next) {
+ /* stucci returns intensity from now on */
+ int a;
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a] && ma->mtex[a]->tex) {
+ tex= blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex);
+ if (tex && tex->type==TEX_STUCCI)
+ ma->mtex[a]->mapto &= ~(MAP_COL|MAP_SPEC|MAP_REF);
+ }
+ }
+ /* transmissivity defaults */
+ if (ma->tx_falloff==0.0f) ma->tx_falloff= 1.0f;
+ }
+
+ /* during 2.41 images with this name were used for viewer node output, lets fix that */
+ if (main->versionfile == 241) {
+ Image *ima;
+ for (ima= main->image.first; ima; ima= ima->id.next)
+ if (strcmp(ima->name, "Compositor")==0) {
+ strcpy(ima->id.name+2, "Viewer Node");
+ strcpy(ima->name, "Viewer Node");
+ }
+ }
+ }
+
+ if (main->versionfile <= 242) {
+ Scene *sce;
+ bScreen *sc;
+ Object *ob;
+ Curve *cu;
+ Material *ma;
+ Mesh *me;
+ Group *group;
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ bNodeTree *ntree;
+ int a;
+
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl;
+
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D*) sl;
+ if (v3d->gridsubdiv == 0)
+ v3d->gridsubdiv = 10;
+ }
+ }
+ sa = sa->next;
+ }
+ }
+
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->toolsettings->select_thresh == 0.0f)
+ sce->toolsettings->select_thresh= 0.01f;
+ if (sce->toolsettings->clean_thresh == 0.0f)
+ sce->toolsettings->clean_thresh = 0.1f;
+
+ if (sce->r.threads==0) {
+ if (sce->r.mode & R_THREADS)
+ sce->r.threads= 2;
+ else
+ sce->r.threads= 1;
+ }
+ if (sce->nodetree)
+ ntree_version_242(sce->nodetree);
+ }
+
+ for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
+ ntree_version_242(ntree);
+
+ /* add default radius values to old curve points */
+ for (cu= main->curve.first; cu; cu= cu->id.next) {
+ for (nu= cu->nurb.first; nu; nu= nu->next) {
+ if (nu) {
+ if (nu->bezt) {
+ for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) {
+ if (!bezt->radius) bezt->radius= 1.0;
+ }
+ }
+ else if (nu->bp) {
+ for (bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
+ if (!bp->radius) bp->radius= 1.0;
+ }
+ }
+ }
+ }
+ }
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ ModifierData *md;
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* check for already existing MinMax (floor) constraint
+ * and update the sticky flagging */
+
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon=curcon->next) {
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_MINMAX:
+ {
+ bMinMaxConstraint *data = curcon->data;
+ if (data->sticky==1)
+ data->flag |= MINMAX_STICKY;
+ else
+ data->flag &= ~MINMAX_STICKY;
+ }
+ break;
+ case CONSTRAINT_TYPE_ROTLIKE:
+ {
+ bRotateLikeConstraint *data = curcon->data;
+
+ /* version patch from buttons_object.c */
+ if (data->flag==0)
+ data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
+ }
+ break;
+ }
+ }
+ }
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) {
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_MINMAX:
+ {
+ bMinMaxConstraint *data = curcon->data;
+ if (data->sticky==1)
+ data->flag |= MINMAX_STICKY;
+ else
+ data->flag &= ~MINMAX_STICKY;
+ }
+ break;
+ case CONSTRAINT_TYPE_KINEMATIC:
+ {
+ bKinematicConstraint *data = curcon->data;
+ if (!(data->flag & CONSTRAINT_IK_POS)) {
+ data->flag |= CONSTRAINT_IK_POS;
+ data->flag |= CONSTRAINT_IK_STRETCH;
+ }
+ }
+ break;
+ case CONSTRAINT_TYPE_ROTLIKE:
+ {
+ bRotateLikeConstraint *data = curcon->data;
+
+ /* version patch from buttons_object.c */
+ if (data->flag==0)
+ data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* copy old object level track settings to curve modifers */
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Curve) {
+ CurveModifierData *cmd = (CurveModifierData*) md;
+
+ if (cmd->defaxis == 0) cmd->defaxis = ob->trackflag+1;
+ }
+ }
+
+ }
+
+ for (ma = main->mat.first; ma; ma= ma->id.next) {
+ if (ma->shad_alpha==0.0f)
+ ma->shad_alpha= 1.0f;
+ if (ma->nodetree)
+ ntree_version_242(ma->nodetree);
+ }
+
+ for (me=main->mesh.first; me; me=me->id.next)
+ customdata_version_242(me);
+
+ for (group= main->group.first; group; group= group->id.next)
+ if (group->layer==0)
+ group->layer= (1<<20)-1;
+
+ /* now, subversion control! */
+ if (main->subversionfile < 3) {
+ Image *ima;
+ Tex *tex;
+
+ /* Image refactor initialize */
+ for (ima= main->image.first; ima; ima= ima->id.next) {
+ ima->source= IMA_SRC_FILE;
+ ima->type= IMA_TYPE_IMAGE;
+
+ ima->gen_x= 256; ima->gen_y= 256;
+ ima->gen_type= 1;
+
+ if (0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name)-2)) {
+ ima->source= IMA_SRC_VIEWER;
+ ima->type= IMA_TYPE_COMPOSITE;
+ }
+ if (0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name)-2)) {
+ ima->source= IMA_SRC_VIEWER;
+ ima->type= IMA_TYPE_R_RESULT;
+ }
+
+ }
+ for (tex= main->tex.first; tex; tex= tex->id.next) {
+ if (tex->type==TEX_IMAGE && tex->ima) {
+ ima= blo_do_versions_newlibadr(fd, lib, tex->ima);
+ if (tex->imaflag & TEX_ANIM5_)
+ ima->source= IMA_SRC_MOVIE;
+ if (tex->imaflag & TEX_FIELDS_)
+ ima->flag |= IMA_FIELDS;
+ if (tex->imaflag & TEX_STD_FIELD_)
+ ima->flag |= IMA_STD_FIELD;
+ }
+ tex->iuser.frames= tex->frames;
+ tex->iuser.fie_ima= (char)tex->fie_ima;
+ tex->iuser.offset= tex->offset;
+ tex->iuser.sfra= tex->sfra;
+ tex->iuser.cycl= (tex->imaflag & TEX_ANIMCYCLIC_)!=0;
+ }
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->nodetree)
+ do_version_ntree_242_2(sce->nodetree);
+ }
+ for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
+ do_version_ntree_242_2(ntree);
+ for (ma = main->mat.first; ma; ma= ma->id.next)
+ if (ma->nodetree)
+ do_version_ntree_242_2(ma->nodetree);
+
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_IMAGE)
+ ((SpaceImage *)sl)->iuser.fie_ima= 2;
+ else if (sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D *)sl;
+ BGpic *bgpic;
+ for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next)
+ bgpic->iuser.fie_ima= 2;
+ }
+ }
+ }
+ }
+ }
+
+ if (main->subversionfile < 4) {
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ sce->r.bake_mode= 1; /* prevent to include render stuff here */
+ sce->r.bake_filter= 2;
+ sce->r.bake_osa= 5;
+ sce->r.bake_flag= R_BAKE_CLEAR;
+ }
+ }
+
+ if (main->subversionfile < 5) {
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ /* improved triangle to quad conversion settings */
+ if (sce->toolsettings->jointrilimit==0.0f)
+ sce->toolsettings->jointrilimit= 0.8f;
+ }
+ }
+ }
+ if (main->versionfile <= 243) {
+ Object *ob= main->object.first;
+ Material *ma;
+
+ for (ma=main->mat.first; ma; ma= ma->id.next) {
+ if (ma->sss_scale==0.0f) {
+ ma->sss_radius[0]= 1.0f;
+ ma->sss_radius[1]= 1.0f;
+ ma->sss_radius[2]= 1.0f;
+ ma->sss_col[0]= 0.8f;
+ ma->sss_col[1]= 0.8f;
+ ma->sss_col[2]= 0.8f;
+ ma->sss_error= 0.05f;
+ ma->sss_scale= 0.1f;
+ ma->sss_ior= 1.3f;
+ ma->sss_colfac= 1.0f;
+ ma->sss_texfac= 0.0f;
+ }
+ if (ma->sss_front==0 && ma->sss_back==0) {
+ ma->sss_front= 1.0f;
+ ma->sss_back= 1.0f;
+ }
+ if (ma->sss_col[0]==0 && ma->sss_col[1]==0 && ma->sss_col[2]==0) {
+ ma->sss_col[0]= ma->r;
+ ma->sss_col[1]= ma->g;
+ ma->sss_col[2]= ma->b;
+ }
+ }
+
+ for (; ob; ob= ob->id.next) {
+ bDeformGroup *curdef;
+
+ for (curdef= ob->defbase.first; curdef; curdef=curdef->next) {
+ /* replace an empty-string name with unique name */
+ if (curdef->name[0] == '\0') {
+ defgroup_unique_name(curdef, ob);
+ }
+ }
+
+ if (main->versionfile < 243 || main->subversionfile < 1) {
+ ModifierData *md;
+
+ /* translate old mirror modifier axis values to new flags */
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Mirror) {
+ MirrorModifierData *mmd = (MirrorModifierData*) md;
+
+ switch (mmd->axis) {
+ case 0:
+ mmd->flag |= MOD_MIR_AXIS_X;
+ break;
+ case 1:
+ mmd->flag |= MOD_MIR_AXIS_Y;
+ break;
+ case 2:
+ mmd->flag |= MOD_MIR_AXIS_Z;
+ break;
+ }
+
+ mmd->axis = 0;
+ }
+ }
+ }
+ }
+
+ /* render layer added, this is not the active layer */
+ if (main->versionfile <= 243 || main->subversionfile < 2) {
+ Mesh *me;
+ for (me=main->mesh.first; me; me=me->id.next)
+ customdata_version_243(me);
+ }
+
+ }
+
+ if (main->versionfile <= 244) {
+ Scene *sce;
+ bScreen *sc;
+ Lamp *la;
+ World *wrld;
+
+ if (main->versionfile != 244 || main->subversionfile < 2) {
+ for (sce= main->scene.first; sce; sce= sce->id.next)
+ sce->r.mode |= R_SSS;
+
+ /* correct older action editors - incorrect scrolling */
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+ sa= sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl;
+
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_ACTION) {
+ SpaceAction *saction= (SpaceAction*) sl;
+
+ saction->v2d.tot.ymin = -1000.0;
+ saction->v2d.tot.ymax = 0.0;
+
+ saction->v2d.cur.ymin = -75.0;
+ saction->v2d.cur.ymax = 5.0;
+ }
+ }
+ sa = sa->next;
+ }
+ }
+ }
+ if (main->versionfile != 244 || main->subversionfile < 3) {
+ /* constraints recode version patch used to be here. Moved to 245 now... */
+
+
+ for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
+ if (wrld->mode & WO_AMB_OCC)
+ wrld->ao_samp_method = WO_AOSAMP_CONSTANT;
+ else
+ wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
+
+ wrld->ao_adapt_thresh = 0.005f;
+ }
+
+ for (la=main->lamp.first; la; la= la->id.next) {
+ if (la->type == LA_AREA)
+ la->ray_samp_method = LA_SAMP_CONSTANT;
+ else
+ la->ray_samp_method = LA_SAMP_HALTON;
+
+ la->adapt_thresh = 0.001f;
+ }
+ }
+ }
+ if (main->versionfile <= 245) {
+ Scene *sce;
+ Object *ob;
+ Image *ima;
+ Lamp *la;
+ Material *ma;
+ ParticleSettings *part;
+ World *wrld;
+ Mesh *me;
+ bNodeTree *ntree;
+ Tex *tex;
+ ModifierData *md;
+ ParticleSystem *psys;
+
+ /* unless the file was created 2.44.3 but not 2.45, update the constraints */
+ if ( !(main->versionfile==244 && main->subversionfile==3) &&
+ ((main->versionfile<245) || (main->versionfile==245 && main->subversionfile==0)) )
+ {
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* fix up constraints due to constraint recode changes (originally at 2.44.3) */
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon=curcon->next) {
+ /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
+ if (curcon->flag & 0x20) {
+ curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ }
+
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_LOCLIMIT:
+ {
+ bLocLimitConstraint *data= (bLocLimitConstraint *)curcon->data;
+
+ /* old limit without parent option for objects */
+ if (data->flag2)
+ curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ }
+ break;
+ }
+ }
+ }
+
+ /* correctly initialize constinv matrix */
+ unit_m4(ob->constinv);
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+
+ for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ /* make sure constraints are all up to date */
+ for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) {
+ /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
+ if (curcon->flag & 0x20) {
+ curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ }
+
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_ACTION:
+ {
+ bActionConstraint *data= (bActionConstraint *)curcon->data;
+
+ /* 'data->local' used to mean that target was in local-space */
+ if (data->local)
+ curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ }
+ break;
+ }
+ }
+
+ /* correctly initialize constinv matrix */
+ unit_m4(pchan->constinv);
+ }
+ }
+ }
+ }
+ }
+
+ /* fix all versions before 2.45 */
+ if (main->versionfile != 245) {
+
+ /* repair preview from 242 - 244*/
+ for (ima= main->image.first; ima; ima= ima->id.next) {
+ ima->preview = NULL;
+ }
+ }
+
+ /* add point caches */
+ for (ob=main->object.first; ob; ob=ob->id.next) {
+ if (ob->soft && !ob->soft->pointcache)
+ ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches);
+
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
+ if (psys->pointcache) {
+ if (psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) {
+ printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n");
+ psys->pointcache->flag &= ~PTCACHE_BAKED;
+ }
+ }
+ else
+ psys->pointcache= BKE_ptcache_add(&psys->ptcaches);
+ }
+
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData*) md;
+ if (!clmd->point_cache)
+ clmd->point_cache= BKE_ptcache_add(&clmd->ptcaches);
+ }
+ }
+ }
+
+ /* Copy over old per-level multires vertex data
+ * into a single vertex array in struct Multires */
+ for (me = main->mesh.first; me; me=me->id.next) {
+ if (me->mr && !me->mr->verts) {
+ MultiresLevel *lvl = me->mr->levels.last;
+ if (lvl) {
+ me->mr->verts = lvl->verts;
+ lvl->verts = NULL;
+ /* Don't need the other vert arrays */
+ for (lvl = lvl->prev; lvl; lvl = lvl->prev) {
+ MEM_freeN(lvl->verts);
+ lvl->verts = NULL;
+ }
+ }
+ }
+ }
+
+ if (main->versionfile != 245 || main->subversionfile < 1) {
+ for (la=main->lamp.first; la; la= la->id.next) {
+ if (la->mode & LA_QUAD) la->falloff_type = LA_FALLOFF_SLIDERS;
+ else la->falloff_type = LA_FALLOFF_INVLINEAR;
+
+ if (la->curfalloff == NULL) {
+ la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
+ curvemapping_initialize(la->curfalloff);
+ }
+ }
+ }
+
+ for (ma=main->mat.first; ma; ma= ma->id.next) {
+ if (ma->samp_gloss_mir == 0) {
+ ma->gloss_mir = ma->gloss_tra= 1.0f;
+ ma->aniso_gloss_mir = 1.0f;
+ ma->samp_gloss_mir = ma->samp_gloss_tra= 18;
+ ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005f;
+ ma->dist_mir = 0.0f;
+ ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
+ }
+
+ if (ma->strand_min == 0.0f)
+ ma->strand_min= 1.0f;
+ }
+
+ for (part=main->particle.first; part; part=part->id.next) {
+ if (part->ren_child_nbr==0)
+ part->ren_child_nbr= part->child_nbr;
+
+ if (part->simplify_refsize==0) {
+ part->simplify_refsize= 1920;
+ part->simplify_rate= 1.0f;
+ part->simplify_transition= 0.1f;
+ part->simplify_viewport= 0.8f;
+ }
+ }
+
+ for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
+ if (wrld->ao_approx_error == 0.0f)
+ wrld->ao_approx_error= 0.25f;
+ }
+
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->nodetree)
+ ntree_version_245(fd, lib, sce->nodetree);
+
+ if (sce->r.simplify_shadowsamples == 0) {
+ sce->r.simplify_subsurf= 6;
+ sce->r.simplify_particles= 1.0f;
+ sce->r.simplify_shadowsamples= 16;
+ sce->r.simplify_aosss= 1.0f;
+ }
+
+ if (sce->r.cineongamma == 0) {
+ sce->r.cineonblack= 95;
+ sce->r.cineonwhite= 685;
+ sce->r.cineongamma= 1.7f;
+ }
+ }
+
+ for (ntree=main->nodetree.first; ntree; ntree= ntree->id.next)
+ ntree_version_245(fd, lib, ntree);
+
+ /* fix for temporary flag changes during 245 cycle */
+ for (ima= main->image.first; ima; ima= ima->id.next) {
+ if (ima->flag & IMA_OLD_PREMUL) {
+ ima->flag &= ~IMA_OLD_PREMUL;
+ ima->flag |= IMA_DO_PREMUL;
+ }
+ }
+
+ for (tex=main->tex.first; tex; tex=tex->id.next) {
+ if (tex->iuser.flag & IMA_OLD_PREMUL) {
+ tex->iuser.flag &= ~IMA_OLD_PREMUL;
+ tex->iuser.flag |= IMA_DO_PREMUL;
+
+ }
+
+ ima= blo_do_versions_newlibadr(fd, lib, tex->ima);
+ if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) {
+ ima->flag &= ~IMA_OLD_PREMUL;
+ ima->flag |= IMA_DO_PREMUL;
+ }
+ }
+ }
+
+ /* sanity check for skgen
+ * */
+ {
+ Scene *sce;
+ for (sce=main->scene.first; sce; sce = sce->id.next) {
+ if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] ||
+ sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
+ sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
+ {
+ sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
+ sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
+ sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
+ }
+ }
+ }
+
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) {
+ Image *ima;
+
+ /* initialize 1:1 Aspect */
+ for (ima= main->image.first; ima; ima= ima->id.next) {
+ ima->aspx = ima->aspy = 1.0f;
+ }
+
+ }
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 4)) {
+ bArmature *arm;
+ ModifierData *md;
+ Object *ob;
+
+ for (arm= main->armature.first; arm; arm= arm->id.next)
+ arm->deformflag |= ARM_DEF_B_BONE_REST;
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Armature)
+ ((ArmatureModifierData*)md)->deformflag |= ARM_DEF_B_BONE_REST;
+ }
+ }
+ }
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 5)) {
+ /* foreground color needs to be something other then black */
+ Scene *sce;
+ for (sce= main->scene.first; sce; sce=sce->id.next) {
+ sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
+ sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */
+ sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */
+ }
+ }
+
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 6)) {
+ Scene *sce;
+ /* fix frs_sec_base */
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ if (sce->r.frs_sec_base == 0) {
+ sce->r.frs_sec_base = 1;
+ }
+ }
+ }
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) {
+ Object *ob;
+ bPoseChannel *pchan;
+ bConstraint *con;
+ bConstraintTarget *ct;
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ if (ob->pose) {
+ for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (con=pchan->constraints.first; con; con=con->next) {
+ if (con->type == CONSTRAINT_TYPE_PYTHON) {
+ bPythonConstraint *data= (bPythonConstraint *)con->data;
+ if (data->tar) {
+ /* version patching needs to be done */
+ ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget");
+
+ ct->tar = data->tar;
+ BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget));
+ ct->space = con->tarspace;
+
+ BLI_addtail(&data->targets, ct);
+ data->tarnum++;
+
+ /* clear old targets to avoid problems */
+ data->tar = NULL;
+ data->subtarget[0]= '\0';
+ }
+ }
+ else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
+ bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data;
+
+ /* new headtail functionality makes Bone-Tip function obsolete */
+ if (data->flag & LOCLIKE_TIP)
+ con->headtail = 1.0f;
+ }
+ }
+ }
+ }
+
+ for (con=ob->constraints.first; con; con=con->next) {
+ if (con->type==CONSTRAINT_TYPE_PYTHON) {
+ bPythonConstraint *data= (bPythonConstraint *)con->data;
+ if (data->tar) {
+ /* version patching needs to be done */
+ ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget");
+
+ ct->tar = data->tar;
+ BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget));
+ ct->space = con->tarspace;
+
+ BLI_addtail(&data->targets, ct);
+ data->tarnum++;
+
+ /* clear old targets to avoid problems */
+ data->tar = NULL;
+ data->subtarget[0]= '\0';
+ }
+ }
+ else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
+ bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data;
+
+ /* new headtail functionality makes Bone-Tip function obsolete */
+ if (data->flag & LOCLIKE_TIP)
+ con->headtail = 1.0f;
+ }
+ }
+
+ if (ob->soft && ob->soft->keys) {
+ SoftBody *sb = ob->soft;
+ int k;
+
+ for (k=0; k<sb->totkey; k++) {
+ if (sb->keys[k])
+ MEM_freeN(sb->keys[k]);
+ }
+
+ MEM_freeN(sb->keys);
+
+ sb->keys = NULL;
+ sb->totkey = 0;
+ }
+ }
+ }
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) {
+ Scene *sce;
+ Object *ob;
+ PartEff *paf=NULL;
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ if (ob->soft && ob->soft->keys) {
+ SoftBody *sb = ob->soft;
+ int k;
+
+ for (k=0; k<sb->totkey; k++) {
+ if (sb->keys[k])
+ MEM_freeN(sb->keys[k]);
+ }
+
+ MEM_freeN(sb->keys);
+
+ sb->keys = NULL;
+ sb->totkey = 0;
+ }
+
+ /* convert old particles to new system */
+ if ((paf = blo_do_version_give_parteff_245(ob))) {
+ ParticleSystem *psys;
+ ModifierData *md;
+ ParticleSystemModifierData *psmd;
+ ParticleSettings *part;
+
+ /* create new particle system */
+ psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
+ psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
+
+ part = psys->part = psys_new_settings("ParticleSettings", main);
+
+ /* needed for proper libdata lookup */
+ blo_do_versions_oldnewmap_insert(fd->libmap, psys->part, psys->part, 0);
+ part->id.lib= ob->id.lib;
+
+ part->id.us--;
+ part->id.flag |= (ob->id.flag & LIB_NEEDLINK);
+
+ psys->totpart=0;
+ psys->flag= PSYS_ENABLED|PSYS_CURRENT;
+
+ BLI_addtail(&ob->particlesystem, psys);
+
+ md= modifier_new(eModifierType_ParticleSystem);
+ BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
+ psmd= (ParticleSystemModifierData*) md;
+ psmd->psys=psys;
+ BLI_addtail(&ob->modifiers, md);
+
+ /* convert settings from old particle system */
+ /* general settings */
+ part->totpart = MIN2(paf->totpart, 100000);
+ part->sta = paf->sta;
+ part->end = paf->end;
+ part->lifetime = paf->lifetime;
+ part->randlife = paf->randlife;
+ psys->seed = paf->seed;
+ part->disp = paf->disp;
+ part->omat = paf->mat[0];
+ part->hair_step = paf->totkey;
+
+ part->eff_group = paf->group;
+
+ /* old system didn't interpolate between keypoints at render time */
+ part->draw_step = part->ren_step = 0;
+
+ /* physics */
+ part->normfac = paf->normfac * 25.0f;
+ part->obfac = paf->obfac;
+ part->randfac = paf->randfac * 25.0f;
+ part->dampfac = paf->damp;
+ copy_v3_v3(part->acc, paf->force);
+
+ /* flags */
+ if (paf->stype & PAF_VECT) {
+ if (paf->flag & PAF_STATIC) {
+ /* new hair lifetime is always 100.0f */
+ float fac = paf->lifetime / 100.0f;
+
+ part->draw_as = PART_DRAW_PATH;
+ part->type = PART_HAIR;
+ psys->recalc |= PSYS_RECALC_REDO;
+
+ part->normfac *= fac;
+ part->randfac *= fac;
+ }
+ else {
+ part->draw_as = PART_DRAW_LINE;
+ part->draw |= PART_DRAW_VEL_LENGTH;
+ part->draw_line[1] = 0.04f;
+ }
+ }
+
+ part->rotmode = PART_ROT_VEL;
+
+ part->flag |= (paf->flag & PAF_BSPLINE) ? PART_HAIR_BSPLINE : 0;
+ part->flag |= (paf->flag & PAF_TRAND) ? PART_TRAND : 0;
+ part->flag |= (paf->flag & PAF_EDISTR) ? PART_EDISTR : 0;
+ part->flag |= (paf->flag & PAF_UNBORN) ? PART_UNBORN : 0;
+ part->flag |= (paf->flag & PAF_DIED) ? PART_DIED : 0;
+ part->from |= (paf->flag & PAF_FACE) ? PART_FROM_FACE : 0;
+ part->draw |= (paf->flag & PAF_SHOWE) ? PART_DRAW_EMITTER : 0;
+
+ psys->vgroup[PSYS_VG_DENSITY] = paf->vertgroup;
+ psys->vgroup[PSYS_VG_VEL] = paf->vertgroup_v;
+ psys->vgroup[PSYS_VG_LENGTH] = paf->vertgroup_v;
+
+ /* dupliobjects */
+ if (ob->transflag & OB_DUPLIVERTS) {
+ Object *dup = main->object.first;
+
+ for (; dup; dup= dup->id.next) {
+ if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) {
+ part->dup_ob = dup;
+ ob->transflag |= OB_DUPLIPARTS;
+ ob->transflag &= ~OB_DUPLIVERTS;
+
+ part->draw_as = PART_DRAW_OB;
+
+ /* needed for proper libdata lookup */
+ blo_do_versions_oldnewmap_insert(fd->libmap, dup, dup, 0);
+ }
+ }
+ }
+
+
+ {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
+ if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE)
+ part->type = PART_FLUID;
+ }
+
+ do_version_free_effects_245(&ob->effect);
+
+ printf("Old particle system converted to new system.\n");
+ }
+ }
+
+ for (sce= main->scene.first; sce; sce=sce->id.next) {
+ ParticleEditSettings *pset= &sce->toolsettings->particle;
+ int a;
+
+ if (pset->brush[0].size == 0) {
+ pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
+ pset->emitterdist= 0.25f;
+ pset->totrekey= 5;
+ pset->totaddkey= 5;
+ pset->brushtype= PE_BRUSH_NONE;
+
+ for (a=0; a<PE_TOT_BRUSH; a++) {
+ pset->brush[a].strength= 50;
+ pset->brush[a].size= 50;
+ pset->brush[a].step= 10;
+ }
+
+ pset->brush[PE_BRUSH_CUT].strength= 100;
+ }
+ }
+ }
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 9)) {
+ Material *ma;
+ int a;
+
+ for (ma=main->mat.first; ma; ma= ma->id.next)
+ if (ma->mode & MA_NORMAP_TANG)
+ for (a=0; a<MAX_MTEX; a++)
+ if (ma->mtex[a] && ma->mtex[a]->tex)
+ ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT;
+ }
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) {
+ Object *ob;
+
+ /* dupliface scale */
+ for (ob= main->object.first; ob; ob= ob->id.next)
+ ob->dupfacesca = 1.0f;
+ }
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) {
+ Object *ob;
+ bActionStrip *strip;
+
+ /* nla-strips - scale */
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ for (strip= ob->nlastrips.first; strip; strip= strip->next) {
+ float length, actlength, repeat;
+
+ if (strip->flag & ACTSTRIP_USESTRIDE)
+ repeat= 1.0f;
+ else
+ repeat= strip->repeat;
+
+ length = strip->end-strip->start;
+ if (length == 0.0f) length= 1.0f;
+ actlength = strip->actend-strip->actstart;
+
+ strip->scale = length / (repeat * actlength);
+ if (strip->scale == 0.0f) strip->scale= 1.0f;
+ }
+ if (ob->soft) {
+ ob->soft->inpush = ob->soft->inspring;
+ ob->soft->shearstiff = 1.0f;
+ }
+ }
+ }
+
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) {
+ Scene *sce;
+ Sequence *seq;
+
+ for (sce=main->scene.first; sce; sce=sce->id.next) {
+ SEQ_BEGIN (sce->ed, seq)
+ {
+ if (seq->blend_mode == 0)
+ seq->blend_opacity = 100.0f;
+ }
+ SEQ_END
+ }
+ }
+
+ /*fix broken group lengths in id properties*/
+ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 15)) {
+ idproperties_fix_group_lengths(main->scene);
+ idproperties_fix_group_lengths(main->library);
+ idproperties_fix_group_lengths(main->object);
+ idproperties_fix_group_lengths(main->mesh);
+ idproperties_fix_group_lengths(main->curve);
+ idproperties_fix_group_lengths(main->mball);
+ idproperties_fix_group_lengths(main->mat);
+ idproperties_fix_group_lengths(main->tex);
+ idproperties_fix_group_lengths(main->image);
+ idproperties_fix_group_lengths(main->latt);
+ idproperties_fix_group_lengths(main->lamp);
+ idproperties_fix_group_lengths(main->camera);
+ idproperties_fix_group_lengths(main->ipo);
+ idproperties_fix_group_lengths(main->key);
+ idproperties_fix_group_lengths(main->world);
+ idproperties_fix_group_lengths(main->screen);
+ idproperties_fix_group_lengths(main->script);
+ idproperties_fix_group_lengths(main->vfont);
+ idproperties_fix_group_lengths(main->text);
+ idproperties_fix_group_lengths(main->sound);
+ idproperties_fix_group_lengths(main->group);
+ idproperties_fix_group_lengths(main->armature);
+ idproperties_fix_group_lengths(main->action);
+ idproperties_fix_group_lengths(main->nodetree);
+ idproperties_fix_group_lengths(main->brush);
+ idproperties_fix_group_lengths(main->particle);
+ }
+
+ /* sun/sky */
+ if (main->versionfile < 246) {
+ Object *ob;
+ bActuator *act;
+
+ /* dRot actuator change direction in 2.46 */
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_OBJECT) {
+ bObjectActuator *ba= act->data;
+
+ ba->drot[0] = -ba->drot[0];
+ ba->drot[1] = -ba->drot[1];
+ ba->drot[2] = -ba->drot[2];
+ }
+ }
+ }
+ }
+
+ // convert fluids to modifier
+ if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
+ Object *ob;
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ if (ob->fluidsimSettings) {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim);
+ BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd);
+
+ MEM_freeN(fluidmd->fss);
+ fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings);
+ fluidmd->fss->ipo = blo_do_versions_newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo);
+ MEM_freeN(ob->fluidsimSettings);
+
+ fluidmd->fss->lastgoodframe = INT_MAX;
+ fluidmd->fss->flag = 0;
+ fluidmd->fss->meshVelocities = NULL;
+ }
+ }
+ }
+
+
+ if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
+ Mesh *me;
+
+ for (me=main->mesh.first; me; me= me->id.next)
+ alphasort_version_246(fd, lib, me);
+ }
+
+ if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
+ Object *ob;
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ if (ob->pd && (ob->pd->forcefield == PFIELD_WIND))
+ ob->pd->f_noise = 0.0f;
+ }
+ }
+
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) {
+ Object *ob;
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ ob->gameflag |= OB_COLLISION;
+ ob->margin = 0.06f;
+ }
+ }
+
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) {
+ Object *ob;
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ // Starting from subversion 3, ACTOR is a separate feature.
+ // Before it was conditioning all the other dynamic flags
+ if (!(ob->gameflag & OB_ACTOR))
+ ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
+ /* suitable default for older files */
+ }
+ }
+
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) {
+ Lamp *la= main->lamp.first;
+ for (; la; la= la->id.next) {
+ la->skyblendtype= MA_RAMP_ADD;
+ la->skyblendfac= 1.0f;
+ }
+ }
+
+ /* set the curve radius interpolation to 2.47 default - easy */
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) {
+ Curve *cu;
+ Nurb *nu;
+
+ for (cu= main->curve.first; cu; cu= cu->id.next) {
+ for (nu= cu->nurb.first; nu; nu= nu->next) {
+ if (nu) {
+ nu->radius_interp = 3;
+
+ /* resolu and resolv are now used differently for surfaces
+ * rather than using the resolution to define the entire number of divisions,
+ * use it for the number of divisions per segment
+ */
+ if (nu->pntsv > 1) {
+ nu->resolu = MAX2( 1, (int)(((float)nu->resolu / (float)nu->pntsu)+0.5f) );
+ nu->resolv = MAX2( 1, (int)(((float)nu->resolv / (float)nu->pntsv)+0.5f) );
+ }
+ }
+ }
+ }
+ }
+ /* direction constraint actuators were always local in previous version */
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) {
+ bActuator *act;
+ Object *ob;
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_CONSTRAINT) {
+ bConstraintActuator *coa = act->data;
+ if (coa->type == ACT_CONST_TYPE_DIST) {
+ coa->flag |= ACT_CONST_LOCAL;
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) {
+ Lamp *la= main->lamp.first;
+ for (; la; la= la->id.next) {
+ la->sky_exposure= 1.0f;
+ }
+ }
+
+ /* BGE message actuators needed OB prefix, very confusing */
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) {
+ bActuator *act;
+ Object *ob;
+
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_MESSAGE) {
+ bMessageActuator *msgAct = (bMessageActuator *) act->data;
+ if (BLI_strnlen(msgAct->toPropName, 3) > 2) {
+ /* strip first 2 chars, would have only worked if these were OB anyway */
+ memmove(msgAct->toPropName, msgAct->toPropName + 2, sizeof(msgAct->toPropName) - 2);
+ }
+ else {
+ msgAct->toPropName[0] = '\0';
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 248) {
+ Lamp *la;
+
+ for (la=main->lamp.first; la; la= la->id.next) {
+ if (la->atm_turbidity == 0.0f) {
+ la->sun_effect_type = 0;
+ la->horizon_brightness = 1.0f;
+ la->spread = 1.0f;
+ la->sun_brightness = 1.0f;
+ la->sun_size = 1.0f;
+ la->backscattered_light = 1.0f;
+ la->atm_turbidity = 2.0f;
+ la->atm_inscattering_factor = 1.0f;
+ la->atm_extinction_factor = 1.0f;
+ la->atm_distance_factor = 1.0f;
+ la->sun_intensity = 1.0f;
+ }
+ }
+ }
+
+ if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) {
+ Scene *sce;
+
+ /* Note, these will need to be added for painting */
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ sce->toolsettings->imapaint.seam_bleed = 2;
+ sce->toolsettings->imapaint.normal_angle = 80;
+
+ /* initialize skeleton generation toolsettings */
+ sce->toolsettings->skgen_resolution = 250;
+ sce->toolsettings->skgen_threshold_internal = 0.1f;
+ sce->toolsettings->skgen_threshold_external = 0.1f;
+ sce->toolsettings->skgen_angle_limit = 30.0f;
+ sce->toolsettings->skgen_length_ratio = 1.3f;
+ sce->toolsettings->skgen_length_limit = 1.5f;
+ sce->toolsettings->skgen_correlation_limit = 0.98f;
+ sce->toolsettings->skgen_symmetry_limit = 0.1f;
+ sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
+ sce->toolsettings->skgen_postpro_passes = 3;
+ sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_SUB_CORRELATION|SKGEN_HARMONIC;
+ sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
+ sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
+ sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
+
+
+ sce->toolsettings->skgen_retarget_angle_weight = 1.0f;
+ sce->toolsettings->skgen_retarget_length_weight = 1.0f;
+ sce->toolsettings->skgen_retarget_distance_weight = 1.0f;
+
+ /* Skeleton Sketching */
+ sce->toolsettings->bone_sketching = 0;
+ sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW;
+ }
+ }
+ if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
+ bScreen *sc;
+
+ /* adjust default settings for Animation Editors */
+ for (sc= main->screen.first; sc; sc= sc->id.next) {
+ ScrArea *sa;
+
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_ACTION:
+ {
+ SpaceAction *sact= (SpaceAction *)sl;
+
+ sact->mode= SACTCONT_DOPESHEET;
+ sact->autosnap= SACTSNAP_FRAME;
+ }
+ break;
+ case SPACE_IPO:
+ {
+ SpaceIpo *sipo= (SpaceIpo *)sl;
+ sipo->autosnap= SACTSNAP_FRAME;
+ }
+ break;
+ case SPACE_NLA:
+ {
+ SpaceNla *snla= (SpaceNla *)sl;
+ snla->autosnap= SACTSNAP_FRAME;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
+ Object *ob;
+
+ /* Adjustments needed after Bullets update */
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ ob->damping *= 0.635f;
+ ob->rdamping = 0.1f + (0.8f * ob->rdamping);
+ }
+ }
+
+ if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) {
+ Scene *sce;
+ World *wrld;
+
+ /* Dome (Fisheye) default parameters */
+ for (sce= main->scene.first; sce; sce= sce->id.next) {
+ sce->r.domeangle = 180;
+ sce->r.domemode = 1;
+ sce->r.domeres = 4;
+ sce->r.domeresbuf = 1.0f;
+ sce->r.dometilt = 0;
+ }
+ /* DBVT culling by default */
+ for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
+ wrld->mode |= WO_DBVT_CULLING;
+ wrld->occlusionRes = 128;
+ }
+ }
+
+ if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) {
+ Object *ob;
+ World *wrld;
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ ob->m_contactProcessingThreshold = 1.0f; //pad3 is used for m_contactProcessingThreshold
+ if (ob->parent) {
+ /* check if top parent has compound shape set and if yes, set this object
+ * to compound shaper as well (was the behavior before, now it's optional) */
+ Object *parent= blo_do_versions_newlibadr(fd, lib, ob->parent);
+ while (parent && parent != ob && parent->parent != NULL) {
+ parent = blo_do_versions_newlibadr(fd, lib, parent->parent);
+ }
+ if (parent) {
+ if (parent->gameflag & OB_CHILD)
+ ob->gameflag |= OB_CHILD;
+ }
+ }
+ }
+ for (wrld=main->world.first; wrld; wrld= wrld->id.next) {
+ wrld->ticrate = 60;
+ wrld->maxlogicstep = 5;
+ wrld->physubstep = 1;
+ wrld->maxphystep = 5;
+ }
+ }
+
+ // correct introduce of seed for wind force
+ if (main->versionfile < 249 && main->subversionfile < 1) {
+ Object *ob;
+ for (ob = main->object.first; ob; ob= ob->id.next) {
+ if (ob->pd)
+ ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128;
+ }
+
+ }
+
+ if (main->versionfile < 249 && main->subversionfile < 2) {
+ Scene *sce= main->scene.first;
+ Sequence *seq;
+ Editing *ed;
+
+ while (sce) {
+ ed= sce->ed;
+ if (ed) {
+ SEQP_BEGIN (ed, seq)
+ {
+ if (seq->strip && seq->strip->proxy) {
+ seq->strip->proxy->quality =90;
+ }
+ }
+ SEQ_END
+ }
+
+ sce= sce->id.next;
+ }
+
+ }
+
+ /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
+ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
+
+ /* don't forget to set version number in blender.c! */
+}
+