| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2020-10-02 23:36:05 +10:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This file handles updating the `startup.blend`, this is used when reading old files. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unlike regular versioning this makes changes that ensure the startup file | 
					
						
							|  |  |  |  * has brushes and other presets setup to take advantage of newer features. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * To update preference defaults see `userdef_default.c`. | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  | #include "MEM_guardedalloc.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"
 | 
					
						
							| 
									
										
										
										
											2019-05-17 15:35:57 +02:00
										 |  |  | #include "BLI_system.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-20 16:14:02 +02:00
										 |  |  | #include "DNA_camera_types.h"
 | 
					
						
							| 
									
										
										
										
											2019-11-20 16:12:32 -05:00
										 |  |  | #include "DNA_curveprofile_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-20 13:47:59 +02:00
										 |  |  | #include "DNA_gpencil_types.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "DNA_light_types.h"
 | 
					
						
							| 
									
										
										
										
											2020-12-15 10:47:58 +11:00
										 |  |  | #include "DNA_material_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-15 18:28:51 +01:00
										 |  |  | #include "DNA_mesh_types.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "DNA_meshdata_types.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-15 18:28:51 +01:00
										 |  |  | #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"
 | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  | #include "BKE_brush.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-20 13:10:56 +02:00
										 |  |  | #include "BKE_colortools.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "BKE_curveprofile.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-09 16:27:24 +01:00
										 |  |  | #include "BKE_gpencil.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  | #include "BKE_layer.h"
 | 
					
						
							| 
									
										
										
										
											2020-02-10 12:58:59 +01:00
										 |  |  | #include "BKE_lib_id.h"
 | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | #include "BKE_main.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-09 16:27:24 +01:00
										 |  |  | #include "BKE_material.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "BKE_mesh.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  | #include "BKE_node.h"
 | 
					
						
							| 
									
										
										
										
											2019-09-27 16:52:08 +02: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"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-24 22:54:51 +11:00
										 |  |  | /* Make preferences read-only, use versioning_userdef.c. */ | 
					
						
							|  |  |  | #define U (*((const UserDef *)&U))
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 09:36:38 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Rename if the ID doesn't exist. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static ID *rename_id_for_versioning(Main *bmain, | 
					
						
							|  |  |  |                                     const short id_type, | 
					
						
							|  |  |  |                                     const char *name_src, | 
					
						
							|  |  |  |                                     const char *name_dst) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   /* We can ignore libraries */ | 
					
						
							|  |  |  |   ListBase *lb = which_libbase(bmain, id_type); | 
					
						
							|  |  |  |   ID *id = NULL; | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |   LISTBASE_FOREACH (ID *, idtest, lb) { | 
					
						
							| 
									
										
										
										
											2019-01-30 09:36:38 +11:00
										 |  |  |     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-06-13 17:40:04 +02:00
										 |  |  | static bool blo_is_builtin_template(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. */ | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   return (!app_template || | 
					
						
							|  |  |  |           STR_ELEM(app_template, "2D_Animation", "Sculpting", "VFX", "Video_Editing")); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-05-19 13:18:50 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | static void blo_update_defaults_screen(bScreen *screen, | 
					
						
							|  |  |  |                                        const char *app_template, | 
					
						
							|  |  |  |                                        const char *workspace_name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   /* For all app templates. */ | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |   LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | 
					
						
							|  |  |  |     LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       /* Some toolbars have been saved as initialized,
 | 
					
						
							|  |  |  |        * we don't want them to have odd zoom-level or scrolling set, see: T47047 */ | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |       if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) { | 
					
						
							| 
									
										
										
										
											2020-08-01 13:02:21 +10:00
										 |  |  |         region->v2d.flag &= ~V2D_IS_INIT; | 
					
						
							| 
									
										
										
										
											2014-02-07 20:26:43 +06:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     /* Set default folder. */ | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |     LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       if (sl->spacetype == 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'; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2018-10-30 08:32:06 +11:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* For builtin templates only. */ | 
					
						
							|  |  |  |   if (!blo_is_builtin_template(app_template)) { | 
					
						
							|  |  |  |     return; | 
					
						
							| 
									
										
										
										
											2019-04-23 08:49:10 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |   LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | 
					
						
							|  |  |  |     LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       /* Remove all stored panels, we want to use defaults
 | 
					
						
							|  |  |  |        * (order, open/closed) as defined by UI code here! */ | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |       BKE_area_region_panels_free(®ion->panels); | 
					
						
							|  |  |  |       BLI_freelistN(®ion->panels_category_active); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /* Reset size so it uses consistent defaults from the region types. */ | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |       region->sizex = 0; | 
					
						
							|  |  |  |       region->sizey = 0; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     if (area->spacetype == SPACE_IMAGE) { | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       if (STREQ(workspace_name, "UV Editing")) { | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |         SpaceImage *sima = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |         if (sima->mode == SI_MODE_VIEW) { | 
					
						
							|  |  |  |           sima->mode = SI_MODE_UV; | 
					
						
							| 
									
										
										
										
											2018-10-19 20:10:14 +11:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-09-27 11:20:27 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     else if (area->spacetype == SPACE_ACTION) { | 
					
						
							| 
									
										
										
										
											2019-11-30 17:03:22 +11:00
										 |  |  |       /* Show markers region, hide channels and collapse summary in timelines. */ | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |       SpaceAction *saction = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-11-30 17:03:22 +11:00
										 |  |  |       saction->flag |= SACTION_SHOW_MARKERS; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       if (saction->mode == SACTCONT_TIMELINE) { | 
					
						
							|  |  |  |         saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |         LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |           if (region->regiontype == RGN_TYPE_CHANNELS) { | 
					
						
							|  |  |  |             region->flag |= RGN_FLAG_HIDDEN; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-08-21 15:21:53 +02:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     else if (area->spacetype == SPACE_GRAPH) { | 
					
						
							|  |  |  |       SpaceGraph *sipo = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-11-30 17:03:22 +11:00
										 |  |  |       sipo->flag |= SIPO_SHOW_MARKERS; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     else if (area->spacetype == SPACE_NLA) { | 
					
						
							|  |  |  |       SpaceNla *snla = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-11-30 17:03:22 +11:00
										 |  |  |       snla->flag |= SNLA_SHOW_MARKERS; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     else if (area->spacetype == SPACE_SEQ) { | 
					
						
							|  |  |  |       SpaceSeq *seq = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2020-12-15 23:15:32 +01:00
										 |  |  |       seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES | SEQ_ZOOM_TO_FIT | SEQ_SHOW_STRIP_OVERLAY | | 
					
						
							|  |  |  |                    SEQ_SHOW_STRIP_SOURCE | SEQ_SHOW_STRIP_NAME | SEQ_SHOW_STRIP_DURATION; | 
					
						
							| 
									
										
										
										
											2021-03-16 17:59:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       seq->render_size = SEQ_RENDER_SIZE_PROXY_100; | 
					
						
							|  |  |  |       seq->flag |= SEQ_USE_PROXIES; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     else if (area->spacetype == SPACE_TEXT) { | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       /* Show syntax and line numbers in Script workspace text editor. */ | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |       SpaceText *stext = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       stext->showsyntax = true; | 
					
						
							|  |  |  |       stext->showlinenrs = true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     else if (area->spacetype == SPACE_VIEW3D) { | 
					
						
							|  |  |  |       View3D *v3d = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       /* Screen space cavity by default for faster performance. */ | 
					
						
							|  |  |  |       v3d->shading.cavity_type = V3D_SHADING_CAVITY_CURVATURE; | 
					
						
							|  |  |  |       v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT; | 
					
						
							|  |  |  |       v3d->overlay.texture_paint_mode_opacity = 1.0f; | 
					
						
							|  |  |  |       v3d->overlay.weight_paint_mode_opacity = 1.0f; | 
					
						
							|  |  |  |       v3d->overlay.vertex_paint_mode_opacity = 1.0f; | 
					
						
							|  |  |  |       /* Use dimmed selected edges. */ | 
					
						
							|  |  |  |       v3d->overlay.edit_flag &= ~V3D_OVERLAY_EDIT_EDGES; | 
					
						
							|  |  |  |       /* grease pencil settings */ | 
					
						
							|  |  |  |       v3d->vertex_opacity = 1.0f; | 
					
						
							|  |  |  |       v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES; | 
					
						
							|  |  |  |       /* Remove dither pattern in wireframe mode. */ | 
					
						
							|  |  |  |       v3d->shading.xray_alpha_wire = 0.0f; | 
					
						
							| 
									
										
										
										
											2020-04-24 15:19:54 +02:00
										 |  |  |       v3d->clip_start = 0.01f; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       /* 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); | 
					
						
							| 
									
										
										
										
											2018-09-20 13:10:56 +02:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-05-18 16:38:53 +02:00
										 |  |  |       /* Disable Curve Normals. */ | 
					
						
							|  |  |  |       v3d->overlay.edit_flag &= ~V3D_OVERLAY_EDIT_CU_NORMALS; | 
					
						
							| 
									
										
										
										
											2018-09-12 11:28:49 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |     else if (area->spacetype == SPACE_CLIP) { | 
					
						
							|  |  |  |       SpaceClip *sclip = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |       sclip->around = V3D_AROUND_CENTER_MEDIAN; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-22 18:33:25 +01:00
										 |  |  |   /* Show tool-header by default (for most cases at least, hide for others). */ | 
					
						
							|  |  |  |   const bool hide_image_tool_header = STREQ(workspace_name, "Rendering"); | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |   LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | 
					
						
							|  |  |  |     LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |       ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; | 
					
						
							| 
									
										
										
										
											2020-01-22 18:33:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |       LISTBASE_FOREACH (ARegion *, region, regionbase) { | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |         if (region->regiontype == RGN_TYPE_TOOL_HEADER) { | 
					
						
							| 
									
										
										
										
											2020-01-22 18:33:25 +01:00
										 |  |  |           if ((sl->spacetype == SPACE_IMAGE) && hide_image_tool_header) { | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |             region->flag |= RGN_FLAG_HIDDEN; | 
					
						
							| 
									
										
										
										
											2020-01-22 18:33:25 +01:00
										 |  |  |           } | 
					
						
							|  |  |  |           else { | 
					
						
							| 
									
										
										
										
											2020-03-06 16:56:42 +01:00
										 |  |  |             region->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER); | 
					
						
							| 
									
										
										
										
											2020-01-22 18:33:25 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2018-10-04 18:12:03 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-12-04 14:13:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /* 2D animation template. */ | 
					
						
							|  |  |  |   if (app_template && STREQ(app_template, "2D_Animation")) { | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |     LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | 
					
						
							| 
									
										
										
										
											2020-05-14 12:28:45 +02:00
										 |  |  |       if (area->spacetype == SPACE_ACTION) { | 
					
						
							|  |  |  |         SpaceAction *saction = area->spacedata.first; | 
					
						
							|  |  |  |         /* Enable Sliders. */ | 
					
						
							|  |  |  |         saction->flag |= SACTION_SLIDERS; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else if (area->spacetype == SPACE_VIEW3D) { | 
					
						
							|  |  |  |         View3D *v3d = area->spacedata.first; | 
					
						
							|  |  |  |         /* Set Material Color by default. */ | 
					
						
							|  |  |  |         v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR; | 
					
						
							|  |  |  |         /* Enable Annotations. */ | 
					
						
							|  |  |  |         v3d->flag2 |= V3D_SHOW_ANNOTATION; | 
					
						
							| 
									
										
										
										
											2019-12-04 14:13:21 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 16:33:01 +02:00
										 |  |  | void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_template) | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-05-26 20:32:21 +02:00
										 |  |  |   LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     if (layout->screen) { | 
					
						
							|  |  |  |       blo_update_defaults_screen(layout->screen, app_template, workspace->id.name + 2); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-29 22:50:14 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   if (blo_is_builtin_template(app_template)) { | 
					
						
							|  |  |  |     /* Clear all tools to use default options instead, ignore the tool saved in the file. */ | 
					
						
							|  |  |  |     while (!BLI_listbase_is_empty(&workspace->tools)) { | 
					
						
							|  |  |  |       BKE_workspace_tool_remove(workspace, workspace->tools.first); | 
					
						
							| 
									
										
										
										
											2019-04-29 22:50:14 +10:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     /* For 2D animation template. */ | 
					
						
							|  |  |  |     if (STREQ(workspace->id.name + 2, "Drawing")) { | 
					
						
							|  |  |  |       workspace->object_mode = OB_MODE_PAINT_GPENCIL; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-11-13 17:21:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* For Sculpting template. */ | 
					
						
							|  |  |  |     if (STREQ(workspace->id.name + 2, "Sculpting")) { | 
					
						
							| 
									
										
										
										
											2020-05-26 20:32:21 +02:00
										 |  |  |       LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { | 
					
						
							| 
									
										
										
										
											2019-11-13 17:21:17 +01:00
										 |  |  |         bScreen *screen = layout->screen; | 
					
						
							|  |  |  |         if (screen) { | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |           LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | 
					
						
							|  |  |  |             LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | 
					
						
							| 
									
										
										
										
											2020-04-03 13:25:03 +02:00
										 |  |  |               if (area->spacetype == SPACE_VIEW3D) { | 
					
						
							|  |  |  |                 View3D *v3d = area->spacedata.first; | 
					
						
							| 
									
										
										
										
											2019-11-13 17:21:17 +01:00
										 |  |  |                 v3d->shading.flag &= ~V3D_SHADING_CAVITY; | 
					
						
							|  |  |  |                 copy_v3_fl(v3d->shading.single_color, 1.0f); | 
					
						
							|  |  |  |                 STRNCPY(v3d->shading.matcap, "basic_1"); | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | static void blo_update_defaults_scene(Main *bmain, Scene *scene) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   scene->r.cfra = 1.0f; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* Don't enable compositing nodes. */ | 
					
						
							|  |  |  |   if (scene->nodetree) { | 
					
						
							| 
									
										
										
										
											2020-04-20 16:14:45 +02:00
										 |  |  |     ntreeFreeEmbeddedTree(scene->nodetree); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     MEM_freeN(scene->nodetree); | 
					
						
							|  |  |  |     scene->nodetree = NULL; | 
					
						
							|  |  |  |     scene->use_nodes = false; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* 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; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-15 13:11:22 +10:00
										 |  |  |   /* Change default cube-map quality. */ | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   scene->eevee.gi_filter_quality = 3.0f; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-22 16:04:25 +02:00
										 |  |  |   /* Enable Soft Shadows by default. */ | 
					
						
							|  |  |  |   scene->eevee.flag |= SCE_EEVEE_SHADOW_SOFT; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-16 21:15:45 +11:00
										 |  |  |   /* Be sure `curfalloff` and primitive are initialized. */ | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   ToolSettings *ts = scene->toolsettings; | 
					
						
							|  |  |  |   if (ts->gp_sculpt.cur_falloff == NULL) { | 
					
						
							| 
									
										
										
										
											2019-08-07 03:21:55 +10:00
										 |  |  |     ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff; | 
					
						
							| 
									
										
										
										
											2020-08-01 13:02:21 +10:00
										 |  |  |     BKE_curvemapping_init(gp_falloff_curve); | 
					
						
							| 
									
										
										
										
											2019-08-07 03:21:55 +10:00
										 |  |  |     BKE_curvemap_reset(gp_falloff_curve->cm, | 
					
						
							|  |  |  |                        &gp_falloff_curve->clipr, | 
					
						
							|  |  |  |                        CURVE_PRESET_GAUSS, | 
					
						
							|  |  |  |                        CURVEMAP_SLOPE_POSITIVE); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (ts->gp_sculpt.cur_primitive == NULL) { | 
					
						
							| 
									
										
										
										
											2019-08-07 03:21:55 +10:00
										 |  |  |     ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive; | 
					
						
							| 
									
										
										
										
											2020-08-01 13:02:21 +10:00
										 |  |  |     BKE_curvemapping_init(gp_primitive_curve); | 
					
						
							| 
									
										
										
										
											2019-08-07 03:21:55 +10:00
										 |  |  |     BKE_curvemap_reset(gp_primitive_curve->cm, | 
					
						
							|  |  |  |                        &gp_primitive_curve->clipr, | 
					
						
							|  |  |  |                        CURVE_PRESET_BELL, | 
					
						
							|  |  |  |                        CURVEMAP_SLOPE_POSITIVE); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-07-26 21:54:57 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |   if (ts->sculpt) { | 
					
						
							|  |  |  |     ts->sculpt->paint.symmetry_flags |= PAINT_SYMMETRY_FEATHER; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-26 21:54:57 +10:00
										 |  |  |   /* Correct default startup UV's. */ | 
					
						
							|  |  |  |   Mesh *me = BLI_findstring(&bmain->meshes, "Cube", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |   if (me && (me->totloop == 24) && (me->mloopuv != NULL)) { | 
					
						
							|  |  |  |     const float uv_values[24][2] = { | 
					
						
							|  |  |  |         {0.625, 0.50}, {0.875, 0.50}, {0.875, 0.75}, {0.625, 0.75}, {0.375, 0.75}, {0.625, 0.75}, | 
					
						
							|  |  |  |         {0.625, 1.00}, {0.375, 1.00}, {0.375, 0.00}, {0.625, 0.00}, {0.625, 0.25}, {0.375, 0.25}, | 
					
						
							|  |  |  |         {0.125, 0.50}, {0.375, 0.50}, {0.375, 0.75}, {0.125, 0.75}, {0.375, 0.50}, {0.625, 0.50}, | 
					
						
							|  |  |  |         {0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50}, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     for (int i = 0; i < ARRAY_SIZE(uv_values); i++) { | 
					
						
							|  |  |  |       copy_v2_v2(me->mloopuv[i].uv, uv_values[i]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-11-20 16:12:32 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /* Make sure that the curve profile is initialized */ | 
					
						
							|  |  |  |   if (ts->custom_bevel_profile_preset == NULL) { | 
					
						
							|  |  |  |     ts->custom_bevel_profile_preset = BKE_curveprofile_add(PROF_PRESET_LINE); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Update defaults in startup.blend, without having to save and embed the file. | 
					
						
							| 
									
										
										
										
											2020-05-06 08:05:19 +10:00
										 |  |  |  * This function can be emptied each time the startup.blend is updated. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note Screen data may be cleared at this point, this will happen in the case | 
					
						
							|  |  |  |  * an app-template's data needs to be versioned when read-file is called with "Load UI" disabled. | 
					
						
							|  |  |  |  * Versioning the screen data can be safely skipped without "Load UI" since the screen data | 
					
						
							|  |  |  |  * will have been versioned when it was first loaded. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  | void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   /* For all app templates. */ | 
					
						
							|  |  |  |   for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { | 
					
						
							| 
									
										
										
										
											2019-06-13 16:33:01 +02:00
										 |  |  |     BLO_update_defaults_workspace(workspace, app_template); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 10:49:18 +02:00
										 |  |  |   /* New grease pencil brushes and vertex paint setup. */ | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     /* Update Grease Pencil brushes. */ | 
					
						
							|  |  |  |     Brush *brush; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Pencil brush. */ | 
					
						
							|  |  |  |     rename_id_for_versioning(bmain, ID_BR, "Draw Pencil", "Pencil"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Pen brush. */ | 
					
						
							|  |  |  |     rename_id_for_versioning(bmain, ID_BR, "Draw Pen", "Pen"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Pen Soft brush. */ | 
					
						
							|  |  |  |     brush = (Brush *)rename_id_for_versioning(bmain, ID_BR, "Draw Soft", "Pencil Soft"); | 
					
						
							|  |  |  |     if (brush) { | 
					
						
							|  |  |  |       brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PEN; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Ink Pen brush. */ | 
					
						
							|  |  |  |     rename_id_for_versioning(bmain, ID_BR, "Draw Ink", "Ink Pen"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Ink Pen Rough brush. */ | 
					
						
							|  |  |  |     rename_id_for_versioning(bmain, ID_BR, "Draw Noise", "Ink Pen Rough"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Marker Bold brush. */ | 
					
						
							|  |  |  |     rename_id_for_versioning(bmain, ID_BR, "Draw Marker", "Marker Bold"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Marker Chisel brush. */ | 
					
						
							|  |  |  |     rename_id_for_versioning(bmain, ID_BR, "Draw Block", "Marker Chisel"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Remove useless Fill Area.001 brush. */ | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, "Fill Area.001", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (brush) { | 
					
						
							|  |  |  |       BKE_id_delete(bmain, brush); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Rename and fix materials and enable default object lights on. */ | 
					
						
							|  |  |  |     if (app_template && STREQ(app_template, "2D_Animation")) { | 
					
						
							|  |  |  |       Material *ma = NULL; | 
					
						
							|  |  |  |       rename_id_for_versioning(bmain, ID_MA, "Black", "Solid Stroke"); | 
					
						
							|  |  |  |       rename_id_for_versioning(bmain, ID_MA, "Red", "Squares Stroke"); | 
					
						
							|  |  |  |       rename_id_for_versioning(bmain, ID_MA, "Grey", "Solid Fill"); | 
					
						
							|  |  |  |       rename_id_for_versioning(bmain, ID_MA, "Black Dots", "Dots Stroke"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /* Dots Stroke. */ | 
					
						
							|  |  |  |       ma = BLI_findstring(&bmain->materials, "Dots Stroke", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |       if (ma == NULL) { | 
					
						
							|  |  |  |         ma = BKE_gpencil_material_add(bmain, "Dots Stroke"); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       ma->gp_style->mode = GP_MATERIAL_MODE_DOT; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /* Squares Stroke. */ | 
					
						
							|  |  |  |       ma = BLI_findstring(&bmain->materials, "Squares Stroke", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |       if (ma == NULL) { | 
					
						
							|  |  |  |         ma = BKE_gpencil_material_add(bmain, "Squares Stroke"); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       ma->gp_style->mode = GP_MATERIAL_MODE_SQUARE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-27 10:49:33 +02:00
										 |  |  |       /* Change Solid Stroke settings. */ | 
					
						
							|  |  |  |       ma = BLI_findstring(&bmain->materials, "Solid Stroke", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |       if (ma != NULL) { | 
					
						
							|  |  |  |         ma->gp_style->mix_rgba[3] = 1.0f; | 
					
						
							|  |  |  |         ma->gp_style->texture_offset[0] = -0.5f; | 
					
						
							|  |  |  |         ma->gp_style->mix_factor = 0.5f; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 10:49:18 +02:00
										 |  |  |       /* Change Solid Fill settings. */ | 
					
						
							|  |  |  |       ma = BLI_findstring(&bmain->materials, "Solid Fill", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |       if (ma != NULL) { | 
					
						
							|  |  |  |         ma->gp_style->flag &= ~GP_MATERIAL_STROKE_SHOW; | 
					
						
							| 
									
										
										
										
											2020-04-27 10:49:33 +02:00
										 |  |  |         ma->gp_style->mix_rgba[3] = 1.0f; | 
					
						
							|  |  |  |         ma->gp_style->texture_offset[0] = -0.5f; | 
					
						
							|  |  |  |         ma->gp_style->mix_factor = 0.5f; | 
					
						
							| 
									
										
										
										
											2020-04-10 10:49:18 +02:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       Object *ob = BLI_findstring(&bmain->objects, "Stroke", offsetof(ID, name) + 2); | 
					
						
							|  |  |  |       if (ob && ob->type == OB_GPENCIL) { | 
					
						
							|  |  |  |         ob->dtx |= OB_USE_GPENCIL_LIGHTS; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Reset all grease pencil brushes. */ | 
					
						
							|  |  |  |     Scene *scene = bmain->scenes.first; | 
					
						
							| 
									
										
										
										
											2020-05-15 16:43:50 +02:00
										 |  |  |     BKE_brush_gpencil_paint_presets(bmain, scene->toolsettings, true); | 
					
						
							| 
									
										
										
										
											2020-05-30 17:31:54 +02:00
										 |  |  |     BKE_brush_gpencil_sculpt_presets(bmain, scene->toolsettings, true); | 
					
						
							|  |  |  |     BKE_brush_gpencil_vertex_presets(bmain, scene->toolsettings, true); | 
					
						
							|  |  |  |     BKE_brush_gpencil_weight_presets(bmain, scene->toolsettings, true); | 
					
						
							| 
									
										
										
										
											2020-04-10 10:49:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Ensure new Paint modes. */ | 
					
						
							|  |  |  |     BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_VERTEX_GPENCIL); | 
					
						
							|  |  |  |     BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_SCULPT_GPENCIL); | 
					
						
							|  |  |  |     BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_WEIGHT_GPENCIL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Enable cursor. */ | 
					
						
							|  |  |  |     GpPaint *gp_paint = scene->toolsettings->gp_paint; | 
					
						
							|  |  |  |     gp_paint->paint.flags |= PAINT_SHOW_BRUSH; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Ensure Palette by default. */ | 
					
						
							|  |  |  |     BKE_gpencil_palette_ensure(bmain, scene); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* For builtin templates only. */ | 
					
						
							|  |  |  |   if (!blo_is_builtin_template(app_template)) { | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* Workspaces. */ | 
					
						
							| 
									
										
										
										
											2020-05-06 08:05:19 +10:00
										 |  |  |   LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) { | 
					
						
							|  |  |  |     LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | 
					
						
							|  |  |  |       LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) { | 
					
						
							| 
									
										
										
										
											2020-05-26 20:32:21 +02:00
										 |  |  |         WorkSpaceLayout *layout = BKE_workspace_active_layout_for_workspace_get( | 
					
						
							|  |  |  |             win->workspace_hook, workspace); | 
					
						
							| 
									
										
										
										
											2020-05-06 08:05:19 +10:00
										 |  |  |         /* Name all screens by their workspaces (avoids 'Default.###' names). */ | 
					
						
							|  |  |  |         /* Default only has one window. */ | 
					
						
							|  |  |  |         if (layout->screen) { | 
					
						
							|  |  |  |           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-08-27 19:09:49 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-06 08:05:19 +10:00
										 |  |  |         /* For some reason we have unused screens, needed until re-saving.
 | 
					
						
							|  |  |  |          * Clear unused layouts because they're visible in the outliner & Python API. */ | 
					
						
							|  |  |  |         LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout_iter, &workspace->layouts) { | 
					
						
							|  |  |  |           if (layout != layout_iter) { | 
					
						
							|  |  |  |             BKE_workspace_layout_remove(bmain, workspace, layout_iter); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-08-27 19:09:49 +10:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-05-24 18:03:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* Scenes */ | 
					
						
							|  |  |  |   for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | 
					
						
							|  |  |  |     blo_update_defaults_scene(bmain, scene); | 
					
						
							| 
									
										
										
										
											2019-05-24 18:03:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     if (app_template && STREQ(app_template, "Video_Editing")) { | 
					
						
							|  |  |  |       /* Filmic is too slow, use standard until it is optimized. */ | 
					
						
							|  |  |  |       STRNCPY(scene->view_settings.view_transform, "Standard"); | 
					
						
							|  |  |  |       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; | 
					
						
							| 
									
										
										
										
											2019-05-24 18:03:25 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-09-27 16:52:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Change default selection mode for Grease Pencil. */ | 
					
						
							|  |  |  |     if (app_template && STREQ(app_template, "2D_Animation")) { | 
					
						
							|  |  |  |       ToolSettings *ts = scene->toolsettings; | 
					
						
							|  |  |  |       ts->gpencil_selectmode_edit = GP_SELECTMODE_STROKE; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-11-21 18:03:38 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* Objects */ | 
					
						
							|  |  |  |   rename_id_for_versioning(bmain, ID_OB, "Lamp", "Light"); | 
					
						
							|  |  |  |   rename_id_for_versioning(bmain, ID_LA, "Lamp", "Light"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (app_template && STREQ(app_template, "2D_Animation")) { | 
					
						
							|  |  |  |     for (Object *object = bmain->objects.first; object; object = object->id.next) { | 
					
						
							|  |  |  |       if (object->type == OB_GPENCIL) { | 
					
						
							|  |  |  |         /* Set grease pencil object in drawing mode */ | 
					
						
							|  |  |  |         bGPdata *gpd = (bGPdata *)object->data; | 
					
						
							|  |  |  |         object->mode = OB_MODE_PAINT_GPENCIL; | 
					
						
							|  |  |  |         gpd->flag |= GP_DATA_STROKE_PAINTMODE; | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2018-11-28 15:57:40 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) { | 
					
						
							|  |  |  |     /* Match default for new meshes. */ | 
					
						
							|  |  |  |     mesh->smoothresh = DEG2RADF(30); | 
					
						
							| 
									
										
										
										
											2019-11-13 17:21:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* For Sculpting template. */ | 
					
						
							|  |  |  |     if (app_template && STREQ(app_template, "Sculpting")) { | 
					
						
							|  |  |  |       mesh->remesh_voxel_size = 0.035f; | 
					
						
							|  |  |  |       mesh->flag |= ME_REMESH_FIX_POLES | ME_REMESH_REPROJECT_VOLUME; | 
					
						
							|  |  |  |       BKE_mesh_smooth_flag_set(mesh, false); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-05-27 17:07:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   for (Camera *camera = bmain->cameras.first; camera; camera = camera->id.next) { | 
					
						
							|  |  |  |     /* Initialize to a useful value. */ | 
					
						
							|  |  |  |     camera->dof.focus_distance = 10.0f; | 
					
						
							|  |  |  |     camera->dof.aperture_fstop = 2.8f; | 
					
						
							| 
									
										
										
										
											2018-11-30 13:26:30 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-23 12:31:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-28 20:04:46 +02:00
										 |  |  |   for (Light *light = bmain->lights.first; light; light = light->id.next) { | 
					
						
							|  |  |  |     /* Fix lights defaults. */ | 
					
						
							|  |  |  |     light->clipsta = 0.05f; | 
					
						
							|  |  |  |     light->att_dist = 40.0f; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |   /* Materials */ | 
					
						
							|  |  |  |   for (Material *ma = bmain->materials.first; ma; ma = ma->id.next) { | 
					
						
							|  |  |  |     /* Update default material to be a bit more rough. */ | 
					
						
							|  |  |  |     ma->roughness = 0.4f; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (ma->nodetree) { | 
					
						
							| 
									
										
										
										
											2020-04-03 19:15:01 +02:00
										 |  |  |       LISTBASE_FOREACH (bNode *, node, &ma->nodetree->nodes) { | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |         if (node->type == SH_NODE_BSDF_PRINCIPLED) { | 
					
						
							|  |  |  |           bNodeSocket *roughness_socket = nodeFindSocket(node, SOCK_IN, "Roughness"); | 
					
						
							|  |  |  |           bNodeSocketValueFloat *roughness_data = roughness_socket->default_value; | 
					
						
							|  |  |  |           roughness_data->value = 0.4f; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Brushes */ | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2019-05-01 18:10:34 +10:00
										 |  |  |     /* Enable for UV sculpt (other brush types will be created as needed),
 | 
					
						
							|  |  |  |      * without this the grab brush will be active but not selectable from the list. */ | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |     const char *brush_name = "Grab"; | 
					
						
							|  |  |  |     Brush *brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							| 
									
										
										
										
											2019-06-13 17:40:04 +02:00
										 |  |  |     if (brush) { | 
					
						
							|  |  |  |       brush->ob_mode |= OB_MODE_EDIT; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-01 18:10:34 +10:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 12:31:37 +02:00
										 |  |  |   for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) { | 
					
						
							|  |  |  |     brush->blur_kernel_radius = 2; | 
					
						
							| 
									
										
										
										
											2019-10-02 03:32:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Use full strength for all non-sculpt brushes,
 | 
					
						
							|  |  |  |      * when painting we want to use full color/weight always. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * Note that sculpt is an exception, | 
					
						
							|  |  |  |      * its values are overwritten by #BKE_brush_sculpt_reset below. */ | 
					
						
							|  |  |  |     brush->alpha = 1.0; | 
					
						
							| 
									
										
										
										
											2019-10-30 16:57:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Enable antialiasing by default */ | 
					
						
							|  |  |  |     brush->sampling_flag |= BRUSH_PAINT_ANTIALIASING; | 
					
						
							| 
									
										
										
										
											2019-04-23 12:31:37 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-06-25 09:32:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     /* Change the spacing of the Smear brush to 3.0% */ | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |     const char *brush_name; | 
					
						
							|  |  |  |     Brush *brush; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     brush_name = "Smear"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							| 
									
										
										
										
											2019-06-25 09:32:06 +02:00
										 |  |  |     if (brush) { | 
					
						
							|  |  |  |       brush->spacing = 3.0; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |     brush_name = "Draw Sharp"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |     if (!brush) { | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_DRAW_SHARP; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |     brush_name = "Elastic Deform"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |     if (!brush) { | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_ELASTIC_DEFORM; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |     brush_name = "Pose"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |     if (!brush) { | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_POSE; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-17 13:00:01 +01:00
										 |  |  |     brush_name = "Multi-plane Scrape"; | 
					
						
							| 
									
										
										
										
											2019-11-06 19:39:34 +01:00
										 |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_MULTIPLANE_SCRAPE; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-01 19:37:25 +01:00
										 |  |  |     brush_name = "Clay Thumb"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_CLAY_THUMB; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     brush_name = "Cloth"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_CLOTH; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     brush_name = "Slide Relax"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_SLIDE_RELAX; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
  - SCULPT_UNDO_COLOR for undo support in sculpt mode
  - SCULPT_UPDATE_COLOR and PBVH flags and rendering
  - Sculpt Color API functions
  - Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
  - Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
  - Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
  - Remesher reprojection in the Voxel Remehser
  - Paint Brush and Smear Brush with color smoothing in alt-smooth mode
  - Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
  - Color Filter
  - Color picker (uses S shortcut, replaces smooth)
  - Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
											
										 
											2020-06-22 20:05:28 +02:00
										 |  |  |     brush_name = "Paint"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_PAINT; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     brush_name = "Smear"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_SMEAR; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
											
										 
											2020-08-10 17:57:01 +02:00
										 |  |  |     brush_name = "Boundary"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_BOUNDARY; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |     brush_name = "Simplify"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |     if (!brush) { | 
					
						
							| 
									
										
										
										
											2019-10-02 03:26:51 +10:00
										 |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_SIMPLIFY; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 19:49:20 +01:00
										 |  |  |     brush_name = "Draw Face Sets"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_DRAW_FACE_SETS; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-12 16:57:36 +02:00
										 |  |  |     brush_name = "Multires Displacement Eraser"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_DISPLACEMENT_ERASER; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-11 22:49:49 +01:00
										 |  |  |     brush_name = "Multires Displacement Smear"; | 
					
						
							|  |  |  |     brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); | 
					
						
							|  |  |  |     if (!brush) { | 
					
						
							|  |  |  |       brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); | 
					
						
							|  |  |  |       id_us_min(&brush->id); | 
					
						
							|  |  |  |       brush->sculpt_tool = SCULPT_TOOL_DISPLACEMENT_SMEAR; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |     /* Use the same tool icon color in the brush cursor */ | 
					
						
							| 
									
										
										
										
											2019-09-26 16:32:27 +02:00
										 |  |  |     for (brush = bmain->brushes.first; brush; brush = brush->id.next) { | 
					
						
							| 
									
										
										
										
											2019-10-02 03:32:51 +10:00
										 |  |  |       if (brush->ob_mode & OB_MODE_SCULPT) { | 
					
						
							|  |  |  |         BLI_assert(brush->sculpt_tool != 0); | 
					
						
							| 
									
										
										
										
											2019-09-26 16:14:02 +02:00
										 |  |  |         BKE_brush_sculpt_reset(brush); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-06-25 09:32:06 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-09-10 13:25:35 +00:00
										 |  |  | } |