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