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