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