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