fix compile error on MinGW32
[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_sdna_types.h"
38 #include "DNA_space_types.h"
39 #include "DNA_screen_types.h"
40 #include "DNA_object_types.h"
41 #include "DNA_modifier_types.h"
42 #include "DNA_sdna_types.h"
43
44 #include "DNA_genfile.h"
45
46
47 #include "BKE_main.h"
48 #include "BKE_node.h"
49
50 #include "BLO_readfile.h"
51
52 #include "readfile.h"
53
54
55 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
56 {
57         if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
58
59                 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
60                         Object *ob;
61
62                         for (ob = main->object.first; ob; ob = ob->id.next) {
63                                 ModifierData *md;
64                                 for (md = ob->modifiers.first; md; md = md->next) {
65                                         if (md->type == eModifierType_Bevel) {
66                                                 BevelModifierData *bmd = (BevelModifierData *)md;
67                                                 bmd->profile = 0.5f;
68                                                 bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
69                                         }
70                                 }
71                         }
72                 }
73
74                 /* nodes don't use fixed node->id any more, clean up */
75                 FOREACH_NODETREE(main, ntree, id) {
76                         if (ntree->type == NTREE_COMPOSIT) {
77                                 bNode *node;
78                                 for (node = ntree->nodes.first; node; node = node->next) {
79                                         if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
80                                                 node->id = NULL;
81                                         }
82                                 }
83                         }
84                 } FOREACH_NODETREE_END
85
86                 {
87                         bScreen *screen;
88
89                         for (screen = main->screen.first; screen; screen = screen->id.next) {
90                                 ScrArea *area;
91                                 for (area = screen->areabase.first; area; area = area->next) {
92                                         SpaceLink *space_link;
93                                         for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
94                                                 if (space_link->spacetype == SPACE_CLIP) {
95                                                         SpaceClip *space_clip = (SpaceClip *) space_link;
96                                                         if (space_clip->mode != SC_MODE_MASKEDIT) {
97                                                                 space_clip->mode = SC_MODE_TRACKING;
98                                                         }
99                                                 }
100                                         }
101                                 }
102                         }
103                 }
104
105                 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
106                         MovieClip *clip;
107                         for (clip = main->movieclip.first; clip; clip = clip->id.next) {
108                                 clip->tracking.settings.default_weight = 1.0f;
109                         }
110                 }
111         }
112 }