| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup blenloader | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2014-09-04 15:03:03 +02:00
										 |  |  | #include "BLI_listbase.h"
 | 
					
						
							| 
									
										
										
										
											2014-04-13 12:18:51 +02:00
										 |  |  | #include "BLI_math.h"
 | 
					
						
							| 
									
										
										
										
											2017-05-12 13:36:35 +02:00
										 |  |  | #include "BLI_string.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-20 13:47:59 +02:00
										 |  |  | #include "DNA_gpencil_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-15 18:28:51 +01:00
										 |  |  | #include "DNA_mesh_types.h"
 | 
					
						
							|  |  |  | #include "DNA_object_types.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | #include "DNA_scene_types.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-07 20:26:43 +06:00
										 |  |  | #include "DNA_screen_types.h"
 | 
					
						
							|  |  |  | #include "DNA_space_types.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | #include "DNA_userdef_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-10-19 20:29:15 +11:00
										 |  |  | #include "DNA_windowmanager_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-15 18:28:51 +01:00
										 |  |  | #include "DNA_workspace_types.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-12 16:51:44 +11:00
										 |  |  | #include "BKE_appdir.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-21 18:03:38 +01:00
										 |  |  | #include "BKE_brush.h"
 | 
					
						
							| 
									
										
										
										
											2019-01-16 18:44:16 +01:00
										 |  |  | #include "BKE_colorband.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-20 13:10:56 +02:00
										 |  |  | #include "BKE_colortools.h"
 | 
					
						
							| 
									
										
										
										
											2019-01-03 11:48:05 +01:00
										 |  |  | #include "BKE_idprop.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-27 16:09:02 +01:00
										 |  |  | #include "BKE_keyconfig.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  | #include "BKE_layer.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-21 18:03:38 +01:00
										 |  |  | #include "BKE_library.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | #include "BKE_main.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  | #include "BKE_node.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-22 16:26:17 +01:00
										 |  |  | #include "BKE_paint.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  | #include "BKE_screen.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-27 11:20:27 +10:00
										 |  |  | #include "BKE_workspace.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "BLO_readfile.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-23 20:20:59 +10:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Override values in in-memory startup.blend, avoids resaving for small changes. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void BLO_update_defaults_userpref_blend(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* default so DPI is detected automatically */ | 
					
						
							|  |  |  |   U.dpi = 0; | 
					
						
							|  |  |  |   U.ui_scale = 1.0f; | 
					
						
							| 
									
										
										
										
											2017-03-27 13:02:41 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef WITH_PYTHON_SECURITY
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* use alternative setting for security nuts
 | 
					
						
							|  |  |  |    * otherwise we'd need to patch the binary blob - startup.blend.c */ | 
					
						
							|  |  |  |   U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE; | 
					
						
							| 
									
										
										
										
											2017-03-27 13:02:41 +11:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE; | 
					
						
							| 
									
										
										
										
											2017-03-27 13:02:41 +11:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-06-27 12:28:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Clear addon preferences. */ | 
					
						
							|  |  |  |   for (bAddon *addon = U.addons.first, *addon_next; addon != NULL; addon = addon_next) { | 
					
						
							|  |  |  |     addon_next = addon->next; | 
					
						
							| 
									
										
										
										
											2019-03-17 09:42:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     if (addon->prop) { | 
					
						
							|  |  |  |       IDP_FreeProperty(addon->prop); | 
					
						
							|  |  |  |       MEM_freeN(addon->prop); | 
					
						
							|  |  |  |       addon->prop = NULL; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-01-03 11:48:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Transform tweak with single click and drag. */ | 
					
						
							|  |  |  |   U.flag |= USER_RELEASECONFIRM; | 
					
						
							| 
									
										
										
										
											2018-11-26 12:18:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Ignore the theme saved in the blend file,
 | 
					
						
							|  |  |  |    * instead use the theme from 'userdef_default_theme.c' */ | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     bTheme *theme = U.themes.first; | 
					
						
							|  |  |  |     memcpy(theme, &U_theme_default, sizeof(bTheme)); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-11-01 14:45:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Leave temp directory empty, will then get appropriate value per OS. */ | 
					
						
							|  |  |  |   U.tempdir[0] = '\0'; | 
					
						
							| 
									
										
										
										
											2018-11-21 12:05:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 01:10:29 +10:00
										 |  |  |   /* Only enable tooltips translation by default,
 | 
					
						
							|  |  |  |    * without actually enabling translation itself, for now. */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   U.transopts = USER_TR_TOOLTIPS; | 
					
						
							|  |  |  |   U.memcachelimit = 4096; | 
					
						
							| 
									
										
										
										
											2018-11-27 16:09:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Auto perspective. */ | 
					
						
							|  |  |  |   U.uiflag |= USER_AUTOPERSP; | 
					
						
							| 
									
										
										
										
											2019-01-03 11:48:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Init weight paint range. */ | 
					
						
							|  |  |  |   BKE_colorband_init(&U.coba_weight, true); | 
					
						
							| 
									
										
										
										
											2019-01-16 18:44:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Default visible section. */ | 
					
						
							|  |  |  |   U.userpref = USER_SECTION_INTERFACE; | 
					
						
							| 
									
										
										
										
											2019-01-16 18:49:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* Default to left click select. */ | 
					
						
							|  |  |  |   BKE_keyconfig_pref_set_select_mouse(&U, 0, true); | 
					
						
							| 
									
										
										
										
											2014-07-23 20:20:59 +10:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 09:36:38 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Rename if the ID doesn't exist. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | static ID *rename_id_for_versioning(Main *bmain, | 
					
						
							|  |  |  |                                     const short id_type, | 
					
						
							|  |  |  |                                     const char *name_src, | 
					
						
							|  |  |  |                                     const char *name_dst) | 
					
						
							| 
									
										
										
										
											2019-01-30 09:36:38 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* We can ignore libraries */ | 
					
						
							|  |  |  |   ListBase *lb = which_libbase(bmain, id_type); | 
					
						
							|  |  |  |   ID *id = NULL; | 
					
						
							|  |  |  |   for (ID *idtest = lb->first; idtest; idtest = idtest->next) { | 
					
						
							|  |  |  |     if (idtest->lib == NULL) { | 
					
						
							|  |  |  |       if (STREQ(idtest->name + 2, name_src)) { | 
					
						
							|  |  |  |         id = idtest; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (STREQ(idtest->name + 2, name_dst)) { | 
					
						
							|  |  |  |         return NULL; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (id != NULL) { | 
					
						
							|  |  |  |     BLI_strncpy(id->name + 2, name_dst, sizeof(id->name) - 2); | 
					
						
							|  |  |  |     /* We know it's unique, this just sorts. */ | 
					
						
							|  |  |  |     BLI_libblock_ensure_unique_name(bmain, id->name); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return id; | 
					
						
							| 
									
										
										
										
											2019-01-30 09:36:38 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-23 20:20:59 +10:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Update defaults in startup.blend, without having to save and embed the file. | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  |  * This function can be emptied each time the startup.blend is updated. */ | 
					
						
							| 
									
										
										
										
											2018-09-12 11:28:49 +02:00
										 |  |  | void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-23 08:49:10 +10:00
										 |  |  |   /* For all builtin templates shipped with Blender. */ | 
					
						
							|  |  |  |   const bool builtin_template = | 
					
						
							|  |  |  |       (!app_template || | 
					
						
							|  |  |  |        STR_ELEM(app_template, "2D_Animation", "Sculpting", "VFX", "Video_Editing")); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* For all startup.blend files. */ | 
					
						
							|  |  |  |   for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { | 
					
						
							|  |  |  |     for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  |       for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							| 
									
										
										
										
											2019-04-22 01:10:29 +10:00
										 |  |  |         /* Remove all stored panels, we want to use defaults
 | 
					
						
							|  |  |  |          * (order, open/closed) as defined by UI code here! */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         BKE_area_region_panels_free(&ar->panels); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /* some toolbars have been saved as initialized,
 | 
					
						
							|  |  |  |          * we don't want them to have odd zoom-level or scrolling set, see: T47047 */ | 
					
						
							|  |  |  |         if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) { | 
					
						
							|  |  |  |           ar->v2d.flag &= ~V2D_IS_INITIALISED; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { | 
					
						
							|  |  |  |         switch (sl->spacetype) { | 
					
						
							|  |  |  |           case SPACE_VIEW3D: { | 
					
						
							|  |  |  |             View3D *v3d = (View3D *)sl; | 
					
						
							|  |  |  |             v3d->overlay.texture_paint_mode_opacity = 1.0f; | 
					
						
							|  |  |  |             v3d->overlay.weight_paint_mode_opacity = 1.0f; | 
					
						
							|  |  |  |             v3d->overlay.vertex_paint_mode_opacity = 1.0f; | 
					
						
							|  |  |  |             /* grease pencil settings */ | 
					
						
							|  |  |  |             v3d->vertex_opacity = 1.0f; | 
					
						
							|  |  |  |             v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES; | 
					
						
							|  |  |  |             /* Skip startups that use the viewport color by default. */ | 
					
						
							|  |  |  |             if (v3d->shading.background_type != V3D_SHADING_BACKGROUND_VIEWPORT) { | 
					
						
							|  |  |  |               copy_v3_fl(v3d->shading.background_color, 0.05f); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           case SPACE_FILE: { | 
					
						
							|  |  |  |             SpaceFile *sfile = (SpaceFile *)sl; | 
					
						
							|  |  |  |             if (sfile->params) { | 
					
						
							|  |  |  |               const char *dir_default = BKE_appdir_folder_default(); | 
					
						
							|  |  |  |               if (dir_default) { | 
					
						
							|  |  |  |                 STRNCPY(sfile->params->dir, dir_default); | 
					
						
							|  |  |  |                 sfile->params->file[0] = '\0'; | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 08:49:10 +10:00
										 |  |  |   if (builtin_template) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     /* Name all screens by their workspaces (avoids 'Default.###' names). */ | 
					
						
							| 
									
										
										
										
											2019-04-23 08:49:10 +10:00
										 |  |  |     /* Default only has one window. */ | 
					
						
							|  |  |  |     wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first; | 
					
						
							|  |  |  |     for (WorkSpace *workspace = bmain->workspaces.first; workspace; | 
					
						
							|  |  |  |          workspace = workspace->id.next) { | 
					
						
							|  |  |  |       WorkSpaceLayout *layout = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook, | 
					
						
							|  |  |  |                                                                             workspace); | 
					
						
							|  |  |  |       bScreen *screen = layout->screen; | 
					
						
							|  |  |  |       BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2); | 
					
						
							|  |  |  |       BLI_libblock_ensure_unique_name(bmain, screen->id.name); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-23 08:49:10 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 08:49:10 +10:00
										 |  |  |   if (app_template == NULL) { | 
					
						
							|  |  |  |     /* 'UV Editing' should use UV mode. */ | 
					
						
							|  |  |  |     bScreen *screen = BLI_findstring(&bmain->screens, "UV Editing", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  |       for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { | 
					
						
							|  |  |  |         if (sl->spacetype == SPACE_IMAGE) { | 
					
						
							|  |  |  |           SpaceImage *sima = (SpaceImage *)sl; | 
					
						
							|  |  |  |           if (sima->mode == SI_MODE_VIEW) { | 
					
						
							|  |  |  |             sima->mode = SI_MODE_UV; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* For 2D animation template. */ | 
					
						
							|  |  |  |   if (app_template && STREQ(app_template, "2D_Animation")) { | 
					
						
							|  |  |  |     for (WorkSpace *workspace = bmain->workspaces.first; workspace; | 
					
						
							|  |  |  |          workspace = workspace->id.next) { | 
					
						
							|  |  |  |       const char *name = workspace->id.name + 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (STREQ(name, "Drawing")) { | 
					
						
							|  |  |  |         workspace->object_mode = OB_MODE_PAINT_GPENCIL; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     /* set object in drawing mode */ | 
					
						
							|  |  |  |     for (Object *object = bmain->objects.first; object; object = object->id.next) { | 
					
						
							|  |  |  |       if (object->type == OB_GPENCIL) { | 
					
						
							|  |  |  |         bGPdata *gpd = (bGPdata *)object->data; | 
					
						
							|  |  |  |         object->mode = OB_MODE_PAINT_GPENCIL; | 
					
						
							|  |  |  |         gpd->flag |= GP_DATA_STROKE_PAINTMODE; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Be sure curfalloff and primitive are initializated */ | 
					
						
							|  |  |  |     for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | 
					
						
							|  |  |  |       ToolSettings *ts = scene->toolsettings; | 
					
						
							|  |  |  |       if (ts->gp_sculpt.cur_falloff == NULL) { | 
					
						
							|  |  |  |         ts->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | 
					
						
							|  |  |  |         CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff; | 
					
						
							|  |  |  |         curvemapping_initialize(gp_falloff_curve); | 
					
						
							|  |  |  |         curvemap_reset(gp_falloff_curve->cm, | 
					
						
							|  |  |  |                        &gp_falloff_curve->clipr, | 
					
						
							|  |  |  |                        CURVE_PRESET_GAUSS, | 
					
						
							|  |  |  |                        CURVEMAP_SLOPE_POSITIVE); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (ts->gp_sculpt.cur_primitive == NULL) { | 
					
						
							|  |  |  |         ts->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | 
					
						
							|  |  |  |         CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive; | 
					
						
							|  |  |  |         curvemapping_initialize(gp_primitive_curve); | 
					
						
							|  |  |  |         curvemap_reset(gp_primitive_curve->cm, | 
					
						
							|  |  |  |                        &gp_primitive_curve->clipr, | 
					
						
							|  |  |  |                        CURVE_PRESET_BELL, | 
					
						
							|  |  |  |                        CURVEMAP_SLOPE_POSITIVE); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (builtin_template) { | 
					
						
							|  |  |  |     /* Clear all tools to use default options instead, ignore the tool saved in the file. */ | 
					
						
							|  |  |  |     for (WorkSpace *workspace = bmain->workspaces.first; workspace; | 
					
						
							|  |  |  |          workspace = workspace->id.next) { | 
					
						
							|  |  |  |       while (!BLI_listbase_is_empty(&workspace->tools)) { | 
					
						
							|  |  |  |         BKE_workspace_tool_remove(workspace, workspace->tools.first); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { | 
					
						
							|  |  |  |       /* Hide channels in timelines. */ | 
					
						
							|  |  |  |       for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  |         SpaceAction *saction = (sa->spacetype == SPACE_ACTION) ? sa->spacedata.first : NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (saction && saction->mode == SACTCONT_TIMELINE) { | 
					
						
							|  |  |  |           for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							|  |  |  |             if (ar->regiontype == RGN_TYPE_CHANNELS) { | 
					
						
							|  |  |  |               ar->flag |= RGN_FLAG_HIDDEN; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | 
					
						
							|  |  |  |       BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       scene->r.cfra = 1.0f; | 
					
						
							|  |  |  |       scene->r.displaymode = R_OUTPUT_WINDOW; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (app_template && STREQ(app_template, "Video_Editing")) { | 
					
						
							|  |  |  |         /* Filmic is too slow, use default until it is optimized. */ | 
					
						
							|  |  |  |         STRNCPY(scene->view_settings.view_transform, "Default"); | 
					
						
							|  |  |  |         STRNCPY(scene->view_settings.look, "None"); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							|  |  |  |         /* AV Sync break physics sim caching, disable until that is fixed. */ | 
					
						
							|  |  |  |         scene->audio.flag &= ~AUDIO_SYNC; | 
					
						
							|  |  |  |         scene->flag &= ~SCE_FRAME_DROP; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /* Don't enable compositing nodes. */ | 
					
						
							|  |  |  |       if (scene->nodetree) { | 
					
						
							|  |  |  |         ntreeFreeNestedTree(scene->nodetree); | 
					
						
							|  |  |  |         MEM_freeN(scene->nodetree); | 
					
						
							|  |  |  |         scene->nodetree = NULL; | 
					
						
							|  |  |  |         scene->use_nodes = false; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /* Rename render layers. */ | 
					
						
							|  |  |  |       BKE_view_layer_rename(bmain, scene, scene->view_layers.first, "View Layer"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /* New EEVEE defaults. */ | 
					
						
							|  |  |  |       scene->eevee.bloom_intensity = 0.05f; | 
					
						
							|  |  |  |       scene->eevee.bloom_clamp = 0.0f; | 
					
						
							|  |  |  |       scene->eevee.motion_blur_shutter = 0.5f; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Rename light objects. */ | 
					
						
							| 
									
										
										
										
											2019-04-22 06:21:49 +10:00
										 |  |  |     rename_id_for_versioning(bmain, ID_OB, "Lamp", "Light"); | 
					
						
							|  |  |  |     rename_id_for_versioning(bmain, ID_LA, "Lamp", "Light"); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) { | 
					
						
							|  |  |  |       /* Match default for new meshes. */ | 
					
						
							|  |  |  |       mesh->smoothresh = DEG2RADF(30); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { | 
					
						
							|  |  |  |     for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  |       for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { | 
					
						
							|  |  |  |         if (sl->spacetype == SPACE_VIEW3D) { | 
					
						
							|  |  |  |           View3D *v3d = (View3D *)sl; | 
					
						
							|  |  |  |           v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | 
					
						
							|  |  |  |     copy_v3_v3(scene->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3}); | 
					
						
							|  |  |  |     copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f); | 
					
						
							|  |  |  |     copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | } |