2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 # include <unistd.h> /* for read close */
24 # include "BLI_winstuff.h"
25 # include "winsock2.h"
26 # include <io.h> // for open close read
27 # include <zlib.h> /* odd include order-issue */
30 /* allow readfile to use deprecated functionality */
31 #define DNA_DEPRECATED_ALLOW
33 #include "DNA_anim_types.h"
34 #include "DNA_armature_types.h"
35 #include "DNA_brush_types.h"
36 #include "DNA_camera_types.h"
37 #include "DNA_cloth_types.h"
38 #include "DNA_constraint_types.h"
39 #include "DNA_fluid_types.h"
40 #include "DNA_ipo_types.h"
41 #include "DNA_key_types.h"
42 #include "DNA_lattice_types.h"
43 #include "DNA_light_types.h"
44 #include "DNA_material_types.h"
45 #include "DNA_mesh_types.h"
46 #include "DNA_meshdata_types.h"
47 #include "DNA_node_types.h"
48 #include "DNA_object_fluidsim_types.h"
49 #include "DNA_object_types.h"
50 #include "DNA_screen_types.h"
51 #include "DNA_sdna_types.h"
52 #include "DNA_sequence_types.h"
53 #include "DNA_sound_types.h"
54 #include "DNA_space_types.h"
55 #include "DNA_view3d_types.h"
56 #include "DNA_world_types.h"
58 #include "MEM_guardedalloc.h"
60 #include "BLI_blenlib.h"
62 #include "BLI_utildefines.h"
64 #include "BKE_anim_visualization.h"
65 #include "BKE_armature.h"
66 #include "BKE_colortools.h"
67 #include "BKE_global.h" // for G
68 #include "BKE_lib_id.h"
70 #include "BKE_modifier.h"
71 #include "BKE_multires.h"
72 #include "BKE_particle.h"
73 #include "BKE_pointcache.h"
74 #include "BKE_screen.h"
75 #include "BKE_sequencer.h"
76 #include "BKE_sound.h"
77 #include "BKE_texture.h"
79 #include "NOD_socket.h"
81 #include "BLO_readfile.h"
87 /* Make preferences read-only, use versioning_userdef.c. */
88 #define U (*((const UserDef *)&U))
91 static void area_add_header_region(ScrArea *area, ListBase *lb)
93 ARegion *region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
95 BLI_addtail(lb, region);
96 region->regiontype = RGN_TYPE_HEADER;
97 if (area->headertype == 1) {
98 region->alignment = RGN_ALIGN_BOTTOM;
101 region->alignment = RGN_ALIGN_TOP;
104 /* initialize view2d data for header region, to allow panning */
105 /* is copy from ui_view2d.c */
106 region->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
107 region->v2d.keepofs = V2D_LOCKOFS_Y;
108 region->v2d.keeptot = V2D_KEEPTOT_STRICT;
109 region->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y;
110 region->v2d.flag = (V2D_PIXELOFS_X | V2D_PIXELOFS_Y);
113 static void sequencer_init_preview_region(ARegion *region)
115 // XXX a bit ugly still, copied from space_sequencer
116 /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
117 region->regiontype = RGN_TYPE_PREVIEW;
118 region->alignment = RGN_ALIGN_TOP;
119 region->flag |= RGN_FLAG_HIDDEN;
120 region->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM;
121 region->v2d.minzoom = 0.00001f;
122 region->v2d.maxzoom = 100000.0f;
123 region->v2d.tot.xmin = -960.0f; /* 1920 width centered */
124 region->v2d.tot.ymin = -540.0f; /* 1080 height centered */
125 region->v2d.tot.xmax = 960.0f;
126 region->v2d.tot.ymax = 540.0f;
127 region->v2d.min[0] = 0.0f;
128 region->v2d.min[1] = 0.0f;
129 region->v2d.max[0] = 12000.0f;
130 region->v2d.max[1] = 12000.0f;
131 region->v2d.cur = region->v2d.tot;
132 region->v2d.align = V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
133 region->v2d.keeptot = V2D_KEEPTOT_FREE;
136 static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
139 ARegion *region_main;
142 /* first channels for ipo action nla... */
143 switch (sl->spacetype) {
145 region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
146 BLI_addtail(lb, region);
147 region->regiontype = RGN_TYPE_CHANNELS;
148 region->alignment = RGN_ALIGN_LEFT;
149 region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
151 /* for some reason, this doesn't seem to go auto like for NLA... */
152 region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
153 BLI_addtail(lb, region);
154 region->regiontype = RGN_TYPE_UI;
155 region->alignment = RGN_ALIGN_RIGHT;
156 region->v2d.scroll = V2D_SCROLL_RIGHT;
157 region->v2d.flag = RGN_FLAG_HIDDEN;
161 region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
162 BLI_addtail(lb, region);
163 region->regiontype = RGN_TYPE_CHANNELS;
164 region->alignment = RGN_ALIGN_LEFT;
165 region->v2d.scroll = V2D_SCROLL_BOTTOM;
166 region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
170 region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
171 BLI_addtail(lb, region);
172 region->regiontype = RGN_TYPE_CHANNELS;
173 region->alignment = RGN_ALIGN_LEFT;
174 region->v2d.scroll = V2D_SCROLL_BOTTOM;
175 region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
177 /* for some reason, some files still don't get this auto */
178 region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
179 BLI_addtail(lb, region);
180 region->regiontype = RGN_TYPE_UI;
181 region->alignment = RGN_ALIGN_RIGHT;
182 region->v2d.scroll = V2D_SCROLL_RIGHT;
183 region->v2d.flag = RGN_FLAG_HIDDEN;
187 region = MEM_callocN(sizeof(ARegion), "nodetree area for node");
188 BLI_addtail(lb, region);
189 region->regiontype = RGN_TYPE_UI;
190 region->alignment = RGN_ALIGN_LEFT;
191 region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
192 region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
193 /* temporarily hide it */
194 region->flag = RGN_FLAG_HIDDEN;
197 region = MEM_callocN(sizeof(ARegion), "nodetree area for node");
198 BLI_addtail(lb, region);
199 region->regiontype = RGN_TYPE_CHANNELS;
200 region->alignment = RGN_ALIGN_LEFT;
202 region = MEM_callocN(sizeof(ARegion), "ui area for file");
203 BLI_addtail(lb, region);
204 region->regiontype = RGN_TYPE_UI;
205 region->alignment = RGN_ALIGN_TOP;
208 region_main = (ARegion *)lb->first;
209 for (; region_main; region_main = region_main->next) {
210 if (region_main->regiontype == RGN_TYPE_WINDOW) {
214 region = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
215 BLI_insertlinkbefore(lb, region_main, region);
216 sequencer_init_preview_region(region);
220 region = MEM_callocN(sizeof(ARegion), "toolbar for view3d");
222 BLI_addtail(lb, region);
223 region->regiontype = RGN_TYPE_TOOLS;
224 region->alignment = RGN_ALIGN_LEFT;
225 region->flag = RGN_FLAG_HIDDEN;
227 /* tool properties */
228 region = MEM_callocN(sizeof(ARegion), "tool properties for view3d");
230 BLI_addtail(lb, region);
231 region->regiontype = RGN_TYPE_TOOL_PROPS;
232 region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
233 region->flag = RGN_FLAG_HIDDEN;
235 /* buttons/list view */
236 region = MEM_callocN(sizeof(ARegion), "buttons for view3d");
238 BLI_addtail(lb, region);
239 region->regiontype = RGN_TYPE_UI;
240 region->alignment = RGN_ALIGN_RIGHT;
241 region->flag = RGN_FLAG_HIDDEN;
243 case SPACE_PROPERTIES:
244 /* context UI region */
245 region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
246 BLI_addtail(lb, region);
247 region->regiontype = RGN_TYPE_UI;
248 region->alignment = RGN_ALIGN_RIGHT;
256 region = MEM_callocN(sizeof(ARegion), "area region from do_versions");
258 BLI_addtail(lb, region);
259 region->winrct = area->totrct;
261 region->regiontype = RGN_TYPE_WINDOW;
264 /* if active spacetype has view2d data, copy that over to main region */
265 /* and we split view3d */
266 switch (sl->spacetype) {
268 blo_do_versions_view3d_split_250((View3D *)sl, lb);
271 case SPACE_OUTLINER: {
272 SpaceOutliner *soops = (SpaceOutliner *)sl;
274 memcpy(®ion->v2d, &soops->v2d, sizeof(View2D));
276 region->v2d.scroll &= ~V2D_SCROLL_LEFT;
277 region->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
278 region->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
279 region->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT);
280 region->v2d.keeptot = V2D_KEEPTOT_STRICT;
281 region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
282 // region->v2d.flag |= V2D_IS_INITIALISED;
286 SpaceGraph *sipo = (SpaceGraph *)sl;
287 memcpy(®ion->v2d, &sipo->v2d, sizeof(View2D));
289 /* init mainarea view2d */
290 region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES);
291 region->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_VERTICAL_HANDLES);
293 region->v2d.min[0] = FLT_MIN;
294 region->v2d.min[1] = FLT_MIN;
296 region->v2d.max[0] = MAXFRAMEF;
297 region->v2d.max[1] = FLT_MAX;
299 // region->v2d.flag |= V2D_IS_INITIALISED;
303 SpaceNla *snla = (SpaceNla *)sl;
304 memcpy(®ion->v2d, &snla->v2d, sizeof(View2D));
306 region->v2d.tot.ymin = (float)(-area->winy) / 3.0f;
307 region->v2d.tot.ymax = 0.0f;
309 region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES);
310 region->v2d.scroll |= (V2D_SCROLL_RIGHT);
311 region->v2d.align = V2D_ALIGN_NO_POS_Y;
312 region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
316 SpaceAction *saction = (SpaceAction *)sl;
318 /* We totally reinit the view for the Action Editor,
319 * as some old instances had some weird cruft set. */
320 region->v2d.tot.xmin = -20.0f;
321 region->v2d.tot.ymin = (float)(-area->winy) / 3.0f;
322 region->v2d.tot.xmax = (float)((area->winx > 120) ? (area->winx) : 120);
323 region->v2d.tot.ymax = 0.0f;
325 region->v2d.cur = region->v2d.tot;
327 region->v2d.min[0] = 0.0f;
328 region->v2d.min[1] = 0.0f;
330 region->v2d.max[0] = MAXFRAMEF;
331 region->v2d.max[1] = FLT_MAX;
333 region->v2d.minzoom = 0.01f;
334 region->v2d.maxzoom = 50;
335 region->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES);
336 region->v2d.scroll |= (V2D_SCROLL_RIGHT);
337 region->v2d.keepzoom = V2D_LOCKZOOM_Y;
338 region->v2d.align = V2D_ALIGN_NO_POS_Y;
339 region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
341 /* for old files with ShapeKey editors open + an action set, clear the action as
342 * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
343 * only shows ShapeKey-rooted actions only)
345 if (saction->mode == SACTCONT_SHAPEKEY) {
346 saction->action = NULL;
351 SpaceSeq *sseq = (SpaceSeq *)sl;
352 memcpy(®ion->v2d, &sseq->v2d, sizeof(View2D));
354 region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES);
355 region->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_VERTICAL_HANDLES);
356 region->v2d.align = V2D_ALIGN_NO_NEG_Y;
357 region->v2d.flag |= V2D_IS_INITIALISED;
361 SpaceNode *snode = (SpaceNode *)sl;
362 memcpy(®ion->v2d, &snode->v2d, sizeof(View2D));
364 region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
365 region->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT;
368 case SPACE_PROPERTIES: {
369 SpaceProperties *sbuts = (SpaceProperties *)sl;
370 memcpy(®ion->v2d, &sbuts->v2d, sizeof(View2D));
372 region->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
376 // SpaceFile *sfile = (SpaceFile *)sl;
377 region->v2d.tot.xmin = region->v2d.tot.ymin = 0;
378 region->v2d.tot.xmax = region->winx;
379 region->v2d.tot.ymax = region->winy;
380 region->v2d.cur = region->v2d.tot;
381 region->regiontype = RGN_TYPE_WINDOW;
382 region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
383 region->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
384 region->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
388 SpaceText *st = (SpaceText *)sl;
389 st->flags |= ST_FIND_WRAP;
391 // case SPACE_XXX: // FIXME... add other ones
392 // memcpy(®ion->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
398 static void do_versions_windowmanager_2_50(bScreen *screen)
404 for (area = screen->areabase.first; area; area = area->next) {
405 /* we keep headertype variable to convert old files only */
406 if (area->headertype) {
407 area_add_header_region(area, &area->regionbase);
410 area_add_window_regions(area, area->spacedata.first, &area->regionbase);
412 /* space imageselect is deprecated */
413 for (sl = area->spacedata.first; sl; sl = sl->next) {
414 if (sl->spacetype == SPACE_IMASEL) {
415 sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
419 /* space sound is deprecated */
420 for (sl = area->spacedata.first; sl; sl = sl->next) {
421 if (sl->spacetype == SPACE_SOUND) {
422 sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
426 /* pushed back spaces also need regions! */
427 if (area->spacedata.first) {
428 sl = area->spacedata.first;
429 for (sl = sl->next; sl; sl = sl->next) {
430 if (area->headertype) {
431 area_add_header_region(area, &sl->regionbase);
433 area_add_window_regions(area, sl, &sl->regionbase);
439 static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name)
443 id->flag = LIB_FAKEUSER;
444 *((short *)id->name) = ID_GD;
446 BKE_id_new_name_validate(lb, id, name);
447 /* alphabetic insertion: is in BKE_id_new_name_validate */
449 BKE_lib_libblock_session_uuid_ensure(id);
451 if (G.debug & G_DEBUG) {
452 printf("Converted GPencil to ID: %s\n", id->name + 2);
456 static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
462 for (area = screen->areabase.first; area; area = area->next) {
463 for (sl = area->spacedata.first; sl; sl = sl->next) {
464 if (sl->spacetype == SPACE_VIEW3D) {
465 View3D *v3d = (View3D *)sl;
467 versions_gpencil_add_main(&main->gpencils, (ID *)v3d->gpd, "GPencil View3D");
471 else if (sl->spacetype == SPACE_NODE) {
472 SpaceNode *snode = (SpaceNode *)sl;
474 versions_gpencil_add_main(&main->gpencils, (ID *)snode->gpd, "GPencil Node");
478 else if (sl->spacetype == SPACE_SEQ) {
479 SpaceSeq *sseq = (SpaceSeq *)sl;
481 versions_gpencil_add_main(&main->gpencils, (ID *)sseq->gpd, "GPencil Node");
485 else if (sl->spacetype == SPACE_IMAGE) {
486 SpaceImage *sima = (SpaceImage *)sl;
487 #if 0 /* see comment on r28002 */
489 versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image");
500 static void do_version_mdef_250(Main *main)
504 MeshDeformModifierData *mmd;
506 for (ob = main->objects.first; ob; ob = ob->id.next) {
507 for (md = ob->modifiers.first; md; md = md->next) {
508 if (md->type == eModifierType_MeshDeform) {
509 mmd = (MeshDeformModifierData *)md;
512 /* make bindcos NULL in order to trick older versions
513 * into thinking that the mesh was not bound yet */
514 mmd->bindcagecos = mmd->bindcos;
517 modifier_mdef_compact_influences(md);
524 static void do_version_constraints_radians_degrees_250(ListBase *lb)
528 for (con = lb->first; con; con = con->next) {
529 if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
530 bKinematicConstraint *data = con->data;
531 data->poleangle *= (float)(M_PI / 180.0);
533 else if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
534 bRotLimitConstraint *data = con->data;
536 data->xmin *= (float)(M_PI / 180.0);
537 data->xmax *= (float)(M_PI / 180.0);
538 data->ymin *= (float)(M_PI / 180.0);
539 data->ymax *= (float)(M_PI / 180.0);
540 data->zmin *= (float)(M_PI / 180.0);
541 data->zmax *= (float)(M_PI / 180.0);
546 static void do_version_bone_roll_256(Bone *bone)
551 copy_m3_m4(submat, bone->arm_mat);
552 mat3_to_vec_roll(submat, NULL, &bone->arm_roll);
554 for (child = bone->childbase.first; child; child = child->next) {
555 do_version_bone_roll_256(child);
559 /* deprecated, only keep this for readfile.c */
560 /* XXX Deprecated function to add a socket in ntree->inputs/ntree->outputs list
561 * (previously called node_group_add_socket). This function has been superseded
562 * by the implementation of proxy nodes. It is still necessary though
563 * for do_versions of pre-2.56.2 code (r35033), so later proxy nodes
564 * can be generated consistently from ntree socket lists.
566 static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup,
571 // bNodeSocketType *stype = ntreeGetSocketType(type);
572 bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket");
574 BLI_strncpy(gsock->name, name, sizeof(gsock->name));
577 gsock->next = gsock->prev = NULL;
578 gsock->new_sock = NULL;
580 /* assign new unique index */
581 gsock->own_index = ngroup->cur_index++;
582 gsock->limit = (in_out == SOCK_IN ? 0xFFF : 1);
584 // if (stype->value_structsize > 0)
585 // gsock->default_value = MEM_callocN(stype->value_structsize, "default socket value");
587 BLI_addtail(in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock);
589 ngroup->update |= (in_out == SOCK_IN ? NTREE_UPDATE_GROUP_IN : NTREE_UPDATE_GROUP_OUT);
594 /* Create default_value structs for node sockets from the internal bNodeStack value.
595 * These structs were used from 2.59.2 on, but are replaced in the subsequent do_versions for
596 * custom nodes by generic ID property values. This conversion happened _after_ do_versions
597 * originally due to messy type initialization for node sockets.
598 * Now created here intermediately for convenience and to keep do_versions consistent.
600 * Node compatibility code is gross ...
602 static void do_versions_socket_default_value_259(bNodeSocket *sock)
604 bNodeSocketValueFloat *valfloat;
605 bNodeSocketValueVector *valvector;
606 bNodeSocketValueRGBA *valrgba;
608 if (sock->default_value) {
612 switch (sock->type) {
614 valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat),
615 "default socket value");
616 valfloat->value = sock->ns.vec[0];
617 valfloat->min = sock->ns.min;
618 valfloat->max = sock->ns.max;
619 valfloat->subtype = PROP_NONE;
622 valvector = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueVector),
623 "default socket value");
624 copy_v3_v3(valvector->value, sock->ns.vec);
625 valvector->min = sock->ns.min;
626 valvector->max = sock->ns.max;
627 valvector->subtype = PROP_NONE;
630 valrgba = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueRGBA),
631 "default socket value");
632 copy_v4_v4(valrgba->value, sock->ns.vec);
637 void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
639 /* WATCH IT!!!: pointers from libdata have not been converted */
641 if (bmain->versionfile < 250) {
650 ParticleSettings *part;
658 for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
659 if (sound->newpackedfile) {
660 sound->packedfile = sound->newpackedfile;
661 sound->newpackedfile = NULL;
665 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
666 if (scene->ed && scene->ed->seqbasep) {
667 SEQ_BEGIN (scene->ed, seq) {
668 if (seq->type == SEQ_TYPE_SOUND_HD) {
670 BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
671 BLI_path_abs(str, BKE_main_blendfile_path(bmain));
672 seq->sound = BKE_sound_new_file(bmain, str);
674 #define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
675 #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
676 /* don't know, if anybody used that this way, but just in case, upgrade to new way... */
677 if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) {
678 BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir);
680 #undef SEQ_USE_PROXY_CUSTOM_DIR
681 #undef SEQ_USE_PROXY_CUSTOM_FILE
687 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
688 do_versions_windowmanager_2_50(screen);
689 do_versions_gpencil_2_50(bmain, screen);
692 /* shader, composite and texture node trees have id.name empty, put something in
693 * to have them show in RNA viewer and accessible otherwise.
695 for (ma = bmain->materials.first; ma; ma = ma->id.next) {
696 if (ma->nodetree && ma->nodetree->id.name[0] == '\0') {
697 strcpy(ma->nodetree->id.name, "NTShader Nodetree");
701 /* and composite trees */
702 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
703 enum { R_PANORAMA = (1 << 10) };
704 if (sce->nodetree && sce->nodetree->id.name[0] == '\0') {
705 strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
708 /* move to cameras */
709 if (sce->r.mode & R_PANORAMA) {
710 for (base = sce->base.first; base; base = base->next) {
711 ob = blo_do_versions_newlibadr(fd, lib, base->object);
713 if (ob->type == OB_CAMERA && !ob->id.lib) {
714 cam = blo_do_versions_newlibadr(fd, lib, ob->data);
715 cam->flag |= CAM_PANORAMA;
719 sce->r.mode &= ~R_PANORAMA;
723 /* and texture trees */
724 for (tx = bmain->textures.first; tx; tx = tx->id.next) {
728 if (tx->nodetree->id.name[0] == '\0') {
729 strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
732 /* which_output 0 is now "not specified" */
733 for (node = tx->nodetree->nodes.first; node; node = node->next) {
734 if (node->type == TEX_NODE_OUTPUT) {
741 /* particle draw and render types */
742 for (part = bmain->particles.first; part; part = part->id.next) {
744 if (part->draw_as == PART_DRAW_DOT) {
745 part->ren_as = PART_DRAW_HALO;
746 part->draw_as = PART_DRAW_REND;
748 else if (part->draw_as <= PART_DRAW_AXIS) {
749 part->ren_as = PART_DRAW_HALO;
752 part->ren_as = part->draw_as;
753 part->draw_as = PART_DRAW_REND;
756 part->path_end = 1.0f;
757 part->clength = 1.0f;
760 /* set old pointcaches to have disk cache flag */
761 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
763 // BKE_ptcache_ids_from_object(&pidlist, ob);
765 // for (pid = pidlist.first; pid; pid = pid->next)
766 // pid->cache->flag |= PTCACHE_DISK_CACHE;
768 // BLI_freelistN(&pidlist);
771 /* type was a mixed flag & enum. move the 2d flag elsewhere */
772 for (cu = bmain->curves.first; cu; cu = cu->id.next) {
775 for (nu = cu->nurb.first; nu; nu = nu->next) {
776 nu->flag |= (nu->type & CU_2D);
782 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
790 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
791 // BKE_ptcache_ids_from_object(&pidlist, ob);
793 // for (pid = pidlist.first; pid; pid = pid->next) {
794 // if (BLI_listbase_is_empty(pid->ptcaches))
795 // pid->ptcaches->first = pid->ptcaches->last = pid->cache;
798 // BLI_freelistN(&pidlist);
800 if (ob->type == OB_MESH) {
801 Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
802 void *olddata = ob->data;
805 /* XXX - library meshes crash on loading most yoFrankie levels,
806 * the multires pointer gets invalid - Campbell */
807 if (me && me->id.lib == NULL && me->mr && me->mr->level_count > 1) {
808 multires_load_old(ob, me);
814 if (ob->totcol && ob->matbits == NULL) {
817 ob->matbits = MEM_calloc_arrayN(ob->totcol, sizeof(char), "ob->matbits");
818 for (a = 0; a < ob->totcol; a++) {
819 ob->matbits[a] = (ob->colbits & (1 << a)) != 0;
825 for (tex = bmain->textures.first; tex; tex = tex->id.next) {
826 if (tex->afmax == 0) {
831 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
832 ts = sce->toolsettings;
833 if (!ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
834 ts->selectmode = SCE_SELECT_VERTEX;
836 /* autokeying - setting should be taken from the user-prefs
837 * but the userprefs version may not have correct flags set
838 * (i.e. will result in blank box when enabled)
840 ts->autokey_mode = U.autokey_mode;
841 if (ts->autokey_mode == 0) {
842 ts->autokey_mode = 2; /* 'add/replace' but not on */
844 ts->uv_selectmode = UV_SELECT_VERTEX;
845 ts->vgroup_weight = 1.0f;
850 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 2)) {
853 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
854 if (ob->flag & 8192) { // OB_POSEMODE = 8192
855 ob->mode |= OB_MODE_POSE;
860 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 4)) {
863 ParticleSettings *part;
864 bool do_gravity = false;
866 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
867 if (sce->unit.scale_length == 0.0f) {
868 sce->unit.scale_length = 1.0f;
872 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
873 /* fluid-sim stuff */
874 FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
875 ob, eModifierType_Fluidsim);
877 fluidmd->fss->fmd = fluidmd;
880 /* rotation modes were added,
881 * but old objects would now default to being 'quaternion based' */
882 ob->rotmode = ROT_MODE_EUL;
885 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
886 if (sce->audio.main == 0.0f) {
887 sce->audio.main = 1.0f;
890 sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
891 sce->r.ffcodecdata.audio_volume = sce->audio.main;
892 sce->audio.distance_model = 2;
893 sce->audio.doppler_factor = 1.0f;
894 sce->audio.speed_of_sound = 343.3f;
897 /* Add default gravity to scenes */
898 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
899 if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
900 is_zero_v3(sce->physics_settings.gravity)) {
901 sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
902 sce->physics_settings.gravity[2] = -9.81f;
903 sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY;
908 /* Assign proper global gravity weights for dynamics
909 * (only z-coordinate is taken into account) */
911 for (part = bmain->particles.first; part; part = part->id.next) {
912 part->effector_weights->global_gravity = part->acc[2] / -9.81f;
916 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
920 for (md = ob->modifiers.first; md; md = md->next) {
921 ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob,
922 eModifierType_Cloth);
924 clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2] /
930 ob->soft->effector_weights->global_gravity = ob->soft->grav / 9.81f;
934 /* Normal wind shape is plane */
936 if (ob->pd->forcefield == PFIELD_WIND) {
937 ob->pd->shape = PFIELD_SHAPE_PLANE;
940 if (ob->pd->flag & PFIELD_PLANAR) {
941 ob->pd->shape = PFIELD_SHAPE_PLANE;
943 else if (ob->pd->flag & PFIELD_SURFACE) {
944 ob->pd->shape = PFIELD_SHAPE_SURFACE;
947 ob->pd->flag |= PFIELD_DO_LOCATION;
952 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) {
955 /* New variables for axis-angle rotations and/or quaternion rotations were added,
956 * and need proper initialization */
957 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
958 /* new variables for all objects */
960 ob->rotAxis[1] = 1.0f;
966 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
967 /* just need to initialise rotation axis properly... */
968 pchan->rotAxis[1] = 1.0f;
974 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 7)) {
983 /* shape keys are no longer applied to the mesh itself, but rather
984 * to the derivedmesh/displist, so here we ensure that the basis
985 * shape key is always set in the mesh coordinates. */
986 for (me = bmain->meshes.first; me; me = me->id.next) {
987 if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) {
988 data = key->refkey->data;
989 tot = MIN2(me->totvert, key->refkey->totelem);
991 for (a = 0; a < tot; a++, data += 3) {
992 copy_v3_v3(me->mvert[a].co, data);
997 for (lt = bmain->lattices.first; lt; lt = lt->id.next) {
998 if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) {
999 data = key->refkey->data;
1000 tot = MIN2(lt->pntsu * lt->pntsv * lt->pntsw, key->refkey->totelem);
1002 for (a = 0; a < tot; a++, data += 3) {
1003 copy_v3_v3(lt->def[a].vec, data);
1008 for (cu = bmain->curves.first; cu; cu = cu->id.next) {
1009 if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) {
1010 data = key->refkey->data;
1012 for (nu = cu->nurb.first; nu; nu = nu->next) {
1014 BezTriple *bezt = nu->bezt;
1016 for (a = 0; a < nu->pntsu; a++, bezt++) {
1017 copy_v3_v3(bezt->vec[0], data);
1019 copy_v3_v3(bezt->vec[1], data);
1021 copy_v3_v3(bezt->vec[2], data);
1028 BPoint *bp = nu->bp;
1030 for (a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
1031 copy_v3_v3(bp->vec, data);
1042 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
1044 Scene *sce = bmain->scenes.first;
1046 if (sce->r.frame_step == 0) {
1047 sce->r.frame_step = 1;
1055 /* ensure all nodes have unique names */
1056 bNodeTree *ntree = bmain->nodetrees.first;
1058 bNode *node = ntree->nodes.first;
1061 nodeUniqueName(ntree, node);
1065 ntree = ntree->id.next;
1070 Object *ob = bmain->objects.first;
1072 /* shaded mode disabled for now */
1073 if (ob->dt == OB_MATERIAL) {
1074 ob->dt = OB_TEXTURE;
1085 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1086 for (area = screen->areabase.first; area; area = area->next) {
1087 for (sl = area->spacedata.first; sl; sl = sl->next) {
1088 if (sl->spacetype == SPACE_VIEW3D) {
1089 View3D *v3d = (View3D *)sl;
1090 if (v3d->drawtype == OB_MATERIAL) {
1091 v3d->drawtype = OB_SOLID;
1099 /* only convert old 2.50 files with color management */
1100 if (bmain->versionfile == 250) {
1101 Scene *sce = bmain->scenes.first;
1102 Material *ma = bmain->materials.first;
1103 Tex *tex = bmain->textures.first;
1106 /* convert to new color management system:
1107 * while previously colors were stored as srgb,
1108 * now they are stored as linear internally,
1109 * with screen gamma correction in certain places in the UI. */
1111 /* don't know what scene is active, so we'll convert if any scene has it enabled... */
1113 if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
1121 srgb_to_linearrgb_v3_v3(&ma->r, &ma->r);
1122 srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr);
1128 ColorBand *band = (ColorBand *)tex->coba;
1129 for (i = 0; i < band->tot; i++) {
1130 CBData *data = band->data + i;
1131 srgb_to_linearrgb_v3_v3(&data->r, &data->r);
1140 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 9)) {
1145 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1146 if (!sce->toolsettings->particle.selectmode) {
1147 sce->toolsettings->particle.selectmode = SCE_SELECT_PATH;
1151 if (bmain->versionfile == 250 && bmain->subversionfile > 1) {
1152 for (me = bmain->meshes.first; me; me = me->id.next) {
1153 multires_load_old_250(me);
1156 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1157 MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(
1158 ob, eModifierType_Multires);
1163 mmd->sculptlvl = mmd->lvl;
1164 mmd->renderlvl = mmd->lvl;
1170 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 10)) {
1173 /* properly initialize hair clothsim data on old files */
1174 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1176 for (md = ob->modifiers.first; md; md = md->next) {
1177 if (md->type == eModifierType_Cloth) {
1178 ClothModifierData *clmd = (ClothModifierData *)md;
1179 if (clmd->sim_parms->velocity_smooth < 0.01f) {
1180 clmd->sim_parms->velocity_smooth = 0.f;
1187 /* fix bad area setup in subversion 10 */
1188 if (bmain->versionfile == 250 && bmain->subversionfile == 10) {
1189 /* fix for new view type in sequencer */
1194 /* remove all preview window in wrong spaces */
1195 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1196 for (area = screen->areabase.first; area; area = area->next) {
1197 for (sl = area->spacedata.first; sl; sl = sl->next) {
1198 if (sl->spacetype != SPACE_SEQ) {
1200 ListBase *regionbase;
1202 if (sl == area->spacedata.first) {
1203 regionbase = &area->regionbase;
1206 regionbase = &sl->regionbase;
1209 for (region = regionbase->first; region; region = region->next) {
1210 if (region->regiontype == RGN_TYPE_PREVIEW) {
1215 if (region && (region->regiontype == RGN_TYPE_PREVIEW)) {
1216 SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ);
1217 BKE_area_region_free(st, region);
1218 BLI_freelinkN(regionbase, region);
1226 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 11)) {
1228 /* fix for new view type in sequencer */
1233 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1234 for (area = screen->areabase.first; area; area = area->next) {
1235 for (sl = area->spacedata.first; sl; sl = sl->next) {
1236 if (sl->spacetype == SPACE_SEQ) {
1238 ARegion *region_main;
1239 ListBase *regionbase;
1240 SpaceSeq *sseq = (SpaceSeq *)sl;
1242 if (sl == area->spacedata.first) {
1243 regionbase = &area->regionbase;
1246 regionbase = &sl->regionbase;
1249 if (sseq->view == 0) {
1250 sseq->view = SEQ_VIEW_SEQUENCE;
1252 if (sseq->mainb == 0) {
1253 sseq->mainb = SEQ_DRAW_IMG_IMBUF;
1256 region_main = (ARegion *)regionbase->first;
1257 for (; region_main; region_main = region_main->next) {
1258 if (region_main->regiontype == RGN_TYPE_WINDOW) {
1262 region = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
1263 BLI_insertlinkbefore(regionbase, region_main, region);
1264 sequencer_init_preview_region(region);
1272 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 12)) {
1276 /* anim viz changes */
1277 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1278 /* initialize object defaults */
1279 animviz_settings_init(&ob->avs);
1281 /* if armature, copy settings for pose from armature data
1282 * performing initialization where appropriate
1284 if (ob->pose && ob->data) {
1285 bArmature *arm = blo_do_versions_newlibadr(fd, lib, ob->data);
1286 if (arm) { /* XXX - why does this fail in some cases? */
1287 bAnimVizSettings *avs = &ob->pose->avs;
1289 /* path settings --------------------- */
1298 if (arm->pathflag & ARM_PATH_FNUMS) {
1299 avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS;
1301 if (arm->pathflag & ARM_PATH_KFRAS) {
1302 avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS;
1304 if (arm->pathflag & ARM_PATH_KFNOS) {
1305 avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS;
1309 if (arm->pathflag & ARM_PATH_HEADS) {
1310 avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS;
1314 if (arm->pathflag & ARM_PATH_ACFRA) {
1315 avs->path_type = MOTIONPATH_TYPE_ACFRA;
1322 animviz_settings_init(&ob->pose->avs);
1327 /* brush texture changes */
1328 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
1329 BKE_texture_mtex_default(&brush->mtex);
1330 BKE_texture_mtex_default(&brush->mask_mtex);
1334 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 13)) {
1335 /* NOTE: if you do more conversion, be sure to do it outside of this and
1336 * increase subversion again, otherwise it will not be correct */
1339 /* convert degrees to radians for internal use */
1340 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1341 bPoseChannel *pchan;
1343 do_version_constraints_radians_degrees_250(&ob->constraints);
1346 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1347 pchan->limitmin[0] *= (float)(M_PI / 180.0);
1348 pchan->limitmin[1] *= (float)(M_PI / 180.0);
1349 pchan->limitmin[2] *= (float)(M_PI / 180.0);
1350 pchan->limitmax[0] *= (float)(M_PI / 180.0);
1351 pchan->limitmax[1] *= (float)(M_PI / 180.0);
1352 pchan->limitmax[2] *= (float)(M_PI / 180.0);
1354 do_version_constraints_radians_degrees_250(&pchan->constraints);
1360 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 14)) {
1361 /* fix for bad View2D extents for Animation Editors */
1366 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1367 for (area = screen->areabase.first; area; area = area->next) {
1368 for (sl = area->spacedata.first; sl; sl = sl->next) {
1369 ListBase *regionbase;
1372 if (sl == area->spacedata.first) {
1373 regionbase = &area->regionbase;
1376 regionbase = &sl->regionbase;
1379 if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
1380 for (region = (ARegion *)regionbase->first; region; region = region->next) {
1381 if (region->regiontype == RGN_TYPE_WINDOW) {
1382 region->v2d.cur.ymax = region->v2d.tot.ymax = 0.0f;
1383 region->v2d.cur.ymin = region->v2d.tot.ymin = (float)(-area->winy) / 3.0f;
1392 if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 17)) {
1396 /* initialize to sane default so toggling on border shows something */
1397 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1398 if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f && sce->r.border.xmax == 0.0f &&
1399 sce->r.border.ymax == 0.0f) {
1400 sce->r.border.xmin = 0.0f;
1401 sce->r.border.ymin = 0.0f;
1402 sce->r.border.xmax = 1.0f;
1403 sce->r.border.ymax = 1.0f;
1406 if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) {
1407 sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
1410 SEQ_BEGIN (sce->ed, seq) {
1416 /* particle brush strength factor was changed from int to float */
1417 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1418 ParticleEditSettings *pset = &sce->toolsettings->particle;
1421 for (a = 0; a < ARRAY_SIZE(pset->brush); a++) {
1422 pset->brush[a].strength /= 100.0f;
1426 /* sequencer changes */
1432 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1433 for (area = screen->areabase.first; area; area = area->next) {
1434 for (sl = area->spacedata.first; sl; sl = sl->next) {
1435 if (sl->spacetype == SPACE_SEQ) {
1436 ARegion *region_preview;
1437 ListBase *regionbase;
1439 if (sl == area->spacedata.first) {
1440 regionbase = &area->regionbase;
1443 regionbase = &sl->regionbase;
1446 region_preview = (ARegion *)regionbase->first;
1447 for (; region_preview; region_preview = region_preview->next) {
1448 if (region_preview->regiontype == RGN_TYPE_PREVIEW) {
1452 if (region_preview && (region_preview->regiontype == RGN_TYPE_PREVIEW)) {
1453 sequencer_init_preview_region(region_preview);
1459 } /* sequencer changes */
1462 if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */
1465 /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_HIDE_OVERLAYS.
1466 * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated.
1467 * Here we clear it for old files so they don't come in with V3D_HIDE_OVERLAYS set,
1468 * which would cause cameras, lights, etc to become invisible */
1469 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1471 for (area = screen->areabase.first; area; area = area->next) {
1473 for (sl = area->spacedata.first; sl; sl = sl->next) {
1474 if (sl->spacetype == SPACE_VIEW3D) {
1475 View3D *v3d = (View3D *)sl;
1476 v3d->flag2 &= ~V3D_HIDE_OVERLAYS;
1483 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 1)) {
1489 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
1491 brush->curve->preset = CURVE_PRESET_SMOOTH;
1495 /* properly initialize active flag for fluidsim modifiers */
1496 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1498 for (md = ob->modifiers.first; md; md = md->next) {
1499 if (md->type == eModifierType_Fluidsim) {
1500 FluidsimModifierData *fmd = (FluidsimModifierData *)md;
1501 fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
1502 fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME;
1507 /* adjustment to color balance node values */
1508 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1509 if (scene->nodetree) {
1510 bNode *node = scene->nodetree->nodes.first;
1513 if (node->type == CMP_NODE_COLORBALANCE) {
1514 NodeColorBalance *n = (NodeColorBalance *)node->storage;
1523 /* check inside node groups too */
1524 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
1525 bNode *node = ntree->nodes.first;
1528 if (node->type == CMP_NODE_COLORBALANCE) {
1529 NodeColorBalance *n = (NodeColorBalance *)node->storage;
1540 /* old-track -> constraints (this time we're really doing it!) */
1541 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 2)) {
1544 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1545 blo_do_version_old_trackto_to_constraints(ob);
1549 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1552 /* Image editor scopes */
1553 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1556 for (area = screen->areabase.first; area; area = area->next) {
1559 for (sl = area->spacedata.first; sl; sl = sl->next) {
1560 if (sl->spacetype == SPACE_IMAGE) {
1561 SpaceImage *sima = (SpaceImage *)sl;
1562 BKE_scopes_new(&sima->scopes);
1569 if (bmain->versionfile < 253) {
1576 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1578 for (area = screen->areabase.first; area; area = area->next) {
1581 for (sl = area->spacedata.first; sl; sl = sl->next) {
1582 if (sl->spacetype == SPACE_NODE) {
1583 SpaceNode *snode = (SpaceNode *)sl;
1584 ListBase *regionbase;
1587 if (sl == area->spacedata.first) {
1588 regionbase = &area->regionbase;
1591 regionbase = &sl->regionbase;
1594 if (snode->v2d.minzoom > 0.09f) {
1595 snode->v2d.minzoom = 0.09f;
1597 if (snode->v2d.maxzoom < 2.31f) {
1598 snode->v2d.maxzoom = 2.31f;
1601 for (region = regionbase->first; region; region = region->next) {
1602 if (region->regiontype == RGN_TYPE_WINDOW) {
1603 if (region->v2d.minzoom > 0.09f) {
1604 region->v2d.minzoom = 0.09f;
1606 if (region->v2d.maxzoom < 2.31f) {
1607 region->v2d.maxzoom = 2.31f;
1616 do_version_mdef_250(bmain);
1618 /* parent type to modifier */
1619 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1621 Object *parent = (Object *)blo_do_versions_newlibadr(fd, lib, ob->parent);
1622 if (parent) { /* parent may not be in group */
1623 enum { PARCURVE = 1 };
1624 if (parent->type == OB_ARMATURE && ob->partype == PARSKEL) {
1625 ArmatureModifierData *amd;
1626 bArmature *arm = (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data);
1628 amd = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
1629 amd->object = ob->parent;
1630 BLI_addtail((ListBase *)&ob->modifiers, amd);
1631 amd->deformflag = arm->deformflag;
1632 ob->partype = PAROBJECT;
1634 else if (parent->type == OB_LATTICE && ob->partype == PARSKEL) {
1635 LatticeModifierData *lmd;
1637 lmd = (LatticeModifierData *)modifier_new(eModifierType_Lattice);
1638 lmd->object = ob->parent;
1639 BLI_addtail((ListBase *)&ob->modifiers, lmd);
1640 ob->partype = PAROBJECT;
1642 else if (parent->type == OB_CURVE && ob->partype == PARCURVE) {
1643 CurveModifierData *cmd;
1645 cmd = (CurveModifierData *)modifier_new(eModifierType_Curve);
1646 cmd->object = ob->parent;
1647 BLI_addtail((ListBase *)&ob->modifiers, cmd);
1648 ob->partype = PAROBJECT;
1654 /* initialize scene active layer */
1655 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1657 for (i = 0; i < 20; i++) {
1658 if (scene->lay & (1 << i)) {
1659 scene->layact = 1 << i;
1665 for (tex = bmain->textures.first; tex; tex = tex->id.next) {
1666 /* If you're picky, this isn't correct until we do a version bump
1667 * since you could set saturation to be 0.0. */
1668 if (tex->saturation == 0.0f) {
1669 tex->saturation = 1.0f;
1675 for (cu = bmain->curves.first; cu; cu = cu->id.next) {
1676 cu->smallcaps_scale = 0.75f;
1680 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1682 SEQ_BEGIN (scene->ed, seq) {
1683 if (seq->sat == 0.0f) {
1690 /* GSOC 2010 Sculpt - New settings for Brush */
1692 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
1695 /* infinite number of dabs */
1696 if (brush->spacing == 0) {
1697 brush->spacing = 10;
1700 /* will have no effect */
1701 if (brush->alpha == 0) {
1702 brush->alpha = 1.0f;
1706 if (brush->unprojected_radius == 0) {
1707 brush->unprojected_radius = 0.125f;
1711 if (brush->size == 0) {
1715 /* can't see overlay */
1716 if (brush->texture_overlay_alpha == 0) {
1717 brush->texture_overlay_alpha = 33;
1720 /* same as draw brush */
1721 if (brush->crease_pinch_factor == 0) {
1722 brush->crease_pinch_factor = 0.5f;
1725 /* will sculpt no vertexes */
1726 if (brush->plane_trim == 0) {
1727 brush->plane_trim = 0.5f;
1730 /* same as smooth stroke off */
1731 if (brush->smooth_stroke_radius == 0) {
1732 brush->smooth_stroke_radius = 75;
1735 /* will keep cursor in one spot */
1736 if (brush->smooth_stroke_radius == 1) {
1737 brush->smooth_stroke_factor = 0.9f;
1741 if (brush->rate == 0) {
1746 if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1747 brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space
1749 /* spacing was originally in pixels, convert it to percentage for new version
1750 * size should not be zero due to sanity check above
1752 brush->spacing = (int)(100 * ((float)brush->spacing) / ((float)brush->size));
1754 if (brush->add_col[0] == 0 && brush->add_col[1] == 0 && brush->add_col[2] == 0) {
1755 brush->add_col[0] = 1.00f;
1756 brush->add_col[1] = 0.39f;
1757 brush->add_col[2] = 0.39f;
1760 if (brush->sub_col[0] == 0 && brush->sub_col[1] == 0 && brush->sub_col[2] == 0) {
1761 brush->sub_col[0] = 0.39f;
1762 brush->sub_col[1] = 0.39f;
1763 brush->sub_col[2] = 1.00f;
1769 /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */
1770 if (bmain->versionfile < 253) {
1772 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1773 if (sce->toolsettings->sculpt_paint_unified_alpha == 0) {
1774 sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
1777 if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0) {
1778 sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f;
1781 if (sce->toolsettings->sculpt_paint_unified_size == 0) {
1782 sce->toolsettings->sculpt_paint_unified_size = 35;
1787 if (bmain->versionfile < 253 || (bmain->versionfile == 253 && bmain->subversionfile < 1)) {
1790 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1793 for (md = ob->modifiers.first; md; md = md->next) {
1794 if (md->type == eModifierType_Fluid) {
1795 FluidModifierData *mmd = (FluidModifierData *)md;
1797 if ((mmd->type & MOD_FLUID_TYPE_DOMAIN) && mmd->domain) {
1798 mmd->domain->vorticity = 2.0f;
1799 mmd->domain->time_scale = 1.0f;
1801 if (!(mmd->domain->flags & (1 << 4))) {
1805 /* delete old MOD_SMOKE_INITVELOCITY flag */
1806 mmd->domain->flags &= ~(1 << 4);
1808 /* for now just add it to all flow objects in the scene */
1811 for (ob2 = bmain->objects.first; ob2; ob2 = ob2->id.next) {
1813 for (md2 = ob2->modifiers.first; md2; md2 = md2->next) {
1814 if (md2->type == eModifierType_Fluid) {
1815 FluidModifierData *mmd2 = (FluidModifierData *)md2;
1817 if ((mmd2->type & MOD_FLUID_TYPE_FLOW) && mmd2->flow) {
1818 mmd2->flow->flags |= FLUID_FLOW_INITVELOCITY;
1825 else if ((mmd->type & MOD_FLUID_TYPE_FLOW) && mmd->flow) {
1826 mmd->flow->vel_multi = 1.0f;
1833 if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 1)) {
1835 ParticleSettings *part;
1838 for (br = bmain->brushes.first; br; br = br->id.next) {
1839 if (br->ob_mode == 0) {
1840 br->ob_mode = OB_MODE_ALL_PAINT;
1844 for (part = bmain->particles.first; part; part = part->id.next) {
1846 part->boids->pitch = 1.0f;
1849 part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
1850 part->kink_amp_clump = 1.f; /* keep old files looking similar */
1853 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1855 for (area = screen->areabase.first; area; area = area->next) {
1857 for (sl = area->spacedata.first; sl; sl = sl->next) {
1858 if (sl->spacetype == SPACE_INFO) {
1859 SpaceInfo *sinfo = (SpaceInfo *)sl;
1862 sinfo->rpt_mask = INFO_RPT_OP;
1864 for (region = area->regionbase.first; region; region = region->next) {
1865 if (region->regiontype == RGN_TYPE_WINDOW) {
1866 region->v2d.scroll = (V2D_SCROLL_RIGHT);
1867 region->v2d.align = V2D_ALIGN_NO_NEG_X |
1868 V2D_ALIGN_NO_NEG_Y; /* align bottom left */
1869 region->v2d.keepofs = V2D_LOCKOFS_X;
1870 region->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM |
1872 region->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
1873 region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
1882 if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 3)) {
1885 /* ocean res is now squared, reset old ones - will be massive */
1886 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1888 for (md = ob->modifiers.first; md; md = md->next) {
1889 if (md->type == eModifierType_Ocean) {
1890 OceanModifierData *omd = (OceanModifierData *)md;
1891 omd->resolution = 7;
1892 omd->oceancache = NULL;
1898 if (bmain->versionfile < 256) {
1903 /* Fix for sample line scope initializing with no height */
1904 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1905 area = screen->areabase.first;
1908 for (sl = area->spacedata.first; sl; sl = sl->next) {
1909 if (sl->spacetype == SPACE_IMAGE) {
1910 SpaceImage *sima = (SpaceImage *)sl;
1911 if (sima->sample_line_hist.height == 0) {
1912 sima->sample_line_hist.height = 100;
1920 /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in
1921 * 2.4x would never reveal this to users as a dummy value always ended up getting used
1924 for (key = bmain->shapekeys.first; key; key = key->id.next) {
1927 for (kb = key->block.first; kb; kb = kb->next) {
1928 if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f)) {
1929 kb->slidermax = kb->slidermin + 1.0f;
1935 if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 1)) {
1936 /* fix for bones that didn't have arm_roll before */
1941 for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
1942 for (bone = arm->bonebase.first; bone; bone = bone->next) {
1943 do_version_bone_roll_256(bone);
1947 /* fix for objects which have zero dquat's
1948 * since this is multiplied with the quat rather than added */
1949 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1950 if (is_zero_v4(ob->dquat)) {
1953 if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) {
1954 unit_axis_angle(ob->drotAxis, &ob->drotAngle);
1959 if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
1962 bNodeSocket *sock, *gsock;
1965 /* node sockets are not exposed automatically any more,
1966 * this mimics the old behavior by adding all unlinked sockets to groups.
1968 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
1969 /* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
1971 /* first make sure the own_index for new sockets is valid */
1972 for (node = ntree->nodes.first; node; node = node->next) {
1973 for (sock = node->inputs.first; sock; sock = sock->next) {
1974 if (sock->own_index >= ntree->cur_index) {
1975 ntree->cur_index = sock->own_index + 1;
1978 for (sock = node->outputs.first; sock; sock = sock->next) {
1979 if (sock->own_index >= ntree->cur_index) {
1980 ntree->cur_index = sock->own_index + 1;
1985 /* add ntree->inputs/ntree->outputs sockets for all unlinked sockets in the group tree. */
1986 for (node = ntree->nodes.first; node; node = node->next) {
1987 for (sock = node->inputs.first; sock; sock = sock->next) {
1988 if (!sock->link && !nodeSocketIsHidden(sock)) {
1990 gsock = do_versions_node_group_add_socket_2_56_2(
1991 ntree, sock->name, sock->type, SOCK_IN);
1993 /* initialize the default socket value */
1994 copy_v4_v4(gsock->ns.vec, sock->ns.vec);
1996 /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
1997 * have to create these directly here.
1998 * These links are updated again in subsequent do_version!
2000 link = MEM_callocN(sizeof(bNodeLink), "link");
2001 BLI_addtail(&ntree->links, link);
2002 link->fromnode = NULL;
2003 link->fromsock = gsock;
2004 link->tonode = node;
2005 link->tosock = sock;
2006 ntree->update |= NTREE_UPDATE_LINKS;
2011 for (sock = node->outputs.first; sock; sock = sock->next) {
2012 if (nodeCountSocketLinks(ntree, sock) == 0 && !nodeSocketIsHidden(sock)) {
2013 gsock = do_versions_node_group_add_socket_2_56_2(
2014 ntree, sock->name, sock->type, SOCK_OUT);
2016 /* initialize the default socket value */
2017 copy_v4_v4(gsock->ns.vec, sock->ns.vec);
2019 /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
2020 * have to create these directly here.
2021 * These links are updated again in subsequent do_version!
2023 link = MEM_callocN(sizeof(bNodeLink), "link");
2024 BLI_addtail(&ntree->links, link);
2025 link->fromnode = node;
2026 link->fromsock = sock;
2027 link->tonode = NULL;
2028 link->tosock = gsock;
2029 ntree->update |= NTREE_UPDATE_LINKS;
2036 /* External group node socket need to adjust their own_index to point at
2037 * associated 'ntree' inputs/outputs internal sockets. This happens in
2038 * do_versions_after_linking_250, after lib linking. */
2042 if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 3)) {
2046 ParticleSettings *part;
2048 /* redraws flag in SpaceTime has been moved to Screen level */
2049 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2050 if (screen->redraws_flag == 0) {
2051 /* just initialize to default? */
2052 /* XXX: we could also have iterated through areas,
2053 * and taken them from the first timeline available... */
2054 screen->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
2058 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
2059 if (brush->height == 0) {
2060 brush->height = 0.4f;
2064 /* replace 'rim material' option for in offset*/
2065 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
2067 for (md = ob->modifiers.first; md; md = md->next) {
2068 if (md->type == eModifierType_Solidify) {
2069 SolidifyModifierData *smd = (SolidifyModifierData *)md;
2070 if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
2071 smd->mat_ofs_rim = 1;
2072 smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
2078 /* particle draw color from material */
2079 for (part = bmain->particles.first; part; part = part->id.next) {
2080 if (part->draw & PART_DRAW_MAT_COL) {
2081 part->draw_col = PART_DRAW_COL_MAT;
2087 if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) {
2088 for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
2089 /* Vertex normal calculation from legacy 'MFace' has been removed.
2090 * update after calculating polygons in file reading code instead. */
2095 if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
2096 /* update blur area sizes from 0..1 range to 0..100 percentage */
2099 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
2100 if (scene->nodetree) {
2101 for (node = scene->nodetree->nodes.first; node; node = node->next) {
2102 if (node->type == CMP_NODE_BLUR) {
2103 NodeBlurData *nbd = node->storage;
2104 nbd->percentx *= 100.0f;
2105 nbd->percenty *= 100.0f;
2112 if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
2113 /* screen view2d settings were not properly initialized T27164.
2114 * v2d->scroll caused the bug but best reset other values too
2115 * which are in old blend files only.
2116 * Need to make less ugly - possibly an iterator? */
2119 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2122 for (area = screen->areabase.first; area; area = area->next) {
2123 SpaceLink *sl = area->spacedata.first;
2124 if (sl->spacetype == SPACE_IMAGE) {
2126 for (region = area->regionbase.first; region; region = region->next) {
2127 if (region->regiontype == RGN_TYPE_WINDOW) {
2128 View2D *v2d = ®ion->v2d;
2129 v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom =
2130 v2d->keepofs = v2d->align = 0;
2135 for (sl = area->spacedata.first; sl; sl = sl->next) {
2136 if (sl->spacetype == SPACE_IMAGE) {
2138 for (region = sl->regionbase.first; region; region = region->next) {
2139 if (region->regiontype == RGN_TYPE_WINDOW) {
2140 View2D *v2d = ®ion->v2d;
2141 v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom =
2142 v2d->keepofs = v2d->align = 0;
2151 ParticleSettings *part;
2152 for (part = bmain->particles.first; part; part = part->id.next) {
2153 /* Initialize particle billboard scale */
2154 part->bb_size[0] = part->bb_size[1] = 1.0f;
2159 if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
2164 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
2165 scene->r.ffcodecdata.audio_channels = 2;
2166 scene->audio.volume = 1.0f;
2167 SEQ_BEGIN (scene->ed, seq) {
2176 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2180 for (area = screen->areabase.first; area; area = area->next) {
2181 SpaceLink *sl = area->spacedata.first;
2182 if (sl->spacetype == SPACE_SEQ) {
2184 for (region = area->regionbase.first; region; region = region->next) {
2185 if (region->regiontype == RGN_TYPE_WINDOW) {
2186 if (region->v2d.min[1] == 4.0f) {
2187 region->v2d.min[1] = 0.5f;
2192 for (sl = area->spacedata.first; sl; sl = sl->next) {
2193 if (sl->spacetype == SPACE_SEQ) {
2195 for (region = sl->regionbase.first; region; region = region->next) {
2196 if (region->regiontype == RGN_TYPE_WINDOW) {
2197 if (region->v2d.min[1] == 4.0f) {
2198 region->v2d.min[1] = 0.5f;
2209 /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve
2211 * We're only patching F-Curves in Actions here, since it is assumed that most
2212 * drivers out there won't be using this (and if they are, they're in the minority).
2213 * While we should aim to fix everything ideally, in practice it's far too hard
2214 * to get to every animdata block, not to mention the performance hit that'd have
2219 for (act = bmain->actions.first; act; act = act->id.next) {
2220 for (fcu = act->curves.first; fcu; fcu = fcu->next) {
2224 /* only need to touch curves that had this flag set */
2225 if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0) {
2228 if ((fcu->totvert == 0) || (fcu->bezt == NULL)) {
2232 /* only change auto-handles to auto-clamped */
2233 for (bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
2234 if (bezt->h1 == HD_AUTO) {
2235 bezt->h1 = HD_AUTO_ANIM;
2237 if (bezt->h2 == HD_AUTO) {
2238 bezt->h2 = HD_AUTO_ANIM;
2242 fcu->flag &= ~FCURVE_AUTO_HANDLES;
2248 if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 2)) {
2250 /* Convert default socket values from bNodeStack */
2251 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2255 for (node = ntree->nodes.first; node; node = node->next) {
2256 for (sock = node->inputs.first; sock; sock = sock->next) {
2257 do_versions_socket_default_value_259(sock);
2259 for (sock = node->outputs.first; sock; sock = sock->next) {
2260 do_versions_socket_default_value_259(sock);
2264 for (sock = ntree->inputs.first; sock; sock = sock->next) {
2265 do_versions_socket_default_value_259(sock);
2267 for (sock = ntree->outputs.first; sock; sock = sock->next) {
2268 do_versions_socket_default_value_259(sock);
2271 ntree->update |= NTREE_UPDATE;
2273 FOREACH_NODETREE_END;
2277 /* Initialize group tree nodetypes.
2278 * These are used to distinguish tree types and
2279 * associate them with specific node types for polling.
2282 /* all node trees in bmain->nodetree are considered groups */
2283 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
2284 ntree->nodetype = NODE_GROUP;
2289 if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 4)) {
2291 /* Adaptive time step for particle systems */
2292 ParticleSettings *part;
2293 for (part = bmain->particles.first; part; part = part->id.next) {
2294 part->courant_target = 0.2f;
2295 part->time_flag &= ~PART_TIME_AUTOSF;
2301 /* updates group node socket identifier so that
2302 * external links to/from the group node are preserved.
2304 static void lib_node_do_versions_group_indices(bNode *gnode)
2306 bNodeTree *ngroup = (bNodeTree *)gnode->id;
2310 for (sock = gnode->outputs.first; sock; sock = sock->next) {
2311 int old_index = sock->to_index;
2313 for (link = ngroup->links.first; link; link = link->next) {
2314 if (link->tonode == NULL && link->fromsock->own_index == old_index) {
2315 strcpy(sock->identifier, link->fromsock->identifier);
2317 sock->own_index = link->fromsock->own_index;
2319 sock->groupsock = NULL;
2323 for (sock = gnode->inputs.first; sock; sock = sock->next) {
2324 int old_index = sock->to_index;
2326 for (link = ngroup->links.first; link; link = link->next) {
2327 if (link->fromnode == NULL && link->tosock->own_index == old_index) {
2328 strcpy(sock->identifier, link->tosock->identifier);
2330 sock->own_index = link->tosock->own_index;
2332 sock->groupsock = NULL;
2338 void do_versions_after_linking_250(Main *bmain)
2340 if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
2341 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2342 /* updates external links for all group nodes in a tree */
2344 for (node = ntree->nodes.first; node; node = node->next) {
2345 if (node->type == NODE_GROUP) {
2346 bNodeTree *ngroup = (bNodeTree *)node->id;
2348 lib_node_do_versions_group_indices(node);
2353 FOREACH_NODETREE_END;