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