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