Cleanup: Remove unwanted debug printf from 7293f6d4863a
[blender.git] / source / blender / blenloader / intern / versioning_270.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Blender Foundation
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  *
22  */
23
24 /** \file blender/blenloader/intern/versioning_270.c
25  *  \ingroup blenloader
26  */
27
28 #include "BLI_utildefines.h"
29 #include "BLI_compiler_attrs.h"
30
31 /* for MinGW32 definition of NULL, could use BLI_blenlib.h instead too */
32 #include <stddef.h>
33
34 /* allow readfile to use deprecated functionality */
35 #define DNA_DEPRECATED_ALLOW
36
37 #include "DNA_brush_types.h"
38 #include "DNA_camera_types.h"
39 #include "DNA_cloth_types.h"
40 #include "DNA_constraint_types.h"
41 #include "DNA_sdna_types.h"
42 #include "DNA_sequence_types.h"
43 #include "DNA_space_types.h"
44 #include "DNA_screen_types.h"
45 #include "DNA_object_types.h"
46 #include "DNA_mesh_types.h"
47 #include "DNA_modifier_types.h"
48 #include "DNA_particle_types.h"
49 #include "DNA_linestyle_types.h"
50 #include "DNA_actuator_types.h"
51
52 #include "DNA_genfile.h"
53
54 #include "BKE_main.h"
55 #include "BKE_modifier.h"
56 #include "BKE_node.h"
57 #include "BKE_sequencer.h"
58 #include "BKE_screen.h"
59
60 #include "BLI_math.h"
61 #include "BLI_listbase.h"
62 #include "BLI_string.h"
63
64 #include "BLO_readfile.h"
65
66 #include "readfile.h"
67
68 #include "MEM_guardedalloc.h"
69
70 static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
71 {
72         bConstraint *con;
73
74         for (con = lb->first; con; con = con->next) {
75                 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
76                         bTransformConstraint *data = (bTransformConstraint *)con->data;
77                         const float deg_to_rad_f = DEG2RADF(1.0f);
78
79                         if (data->from == TRANS_ROTATION) {
80                                 mul_v3_fl(data->from_min, deg_to_rad_f);
81                                 mul_v3_fl(data->from_max, deg_to_rad_f);
82                         }
83
84                         if (data->to == TRANS_ROTATION) {
85                                 mul_v3_fl(data->to_min, deg_to_rad_f);
86                                 mul_v3_fl(data->to_max, deg_to_rad_f);
87                         }
88                 }
89         }
90 }
91
92 static void do_version_constraints_radians_degrees_270_5(ListBase *lb)
93 {
94         bConstraint *con;
95
96         for (con = lb->first; con; con = con->next) {
97                 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
98                         bTransformConstraint *data = (bTransformConstraint *)con->data;
99
100                         if (data->from == TRANS_ROTATION) {
101                                 copy_v3_v3(data->from_min_rot, data->from_min);
102                                 copy_v3_v3(data->from_max_rot, data->from_max);
103                         }
104                         else if (data->from == TRANS_SCALE) {
105                                 copy_v3_v3(data->from_min_scale, data->from_min);
106                                 copy_v3_v3(data->from_max_scale, data->from_max);
107                         }
108
109                         if (data->to == TRANS_ROTATION) {
110                                 copy_v3_v3(data->to_min_rot, data->to_min);
111                                 copy_v3_v3(data->to_max_rot, data->to_max);
112                         }
113                         else if (data->to == TRANS_SCALE) {
114                                 copy_v3_v3(data->to_min_scale, data->to_min);
115                                 copy_v3_v3(data->to_max_scale, data->to_max);
116                         }
117                 }
118         }
119 }
120
121 static void do_version_constraints_stretch_to_limits(ListBase *lb)
122 {
123         bConstraint *con;
124
125         for (con = lb->first; con; con = con->next) {
126                 if (con->type == CONSTRAINT_TYPE_STRETCHTO) {
127                         bStretchToConstraint *data = (bStretchToConstraint *)con->data;
128                         data->bulge_min = 1.0f;
129                         data->bulge_max = 1.0f;
130                 }
131         }
132 }
133
134 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
135 {
136         if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
137
138                 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
139                         Object *ob;
140
141                         for (ob = main->object.first; ob; ob = ob->id.next) {
142                                 ModifierData *md;
143                                 for (md = ob->modifiers.first; md; md = md->next) {
144                                         if (md->type == eModifierType_Bevel) {
145                                                 BevelModifierData *bmd = (BevelModifierData *)md;
146                                                 bmd->profile = 0.5f;
147                                                 bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
148                                         }
149                                 }
150                         }
151                 }
152
153                 /* nodes don't use fixed node->id any more, clean up */
154                 FOREACH_NODETREE(main, ntree, id) {
155                         if (ntree->type == NTREE_COMPOSIT) {
156                                 bNode *node;
157                                 for (node = ntree->nodes.first; node; node = node->next) {
158                                         if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
159                                                 node->id = NULL;
160                                         }
161                                 }
162                         }
163                 } FOREACH_NODETREE_END
164
165                 {
166                         bScreen *screen;
167
168                         for (screen = main->screen.first; screen; screen = screen->id.next) {
169                                 ScrArea *area;
170                                 for (area = screen->areabase.first; area; area = area->next) {
171                                         SpaceLink *space_link;
172                                         for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
173                                                 if (space_link->spacetype == SPACE_CLIP) {
174                                                         SpaceClip *space_clip = (SpaceClip *) space_link;
175                                                         if (space_clip->mode != SC_MODE_MASKEDIT) {
176                                                                 space_clip->mode = SC_MODE_TRACKING;
177                                                         }
178                                                 }
179                                         }
180                                 }
181                         }
182                 }
183
184                 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
185                         MovieClip *clip;
186                         for (clip = main->movieclip.first; clip; clip = clip->id.next) {
187                                 clip->tracking.settings.default_weight = 1.0f;
188                         }
189                 }
190         }
191
192         if (!MAIN_VERSION_ATLEAST(main, 270, 1)) {
193                 Scene *sce;
194                 Object *ob;
195
196                 /* Update Transform constraint (another deg -> rad stuff). */
197                 for (ob = main->object.first; ob; ob = ob->id.next) {
198                         do_version_constraints_radians_degrees_270_1(&ob->constraints);
199
200                         if (ob->pose) {
201                                 /* Bones constraints! */
202                                 bPoseChannel *pchan;
203                                 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
204                                         do_version_constraints_radians_degrees_270_1(&pchan->constraints);
205                                 }
206                         }
207                 }
208
209                 for (sce = main->scene.first; sce; sce = sce->id.next) {
210                         if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) {
211                                 sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO;
212                         }
213                 }
214         }
215
216         if (!MAIN_VERSION_ATLEAST(main, 270, 2)) {
217                 Mesh *me;
218
219                 /* Mesh smoothresh deg->rad. */
220                 for (me = main->mesh.first; me; me = me->id.next) {
221                         me->smoothresh = DEG2RADF(me->smoothresh);
222                 }
223         }
224
225         if (!MAIN_VERSION_ATLEAST(main, 270, 3)) {
226                 FreestyleLineStyle *linestyle;
227
228                 for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
229                         linestyle->flag |= LS_NO_SORTING;
230                         linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
231                         linestyle->integration_type = LS_INTEGRATION_MEAN;
232                 }
233         }
234
235         if (!MAIN_VERSION_ATLEAST(main, 270, 4)) {
236                 /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
237                  * This will always reset situation to a valid state.
238                  */
239                 bScreen *sc;
240
241                 for (sc = main->screen.first; sc; sc = sc->id.next) {
242                         ScrArea *sa;
243                         for (sa = sc->areabase.first; sa; sa = sa->next) {
244                                 SpaceLink *sl;
245
246                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
247                                         ARegion *ar;
248                                         ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
249
250                                         for (ar = lb->first; ar; ar = ar->next) {
251                                                 BLI_listbase_clear(&ar->ui_previews);
252                                         }
253                                 }
254                         }
255                 }
256         }
257
258         if (!MAIN_VERSION_ATLEAST(main, 270, 5)) {
259                 Object *ob;
260
261                 /* Update Transform constraint (again :|). */
262                 for (ob = main->object.first; ob; ob = ob->id.next) {
263                         do_version_constraints_radians_degrees_270_5(&ob->constraints);
264
265                         if (ob->pose) {
266                                 /* Bones constraints! */
267                                 bPoseChannel *pchan;
268                                 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
269                                         do_version_constraints_radians_degrees_270_5(&pchan->constraints);
270                                 }
271                         }
272                 }
273         }
274
275         if (!MAIN_VERSION_ATLEAST(main, 271, 0)) {
276                 if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) {
277                         Material *ma;
278
279                         for (ma = main->mat.first; ma; ma = ma->id.next)
280                                 ma->mode2 = MA_CASTSHADOW;
281                 }
282
283                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
284                         Scene *sce;
285
286                         for (sce = main->scene.first; sce; sce = sce->id.next) {
287                                 sce->r.bake.flag = R_BAKE_CLEAR;
288                                 sce->r.bake.width = 512;
289                                 sce->r.bake.height = 512;
290                                 sce->r.bake.margin = 16;
291                                 sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
292                                 sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
293                                 sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
294                                 sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
295                                 BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
296
297                                 sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
298                                 sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
299                                 sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
300                                 sce->r.bake.im_format.quality = 90;
301                                 sce->r.bake.im_format.compress = 15;
302                         }
303                 }
304
305                 if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) {
306                         FreestyleLineStyle *linestyle;
307
308                         for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
309                                 linestyle->flag |= LS_TEXTURE;
310                                 linestyle->texstep = 1.0;
311                         }
312                 }
313
314                 {
315                         Scene *scene;
316                         for (scene = main->scene.first; scene; scene = scene->id.next) {
317                                 int num_layers = BLI_listbase_count(&scene->r.layers);
318                                 scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
319                         }
320                 }
321         }
322
323         if (!MAIN_VERSION_ATLEAST(main, 271, 1)) {
324                 if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) {
325                         Material *mat;
326
327                         for (mat = main->mat.first; mat; mat = mat->id.next) {
328                                 mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
329                                 mat->line_col[3] = mat->alpha;
330                         }
331                 }
332
333                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
334                         Scene *scene;
335                         for (scene = main->scene.first; scene; scene = scene->id.next) {
336                                 scene->r.preview_start_resolution = 64;
337                         }
338                 }
339         }
340
341         if (!MAIN_VERSION_ATLEAST(main, 271, 2)) {
342                 /* init up & track axis property of trackto actuators */
343                 Object *ob;
344
345                 for (ob = main->object.first; ob; ob = ob->id.next) {
346                         bActuator *act;
347                         for (act = ob->actuators.first; act; act = act->next) {
348                                 if (act->type == ACT_EDIT_OBJECT) {
349                                         bEditObjectActuator *eoact = act->data;
350                                         eoact->trackflag = ob->trackflag;
351                                         /* if trackflag is pointing +-Z axis then upflag should point Y axis.
352                                          * Rest of trackflag cases, upflag should be point z axis */
353                                         if ((ob->trackflag == OB_POSZ) || (ob->trackflag == OB_NEGZ)) {
354                                                 eoact->upflag = 1;
355                                         }
356                                         else {
357                                                 eoact->upflag = 2;
358                                         }
359                                 }
360                         }
361                 }
362         }
363
364         if (!MAIN_VERSION_ATLEAST(main, 271, 3)) {
365                 Brush *br;
366
367                 for (br = main->brush.first; br; br = br->id.next) {
368                         br->fill_threshold = 0.2f;
369                 }
370
371                 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "int", "mat")) {
372                         Object *ob;
373                         for (ob = main->object.first; ob; ob = ob->id.next) {
374                                 ModifierData *md;
375
376                                 for (md = ob->modifiers.first; md; md = md->next) {
377                                         if (md->type == eModifierType_Bevel) {
378                                                 BevelModifierData *bmd = (BevelModifierData *)md;
379                                                 bmd->mat = -1;
380                                         }
381                                 }
382                         }
383                 }
384         }
385
386         if (!MAIN_VERSION_ATLEAST(main, 271, 6)) {
387                 Object *ob;
388                 for (ob = main->object.first; ob; ob = ob->id.next) {
389                         ModifierData *md;
390
391                         for (md = ob->modifiers.first; md; md = md->next) {
392                                 if (md->type == eModifierType_ParticleSystem) {
393                                         ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
394                                         if (pmd->psys && pmd->psys->clmd) {
395                                                 pmd->psys->clmd->sim_parms->vel_damping = 1.0f;
396                                         }
397                                 }
398                         }
399                 }
400         }
401
402         if (!MAIN_VERSION_ATLEAST(main, 272, 0)) {
403                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
404                         Scene *scene;
405                         for (scene = main->scene.first; scene; scene = scene->id.next) {
406                                 scene->r.preview_start_resolution = 64;
407                         }
408                 }
409         }
410
411         if (!MAIN_VERSION_ATLEAST(main, 272, 1)) {
412                 Brush *br;
413                 for (br = main->brush.first; br; br = br->id.next) {
414                         if ((br->ob_mode & OB_MODE_SCULPT) && ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
415                                 br->alpha = 1.0f;
416                 }
417         }
418
419         if (!MAIN_VERSION_ATLEAST(main, 272, 2)) {
420                 if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
421                         Image *image;
422                         for (image = main->image.first; image != NULL; image = image->id.next) {
423                                 image->gen_color[3] = 1.0f;
424                         }
425                 }
426
427                 if (!DNA_struct_elem_find(fd->filesdna, "bStretchToConstraint", "float", "bulge_min")) {
428                         Object *ob;
429
430                         /* Update Transform constraint (again :|). */
431                         for (ob = main->object.first; ob; ob = ob->id.next) {
432                                 do_version_constraints_stretch_to_limits(&ob->constraints);
433
434                                 if (ob->pose) {
435                                         /* Bones constraints! */
436                                         bPoseChannel *pchan;
437                                         for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
438                                                 do_version_constraints_stretch_to_limits(&pchan->constraints);
439                                         }
440                                 }
441                         }
442                 }
443         }
444
445         if (!MAIN_VERSION_ATLEAST(main, 273, 1)) {
446 #define BRUSH_RAKE (1 << 7)
447 #define BRUSH_RANDOM_ROTATION (1 << 25)
448
449                 Brush *br;
450
451                 for (br = main->brush.first; br; br = br->id.next) {
452                         if (br->flag & BRUSH_RAKE) {
453                                 br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
454                                 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
455                         }
456                         else if (br->flag & BRUSH_RANDOM_ROTATION) {
457                                 br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
458                                 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
459                         }
460                         br->mtex.random_angle = 2.0 * M_PI;
461                         br->mask_mtex.random_angle = 2.0 * M_PI;
462                 }
463
464 #undef BRUSH_RAKE
465 #undef BRUSH_RANDOM_ROTATION
466         }
467
468         /* Customizable Safe Areas */
469         if (!MAIN_VERSION_ATLEAST(main, 273, 2)) {
470                 if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) {
471                         Scene *scene;
472
473                         for (scene = main->scene.first; scene; scene = scene->id.next) {
474                                 copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f);
475                                 copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f);
476                                 copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f);
477                                 copy_v2_fl2(scene->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
478                         }
479                 }
480         }
481         
482         if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
483                 ParticleSettings *part;
484                 for (part = main->particle.first; part; part = part->id.next) {
485                         if (part->clumpcurve)
486                                 part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
487                         if (part->roughcurve)
488                                 part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
489                 }
490         }
491
492         if (!MAIN_VERSION_ATLEAST(main, 273, 6)) {
493                 if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
494                         Object *ob;
495                         ModifierData *md;
496                         for (ob = main->object.first; ob; ob = ob->id.next) {
497                                 for (md = ob->modifiers.first; md; md = md->next) {
498                                         if (md->type == eModifierType_Cloth) {
499                                                 ClothModifierData *clmd = (ClothModifierData *)md;
500                                                 clmd->sim_parms->bending_damping = 0.5f;
501                                         }
502                                         else if (md->type == eModifierType_ParticleSystem) {
503                                                 ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
504                                                 if (pmd->psys->clmd) {
505                                                         pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
506                                                 }
507                                         }
508                                 }
509                         }
510                 }
511
512                 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
513                         ParticleSettings *part;
514                         for (part = main->particle.first; part; part = part->id.next) {
515                                 part->clump_noise_size = 1.0f;
516                         }
517                 }
518
519                 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
520                         ParticleSettings *part;
521                         for (part = main->particle.first; part; part = part->id.next) {
522                                 part->kink_extra_steps = 4;
523                         }
524                 }
525
526                 if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
527                         ParticleSettings *part;
528                         for (part = main->particle.first; part; part = part->id.next) {
529                                 int a;
530                                 for (a = 0; a < MAX_MTEX; a++) {
531                                         MTex *mtex = part->mtex[a];
532                                         if (mtex) {
533                                                 mtex->kinkampfac = 1.0f;
534                                         }
535                                 }
536                         }
537                 }
538
539                 if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
540                         Object *ob;
541
542                         for (ob = main->object.first; ob; ob = ob->id.next) {
543                                 ModifierData *md;
544                                 for (md = ob->modifiers.first; md; md = md->next) {
545                                         if (md->type == eModifierType_Hook) {
546                                                 HookModifierData *hmd = (HookModifierData *)md;
547                                                 hmd->falloff_type = eHook_Falloff_InvSquare;
548                                         }
549                                 }
550                         }
551                 }
552
553                 if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
554                         FOREACH_NODETREE(main, ntree, id) {
555                                 if (ntree->type == NTREE_COMPOSIT) {
556                                         bNode *node;
557                                         for (node = ntree->nodes.first; node; node = node->next) {
558                                                 if (ELEM(node->type, CMP_NODE_PLANETRACKDEFORM)) {
559                                                         NodePlaneTrackDeformData *data = node->storage;
560                                                         data->flag = 0;
561                                                         data->motion_blur_samples = 16;
562                                                         data->motion_blur_shutter = 0.5f;
563                                                 }
564                                         }
565                                 }
566                         }
567                         FOREACH_NODETREE_END
568                 }
569
570                 if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
571                         Camera *ca;
572                         for (ca = main->camera.first; ca; ca = ca->id.next) {
573                                 ca->gpu_dof.fstop = 128.0f;
574                                 ca->gpu_dof.focal_length = 1.0f;
575                                 ca->gpu_dof.focus_distance = 1.0f;
576                                 ca->gpu_dof.sensor = 1.0f;
577                         }
578                 }
579         }
580
581         if (!MAIN_VERSION_ATLEAST(main, 273, 7)) {
582                 bScreen *scr;
583                 ScrArea *sa;
584                 SpaceLink *sl;
585                 ARegion *ar;
586
587                 for (scr = main->screen.first; scr; scr = scr->id.next) {
588                         /* Remove old deprecated region from filebrowsers */
589                         for (sa = scr->areabase.first; sa; sa = sa->next) {
590                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
591                                         if (sl->spacetype == SPACE_FILE) {
592                                                 for (ar = sl->regionbase.first; ar; ar = ar->next) {
593                                                         if (ar->regiontype == RGN_TYPE_CHANNELS) {
594                                                                 break;
595                                                         }
596                                                 }
597
598                                                 if (ar) {
599                                                         /* Free old deprecated 'channel' region... */
600                                                         BKE_area_region_free(NULL, ar);
601                                                         BLI_freelinkN(&sl->regionbase, ar);
602                                                 }
603                                         }
604                                 }
605                         }
606                 }
607         }
608
609         if (!MAIN_VERSION_ATLEAST(main, 273, 8)) {
610                 Object *ob;
611                 for (ob = main->object.first; ob != NULL; ob = ob->id.next) {
612                         ModifierData *md;
613                         for (md = ob->modifiers.last; md != NULL; md = md->prev) {
614                                 if (modifier_unique_name(&ob->modifiers, md)) {
615                                         printf("Warning: Object '%s' had several modifiers with the "
616                                                "same name, renamed one of them to '%s'.\n",
617                                                ob->id.name + 2, md->name);
618                                 }
619                         }
620                 }
621         }
622
623         if (!MAIN_VERSION_ATLEAST(main, 273, 9)) {
624                 bScreen *scr;
625                 ScrArea *sa;
626                 SpaceLink *sl;
627                 ARegion *ar;
628
629                 /* Make sure sequencer preview area limits zoom */
630                 for (scr = main->screen.first; scr; scr = scr->id.next) {
631                         for (sa = scr->areabase.first; sa; sa = sa->next) {
632                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
633                                         if (sl->spacetype == SPACE_SEQ) {
634                                                 for (ar = sl->regionbase.first; ar; ar = ar->next) {
635                                                         if (ar->regiontype == RGN_TYPE_PREVIEW) {
636                                                                 ar->v2d.keepzoom |= V2D_LIMITZOOM;
637                                                                 ar->v2d.minzoom = 0.001f;
638                                                                 ar->v2d.maxzoom = 1000.0f;
639                                                                 break;
640                                                         }
641                                                 }
642                                         }
643                                 }
644                         }
645                 }
646         }
647
648         if (!MAIN_VERSION_ATLEAST(main, 274, 1)) {
649                 /* particle systems need to be forced to redistribute for jitter mode fix */
650                 {
651                         Object *ob;
652                         ParticleSystem *psys;
653                         for (ob = main->object.first; ob; ob = ob->id.next) {
654                                 for (psys = ob->particlesystem.first; psys; psys = psys->next) {
655                                         psys->recalc |= PSYS_RECALC_RESET;
656                                 }
657                         }
658                 }
659
660                 /* hysteresis setted to 10% but not actived */
661                 if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
662                         Object *ob;
663                         for (ob = main->object.first; ob; ob = ob->id.next) {
664                                 LodLevel *level;
665                                 for (level = ob->lodlevels.first; level; level = level->next) {
666                                         level->obhysteresis = 10;
667                                 }
668                         }
669                 }
670
671                 if (!DNA_struct_elem_find(fd->filesdna, "GameData", "int", "scehysteresis")) {
672                         Scene *scene;
673                         for (scene = main->scene.first; scene; scene = scene->id.next) {
674                                 scene->gm.scehysteresis = 10;
675                         }
676                 }
677         }
678
679         if (!MAIN_VERSION_ATLEAST(main, 274, 2)) {
680                 FOREACH_NODETREE(main, ntree, id) {
681                         bNode *node;
682                         bNodeSocket *sock;
683
684                         for (node = ntree->nodes.first; node; node = node->next) {
685                                 if (node->type == SH_NODE_MATERIAL) {
686                                         for (sock = node->inputs.first; sock; sock = sock->next) {
687                                                 if (STREQ(sock->name, "Refl")) {
688                                                         BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
689                                                 }
690                                         }
691                                 }
692                                 else if (node->type == SH_NODE_MATERIAL_EXT) {
693                                         for (sock = node->outputs.first; sock; sock = sock->next) {
694                                                 if (STREQ(sock->name, "Refl")) {
695                                                         BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
696                                                 }
697                                                 else if (STREQ(sock->name, "Ray Mirror")) {
698                                                         BLI_strncpy(sock->name, "Reflectivity", sizeof(sock->name));
699                                                 }
700                                         }
701                                 }
702                         }
703                 } FOREACH_NODETREE_END
704         }
705
706         if (!DNA_struct_elem_find(fd->filesdna, "Sequence", "char", "storage")) {
707                 Scene *scene;
708                 Sequence *seq;
709
710 #define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
711 #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
712
713                 for (scene = main->scene.first; scene; scene = scene->id.next) {
714                         SEQ_BEGIN (scene->ed, seq) {
715                                 if (seq->strip && seq->strip->proxy) {
716                                         if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
717                                                 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
718                                         if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
719                                                 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
720                                 }
721                         }
722                         SEQ_END
723                 }
724 #undef SEQ_USE_PROXY_CUSTOM_DIR
725 #undef SEQ_USE_PROXY_CUSTOM_FILE
726         }
727 }