87ccfedcff3830ed84daf205fad8d5e6a4d7c694
[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_anim_types.h"
38 #include "DNA_armature_types.h"
39 #include "DNA_brush_types.h"
40 #include "DNA_camera_types.h"
41 #include "DNA_cloth_types.h"
42 #include "DNA_constraint_types.h"
43 #include "DNA_gpencil_types.h"
44 #include "DNA_sdna_types.h"
45 #include "DNA_sequence_types.h"
46 #include "DNA_space_types.h"
47 #include "DNA_screen_types.h"
48 #include "DNA_object_force.h"
49 #include "DNA_object_types.h"
50 #include "DNA_mask_types.h"
51 #include "DNA_mesh_types.h"
52 #include "DNA_modifier_types.h"
53 #include "DNA_particle_types.h"
54 #include "DNA_linestyle_types.h"
55 #include "DNA_actuator_types.h"
56 #include "DNA_view3d_types.h"
57 #include "DNA_smoke_types.h"
58 #include "DNA_rigidbody_types.h"
59
60 #include "DNA_genfile.h"
61
62 #include "BKE_animsys.h"
63 #include "BKE_colortools.h"
64 #include "BKE_library.h"
65 #include "BKE_main.h"
66 #include "BKE_mask.h"
67 #include "BKE_modifier.h"
68 #include "BKE_node.h"
69 #include "BKE_scene.h"
70 #include "BKE_sequencer.h"
71 #include "BKE_screen.h"
72 #include "BKE_tracking.h"
73 #include "BKE_gpencil.h"
74
75 #include "BLI_math.h"
76 #include "BLI_listbase.h"
77 #include "BLI_string.h"
78
79 #include "BLO_readfile.h"
80
81 #include "NOD_common.h"
82 #include "NOD_socket.h"
83 #include "NOD_composite.h"
84
85 #include "readfile.h"
86
87 #include "MEM_guardedalloc.h"
88
89 /**
90  * Setup rotation stabilization from ancient single track spec.
91  * Former Version of 2D stabilization used a single tracking marker to determine the rotation
92  * to be compensated. Now several tracks can contribute to rotation detection and this feature
93  * is enabled by the MovieTrackingTrack#flag on a per track base.
94  */
95 static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabilization *stab)
96 {
97         if (stab->rot_track) {
98                 if (!(stab->rot_track->flag & TRACK_USE_2D_STAB_ROT)) {
99                         stab->tot_rot_track++;
100                         stab->rot_track->flag |= TRACK_USE_2D_STAB_ROT;
101                 }
102         }
103         stab->rot_track = NULL; /* this field is now ignored */
104 }
105
106 static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
107 {
108         bConstraint *con;
109
110         for (con = lb->first; con; con = con->next) {
111                 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
112                         bTransformConstraint *data = (bTransformConstraint *)con->data;
113                         const float deg_to_rad_f = DEG2RADF(1.0f);
114
115                         if (data->from == TRANS_ROTATION) {
116                                 mul_v3_fl(data->from_min, deg_to_rad_f);
117                                 mul_v3_fl(data->from_max, deg_to_rad_f);
118                         }
119
120                         if (data->to == TRANS_ROTATION) {
121                                 mul_v3_fl(data->to_min, deg_to_rad_f);
122                                 mul_v3_fl(data->to_max, deg_to_rad_f);
123                         }
124                 }
125         }
126 }
127
128 static void do_version_constraints_radians_degrees_270_5(ListBase *lb)
129 {
130         bConstraint *con;
131
132         for (con = lb->first; con; con = con->next) {
133                 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
134                         bTransformConstraint *data = (bTransformConstraint *)con->data;
135
136                         if (data->from == TRANS_ROTATION) {
137                                 copy_v3_v3(data->from_min_rot, data->from_min);
138                                 copy_v3_v3(data->from_max_rot, data->from_max);
139                         }
140                         else if (data->from == TRANS_SCALE) {
141                                 copy_v3_v3(data->from_min_scale, data->from_min);
142                                 copy_v3_v3(data->from_max_scale, data->from_max);
143                         }
144
145                         if (data->to == TRANS_ROTATION) {
146                                 copy_v3_v3(data->to_min_rot, data->to_min);
147                                 copy_v3_v3(data->to_max_rot, data->to_max);
148                         }
149                         else if (data->to == TRANS_SCALE) {
150                                 copy_v3_v3(data->to_min_scale, data->to_min);
151                                 copy_v3_v3(data->to_max_scale, data->to_max);
152                         }
153                 }
154         }
155 }
156
157 static void do_version_constraints_stretch_to_limits(ListBase *lb)
158 {
159         bConstraint *con;
160
161         for (con = lb->first; con; con = con->next) {
162                 if (con->type == CONSTRAINT_TYPE_STRETCHTO) {
163                         bStretchToConstraint *data = (bStretchToConstraint *)con->data;
164                         data->bulge_min = 1.0f;
165                         data->bulge_max = 1.0f;
166                 }
167         }
168 }
169
170 static void do_version_action_editor_properties_region(ListBase *regionbase)
171 {
172         ARegion *ar;
173         
174         for (ar = regionbase->first; ar; ar = ar->next) {
175                 if (ar->regiontype == RGN_TYPE_UI) {
176                         /* already exists */
177                         return;
178                 }
179                 else if (ar->regiontype == RGN_TYPE_WINDOW) {
180                         /* add new region here */
181                         ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
182                         
183                         BLI_insertlinkbefore(regionbase, ar, arnew);
184                         
185                         arnew->regiontype = RGN_TYPE_UI;
186                         arnew->alignment = RGN_ALIGN_RIGHT;
187                         arnew->flag = RGN_FLAG_HIDDEN;
188                         
189                         return;
190                 }
191         }
192 }
193
194 static void do_version_bones_super_bbone(ListBase *lb)
195 {
196         for (Bone *bone = lb->first; bone; bone = bone->next) {
197                 bone->scaleIn = 1.0f;
198                 bone->scaleOut = 1.0f;
199                 
200                 do_version_bones_super_bbone(&bone->childbase);
201         }
202 }
203
204 /* TODO(sergey): Consider making it somewhat more generic function in BLI_anim.h. */
205 static void anim_change_prop_name(FCurve *fcu,
206                                   const char *prefix,
207                                   const char *old_prop_name,
208                                   const char *new_prop_name)
209 {
210         const char *old_path = BLI_sprintfN("%s.%s", prefix, old_prop_name);
211         if (STREQ(fcu->rna_path, old_path)) {
212                 MEM_freeN(fcu->rna_path);
213                 fcu->rna_path = BLI_sprintfN("%s.%s", prefix, new_prop_name);
214         }
215         MEM_freeN((char *)old_path);
216 }
217
218 static void do_version_hue_sat_node(bNodeTree *ntree, bNode *node)
219 {
220         if (node->storage == NULL) {
221                 return;
222         }
223
224         /* Make sure new sockets are properly created. */
225         node_verify_socket_templates(ntree, node);
226         /* Convert value from old storage to new sockets. */
227         NodeHueSat *nhs = node->storage;
228         bNodeSocket *hue = nodeFindSocket(node, SOCK_IN, "Hue"),
229                     *saturation = nodeFindSocket(node, SOCK_IN, "Saturation"),
230                     *value = nodeFindSocket(node, SOCK_IN, "Value");
231         ((bNodeSocketValueFloat *)hue->default_value)->value = nhs->hue;
232         ((bNodeSocketValueFloat *)saturation->default_value)->value = nhs->sat;
233         ((bNodeSocketValueFloat *)value->default_value)->value = nhs->val;
234         /* Take care of possible animation. */
235         AnimData *adt = BKE_animdata_from_id(&ntree->id);
236         if (adt != NULL && adt->action != NULL) {
237                 const char *prefix = BLI_sprintfN("nodes[\"%s\"]", node->name);
238                 for (FCurve *fcu = adt->action->curves.first; fcu != NULL; fcu = fcu->next) {
239                         if (STRPREFIX(fcu->rna_path, prefix)) {
240                                 anim_change_prop_name(fcu, prefix, "color_hue", "inputs[1].default_value");
241                                 anim_change_prop_name(fcu, prefix, "color_saturation", "inputs[2].default_value");
242                                 anim_change_prop_name(fcu, prefix, "color_value", "inputs[3].default_value");
243                         }
244                 }
245                 MEM_freeN((char *)prefix);
246         }
247         /* Free storage, it is no longer used. */
248         MEM_freeN(node->storage);
249         node->storage = NULL;
250 }
251
252 static void do_versions_compositor_render_passes_storage(bNode *node)
253 {
254         int pass_index = 0;
255         const char *sockname;
256         for (bNodeSocket *sock = node->outputs.first; sock && pass_index < 31; sock = sock->next, pass_index++) {
257                 if (sock->storage == NULL) {
258                         NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
259                         sock->storage = sockdata;
260                         BLI_strncpy(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(pass_index), sizeof(sockdata->pass_name));
261
262                         if (pass_index == 0) sockname = "Image";
263                         else if (pass_index == 1) sockname = "Alpha";
264                         else sockname = node_cmp_rlayers_sock_to_pass(pass_index);
265                         BLI_strncpy(sock->name, sockname, sizeof(sock->name));
266                 }
267         }
268 }
269
270 static void do_versions_compositor_render_passes(bNodeTree *ntree)
271 {
272         for (bNode *node = ntree->nodes.first; node; node = node->next) {
273                 if (node->type == CMP_NODE_R_LAYERS) {
274                         /* First we make sure existing sockets have proper names.
275                          * This is important because otherwise verification will
276                          * drop links from sockets which were renamed.
277                          */
278                         do_versions_compositor_render_passes_storage(node);
279                         /* Make sure new sockets are properly created. */
280                         node_verify_socket_templates(ntree, node);
281                         /* Make sure all possibly created sockets have proper storage. */
282                         do_versions_compositor_render_passes_storage(node);
283                 }
284         }
285 }
286
287 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
288 {
289         if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
290
291                 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
292                         Object *ob;
293
294                         for (ob = main->object.first; ob; ob = ob->id.next) {
295                                 ModifierData *md;
296                                 for (md = ob->modifiers.first; md; md = md->next) {
297                                         if (md->type == eModifierType_Bevel) {
298                                                 BevelModifierData *bmd = (BevelModifierData *)md;
299                                                 bmd->profile = 0.5f;
300                                                 bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
301                                         }
302                                 }
303                         }
304                 }
305
306                 /* nodes don't use fixed node->id any more, clean up */
307                 FOREACH_NODETREE(main, ntree, id) {
308                         if (ntree->type == NTREE_COMPOSIT) {
309                                 bNode *node;
310                                 for (node = ntree->nodes.first; node; node = node->next) {
311                                         if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
312                                                 node->id = NULL;
313                                         }
314                                 }
315                         }
316                 } FOREACH_NODETREE_END
317
318                 {
319                         bScreen *screen;
320
321                         for (screen = main->screen.first; screen; screen = screen->id.next) {
322                                 ScrArea *area;
323                                 for (area = screen->areabase.first; area; area = area->next) {
324                                         SpaceLink *space_link;
325                                         for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
326                                                 if (space_link->spacetype == SPACE_CLIP) {
327                                                         SpaceClip *space_clip = (SpaceClip *) space_link;
328                                                         if (space_clip->mode != SC_MODE_MASKEDIT) {
329                                                                 space_clip->mode = SC_MODE_TRACKING;
330                                                         }
331                                                 }
332                                         }
333                                 }
334                         }
335                 }
336
337                 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
338                         MovieClip *clip;
339                         for (clip = main->movieclip.first; clip; clip = clip->id.next) {
340                                 clip->tracking.settings.default_weight = 1.0f;
341                         }
342                 }
343         }
344
345         if (!MAIN_VERSION_ATLEAST(main, 270, 1)) {
346                 Scene *sce;
347                 Object *ob;
348
349                 /* Update Transform constraint (another deg -> rad stuff). */
350                 for (ob = main->object.first; ob; ob = ob->id.next) {
351                         do_version_constraints_radians_degrees_270_1(&ob->constraints);
352
353                         if (ob->pose) {
354                                 /* Bones constraints! */
355                                 bPoseChannel *pchan;
356                                 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
357                                         do_version_constraints_radians_degrees_270_1(&pchan->constraints);
358                                 }
359                         }
360                 }
361
362                 for (sce = main->scene.first; sce; sce = sce->id.next) {
363                         if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) {
364                                 sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO;
365                         }
366                 }
367         }
368
369         if (!MAIN_VERSION_ATLEAST(main, 270, 2)) {
370                 Mesh *me;
371
372                 /* Mesh smoothresh deg->rad. */
373                 for (me = main->mesh.first; me; me = me->id.next) {
374                         me->smoothresh = DEG2RADF(me->smoothresh);
375                 }
376         }
377
378         if (!MAIN_VERSION_ATLEAST(main, 270, 3)) {
379                 FreestyleLineStyle *linestyle;
380
381                 for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
382                         linestyle->flag |= LS_NO_SORTING;
383                         linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
384                         linestyle->integration_type = LS_INTEGRATION_MEAN;
385                 }
386         }
387
388         if (!MAIN_VERSION_ATLEAST(main, 270, 4)) {
389                 /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
390                  * This will always reset situation to a valid state.
391                  */
392                 bScreen *sc;
393
394                 for (sc = main->screen.first; sc; sc = sc->id.next) {
395                         ScrArea *sa;
396                         for (sa = sc->areabase.first; sa; sa = sa->next) {
397                                 SpaceLink *sl;
398
399                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
400                                         ARegion *ar;
401                                         ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
402
403                                         for (ar = lb->first; ar; ar = ar->next) {
404                                                 BLI_listbase_clear(&ar->ui_previews);
405                                         }
406                                 }
407                         }
408                 }
409         }
410
411         if (!MAIN_VERSION_ATLEAST(main, 270, 5)) {
412                 Object *ob;
413
414                 /* Update Transform constraint (again :|). */
415                 for (ob = main->object.first; ob; ob = ob->id.next) {
416                         do_version_constraints_radians_degrees_270_5(&ob->constraints);
417
418                         if (ob->pose) {
419                                 /* Bones constraints! */
420                                 bPoseChannel *pchan;
421                                 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
422                                         do_version_constraints_radians_degrees_270_5(&pchan->constraints);
423                                 }
424                         }
425                 }
426         }
427
428         if (!MAIN_VERSION_ATLEAST(main, 271, 0)) {
429                 if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) {
430                         Material *ma;
431
432                         for (ma = main->mat.first; ma; ma = ma->id.next)
433                                 ma->mode2 = MA_CASTSHADOW;
434                 }
435
436                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
437                         Scene *sce;
438
439                         for (sce = main->scene.first; sce; sce = sce->id.next) {
440                                 sce->r.bake.flag = R_BAKE_CLEAR;
441                                 sce->r.bake.width = 512;
442                                 sce->r.bake.height = 512;
443                                 sce->r.bake.margin = 16;
444                                 sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
445                                 sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
446                                 sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
447                                 sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
448                                 BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
449
450                                 sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
451                                 sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
452                                 sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
453                                 sce->r.bake.im_format.quality = 90;
454                                 sce->r.bake.im_format.compress = 15;
455                         }
456                 }
457
458                 if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) {
459                         FreestyleLineStyle *linestyle;
460
461                         for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
462                                 linestyle->flag |= LS_TEXTURE;
463                                 linestyle->texstep = 1.0;
464                         }
465                 }
466
467                 {
468                         Scene *scene;
469                         for (scene = main->scene.first; scene; scene = scene->id.next) {
470                                 int num_layers = BLI_listbase_count(&scene->r.layers);
471                                 scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
472                         }
473                 }
474         }
475
476         if (!MAIN_VERSION_ATLEAST(main, 271, 1)) {
477                 if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) {
478                         Material *mat;
479
480                         for (mat = main->mat.first; mat; mat = mat->id.next) {
481                                 mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
482                                 mat->line_col[3] = mat->alpha;
483                         }
484                 }
485
486                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
487                         Scene *scene;
488                         for (scene = main->scene.first; scene; scene = scene->id.next) {
489                                 scene->r.preview_start_resolution = 64;
490                         }
491                 }
492         }
493
494         if (!MAIN_VERSION_ATLEAST(main, 271, 2)) {
495                 /* init up & track axis property of trackto actuators */
496                 Object *ob;
497
498                 for (ob = main->object.first; ob; ob = ob->id.next) {
499                         bActuator *act;
500                         for (act = ob->actuators.first; act; act = act->next) {
501                                 if (act->type == ACT_EDIT_OBJECT) {
502                                         bEditObjectActuator *eoact = act->data;
503                                         eoact->trackflag = ob->trackflag;
504                                         /* if trackflag is pointing +-Z axis then upflag should point Y axis.
505                                          * Rest of trackflag cases, upflag should be point z axis */
506                                         if ((ob->trackflag == OB_POSZ) || (ob->trackflag == OB_NEGZ)) {
507                                                 eoact->upflag = 1;
508                                         }
509                                         else {
510                                                 eoact->upflag = 2;
511                                         }
512                                 }
513                         }
514                 }
515         }
516
517         if (!MAIN_VERSION_ATLEAST(main, 271, 3)) {
518                 Brush *br;
519
520                 for (br = main->brush.first; br; br = br->id.next) {
521                         br->fill_threshold = 0.2f;
522                 }
523
524                 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "int", "mat")) {
525                         Object *ob;
526                         for (ob = main->object.first; ob; ob = ob->id.next) {
527                                 ModifierData *md;
528
529                                 for (md = ob->modifiers.first; md; md = md->next) {
530                                         if (md->type == eModifierType_Bevel) {
531                                                 BevelModifierData *bmd = (BevelModifierData *)md;
532                                                 bmd->mat = -1;
533                                         }
534                                 }
535                         }
536                 }
537         }
538
539         if (!MAIN_VERSION_ATLEAST(main, 271, 6)) {
540                 Object *ob;
541                 for (ob = main->object.first; ob; ob = ob->id.next) {
542                         ModifierData *md;
543
544                         for (md = ob->modifiers.first; md; md = md->next) {
545                                 if (md->type == eModifierType_ParticleSystem) {
546                                         ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
547                                         if (pmd->psys && pmd->psys->clmd) {
548                                                 pmd->psys->clmd->sim_parms->vel_damping = 1.0f;
549                                         }
550                                 }
551                         }
552                 }
553         }
554
555         if (!MAIN_VERSION_ATLEAST(main, 272, 0)) {
556                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
557                         Scene *scene;
558                         for (scene = main->scene.first; scene; scene = scene->id.next) {
559                                 scene->r.preview_start_resolution = 64;
560                         }
561                 }
562         }
563
564         if (!MAIN_VERSION_ATLEAST(main, 272, 1)) {
565                 Brush *br;
566                 for (br = main->brush.first; br; br = br->id.next) {
567                         if ((br->ob_mode & OB_MODE_SCULPT) && ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
568                                 br->alpha = 1.0f;
569                 }
570         }
571
572         if (!MAIN_VERSION_ATLEAST(main, 272, 2)) {
573                 if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
574                         Image *image;
575                         for (image = main->image.first; image != NULL; image = image->id.next) {
576                                 image->gen_color[3] = 1.0f;
577                         }
578                 }
579
580                 if (!DNA_struct_elem_find(fd->filesdna, "bStretchToConstraint", "float", "bulge_min")) {
581                         Object *ob;
582
583                         /* Update Transform constraint (again :|). */
584                         for (ob = main->object.first; ob; ob = ob->id.next) {
585                                 do_version_constraints_stretch_to_limits(&ob->constraints);
586
587                                 if (ob->pose) {
588                                         /* Bones constraints! */
589                                         bPoseChannel *pchan;
590                                         for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
591                                                 do_version_constraints_stretch_to_limits(&pchan->constraints);
592                                         }
593                                 }
594                         }
595                 }
596         }
597
598         if (!MAIN_VERSION_ATLEAST(main, 273, 1)) {
599 #define BRUSH_RAKE (1 << 7)
600 #define BRUSH_RANDOM_ROTATION (1 << 25)
601
602                 Brush *br;
603
604                 for (br = main->brush.first; br; br = br->id.next) {
605                         if (br->flag & BRUSH_RAKE) {
606                                 br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
607                                 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
608                         }
609                         else if (br->flag & BRUSH_RANDOM_ROTATION) {
610                                 br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
611                                 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
612                         }
613                         br->mtex.random_angle = 2.0 * M_PI;
614                         br->mask_mtex.random_angle = 2.0 * M_PI;
615                 }
616         }
617
618 #undef BRUSH_RAKE
619 #undef BRUSH_RANDOM_ROTATION
620
621         /* Customizable Safe Areas */
622         if (!MAIN_VERSION_ATLEAST(main, 273, 2)) {
623                 if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) {
624                         Scene *scene;
625
626                         for (scene = main->scene.first; scene; scene = scene->id.next) {
627                                 copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f);
628                                 copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f);
629                                 copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f);
630                                 copy_v2_fl2(scene->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
631                         }
632                 }
633         }
634         
635         if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
636                 ParticleSettings *part;
637                 for (part = main->particle.first; part; part = part->id.next) {
638                         if (part->clumpcurve)
639                                 part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
640                         if (part->roughcurve)
641                                 part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
642                 }
643         }
644
645         if (!MAIN_VERSION_ATLEAST(main, 273, 6)) {
646                 if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
647                         Object *ob;
648                         ModifierData *md;
649                         for (ob = main->object.first; ob; ob = ob->id.next) {
650                                 for (md = ob->modifiers.first; md; md = md->next) {
651                                         if (md->type == eModifierType_Cloth) {
652                                                 ClothModifierData *clmd = (ClothModifierData *)md;
653                                                 clmd->sim_parms->bending_damping = 0.5f;
654                                         }
655                                         else if (md->type == eModifierType_ParticleSystem) {
656                                                 ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
657                                                 if (pmd->psys->clmd) {
658                                                         pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
659                                                 }
660                                         }
661                                 }
662                         }
663                 }
664
665                 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
666                         ParticleSettings *part;
667                         for (part = main->particle.first; part; part = part->id.next) {
668                                 part->clump_noise_size = 1.0f;
669                         }
670                 }
671
672                 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
673                         ParticleSettings *part;
674                         for (part = main->particle.first; part; part = part->id.next) {
675                                 part->kink_extra_steps = 4;
676                         }
677                 }
678
679                 if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
680                         ParticleSettings *part;
681                         for (part = main->particle.first; part; part = part->id.next) {
682                                 int a;
683                                 for (a = 0; a < MAX_MTEX; a++) {
684                                         MTex *mtex = part->mtex[a];
685                                         if (mtex) {
686                                                 mtex->kinkampfac = 1.0f;
687                                         }
688                                 }
689                         }
690                 }
691
692                 if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
693                         Object *ob;
694
695                         for (ob = main->object.first; ob; ob = ob->id.next) {
696                                 ModifierData *md;
697                                 for (md = ob->modifiers.first; md; md = md->next) {
698                                         if (md->type == eModifierType_Hook) {
699                                                 HookModifierData *hmd = (HookModifierData *)md;
700                                                 hmd->falloff_type = eHook_Falloff_InvSquare;
701                                         }
702                                 }
703                         }
704                 }
705
706                 if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
707                         FOREACH_NODETREE(main, ntree, id) {
708                                 if (ntree->type == NTREE_COMPOSIT) {
709                                         bNode *node;
710                                         for (node = ntree->nodes.first; node; node = node->next) {
711                                                 if (ELEM(node->type, CMP_NODE_PLANETRACKDEFORM)) {
712                                                         NodePlaneTrackDeformData *data = node->storage;
713                                                         data->flag = 0;
714                                                         data->motion_blur_samples = 16;
715                                                         data->motion_blur_shutter = 0.5f;
716                                                 }
717                                         }
718                                 }
719                         }
720                         FOREACH_NODETREE_END
721                 }
722
723                 if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
724                         Camera *ca;
725                         for (ca = main->camera.first; ca; ca = ca->id.next) {
726                                 ca->gpu_dof.fstop = 128.0f;
727                                 ca->gpu_dof.focal_length = 1.0f;
728                                 ca->gpu_dof.focus_distance = 1.0f;
729                                 ca->gpu_dof.sensor = 1.0f;
730                         }
731                 }
732         }
733
734         if (!MAIN_VERSION_ATLEAST(main, 273, 8)) {
735                 Object *ob;
736                 for (ob = main->object.first; ob != NULL; ob = ob->id.next) {
737                         ModifierData *md;
738                         for (md = ob->modifiers.last; md != NULL; md = md->prev) {
739                                 if (modifier_unique_name(&ob->modifiers, md)) {
740                                         printf("Warning: Object '%s' had several modifiers with the "
741                                                "same name, renamed one of them to '%s'.\n",
742                                                ob->id.name + 2, md->name);
743                                 }
744                         }
745                 }
746         }
747
748         if (!MAIN_VERSION_ATLEAST(main, 273, 9)) {
749                 bScreen *scr;
750                 ScrArea *sa;
751                 SpaceLink *sl;
752                 ARegion *ar;
753
754                 /* Make sure sequencer preview area limits zoom */
755                 for (scr = main->screen.first; scr; scr = scr->id.next) {
756                         for (sa = scr->areabase.first; sa; sa = sa->next) {
757                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
758                                         if (sl->spacetype == SPACE_SEQ) {
759                                                 for (ar = sl->regionbase.first; ar; ar = ar->next) {
760                                                         if (ar->regiontype == RGN_TYPE_PREVIEW) {
761                                                                 ar->v2d.keepzoom |= V2D_LIMITZOOM;
762                                                                 ar->v2d.minzoom = 0.001f;
763                                                                 ar->v2d.maxzoom = 1000.0f;
764                                                                 break;
765                                                         }
766                                                 }
767                                         }
768                                 }
769                         }
770                 }
771         }
772
773         if (!MAIN_VERSION_ATLEAST(main, 274, 1)) {
774                 /* particle systems need to be forced to redistribute for jitter mode fix */
775                 {
776                         Object *ob;
777                         ParticleSystem *psys;
778                         for (ob = main->object.first; ob; ob = ob->id.next) {
779                                 for (psys = ob->particlesystem.first; psys; psys = psys->next) {
780                                         if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) {
781                                                 psys->recalc |= PSYS_RECALC_RESET;
782                                         }
783                                 }
784                         }
785                 }
786
787                 /* hysteresis setted to 10% but not actived */
788                 if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
789                         Object *ob;
790                         for (ob = main->object.first; ob; ob = ob->id.next) {
791                                 LodLevel *level;
792                                 for (level = ob->lodlevels.first; level; level = level->next) {
793                                         level->obhysteresis = 10;
794                                 }
795                         }
796                 }
797
798                 if (!DNA_struct_elem_find(fd->filesdna, "GameData", "int", "scehysteresis")) {
799                         Scene *scene;
800                         for (scene = main->scene.first; scene; scene = scene->id.next) {
801                                 scene->gm.scehysteresis = 10;
802                         }
803                 }
804         }
805
806         if (!MAIN_VERSION_ATLEAST(main, 274, 2)) {
807                 FOREACH_NODETREE(main, ntree, id) {
808                         bNode *node;
809                         bNodeSocket *sock;
810
811                         for (node = ntree->nodes.first; node; node = node->next) {
812                                 if (node->type == SH_NODE_MATERIAL) {
813                                         for (sock = node->inputs.first; sock; sock = sock->next) {
814                                                 if (STREQ(sock->name, "Refl")) {
815                                                         BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
816                                                 }
817                                         }
818                                 }
819                                 else if (node->type == SH_NODE_MATERIAL_EXT) {
820                                         for (sock = node->outputs.first; sock; sock = sock->next) {
821                                                 if (STREQ(sock->name, "Refl")) {
822                                                         BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
823                                                 }
824                                                 else if (STREQ(sock->name, "Ray Mirror")) {
825                                                         BLI_strncpy(sock->name, "Reflectivity", sizeof(sock->name));
826                                                 }
827                                         }
828                                 }
829                         }
830                 } FOREACH_NODETREE_END
831         }
832
833         if (!MAIN_VERSION_ATLEAST(main, 274, 4)) {
834                 SceneRenderView *srv;
835                 wmWindowManager *wm;
836                 bScreen *screen;
837                 wmWindow *win;
838                 Scene *scene;
839                 Camera *cam;
840                 Image *ima;
841
842                 for (scene = main->scene.first; scene; scene = scene->id.next) {
843                         Sequence *seq;
844
845                         BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
846                         srv = scene->r.views.first;
847                         BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
848
849                         BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
850                         srv = scene->r.views.last;
851                         BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
852
853                         SEQ_BEGIN (scene->ed, seq)
854                         {
855                                 seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
856
857 #define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
858 #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
859                                 if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) {
860                                         if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
861                                                 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
862                                         if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
863                                                 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
864                                 }
865 #undef SEQ_USE_PROXY_CUSTOM_DIR
866 #undef SEQ_USE_PROXY_CUSTOM_FILE
867
868                         }
869                         SEQ_END
870                 }
871
872                 for (screen = main->screen.first; screen; screen = screen->id.next) {
873                         ScrArea *sa;
874                         for (sa = screen->areabase.first; sa; sa = sa->next) {
875                                 SpaceLink *sl;
876
877                                 for (sl = sa->spacedata.first; sl; sl = sl->next) {
878                                         switch (sl->spacetype) {
879                                                 case SPACE_VIEW3D:
880                                                 {
881                                                         View3D *v3d = (View3D *)sl;
882                                                         v3d->stereo3d_camera = STEREO_3D_ID;
883                                                         v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
884                                                         v3d->stereo3d_convergence_alpha = 0.15f;
885                                                         v3d->stereo3d_volume_alpha = 0.05f;
886                                                         break;
887                                                 }
888                                                 case SPACE_IMAGE:
889                                                 {
890                                                         SpaceImage *sima = (SpaceImage *) sl;
891                                                         sima->iuser.flag |= IMA_SHOW_STEREO;
892                                                         break;
893                                                 }
894                                         }
895                                 }
896                         }
897                 }
898
899                 for (cam = main->camera.first; cam; cam = cam->id.next) {
900                         cam->stereo.interocular_distance = 0.065f;
901                         cam->stereo.convergence_distance = 30.0f * 0.065f;
902                 }
903
904                 for (ima = main->image.first; ima; ima = ima->id.next) {
905                         ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format");
906
907                         if (ima->packedfile) {
908                                 ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed File");
909                                 BLI_addtail(&ima->packedfiles, imapf);
910
911                                 imapf->packedfile = ima->packedfile;
912                                 BLI_strncpy(imapf->filepath, ima->name, FILE_MAX);
913                                 ima->packedfile = NULL;
914                         }
915                 }
916
917                 for (wm = main->wm.first; wm; wm = wm->id.next) {
918                         for (win = wm->windows.first; win; win = win->next) {
919                                 win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
920                         }
921                 }
922         }
923
924         if (!MAIN_VERSION_ATLEAST(main, 274, 6)) {
925                 bScreen *screen;
926
927                 if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) {
928                         for (screen = main->screen.first; screen; screen = screen->id.next) {
929                                 ScrArea *sa;
930
931                                 for (sa = screen->areabase.first; sa; sa = sa->next) {
932                                         SpaceLink *sl;
933
934                                         for (sl = sa->spacedata.first; sl; sl = sl->next) {
935                                                 if (sl->spacetype == SPACE_FILE) {
936                                                         SpaceFile *sfile = (SpaceFile *)sl;
937
938                                                         if (sfile->params) {
939                                                                 sfile->params->thumbnail_size = 128;
940                                                         }
941                                                 }
942                                         }
943                                 }
944                         }
945                 }
946
947                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) {
948                         Scene *scene;
949                         for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
950                                 scene->r.simplify_subsurf_render = scene->r.simplify_subsurf;
951                                 scene->r.simplify_particles_render = scene->r.simplify_particles;
952                         }
953                 }
954
955                 if (!DNA_struct_elem_find(fd->filesdna, "DecimateModifierData", "float", "defgrp_factor")) {
956                         Object *ob;
957
958                         for (ob = main->object.first; ob; ob = ob->id.next) {
959                                 ModifierData *md;
960                                 for (md = ob->modifiers.first; md; md = md->next) {
961                                         if (md->type == eModifierType_Decimate) {
962                                                 DecimateModifierData *dmd = (DecimateModifierData *)md;
963                                                 dmd->defgrp_factor = 1.0f;
964                                         }
965                                 }
966                         }
967                 }
968         }
969
970         if (!MAIN_VERSION_ATLEAST(main, 275, 3)) {
971                 Brush *br;
972 #define BRUSH_TORUS (1 << 1)
973                 for (br = main->brush.first; br; br = br->id.next) {
974                         br->flag &= ~BRUSH_TORUS;
975                 }
976 #undef BRUSH_TORUS
977         }
978
979         if (!MAIN_VERSION_ATLEAST(main, 276, 2)) {
980                 if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) {
981                         Object *ob;
982
983                         for (ob = main->object.first; ob; ob = ob->id.next) {
984                                 if (ob->pose) {
985                                         bPoseChannel *pchan;
986                                         for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
987                                                 pchan->custom_scale = 1.0f;
988                                         }
989                                 }
990                         }
991                 }
992
993                 {
994                         bScreen *screen;
995 #define RV3D_VIEW_PERSPORTHO     7
996                         for (screen = main->screen.first; screen; screen = screen->id.next) {
997                                 ScrArea *sa;
998                                 for (sa = screen->areabase.first; sa; sa = sa->next) {
999                                         SpaceLink *sl;
1000                                         for (sl = sa->spacedata.first; sl; sl = sl->next) {
1001                                                 if (sl->spacetype == SPACE_VIEW3D) {
1002                                                         ARegion *ar;
1003                                                         ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
1004                                                         for (ar = lb->first; ar; ar = ar->next) {
1005                                                                 if (ar->regiontype == RGN_TYPE_WINDOW) {
1006                                                                         if (ar->regiondata) {
1007                                                                                 RegionView3D *rv3d = ar->regiondata;
1008                                                                                 if (rv3d->view == RV3D_VIEW_PERSPORTHO) {
1009                                                                                         rv3d->view = RV3D_VIEW_USER;
1010                                                                                 }
1011                                                                         }
1012                                                                 }
1013                                                         }
1014                                                         break;
1015                                                 }
1016                                         }
1017                                 }
1018                         }
1019 #undef RV3D_VIEW_PERSPORTHO
1020                 }
1021
1022                 {
1023                         Lamp *lamp;
1024 #define LA_YF_PHOTON    5
1025                         for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
1026                                 if (lamp->type == LA_YF_PHOTON) {
1027                                         lamp->type = LA_LOCAL;
1028                                 }
1029                         }
1030 #undef LA_YF_PHOTON
1031                 }
1032
1033                 {
1034                         Object *ob;
1035                         for (ob = main->object.first; ob; ob = ob->id.next) {
1036                                 if (ob->body_type == OB_BODY_TYPE_CHARACTER && (ob->gameflag & OB_BOUNDS) && ob->collision_boundtype == OB_BOUND_TRIANGLE_MESH) {
1037                                         ob->boundtype = ob->collision_boundtype = OB_BOUND_BOX;
1038                                 }
1039                         }
1040                 }
1041
1042         }
1043
1044         if (!MAIN_VERSION_ATLEAST(main, 276, 3)) {
1045                 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "CurveMapping", "mblur_shutter_curve")) {
1046                         Scene *scene;
1047                         for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1048                                 CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
1049                                 curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
1050                                 curvemapping_initialize(curve_mapping);
1051                                 curvemap_reset(curve_mapping->cm,
1052                                                &curve_mapping->clipr,
1053                                                CURVE_PRESET_MAX,
1054                                                CURVEMAP_SLOPE_POS_NEG);
1055                         }
1056                 }
1057         }
1058
1059         if (!MAIN_VERSION_ATLEAST(main, 276, 4)) {
1060                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1061                         ToolSettings *ts = scene->toolsettings;
1062                         
1063                         if (ts->gp_sculpt.brush[0].size == 0) {
1064                                 GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
1065                                 GP_EditBrush_Data *brush;
1066                                 
1067                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH];
1068                                 brush->size = 25;
1069                                 brush->strength = 0.3f;
1070                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE;
1071                                 
1072                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS];
1073                                 brush->size = 25;
1074                                 brush->strength = 0.5f;
1075                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1076                                 
1077                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB];
1078                                 brush->size = 50;
1079                                 brush->strength = 0.3f;
1080                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1081                                 
1082                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH];
1083                                 brush->size = 25;
1084                                 brush->strength = 0.3f;
1085                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1086                                 
1087                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST];
1088                                 brush->size = 50;
1089                                 brush->strength = 0.3f; // XXX?
1090                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1091                                 
1092                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH];
1093                                 brush->size = 50;
1094                                 brush->strength = 0.5f; // XXX?
1095                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1096                                 
1097                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMIZE];
1098                                 brush->size = 25;
1099                                 brush->strength = 0.5f;
1100                                 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1101                                 
1102                                 brush = &gset->brush[GP_EDITBRUSH_TYPE_CLONE];
1103                                 brush->size = 50;
1104                                 brush->strength = 1.0f;
1105                         }
1106                         
1107                         if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "gpencil_v3d_align")) {
1108 #if 0 /* XXX: Cannot do this, as we get random crashes... */
1109                                 if (scene->gpd) {
1110                                         bGPdata *gpd = scene->gpd;
1111                                         
1112                                         /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */
1113                                         ts->gpencil_v3d_align = 0;
1114                                         
1115                                         if (gpd->flag & GP_DATA_VIEWALIGN)    ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE;
1116                                         if (gpd->flag & GP_DATA_DEPTH_VIEW)   ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW;
1117                                         if (gpd->flag & GP_DATA_DEPTH_STROKE) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE;
1118                                         
1119                                         if (gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS)
1120                                                 ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE_ENDPOINTS;
1121                                 }
1122                                 else {
1123                                         /* Default to cursor for all standard 3D views */
1124                                         ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
1125                                 }
1126 #endif
1127                                 
1128                                 ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
1129                                 ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE;
1130                                 ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
1131                                 ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
1132                         }
1133                 }
1134                 
1135                 for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
1136                         bool enabled = false;
1137                         
1138                         /* Ensure that the datablock's onionskinning toggle flag
1139                          * stays in sync with the status of the actual layers
1140                          */
1141                         for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
1142                                 if (gpl->flag & GP_LAYER_ONIONSKIN) {
1143                                         enabled = true;
1144                                 }
1145                         }
1146                         
1147                         if (enabled)
1148                                 gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
1149                         else
1150                                 gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
1151                 }
1152
1153                 if (!DNA_struct_elem_find(fd->filesdna, "Object", "unsigned char", "max_jumps")) {
1154                         for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1155                                 ob->max_jumps = 1;
1156                         }
1157                 }
1158         }
1159         if (!MAIN_VERSION_ATLEAST(main, 276, 5)) {
1160                 ListBase *lbarray[MAX_LIBARRAY];
1161                 int a;
1162
1163                 /* Important to clear all non-persistent flags from older versions here, otherwise they could collide
1164                  * with any new persistent flag we may add in the future. */
1165                 a = set_listbasepointers(main, lbarray);
1166                 while (a--) {
1167                         for (ID *id = lbarray[a]->first; id; id = id->next) {
1168                                 id->flag &= LIB_FAKEUSER;
1169                         }
1170                 }
1171         }
1172
1173         if (!MAIN_VERSION_ATLEAST(main, 276, 7)) {
1174                 Scene *scene;
1175                 for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1176                         scene->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL;
1177                 }
1178         }
1179
1180         if (!MAIN_VERSION_ATLEAST(main, 277, 1)) {
1181                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1182                         ParticleEditSettings *pset = &scene->toolsettings->particle;
1183                         for (int a = 0; a < PE_TOT_BRUSH; a++) {
1184                                 if (pset->brush[a].strength > 1.0f) {
1185                                         pset->brush[a].strength *= 0.01f;
1186                                 }
1187                         }
1188                 }
1189
1190                 for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
1191                         for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
1192                                 for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
1193                                         ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
1194                                         /* Bug: Was possible to add preview region to sequencer view by using AZones. */
1195                                         if (sl->spacetype == SPACE_SEQ) {
1196                                                 SpaceSeq *sseq = (SpaceSeq *)sl;
1197                                                 if (sseq->view == SEQ_VIEW_SEQUENCE) {
1198                                                         for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
1199                                                                 /* remove preview region for sequencer-only view! */
1200                                                                 if (ar->regiontype == RGN_TYPE_PREVIEW) {
1201                                                                         ar->flag |= RGN_FLAG_HIDDEN;
1202                                                                         ar->alignment = RGN_ALIGN_NONE;
1203                                                                         break;
1204                                                                 }
1205                                                         }
1206                                                 }
1207                                         }
1208                                         /* Remove old deprecated region from filebrowsers */
1209                                         else if (sl->spacetype == SPACE_FILE) {
1210                                                 for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
1211                                                         if (ar->regiontype == RGN_TYPE_CHANNELS) {
1212                                                                 /* Free old deprecated 'channel' region... */
1213                                                                 BKE_area_region_free(NULL, ar);
1214                                                                 BLI_freelinkN(regionbase, ar);
1215                                                                 break;
1216                                                         }
1217                                                 }
1218                                         }
1219                                 }
1220                         }
1221                 }
1222
1223                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1224                         CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings;
1225                         if (cps->error_threshold == 0) {
1226                                 cps->curve_type = CU_BEZIER;
1227                                 cps->flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
1228                                 cps->error_threshold = 8;
1229                                 cps->radius_max = 1.0f;
1230                                 cps->corner_angle = DEG2RADF(70.0f);
1231                         }
1232                 }
1233
1234                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1235                         Sequence *seq;
1236
1237                         SEQ_BEGIN (scene->ed, seq)
1238                         {
1239                                 if (seq->type == SEQ_TYPE_TEXT) {
1240                                         TextVars *data = seq->effectdata;
1241                                         if (data != NULL && data->color[3] == 0.0f) {
1242                                                 copy_v4_fl(data->color, 1.0f);
1243                                                 data->shadow_color[3] = 1.0f;
1244                                         }
1245                                 }
1246                         }
1247                         SEQ_END
1248                 }
1249
1250                 /* Adding "Properties" region to DopeSheet */
1251                 for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
1252                         for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
1253                                 /* handle pushed-back space data first */
1254                                 for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
1255                                         if (sl->spacetype == SPACE_ACTION) {
1256                                                 SpaceAction *saction = (SpaceAction *)sl;
1257                                                 do_version_action_editor_properties_region(&saction->regionbase);
1258                                         }
1259                                 }
1260                                 
1261                                 /* active spacedata info must be handled too... */
1262                                 if (sa->spacetype == SPACE_ACTION) {
1263                                         do_version_action_editor_properties_region(&sa->regionbase);
1264                                 }
1265                         }
1266                 }
1267         }
1268
1269         if (!MAIN_VERSION_ATLEAST(main, 277, 2)) {
1270                 if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scaleIn")) {
1271                         for (bArmature *arm = main->armature.first; arm; arm = arm->id.next) {
1272                                 do_version_bones_super_bbone(&arm->bonebase);
1273                         }
1274                 }
1275                 if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) {
1276                         for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1277                                 if (ob->pose) {
1278                                         for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1279                                                 /* see do_version_bones_super_bbone()... */
1280                                                 pchan->scaleIn = 1.0f;
1281                                                 pchan->scaleOut = 1.0f;
1282                                                 
1283                                                 /* also make sure some legacy (unused for over a decade) flags are unset,
1284                                                  * so that we can reuse them for stuff that matters now...
1285                                                  * (i.e. POSE_IK_MAT, (unknown/unused x 4), POSE_HAS_IK)
1286                                                  *
1287                                                  * These seem to have been runtime flags used by the IK solver, but that stuff
1288                                                  * should be able to be recalculated automatically anyway, so it should be fine.
1289                                                  */
1290                                                 pchan->flag &= ~((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8));
1291                                         }
1292                                 }
1293                         }
1294                 }
1295
1296                 for (Camera *camera = main->camera.first; camera != NULL; camera = camera->id.next) {
1297                         if (camera->stereo.pole_merge_angle_from == 0.0f &&
1298                             camera->stereo.pole_merge_angle_to == 0.0f)
1299                         {
1300                                 camera->stereo.pole_merge_angle_from = DEG2RADF(60.0f);
1301                                 camera->stereo.pole_merge_angle_to = DEG2RADF(75.0f);
1302                         }
1303                 }
1304
1305                 if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) {
1306                         Object *ob;
1307
1308                         for (ob = main->object.first; ob; ob = ob->id.next) {
1309                                 ModifierData *md;
1310                                 for (md = ob->modifiers.first; md; md = md->next) {
1311                                         if (md->type == eModifierType_NormalEdit) {
1312                                                 NormalEditModifierData *nemd = (NormalEditModifierData *)md;
1313                                                 nemd->mix_limit = DEG2RADF(180.0f);
1314                                         }
1315                                 }
1316                         }
1317                 }
1318
1319                 if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) {
1320                         Object *ob;
1321                         for (ob = main->object.first; ob; ob = ob->id.next) {
1322                                 ModifierData *md;
1323                                 for (md = ob->modifiers.first; md; md = md->next) {
1324                                         if (md->type == eModifierType_Boolean) {
1325                                                 BooleanModifierData *bmd = (BooleanModifierData *)md;
1326                                                 bmd->double_threshold = 1e-6f;
1327                                         }
1328                                 }
1329                         }
1330                 }
1331
1332                 for (Brush *br = main->brush.first; br; br = br->id.next) {
1333                         if (br->sculpt_tool == SCULPT_TOOL_FLATTEN) {
1334                                 br->flag |= BRUSH_ACCUMULATE;
1335                         }
1336                 }
1337
1338                 if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "time_scale")) {
1339                         Object *ob;
1340                         ModifierData *md;
1341                         for (ob = main->object.first; ob; ob = ob->id.next) {
1342                                 for (md = ob->modifiers.first; md; md = md->next) {
1343                                         if (md->type == eModifierType_Cloth) {
1344                                                 ClothModifierData *clmd = (ClothModifierData *)md;
1345                                                 clmd->sim_parms->time_scale = 1.0f;
1346                                         }
1347                                         else if (md->type == eModifierType_ParticleSystem) {
1348                                                 ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
1349                                                 if (pmd->psys->clmd) {
1350                                                         pmd->psys->clmd->sim_parms->time_scale = 1.0f;
1351                                                 }
1352                                         }
1353                                 }
1354                         }
1355                 }
1356         }
1357
1358         if (!MAIN_VERSION_ATLEAST(main, 277, 3)) {
1359                 /* ------- init of grease pencil initialization --------------- */
1360                 if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "*palcolor")) {
1361                         for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1362                                 ToolSettings *ts = scene->toolsettings;
1363                                 /* initialize use position for sculpt brushes */
1364                                 ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION;
1365                                 /* initialize  selected vertices alpha factor */
1366                                 ts->gp_sculpt.alpha = 1.0f;
1367
1368                                 /* new strength sculpt brush */
1369                                 if (ts->gp_sculpt.brush[0].size >= 11) {
1370                                         GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
1371                                         GP_EditBrush_Data *brush;
1372
1373                                         brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH];
1374                                         brush->size = 25;
1375                                         brush->strength = 0.5f;
1376                                         brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1377                                 }
1378                         }
1379                         /* create a default grease pencil drawing brushes set */
1380                         if (!BLI_listbase_is_empty(&main->gpencil)) {
1381                                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1382                                         ToolSettings *ts = scene->toolsettings;
1383                                         if (BLI_listbase_is_empty(&ts->gp_brushes)) {
1384                                                 BKE_gpencil_brush_init_presets(ts);
1385                                         }
1386                                 }
1387                         }
1388                         /* Convert Grease Pencil to new palettes/brushes
1389                          * Loop all strokes and create the palette and all colors
1390                          */
1391                         for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
1392                                 if (BLI_listbase_is_empty(&gpd->palettes)) {
1393                                         /* create palette */
1394                                         bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette", true);
1395                                         for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
1396                                                 /* create color using layer name */
1397                                                 bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_addnew(palette, gpl->info, true);
1398                                                 if (palcolor != NULL) {
1399                                                         /* set color attributes */
1400                                                         copy_v4_v4(palcolor->color, gpl->color);
1401                                                         copy_v4_v4(palcolor->fill, gpl->fill);
1402                                                         
1403                                                         if (gpl->flag & GP_LAYER_HIDE)       palcolor->flag |= PC_COLOR_HIDE;
1404                                                         if (gpl->flag & GP_LAYER_LOCKED)     palcolor->flag |= PC_COLOR_LOCKED;
1405                                                         if (gpl->flag & GP_LAYER_ONIONSKIN)  palcolor->flag |= PC_COLOR_ONIONSKIN;
1406                                                         if (gpl->flag & GP_LAYER_VOLUMETRIC) palcolor->flag |= PC_COLOR_VOLUMETRIC;
1407                                                         if (gpl->flag & GP_LAYER_HQ_FILL)    palcolor->flag |= PC_COLOR_HQ_FILL;
1408                                                         
1409                                                         /* set layer opacity to 1 */
1410                                                         gpl->opacity = 1.0f;
1411                                                         
1412                                                         /* set tint color */
1413                                                         ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f);
1414                                                         
1415                                                         /* flush relevant layer-settings to strokes */
1416                                                         for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
1417                                                                 for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
1418                                                                         /* set stroke to palette and force recalculation */
1419                                                                         BLI_strncpy(gps->colorname, gpl->info, sizeof(gps->colorname));
1420                                                                         gps->palcolor = NULL;
1421                                                                         gps->flag |= GP_STROKE_RECALC_COLOR;
1422                                                                         gps->thickness = gpl->thickness;
1423                                                                         
1424                                                                         /* set alpha strength to 1 */
1425                                                                         for (int i = 0; i < gps->totpoints; i++) {
1426                                                                                 gps->points[i].strength = 1.0f;
1427                                                                         }
1428                                                                 }
1429                                                         }
1430                                                 }
1431                                                 
1432                                                 /* set thickness to 0 (now it is a factor to override stroke thickness) */
1433                                                 gpl->thickness = 0.0f;
1434                                         }
1435                                         /* set first color as active */
1436                                         if (palette->colors.first)
1437                                                 BKE_gpencil_palettecolor_setactive(palette, palette->colors.first);
1438                                 }
1439                         }
1440                 }
1441                 /* ------- end of grease pencil initialization --------------- */
1442         }
1443
1444         if (!MAIN_VERSION_ATLEAST(main, 278, 0)) {
1445                 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) {
1446                         MovieClip *clip;
1447                         for (clip = main->movieclip.first; clip; clip = clip->id.next) {
1448                                 MovieTracking *tracking = &clip->tracking;
1449                                 MovieTrackingObject *tracking_object;
1450                                 for (tracking_object = tracking->objects.first;
1451                                      tracking_object != NULL;
1452                                      tracking_object = tracking_object->next)
1453                                 {
1454                                         ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
1455                                         MovieTrackingTrack *track;
1456                                         for (track = tracksbase->first;
1457                                              track != NULL;
1458                                              track = track->next)
1459                                         {
1460                                                 track->weight_stab = track->weight;
1461                                         }
1462                                 }
1463                         }
1464                 }
1465
1466                 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) {
1467                         MovieClip *clip;
1468                         for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) {
1469                                 if (clip->tracking.stabilization.rot_track) {
1470                                         migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization);
1471                                 }
1472                                 if (clip->tracking.stabilization.scale == 0.0f) {
1473                                         /* ensure init.
1474                                          * Was previously used for autoscale only,
1475                                          * now used always (as "target scale") */
1476                                         clip->tracking.stabilization.scale = 1.0f;
1477                                 }
1478                                 /* blender prefers 1-based frame counting;
1479                                  * thus using frame 1 as reference typically works best */
1480                                 clip->tracking.stabilization.anchor_frame = 1;
1481                                 /* by default show the track lists expanded, to improve "discoverability" */
1482                                 clip->tracking.stabilization.flag |= TRACKING_SHOW_STAB_TRACKS;
1483                                 /* deprecated, not used anymore */
1484                                 clip->tracking.stabilization.ok = false;
1485                         }
1486                 }
1487         }
1488         if (!MAIN_VERSION_ATLEAST(main, 278, 2)) {
1489                 if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "ffmpeg_preset")) {
1490                         for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1491                                 /* "medium" is the preset FFmpeg uses when no presets are given. */
1492                                 scene->r.ffcodecdata.ffmpeg_preset = FFM_PRESET_MEDIUM;
1493                         }
1494                 }
1495                 if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "constant_rate_factor")) {
1496                         for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1497                                 /* fall back to behaviour from before we introduced CRF for old files */
1498                                 scene->r.ffcodecdata.constant_rate_factor = FFM_CRF_NONE;
1499                         }
1500                 }
1501
1502                 if (!DNA_struct_elem_find(fd->filesdna, "SmokeModifierData", "float", "slice_per_voxel")) {
1503                         Object *ob;
1504                         ModifierData *md;
1505
1506                         for (ob = main->object.first; ob; ob = ob->id.next) {
1507                                 for (md = ob->modifiers.first; md; md = md->next) {
1508                                         if (md->type == eModifierType_Smoke) {
1509                                                 SmokeModifierData *smd = (SmokeModifierData *)md;
1510                                                 if (smd->domain) {
1511                                                         smd->domain->slice_per_voxel = 5.0f;
1512                                                         smd->domain->slice_depth = 0.5f;
1513                                                         smd->domain->display_thickness = 1.0f;
1514                                                 }
1515                                         }
1516                                 }
1517                         }
1518                 }
1519         }
1520
1521         if (!MAIN_VERSION_ATLEAST(main, 278, 3)) {
1522                 for (Scene *scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1523                         if (scene->toolsettings != NULL) {
1524                                 ToolSettings *ts = scene->toolsettings;
1525                                 ParticleEditSettings *pset = &ts->particle;
1526                                 for (int a = 0; a < PE_TOT_BRUSH; a++) {
1527                                         if (pset->brush[a].count == 0) {
1528                                                 pset->brush[a].count = 10;
1529                                         }
1530                                 }
1531                         }
1532                 }
1533
1534                 if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyCon", "float", "spring_stiffness_ang_x")) {
1535                         Object *ob;
1536                         for (ob = main->object.first; ob; ob = ob->id.next) {
1537                                 RigidBodyCon *rbc = ob->rigidbody_constraint;
1538                                 if (rbc) {
1539                                         rbc->spring_stiffness_ang_x = 10.0;
1540                                         rbc->spring_stiffness_ang_y = 10.0;
1541                                         rbc->spring_stiffness_ang_z = 10.0;
1542                                         rbc->spring_damping_ang_x = 0.5;
1543                                         rbc->spring_damping_ang_y = 0.5;
1544                                         rbc->spring_damping_ang_z = 0.5;
1545                                 }
1546                         }
1547                 }
1548
1549                 /* constant detail for sculpting is now a resolution value instead of
1550                  * a percentage, we reuse old DNA struct member but convert it */
1551                 for (Scene *scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1552                         if (scene->toolsettings != NULL) {
1553                                 ToolSettings *ts = scene->toolsettings;
1554                                 if (ts->sculpt && ts->sculpt->constant_detail != 0.0f) {
1555                                         ts->sculpt->constant_detail = 100.0f / ts->sculpt->constant_detail;
1556                                 }
1557                         }
1558                 }
1559         }
1560
1561         if (!MAIN_VERSION_ATLEAST(main, 278, 4)) {
1562                 const float sqrt_3 = (float)M_SQRT3;
1563                 for (Brush *br = main->brush.first; br; br = br->id.next) {
1564                         br->fill_threshold /= sqrt_3;
1565                 }
1566
1567                 /* Custom motion paths */
1568                 if (!DNA_struct_elem_find(fd->filesdna, "bMotionPath", "int", "line_thickness")) {
1569                         Object *ob;
1570                         for (ob = main->object.first; ob; ob = ob->id.next) {
1571                                 bMotionPath *mpath;
1572                                 bPoseChannel *pchan;
1573                                 mpath = ob->mpath;
1574                                 if (mpath) {
1575                                         mpath->color[0] = 1.0f;
1576                                         mpath->color[1] = 0.0f;
1577                                         mpath->color[2] = 0.0f;
1578                                         mpath->line_thickness = 1;
1579                                         mpath->flag |= MOTIONPATH_FLAG_LINES;
1580                                 }
1581                                 /* bones motion path */
1582                                 if (ob->pose) {
1583                                         for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1584                                                 mpath = pchan->mpath;
1585                                                 if (mpath) {
1586                                                         mpath->color[0] = 1.0f;
1587                                                         mpath->color[1] = 0.0f;
1588                                                         mpath->color[2] = 0.0f;
1589                                                         mpath->line_thickness = 1;
1590                                                         mpath->flag |= MOTIONPATH_FLAG_LINES;
1591                                                 }
1592                                         }
1593                                 }
1594                         }
1595                 }
1596         }
1597
1598         if (!MAIN_VERSION_ATLEAST(main, 278, 5)) {
1599                 /* Mask primitive adding code was not initializing correctly id_type of its points' parent. */
1600                 for (Mask *mask = main->mask.first; mask; mask = mask->id.next) {
1601                         for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) {
1602                                 for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) {
1603                                         int i = 0;
1604                                         for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) {
1605                                                 if (mspoint->parent.id_type == 0) {
1606                                                         BKE_mask_parent_init(&mspoint->parent);
1607                                                 }
1608                                         }
1609                                 }
1610                         }
1611                 }
1612
1613                 /* Fix for T50736, Glare comp node using same var for two different things. */
1614                 if (!DNA_struct_elem_find(fd->filesdna, "NodeGlare", "char", "star_45")) {
1615                         FOREACH_NODETREE(main, ntree, id) {
1616                                 if (ntree->type == NTREE_COMPOSIT) {
1617                                         ntreeSetTypes(NULL, ntree);
1618                                         for (bNode *node = ntree->nodes.first; node; node = node->next) {
1619                                                 if (node->type == CMP_NODE_GLARE) {
1620                                                         NodeGlare *ndg = node->storage;
1621                                                         switch (ndg->type) {
1622                                                                 case 2:  /* Grrrr! magic numbers :( */
1623                                                                         ndg->streaks = ndg->angle;
1624                                                                         break;
1625                                                                 case 0:
1626                                                                         ndg->star_45 = ndg->angle != 0;
1627                                                                         break;
1628                                                                 default:
1629                                                                         break;
1630                                                         }
1631                                                 }
1632                                         }
1633                                 }
1634                         } FOREACH_NODETREE_END
1635                 }
1636
1637                 if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) {
1638                         for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1639                                 for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
1640                                         if (md->type == eModifierType_SurfaceDeform) {
1641                                                 SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
1642                                                 unit_m4(smd->mat);
1643                                         }
1644                                 }
1645                         }
1646                 }
1647
1648                 FOREACH_NODETREE(main, ntree, id) {
1649                         if (ntree->type == NTREE_COMPOSIT) {
1650                                 do_versions_compositor_render_passes(ntree);
1651                         }
1652                 } FOREACH_NODETREE_END
1653         }
1654
1655         {
1656                 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1657                         if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
1658                                 scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
1659                         }
1660                 }
1661
1662                 /* Fix related to VGroup modifiers creating named defgroup CD layers! See T51520. */
1663                 for (Mesh *me = main->mesh.first; me; me = me->id.next) {
1664                         CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
1665                 }
1666         }
1667 }
1668
1669 void do_versions_after_linking_270(Main *main)
1670 {
1671         /* To be added to next subversion bump! */
1672         {
1673                 FOREACH_NODETREE(main, ntree, id) {
1674                         if (ntree->type == NTREE_COMPOSIT) {
1675                                 ntreeSetTypes(NULL, ntree);
1676                                 for (bNode *node = ntree->nodes.first; node; node = node->next) {
1677                                         if (node->type == CMP_NODE_HUE_SAT) {
1678                                                 do_version_hue_sat_node(ntree, node);
1679                                         }
1680                                 }
1681                         }
1682                 } FOREACH_NODETREE_END
1683         }
1684 }