Boolean Modifier: Add back BMesh option
[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_armature_types.h"
38 #include "DNA_brush_types.h"
39 #include "DNA_camera_types.h"
40 #include "DNA_cloth_types.h"
41 #include "DNA_constraint_types.h"
42 #include "DNA_gpencil_types.h"
43 #include "DNA_sdna_types.h"
44 #include "DNA_sequence_types.h"
45 #include "DNA_space_types.h"
46 #include "DNA_screen_types.h"
47 #include "DNA_object_force.h"
48 #include "DNA_object_types.h"
49 #include "DNA_mesh_types.h"
50 #include "DNA_modifier_types.h"
51 #include "DNA_particle_types.h"
52 #include "DNA_linestyle_types.h"
53 #include "DNA_actuator_types.h"
54 #include "DNA_view3d_types.h"
55
56 #include "DNA_genfile.h"
57
58 #include "BKE_colortools.h"
59 #include "BKE_library.h"
60 #include "BKE_main.h"
61 #include "BKE_modifier.h"
62 #include "BKE_node.h"
63 #include "BKE_scene.h"
64 #include "BKE_sequencer.h"
65 #include "BKE_screen.h"
66
67 #include "BLI_math.h"
68 #include "BLI_listbase.h"
69 #include "BLI_string.h"
70
71 #include "BLO_readfile.h"
72
73 #include "readfile.h"
74
75 #include "MEM_guardedalloc.h"
76
77 static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
78 {
79         bConstraint *con;
80
81         for (con = lb->first; con; con = con->next) {
82                 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
83                         bTransformConstraint *data = (bTransformConstraint *)con->data;
84                         const float deg_to_rad_f = DEG2RADF(1.0f);
85
86                         if (data->from == TRANS_ROTATION) {
87                                 mul_v3_fl(data->from_min, deg_to_rad_f);
88                                 mul_v3_fl(data->from_max, deg_to_rad_f);
89                         }
90
91                         if (data->to == TRANS_ROTATION) {
92                                 mul_v3_fl(data->to_min, deg_to_rad_f);
93                                 mul_v3_fl(data->to_max, deg_to_rad_f);
94                         }
95                 }
96         }
97 }
98
99 static void do_version_constraints_radians_degrees_270_5(ListBase *lb)
100 {
101         bConstraint *con;
102
103         for (con = lb->first; con; con = con->next) {
104                 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
105                         bTransformConstraint *data = (bTransformConstraint *)con->data;
106
107                         if (data->from == TRANS_ROTATION) {
108                                 copy_v3_v3(data->from_min_rot, data->from_min);
109                                 copy_v3_v3(data->from_max_rot, data->from_max);
110                         }
111                         else if (data->from == TRANS_SCALE) {
112                                 copy_v3_v3(data->from_min_scale, data->from_min);
113                                 copy_v3_v3(data->from_max_scale, data->from_max);
114                         }
115
116                         if (data->to == TRANS_ROTATION) {
117                                 copy_v3_v3(data->to_min_rot, data->to_min);
118                                 copy_v3_v3(data->to_max_rot, data->to_max);
119                         }
120                         else if (data->to == TRANS_SCALE) {
121                                 copy_v3_v3(data->to_min_scale, data->to_min);
122                                 copy_v3_v3(data->to_max_scale, data->to_max);
123                         }
124                 }
125         }
126 }
127
128 static void do_version_constraints_stretch_to_limits(ListBase *lb)
129 {
130         bConstraint *con;
131
132         for (con = lb->first; con; con = con->next) {
133                 if (con->type == CONSTRAINT_TYPE_STRETCHTO) {
134                         bStretchToConstraint *data = (bStretchToConstraint *)con->data;
135                         data->bulge_min = 1.0f;
136                         data->bulge_max = 1.0f;
137                 }
138         }
139 }
140
141 static void do_version_action_editor_properties_region(ListBase *regionbase)
142 {
143         ARegion *ar;
144         
145         for (ar = regionbase->first; ar; ar = ar->next) {
146                 if (ar->regiontype == RGN_TYPE_UI) {
147                         /* already exists */
148                         return;
149                 }
150                 else if (ar->regiontype == RGN_TYPE_WINDOW) {
151                         /* add new region here */
152                         ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
153                         
154                         BLI_insertlinkbefore(regionbase, ar, arnew);
155                         
156                         arnew->regiontype = RGN_TYPE_UI;
157                         arnew->alignment = RGN_ALIGN_RIGHT;
158                         arnew->flag = RGN_FLAG_HIDDEN;
159                         
160                         return;
161                 }
162         }
163 }
164
165 static void do_version_bones_super_bbone(ListBase *lb)
166 {
167         for (Bone *bone = lb->first; bone; bone = bone->next) {
168                 bone->scaleIn = 1.0f;
169                 bone->scaleOut = 1.0f;
170                 
171                 do_version_bones_super_bbone(&bone->childbase);
172         }
173 }
174
175 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
176 {
177         if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
178
179                 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
180                         Object *ob;
181
182                         for (ob = main->object.first; ob; ob = ob->id.next) {
183                                 ModifierData *md;
184                                 for (md = ob->modifiers.first; md; md = md->next) {
185                                         if (md->type == eModifierType_Bevel) {
186                                                 BevelModifierData *bmd = (BevelModifierData *)md;
187                                                 bmd->profile = 0.5f;
188                                                 bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
189                                         }
190                                 }
191                         }
192                 }
193
194                 /* nodes don't use fixed node->id any more, clean up */
195                 FOREACH_NODETREE(main, ntree, id) {
196                         if (ntree->type == NTREE_COMPOSIT) {
197                                 bNode *node;
198                                 for (node = ntree->nodes.first; node; node = node->next) {
199                                         if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
200                                                 node->id = NULL;
201                                         }
202                                 }
203                         }
204                 } FOREACH_NODETREE_END
205
206                 {
207                         bScreen *screen;
208
209                         for (screen = main->screen.first; screen; screen = screen->id.next) {
210                                 ScrArea *area;
211                                 for (area = screen->areabase.first; area; area = area->next) {
212                                         SpaceLink *space_link;
213                                         for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
214                                                 if (space_link->spacetype == SPACE_CLIP) {
215                                                         SpaceClip *space_clip = (SpaceClip *) space_link;
216                                                         if (space_clip->mode != SC_MODE_MASKEDIT) {
217                                                                 space_clip->mode = SC_MODE_TRACKING;
218                                                         }
219                                                 }
220                                         }
221                                 }
222                         }
223                 }
224
225                 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
226                         MovieClip *clip;
227                         for (clip = main->movieclip.first; clip; clip = clip->id.next) {
228                                 clip->tracking.settings.default_weight = 1.0f;
229                         }
230                 }
231         }
232
233         if (!MAIN_VERSION_ATLEAST(main, 270, 1)) {
234                 Scene *sce;
235                 Object *ob;
236
237                 /* Update Transform constraint (another deg -> rad stuff). */
238                 for (ob = main->object.first; ob; ob = ob->id.next) {
239                         do_version_constraints_radians_degrees_270_1(&ob->constraints);
240
241                         if (ob->pose) {
242                                 /* Bones constraints! */
243                                 bPoseChannel *pchan;
244                                 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
245                                         do_version_constraints_radians_degrees_270_1(&pchan->constraints);
246                                 }
247                         }
248                 }
249
250                 for (sce = main->scene.first; sce; sce = sce->id.next) {
251                         if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) {
252                                 sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO;
253                         }
254                 }
255         }
256
257         if (!MAIN_VERSION_ATLEAST(main, 270, 2)) {
258                 Mesh *me;
259
260                 /* Mesh smoothresh deg->rad. */
261                 for (me = main->mesh.first; me; me = me->id.next) {
262                         me->smoothresh = DEG2RADF(me->smoothresh);
263                 }
264         }
265
266         if (!MAIN_VERSION_ATLEAST(main, 270, 3)) {
267                 FreestyleLineStyle *linestyle;
268
269                 for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
270                         linestyle->flag |= LS_NO_SORTING;
271                         linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
272                         linestyle->integration_type = LS_INTEGRATION_MEAN;
273                 }
274         }
275
276         if (!MAIN_VERSION_ATLEAST(main, 270, 4)) {
277                 /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
278                  * This will always reset situation to a valid state.
279                  */
280                 bScreen *sc;
281
282                 for (sc = main->screen.first; sc; sc = sc->id.next) {
283                         ScrArea *sa;
284                         for (sa = sc->areabase.first; sa; sa = sa->next) {
285                                 SpaceLink *sl;
286
287                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
288                                         ARegion *ar;
289                                         ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
290
291                                         for (ar = lb->first; ar; ar = ar->next) {
292                                                 BLI_listbase_clear(&ar->ui_previews);
293                                         }
294                                 }
295                         }
296                 }
297         }
298
299         if (!MAIN_VERSION_ATLEAST(main, 270, 5)) {
300                 Object *ob;
301
302                 /* Update Transform constraint (again :|). */
303                 for (ob = main->object.first; ob; ob = ob->id.next) {
304                         do_version_constraints_radians_degrees_270_5(&ob->constraints);
305
306                         if (ob->pose) {
307                                 /* Bones constraints! */
308                                 bPoseChannel *pchan;
309                                 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
310                                         do_version_constraints_radians_degrees_270_5(&pchan->constraints);
311                                 }
312                         }
313                 }
314         }
315
316         if (!MAIN_VERSION_ATLEAST(main, 271, 0)) {
317                 if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) {
318                         Material *ma;
319
320                         for (ma = main->mat.first; ma; ma = ma->id.next)
321                                 ma->mode2 = MA_CASTSHADOW;
322                 }
323
324                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
325                         Scene *sce;
326
327                         for (sce = main->scene.first; sce; sce = sce->id.next) {
328                                 sce->r.bake.flag = R_BAKE_CLEAR;
329                                 sce->r.bake.width = 512;
330                                 sce->r.bake.height = 512;
331                                 sce->r.bake.margin = 16;
332                                 sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
333                                 sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
334                                 sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
335                                 sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
336                                 BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
337
338                                 sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
339                                 sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
340                                 sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
341                                 sce->r.bake.im_format.quality = 90;
342                                 sce->r.bake.im_format.compress = 15;
343                         }
344                 }
345
346                 if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) {
347                         FreestyleLineStyle *linestyle;
348
349                         for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
350                                 linestyle->flag |= LS_TEXTURE;
351                                 linestyle->texstep = 1.0;
352                         }
353                 }
354
355                 {
356                         Scene *scene;
357                         for (scene = main->scene.first; scene; scene = scene->id.next) {
358                                 int num_layers = BLI_listbase_count(&scene->r.layers);
359                                 scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
360                         }
361                 }
362         }
363
364         if (!MAIN_VERSION_ATLEAST(main, 271, 1)) {
365                 if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) {
366                         Material *mat;
367
368                         for (mat = main->mat.first; mat; mat = mat->id.next) {
369                                 mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
370                                 mat->line_col[3] = mat->alpha;
371                         }
372                 }
373
374                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
375                         Scene *scene;
376                         for (scene = main->scene.first; scene; scene = scene->id.next) {
377                                 scene->r.preview_start_resolution = 64;
378                         }
379                 }
380         }
381
382         if (!MAIN_VERSION_ATLEAST(main, 271, 2)) {
383                 /* init up & track axis property of trackto actuators */
384                 Object *ob;
385
386                 for (ob = main->object.first; ob; ob = ob->id.next) {
387                         bActuator *act;
388                         for (act = ob->actuators.first; act; act = act->next) {
389                                 if (act->type == ACT_EDIT_OBJECT) {
390                                         bEditObjectActuator *eoact = act->data;
391                                         eoact->trackflag = ob->trackflag;
392                                         /* if trackflag is pointing +-Z axis then upflag should point Y axis.
393                                          * Rest of trackflag cases, upflag should be point z axis */
394                                         if ((ob->trackflag == OB_POSZ) || (ob->trackflag == OB_NEGZ)) {
395                                                 eoact->upflag = 1;
396                                         }
397                                         else {
398                                                 eoact->upflag = 2;
399                                         }
400                                 }
401                         }
402                 }
403         }
404
405         if (!MAIN_VERSION_ATLEAST(main, 271, 3)) {
406                 Brush *br;
407
408                 for (br = main->brush.first; br; br = br->id.next) {
409                         br->fill_threshold = 0.2f;
410                 }
411
412                 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "int", "mat")) {
413                         Object *ob;
414                         for (ob = main->object.first; ob; ob = ob->id.next) {
415                                 ModifierData *md;
416
417                                 for (md = ob->modifiers.first; md; md = md->next) {
418                                         if (md->type == eModifierType_Bevel) {
419                                                 BevelModifierData *bmd = (BevelModifierData *)md;
420                                                 bmd->mat = -1;
421                                         }
422                                 }
423                         }
424                 }
425         }
426
427         if (!MAIN_VERSION_ATLEAST(main, 271, 6)) {
428                 Object *ob;
429                 for (ob = main->object.first; ob; ob = ob->id.next) {
430                         ModifierData *md;
431
432                         for (md = ob->modifiers.first; md; md = md->next) {
433                                 if (md->type == eModifierType_ParticleSystem) {
434                                         ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
435                                         if (pmd->psys && pmd->psys->clmd) {
436                                                 pmd->psys->clmd->sim_parms->vel_damping = 1.0f;
437                                         }
438                                 }
439                         }
440                 }
441         }
442
443         if (!MAIN_VERSION_ATLEAST(main, 272, 0)) {
444                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
445                         Scene *scene;
446                         for (scene = main->scene.first; scene; scene = scene->id.next) {
447                                 scene->r.preview_start_resolution = 64;
448                         }
449                 }
450         }
451
452         if (!MAIN_VERSION_ATLEAST(main, 272, 1)) {
453                 Brush *br;
454                 for (br = main->brush.first; br; br = br->id.next) {
455                         if ((br->ob_mode & OB_MODE_SCULPT) && ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
456                                 br->alpha = 1.0f;
457                 }
458         }
459
460         if (!MAIN_VERSION_ATLEAST(main, 272, 2)) {
461                 if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
462                         Image *image;
463                         for (image = main->image.first; image != NULL; image = image->id.next) {
464                                 image->gen_color[3] = 1.0f;
465                         }
466                 }
467
468                 if (!DNA_struct_elem_find(fd->filesdna, "bStretchToConstraint", "float", "bulge_min")) {
469                         Object *ob;
470
471                         /* Update Transform constraint (again :|). */
472                         for (ob = main->object.first; ob; ob = ob->id.next) {
473                                 do_version_constraints_stretch_to_limits(&ob->constraints);
474
475                                 if (ob->pose) {
476                                         /* Bones constraints! */
477                                         bPoseChannel *pchan;
478                                         for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
479                                                 do_version_constraints_stretch_to_limits(&pchan->constraints);
480                                         }
481                                 }
482                         }
483                 }
484         }
485
486         if (!MAIN_VERSION_ATLEAST(main, 273, 1)) {
487 #define BRUSH_RAKE (1 << 7)
488 #define BRUSH_RANDOM_ROTATION (1 << 25)
489
490                 Brush *br;
491
492                 for (br = main->brush.first; br; br = br->id.next) {
493                         if (br->flag & BRUSH_RAKE) {
494                                 br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
495                                 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
496                         }
497                         else if (br->flag & BRUSH_RANDOM_ROTATION) {
498                                 br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
499                                 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
500                         }
501                         br->mtex.random_angle = 2.0 * M_PI;
502                         br->mask_mtex.random_angle = 2.0 * M_PI;
503                 }
504         }
505
506 #undef BRUSH_RAKE
507 #undef BRUSH_RANDOM_ROTATION
508
509         /* Customizable Safe Areas */
510         if (!MAIN_VERSION_ATLEAST(main, 273, 2)) {
511                 if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) {
512                         Scene *scene;
513
514                         for (scene = main->scene.first; scene; scene = scene->id.next) {
515                                 copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f);
516                                 copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f);
517                                 copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f);
518                                 copy_v2_fl2(scene->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
519                         }
520                 }
521         }
522         
523         if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
524                 ParticleSettings *part;
525                 for (part = main->particle.first; part; part = part->id.next) {
526                         if (part->clumpcurve)
527                                 part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
528                         if (part->roughcurve)
529                                 part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
530                 }
531         }
532
533         if (!MAIN_VERSION_ATLEAST(main, 273, 6)) {
534                 if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
535                         Object *ob;
536                         ModifierData *md;
537                         for (ob = main->object.first; ob; ob = ob->id.next) {
538                                 for (md = ob->modifiers.first; md; md = md->next) {
539                                         if (md->type == eModifierType_Cloth) {
540                                                 ClothModifierData *clmd = (ClothModifierData *)md;
541                                                 clmd->sim_parms->bending_damping = 0.5f;
542                                         }
543                                         else if (md->type == eModifierType_ParticleSystem) {
544                                                 ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
545                                                 if (pmd->psys->clmd) {
546                                                         pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
547                                                 }
548                                         }
549                                 }
550                         }
551                 }
552
553                 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
554                         ParticleSettings *part;
555                         for (part = main->particle.first; part; part = part->id.next) {
556                                 part->clump_noise_size = 1.0f;
557                         }
558                 }
559
560                 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
561                         ParticleSettings *part;
562                         for (part = main->particle.first; part; part = part->id.next) {
563                                 part->kink_extra_steps = 4;
564                         }
565                 }
566
567                 if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
568                         ParticleSettings *part;
569                         for (part = main->particle.first; part; part = part->id.next) {
570                                 int a;
571                                 for (a = 0; a < MAX_MTEX; a++) {
572                                         MTex *mtex = part->mtex[a];
573                                         if (mtex) {
574                                                 mtex->kinkampfac = 1.0f;
575                                         }
576                                 }
577                         }
578                 }
579
580                 if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
581                         Object *ob;
582
583                         for (ob = main->object.first; ob; ob = ob->id.next) {
584                                 ModifierData *md;
585                                 for (md = ob->modifiers.first; md; md = md->next) {
586                                         if (md->type == eModifierType_Hook) {
587                                                 HookModifierData *hmd = (HookModifierData *)md;
588                                                 hmd->falloff_type = eHook_Falloff_InvSquare;
589                                         }
590                                 }
591                         }
592                 }
593
594                 if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
595                         FOREACH_NODETREE(main, ntree, id) {
596                                 if (ntree->type == NTREE_COMPOSIT) {
597                                         bNode *node;
598                                         for (node = ntree->nodes.first; node; node = node->next) {
599                                                 if (ELEM(node->type, CMP_NODE_PLANETRACKDEFORM)) {
600                                                         NodePlaneTrackDeformData *data = node->storage;
601                                                         data->flag = 0;
602                                                         data->motion_blur_samples = 16;
603                                                         data->motion_blur_shutter = 0.5f;
604                                                 }
605                                         }
606                                 }
607                         }
608                         FOREACH_NODETREE_END
609                 }
610
611                 if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
612                         Camera *ca;
613                         for (ca = main->camera.first; ca; ca = ca->id.next) {
614                                 ca->gpu_dof.fstop = 128.0f;
615                                 ca->gpu_dof.focal_length = 1.0f;
616                                 ca->gpu_dof.focus_distance = 1.0f;
617                                 ca->gpu_dof.sensor = 1.0f;
618                         }
619                 }
620         }
621
622         if (!MAIN_VERSION_ATLEAST(main, 273, 8)) {
623                 Object *ob;
624                 for (ob = main->object.first; ob != NULL; ob = ob->id.next) {
625                         ModifierData *md;
626                         for (md = ob->modifiers.last; md != NULL; md = md->prev) {
627                                 if (modifier_unique_name(&ob->modifiers, md)) {
628                                         printf("Warning: Object '%s' had several modifiers with the "
629                                                "same name, renamed one of them to '%s'.\n",
630                                                ob->id.name + 2, md->name);
631                                 }
632                         }
633                 }
634         }
635
636         if (!MAIN_VERSION_ATLEAST(main, 273, 9)) {
637                 bScreen *scr;
638                 ScrArea *sa;
639                 SpaceLink *sl;
640                 ARegion *ar;
641
642                 /* Make sure sequencer preview area limits zoom */
643                 for (scr = main->screen.first; scr; scr = scr->id.next) {
644                         for (sa = scr->areabase.first; sa; sa = sa->next) {
645                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
646                                         if (sl->spacetype == SPACE_SEQ) {
647                                                 for (ar = sl->regionbase.first; ar; ar = ar->next) {
648                                                         if (ar->regiontype == RGN_TYPE_PREVIEW) {
649                                                                 ar->v2d.keepzoom |= V2D_LIMITZOOM;
650                                                                 ar->v2d.minzoom = 0.001f;
651                                                                 ar->v2d.maxzoom = 1000.0f;
652                                                                 break;
653                                                         }
654                                                 }
655                                         }
656                                 }
657                         }
658                 }
659         }
660
661         if (!MAIN_VERSION_ATLEAST(main, 274, 1)) {
662                 /* particle systems need to be forced to redistribute for jitter mode fix */
663                 {
664                         Object *ob;
665                         ParticleSystem *psys;
666                         for (ob = main->object.first; ob; ob = ob->id.next) {
667                                 for (psys = ob->particlesystem.first; psys; psys = psys->next) {
668                                         if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) {
669                                                 psys->recalc |= PSYS_RECALC_RESET;
670                                         }
671                                 }
672                         }
673                 }
674
675                 /* hysteresis setted to 10% but not actived */
676                 if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
677                         Object *ob;
678                         for (ob = main->object.first; ob; ob = ob->id.next) {
679                                 LodLevel *level;
680                                 for (level = ob->lodlevels.first; level; level = level->next) {
681                                         level->obhysteresis = 10;
682                                 }
683                         }
684                 }
685
686                 if (!DNA_struct_elem_find(fd->filesdna, "GameData", "int", "scehysteresis")) {
687                         Scene *scene;
688                         for (scene = main->scene.first; scene; scene = scene->id.next) {
689                                 scene->gm.scehysteresis = 10;
690                         }
691                 }
692         }
693
694         if (!MAIN_VERSION_ATLEAST(main, 274, 2)) {
695                 FOREACH_NODETREE(main, ntree, id) {
696                         bNode *node;
697                         bNodeSocket *sock;
698
699                         for (node = ntree->nodes.first; node; node = node->next) {
700                                 if (node->type == SH_NODE_MATERIAL) {
701                                         for (sock = node->inputs.first; sock; sock = sock->next) {
702                                                 if (STREQ(sock->name, "Refl")) {
703                                                         BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
704                                                 }
705                                         }
706                                 }
707                                 else if (node->type == SH_NODE_MATERIAL_EXT) {
708                                         for (sock = node->outputs.first; sock; sock = sock->next) {
709                                                 if (STREQ(sock->name, "Refl")) {
710                                                         BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
711                                                 }
712                                                 else if (STREQ(sock->name, "Ray Mirror")) {
713                                                         BLI_strncpy(sock->name, "Reflectivity", sizeof(sock->name));
714                                                 }
715                                         }
716                                 }
717                         }
718                 } FOREACH_NODETREE_END
719         }
720
721         if (!MAIN_VERSION_ATLEAST(main, 274, 4)) {
722                 SceneRenderView *srv;
723                 wmWindowManager *wm;
724                 bScreen *screen;
725                 wmWindow *win;
726                 Scene *scene;
727                 Camera *cam;
728                 Image *ima;
729
730                 for (scene = main->scene.first; scene; scene = scene->id.next) {
731                         Sequence *seq;
732
733                         BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
734                         srv = scene->r.views.first;
735                         BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
736
737                         BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
738                         srv = scene->r.views.last;
739                         BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
740
741                         SEQ_BEGIN (scene->ed, seq)
742                         {
743                                 seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
744
745 #define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
746 #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
747                                 if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) {
748                                         if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
749                                                 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
750                                         if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
751                                                 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
752                                 }
753 #undef SEQ_USE_PROXY_CUSTOM_DIR
754 #undef SEQ_USE_PROXY_CUSTOM_FILE
755
756                         }
757                         SEQ_END
758                 }
759
760                 for (screen = main->screen.first; screen; screen = screen->id.next) {
761                         ScrArea *sa;
762                         for (sa = screen->areabase.first; sa; sa = sa->next) {
763                                 SpaceLink *sl;
764
765                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
766                                         switch (sl->spacetype) {
767                                                 case SPACE_VIEW3D:
768                                                 {
769                                                         View3D *v3d = (View3D *)sl;
770                                                         v3d->stereo3d_camera = STEREO_3D_ID;
771                                                         v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
772                                                         v3d->stereo3d_convergence_alpha = 0.15f;
773                                                         v3d->stereo3d_volume_alpha = 0.05f;
774                                                         break;
775                                                 }
776                                                 case SPACE_IMAGE:
777                                                 {
778                                                         SpaceImage *sima = (SpaceImage *) sl;
779                                                         sima->iuser.flag |= IMA_SHOW_STEREO;
780                                                         break;
781                                                 }
782                                         }
783                                 }
784                         }
785                 }
786
787                 for (cam = main->camera.first; cam; cam = cam->id.next) {
788                         cam->stereo.interocular_distance = 0.065f;
789                         cam->stereo.convergence_distance = 30.0f * 0.065f;
790                 }
791
792                 for (ima = main->image.first; ima; ima = ima->id.next) {
793                         ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format");
794
795                         if (ima->packedfile) {
796                                 ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed File");
797                                 BLI_addtail(&ima->packedfiles, imapf);
798
799                                 imapf->packedfile = ima->packedfile;
800                                 BLI_strncpy(imapf->filepath, ima->name, FILE_MAX);
801                                 ima->packedfile = NULL;
802                         }
803                 }
804
805                 for (wm = main->wm.first; wm; wm = wm->id.next) {
806                         for (win = wm->windows.first; win; win = win->next) {
807                                 win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
808                         }
809                 }
810         }
811
812         if (!MAIN_VERSION_ATLEAST(main, 274, 6)) {
813                 bScreen *screen;
814
815                 if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) {
816                         for (screen = main->screen.first; screen; screen = screen->id.next) {
817                                 ScrArea *sa;
818
819                                 for (sa = screen->areabase.first; sa; sa = sa->next) {
820                                         SpaceLink *sl;
821
822                                         for (sl = sa->spacedata.first; sl; sl = sl->next) {
823                                                 if (sl->spacetype == SPACE_FILE) {
824                                                         SpaceFile *sfile = (SpaceFile *)sl;
825
826                                                         if (sfile->params) {
827                                                                 sfile->params->thumbnail_size = 128;
828                                                         }
829                                                 }
830                                         }
831                                 }
832                         }
833                 }
834
835                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) {
836                         Scene *scene;
837                         for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
838                                 scene->r.simplify_subsurf_render = scene->r.simplify_subsurf;
839                                 scene->r.simplify_particles_render = scene->r.simplify_particles;
840                         }
841                 }
842
843                 if (!DNA_struct_elem_find(fd->filesdna, "DecimateModifierData", "float", "defgrp_factor")) {
844                         Object *ob;
845
846                         for (ob = main->object.first; ob; ob = ob->id.next) {
847                                 ModifierData *md;
848                                 for (md = ob->modifiers.first; md; md = md->next) {
849                                         if (md->type == eModifierType_Decimate) {
850                                                 DecimateModifierData *dmd = (DecimateModifierData *)md;
851                                                 dmd->defgrp_factor = 1.0f;
852                                         }
853                                 }
854                         }
855                 }
856         }
857
858         if (!MAIN_VERSION_ATLEAST(main, 275, 3)) {
859                 Brush *br;
860 #define BRUSH_TORUS (1 << 1)
861                 for (br = main->brush.first; br; br = br->id.next) {
862                         br->flag &= ~BRUSH_TORUS;
863                 }
864 #undef BRUSH_TORUS
865         }
866
867         if (!MAIN_VERSION_ATLEAST(main, 276, 2)) {
868                 if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) {
869                         Object *ob;
870
871                         for (ob = main->object.first; ob; ob = ob->id.next) {
872                                 if (ob->pose) {
873                                         bPoseChannel *pchan;
874                                         for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
875                                                 pchan->custom_scale = 1.0f;
876                                         }
877                                 }
878                         }
879                 }
880
881                 {
882                         bScreen *screen;
883 #define RV3D_VIEW_PERSPORTHO     7
884                         for (screen = main->screen.first; screen; screen = screen->id.next) {
885                                 ScrArea *sa;
886                                 for (sa = screen->areabase.first; sa; sa = sa->next) {
887                                         SpaceLink *sl;
888                                         for (sl = sa->spacedata.first; sl; sl = sl->next) {
889                                                 if (sl->spacetype == SPACE_VIEW3D) {
890                                                         ARegion *ar;
891                                                         ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
892                                                         for (ar = lb->first; ar; ar = ar->next) {
893                                                                 if (ar->regiontype == RGN_TYPE_WINDOW) {
894                                                                         if (ar->regiondata) {
895                                                                                 RegionView3D *rv3d = ar->regiondata;
896                                                                                 if (rv3d->view == RV3D_VIEW_PERSPORTHO) {
897                                                                                         rv3d->view = RV3D_VIEW_USER;
898                                                                                 }
899                                                                         }
900                                                                 }
901                                                         }
902                                                         break;
903                                                 }
904                                         }
905                                 }
906                         }
907 #undef RV3D_VIEW_PERSPORTHO
908                 }
909
910                 {
911                         Lamp *lamp;
912 #define LA_YF_PHOTON    5
913                         for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
914                                 if (lamp->type == LA_YF_PHOTON) {
915                                         lamp->type = LA_LOCAL;
916                                 }
917                         }
918 #undef LA_YF_PHOTON
919                 }
920
921                 {
922                         Object *ob;
923                         for (ob = main->object.first; ob; ob = ob->id.next) {
924                                 if (ob->body_type == OB_BODY_TYPE_CHARACTER && (ob->gameflag & OB_BOUNDS) && ob->collision_boundtype == OB_BOUND_TRIANGLE_MESH) {
925                                         ob->boundtype = ob->collision_boundtype = OB_BOUND_BOX;
926                                 }
927                         }
928                 }
929
930         }
931
932         if (!MAIN_VERSION_ATLEAST(main, 276, 3)) {
933                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "CurveMapping", "mblur_shutter_curve")) {
934                         Scene *scene;
935                         for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
936                                 CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
937                                 curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
938                                 curvemapping_initialize(curve_mapping);
939                                 curvemap_reset(curve_mapping->cm,
940                                                &curve_mapping->clipr,
941                                                CURVE_PRESET_MAX,
942                                                CURVEMAP_SLOPE_POS_NEG);
943                         }
944                 }
945         }
946
947         if (!MAIN_VERSION_ATLEAST(main, 276, 4)) {
948                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
949                         ToolSettings *ts = scene->toolsettings;
950                         
951                         if (ts->gp_sculpt.brush[0].size == 0) {
952                                 GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
953                                 GP_EditBrush_Data *brush;
954                                 
955                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH];
956                                 brush->size = 25;
957                                 brush->strength = 0.3f;
958                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE;
959                                 
960                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS];
961                                 brush->size = 25;
962                                 brush->strength = 0.5f;
963                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
964                                 
965                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB];
966                                 brush->size = 50;
967                                 brush->strength = 0.3f;
968                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
969                                 
970                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH];
971                                 brush->size = 25;
972                                 brush->strength = 0.3f;
973                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
974                                 
975                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST];
976                                 brush->size = 50;
977                                 brush->strength = 0.3f; // XXX?
978                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
979                                 
980                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH];
981                                 brush->size = 50;
982                                 brush->strength = 0.5f; // XXX?
983                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
984                                 
985                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMIZE];
986                                 brush->size = 25;
987                                 brush->strength = 0.5f;
988                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
989                                 
990                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_CLONE];
991                                 brush->size = 50;
992                                 brush->strength = 1.0f;
993                         }
994                         
995                         if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "gpencil_v3d_align")) {
996 #if 0 /* XXX: Cannot do this, as we get random crashes... */
997                                 if (scene->gpd) {
998                                         bGPdata *gpd = scene->gpd;
999                                         
1000                                         /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */
1001                                         ts->gpencil_v3d_align = 0;
1002                                         
1003                                         if (gpd->flag & GP_DATA_VIEWALIGN)    ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE;
1004                                         if (gpd->flag & GP_DATA_DEPTH_VIEW)   ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW;
1005                                         if (gpd->flag & GP_DATA_DEPTH_STROKE) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE;
1006                                         
1007                                         if (gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS)
1008                                                 ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE_ENDPOINTS;
1009                                 }
1010                                 else {
1011                                         /* Default to cursor for all standard 3D views */
1012                                         ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
1013                                 }
1014 #endif
1015                                 
1016                                 ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
1017                                 ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE;
1018                                 ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
1019                                 ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
1020                         }
1021                 }
1022                 
1023                 for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
1024                         bool enabled = false;
1025                         
1026                         /* Ensure that the datablock's onionskinning toggle flag
1027                          * stays in sync with the status of the actual layers
1028                          */
1029                         for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
1030                                 if (gpl->flag & GP_LAYER_ONIONSKIN) {
1031                                         enabled = true;
1032                                 }
1033                         }
1034                         
1035                         if (enabled)
1036                                 gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
1037                         else
1038                                 gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
1039                 }
1040
1041                 if (!DNA_struct_elem_find(fd->filesdna, "Object", "unsigned char", "max_jumps")) {
1042                         for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1043                                 ob->max_jumps = 1;
1044                         }
1045                 }
1046         }
1047         if (!MAIN_VERSION_ATLEAST(main, 276, 5)) {
1048                 ListBase *lbarray[MAX_LIBARRAY];
1049                 int a;
1050
1051                 /* Important to clear all non-persistent flags from older versions here, otherwise they could collide
1052                  * with any new persistent flag we may add in the future. */
1053                 a = set_listbasepointers(main, lbarray);
1054                 while (a--) {
1055                         for (ID *id = lbarray[a]->first; id; id = id->next) {
1056                                 id->flag &= LIB_FAKEUSER;
1057                         }
1058                 }
1059         }
1060
1061         if (!MAIN_VERSION_ATLEAST(main, 276, 7)) {
1062                 Scene *scene;
1063                 for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1064                         scene->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL;
1065                 }
1066         }
1067
1068         if (!MAIN_VERSION_ATLEAST(main, 277, 1)) {
1069                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1070                         ParticleEditSettings *pset = &scene->toolsettings->particle;
1071                         for (int a = 0; a < PE_TOT_BRUSH; a++) {
1072                                 if (pset->brush[a].strength > 1.0f) {
1073                                         pset->brush[a].strength *= 0.01f;
1074                                 }
1075                         }
1076                 }
1077
1078                 /* init grease pencil smooth level iterations */
1079                 for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
1080                         for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
1081                                 if (gpl->draw_smoothlvl == 0) {
1082                                         gpl->draw_smoothlvl = 1;
1083                                 }
1084                         }
1085                 }
1086
1087                 for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
1088                         for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
1089                                 for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
1090                                         ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
1091                                         /* Bug: Was possible to add preview region to sequencer view by using AZones. */
1092                                         if (sl->spacetype == SPACE_SEQ) {
1093                                                 SpaceSeq *sseq = (SpaceSeq *)sl;
1094                                                 if (sseq->view == SEQ_VIEW_SEQUENCE) {
1095                                                         for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
1096                                                                 /* remove preview region for sequencer-only view! */
1097                                                                 if (ar->regiontype == RGN_TYPE_PREVIEW) {
1098                                                                         ar->flag |= RGN_FLAG_HIDDEN;
1099                                                                         ar->alignment = RGN_ALIGN_NONE;
1100                                                                         break;
1101                                                                 }
1102                                                         }
1103                                                 }
1104                                         }
1105                                         /* Remove old deprecated region from filebrowsers */
1106                                         else if (sl->spacetype == SPACE_FILE) {
1107                                                 for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
1108                                                         if (ar->regiontype == RGN_TYPE_CHANNELS) {
1109                                                                 /* Free old deprecated 'channel' region... */
1110                                                                 BKE_area_region_free(NULL, ar);
1111                                                                 BLI_freelinkN(regionbase, ar);
1112                                                                 break;
1113                                                         }
1114                                                 }
1115                                         }
1116                                 }
1117                         }
1118                 }
1119
1120                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1121                         CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings;
1122                         if (cps->error_threshold == 0) {
1123                                 cps->curve_type = CU_BEZIER;
1124                                 cps->flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
1125                                 cps->error_threshold = 8;
1126                                 cps->radius_max = 1.0f;
1127                                 cps->corner_angle = DEG2RADF(70.0f);
1128                         }
1129                 }
1130
1131                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1132                         Sequence *seq;
1133
1134                         SEQ_BEGIN (scene->ed, seq)
1135                         {
1136                                 if (seq->type == SEQ_TYPE_TEXT) {
1137                                         TextVars *data = seq->effectdata;
1138                                         if (data->color[3] == 0.0f) {
1139                                                 copy_v4_fl(data->color, 1.0f);
1140                                                 data->shadow_color[3] = 1.0f;
1141                                         }
1142                                 }
1143                         }
1144                         SEQ_END
1145                 }
1146
1147                 /* Adding "Properties" region to DopeSheet */
1148                 for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
1149                         for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
1150                                 /* handle pushed-back space data first */
1151                                 for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
1152                                         if (sl->spacetype == SPACE_ACTION) {
1153                                                 SpaceAction *saction = (SpaceAction *)sl;
1154                                                 do_version_action_editor_properties_region(&saction->regionbase);
1155                                         }
1156                                 }
1157                                 
1158                                 /* active spacedata info must be handled too... */
1159                                 if (sa->spacetype == SPACE_ACTION) {
1160                                         do_version_action_editor_properties_region(&sa->regionbase);
1161                                 }
1162                         }
1163                 }
1164         }
1165
1166         if (!MAIN_VERSION_ATLEAST(main, 277, 2)) {
1167                 if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scaleIn")) {
1168                         for (bArmature *arm = main->armature.first; arm; arm = arm->id.next) {
1169                                 do_version_bones_super_bbone(&arm->bonebase);
1170                         }
1171                 }
1172                 if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) {
1173                         for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1174                                 if (ob->pose) {
1175                                         for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1176                                                 /* see do_version_bones_super_bbone()... */
1177                                                 pchan->scaleIn = 1.0f;
1178                                                 pchan->scaleOut = 1.0f;
1179                                                 
1180                                                 /* also make sure some legacy (unused for over a decade) flags are unset,
1181                                                  * so that we can reuse them for stuff that matters now...
1182                                                  * (i.e. POSE_IK_MAT, (unknown/unused x 4), POSE_HAS_IK)
1183                                                  *
1184                                                  * These seem to have been runtime flags used by the IK solver, but that stuff
1185                                                  * should be able to be recalculated automatically anyway, so it should be fine.
1186                                                  */
1187                                                 pchan->flag &= ~((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8));
1188                                         }
1189                                 }
1190                         }
1191                 }
1192
1193                 for (Camera *camera = main->camera.first; camera != NULL; camera = camera->id.next) {
1194                         if (camera->stereo.pole_merge_angle_from == 0.0f &&
1195                             camera->stereo.pole_merge_angle_to == 0.0f)
1196                         {
1197                                 camera->stereo.pole_merge_angle_from = DEG2RAD(60.0f);
1198                                 camera->stereo.pole_merge_angle_to = DEG2RAD(75.0f);
1199                         }
1200                 }
1201
1202                 if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) {
1203                         Object *ob;
1204
1205                         for (ob = main->object.first; ob; ob = ob->id.next) {
1206                                 ModifierData *md;
1207                                 for (md = ob->modifiers.first; md; md = md->next) {
1208                                         if (md->type == eModifierType_NormalEdit) {
1209                                                 NormalEditModifierData *nemd = (NormalEditModifierData *)md;
1210                                                 nemd->mix_limit = DEG2RADF(180.0f);
1211                                         }
1212                                 }
1213                         }
1214                 }
1215
1216                 if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) {
1217                         Object *ob;
1218                         for (ob = main->object.first; ob; ob = ob->id.next) {
1219                                 ModifierData *md;
1220                                 for (md = ob->modifiers.first; md; md = md->next) {
1221                                         if (md->type == eModifierType_Boolean) {
1222                                                 BooleanModifierData *bmd = (BooleanModifierData *)md;
1223                                                 bmd->double_threshold = 1e-6f;
1224                                         }
1225                                 }
1226                         }
1227                 }
1228         }
1229 }