cfe90fe042c25c1926858cd04372a670f0dd70e4
[blender.git] / source / blender / blenloader / intern / versioning_defaults.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_defaults.c
25  *  \ingroup blenloader
26  */
27
28 #include "BLI_utildefines.h"
29 #include "BLI_listbase.h"
30 #include "BLI_math.h"
31
32 #include "DNA_brush_types.h"
33 #include "DNA_freestyle_types.h"
34 #include "DNA_linestyle_types.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_screen_types.h"
37 #include "DNA_space_types.h"
38 #include "DNA_userdef_types.h"
39 #include "DNA_mesh_types.h"
40 #include "DNA_material_types.h"
41 #include "DNA_object_types.h"
42
43 #include "BKE_brush.h"
44 #include "BKE_library.h"
45 #include "BKE_main.h"
46
47 #include "BLO_readfile.h"
48
49
50 /**
51  * Override values in in-memory startup.blend, avoids resaving for small changes.
52  */
53 void BLO_update_defaults_userpref_blend(void)
54 {
55         /* defaults from T37518 */
56
57         U.uiflag |= USER_ZBUF_CURSOR;
58         U.uiflag |= USER_QUIT_PROMPT;
59         U.uiflag |= USER_CONTINUOUS_MOUSE;
60
61         U.versions = 1;
62         U.savetime = 2;
63 }
64
65 /**
66  * Update defaults in startup.blend, without having to save and embed the file.
67  * This function can be emptied each time the startup.blend is updated. */
68 void BLO_update_defaults_startup_blend(Main *bmain)
69 {
70         Scene *scene;
71         SceneRenderLayer *srl;
72         FreestyleLineStyle *linestyle;
73         Mesh *me;
74         Material *mat;
75
76         for (scene = bmain->scene.first; scene; scene = scene->id.next) {
77                 scene->r.im_format.planes = R_IMF_PLANES_RGBA;
78                 scene->r.im_format.compress = 15;
79                 scene->r.svg_mode = FREESTYLE_CONTROL_SVG_FRAME;
80
81                 for (srl = scene->r.layers.first; srl; srl = srl->next) {
82                         srl->freestyleConfig.sphere_radius = 0.1f;
83                         srl->pass_alpha_threshold = 0.5f;
84                 }
85
86                 if (scene->toolsettings) {
87                         ToolSettings *ts = scene->toolsettings;
88
89                         if (ts->sculpt) {
90                                 Sculpt *sculpt = ts->sculpt;
91                                 sculpt->paint.symmetry_flags |= PAINT_SYMM_X;
92                                 sculpt->flags |= SCULPT_DYNTOPO_COLLAPSE;
93                                 sculpt->detail_size = 12;
94                         }
95                 }
96         }
97
98         for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) {
99                 linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE;
100                 linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
101                 linestyle->integration_type = LS_INTEGRATION_MEAN;
102                 linestyle->texstep = 1.0;
103                 linestyle->chain_count = 10;
104         }
105
106         {
107                 bScreen *screen;
108
109                 for (screen = bmain->screen.first; screen; screen = screen->id.next) {
110                         ScrArea *area;
111                         for (area = screen->areabase.first; area; area = area->next) {
112                                 SpaceLink *space_link;
113                                 ARegion *ar;
114
115                                 for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
116                                         if (space_link->spacetype == SPACE_CLIP) {
117                                                 SpaceClip *space_clip = (SpaceClip *) space_link;
118                                                 space_clip->flag &= ~SC_MANUAL_CALIBRATION;
119                                         }
120                                 }
121
122                                 /* Remove all stored panels, we want to use defaults (order, open/closed) as defined by UI code here! */
123                                 for (ar = area->regionbase.first; ar; ar = ar->next) {
124                                         BLI_freelistN(&ar->panels);
125                                 }
126                         }
127                 }
128         }
129
130         for (me = bmain->mesh.first; me; me = me->id.next) {
131                 me->smoothresh = DEG2RADF(180.0f);
132                 me->flag &= ~ME_TWOSIDED;
133         }
134
135         for (mat = bmain->mat.first; mat; mat = mat->id.next) {
136                 mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
137                 mat->line_col[3] = 1.0f;
138         }
139
140         {
141                 Brush *br;
142                 br = BKE_brush_add(bmain, "Fill");
143                 br->imagepaint_tool = PAINT_TOOL_FILL;
144                 br->ob_mode = OB_MODE_TEXTURE_PAINT;
145
146                 br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Mask");
147                 if (br) {
148                         br->imagepaint_tool = PAINT_TOOL_MASK;
149                         br->ob_mode |= OB_MODE_TEXTURE_PAINT;
150                 }
151         }
152 }
153