Blender  V2.93
versioning_defaults.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
28 #include "MEM_guardedalloc.h"
29 
30 #include "BLI_listbase.h"
31 #include "BLI_math.h"
32 #include "BLI_string.h"
33 #include "BLI_system.h"
34 #include "BLI_utildefines.h"
35 
36 #include "DNA_camera_types.h"
37 #include "DNA_curveprofile_types.h"
38 #include "DNA_gpencil_types.h"
39 #include "DNA_light_types.h"
40 #include "DNA_material_types.h"
41 #include "DNA_mesh_types.h"
42 #include "DNA_meshdata_types.h"
43 #include "DNA_object_types.h"
44 #include "DNA_scene_types.h"
45 #include "DNA_screen_types.h"
46 #include "DNA_space_types.h"
47 #include "DNA_userdef_types.h"
49 #include "DNA_workspace_types.h"
50 
51 #include "BKE_appdir.h"
52 #include "BKE_brush.h"
53 #include "BKE_colortools.h"
54 #include "BKE_curveprofile.h"
55 #include "BKE_gpencil.h"
56 #include "BKE_layer.h"
57 #include "BKE_lib_id.h"
58 #include "BKE_main.h"
59 #include "BKE_material.h"
60 #include "BKE_mesh.h"
61 #include "BKE_node.h"
62 #include "BKE_paint.h"
63 #include "BKE_screen.h"
64 #include "BKE_workspace.h"
65 
66 #include "BLO_readfile.h"
67 
68 /* Make preferences read-only, use versioning_userdef.c. */
69 #define U (*((const UserDef *)&U))
70 
75  const short id_type,
76  const char *name_src,
77  const char *name_dst)
78 {
79  /* We can ignore libraries */
80  ListBase *lb = which_libbase(bmain, id_type);
81  ID *id = NULL;
82  LISTBASE_FOREACH (ID *, idtest, lb) {
83  if (idtest->lib == NULL) {
84  if (STREQ(idtest->name + 2, name_src)) {
85  id = idtest;
86  }
87  if (STREQ(idtest->name + 2, name_dst)) {
88  return NULL;
89  }
90  }
91  }
92  if (id != NULL) {
93  BLI_strncpy(id->name + 2, name_dst, sizeof(id->name) - 2);
94  /* We know it's unique, this just sorts. */
96  }
97  return id;
98 }
99 
100 static bool blo_is_builtin_template(const char *app_template)
101 {
102  /* For all builtin templates shipped with Blender. */
103  return (!app_template ||
104  STR_ELEM(app_template, "2D_Animation", "Sculpting", "VFX", "Video_Editing"));
105 }
106 
108  const char *app_template,
109  const char *workspace_name)
110 {
111  /* For all app templates. */
112  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
113  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
114  /* Some toolbars have been saved as initialized,
115  * we don't want them to have odd zoom-level or scrolling set, see: T47047 */
116  if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
117  region->v2d.flag &= ~V2D_IS_INIT;
118  }
119  }
120 
121  /* Set default folder. */
122  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
123  if (sl->spacetype == SPACE_FILE) {
124  SpaceFile *sfile = (SpaceFile *)sl;
125  if (sfile->params) {
126  const char *dir_default = BKE_appdir_folder_default();
127  if (dir_default) {
128  STRNCPY(sfile->params->dir, dir_default);
129  sfile->params->file[0] = '\0';
130  }
131  }
132  }
133  }
134  }
135 
136  /* For builtin templates only. */
138  return;
139  }
140 
141  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
142  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
143  /* Remove all stored panels, we want to use defaults
144  * (order, open/closed) as defined by UI code here! */
145  BKE_area_region_panels_free(&region->panels);
146  BLI_freelistN(&region->panels_category_active);
147 
148  /* Reset size so it uses consistent defaults from the region types. */
149  region->sizex = 0;
150  region->sizey = 0;
151  }
152 
153  if (area->spacetype == SPACE_IMAGE) {
154  if (STREQ(workspace_name, "UV Editing")) {
155  SpaceImage *sima = area->spacedata.first;
156  if (sima->mode == SI_MODE_VIEW) {
157  sima->mode = SI_MODE_UV;
158  }
159  }
160  }
161  else if (area->spacetype == SPACE_ACTION) {
162  /* Show markers region, hide channels and collapse summary in timelines. */
163  SpaceAction *saction = area->spacedata.first;
164  saction->flag |= SACTION_SHOW_MARKERS;
165  if (saction->mode == SACTCONT_TIMELINE) {
166  saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;
167 
168  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
169  if (region->regiontype == RGN_TYPE_CHANNELS) {
170  region->flag |= RGN_FLAG_HIDDEN;
171  }
172  }
173  }
174  }
175  else if (area->spacetype == SPACE_GRAPH) {
176  SpaceGraph *sipo = area->spacedata.first;
177  sipo->flag |= SIPO_SHOW_MARKERS;
178  }
179  else if (area->spacetype == SPACE_NLA) {
180  SpaceNla *snla = area->spacedata.first;
181  snla->flag |= SNLA_SHOW_MARKERS;
182  }
183  else if (area->spacetype == SPACE_SEQ) {
184  SpaceSeq *seq = area->spacedata.first;
187 
189  seq->flag |= SEQ_USE_PROXIES;
190  }
191  else if (area->spacetype == SPACE_TEXT) {
192  /* Show syntax and line numbers in Script workspace text editor. */
193  SpaceText *stext = area->spacedata.first;
194  stext->showsyntax = true;
195  stext->showlinenrs = true;
196  }
197  else if (area->spacetype == SPACE_VIEW3D) {
198  View3D *v3d = area->spacedata.first;
199  /* Screen space cavity by default for faster performance. */
205  /* Use dimmed selected edges. */
207  /* grease pencil settings */
208  v3d->vertex_opacity = 1.0f;
210  /* Remove dither pattern in wireframe mode. */
211  v3d->shading.xray_alpha_wire = 0.0f;
212  v3d->clip_start = 0.01f;
213  /* Skip startups that use the viewport color by default. */
215  copy_v3_fl(v3d->shading.background_color, 0.05f);
216  }
217  /* Disable Curve Normals. */
219  }
220  else if (area->spacetype == SPACE_CLIP) {
221  SpaceClip *sclip = area->spacedata.first;
223  }
224  }
225 
226  /* Show tool-header by default (for most cases at least, hide for others). */
227  const bool hide_image_tool_header = STREQ(workspace_name, "Rendering");
228  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
229  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
230  ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
231 
232  LISTBASE_FOREACH (ARegion *, region, regionbase) {
233  if (region->regiontype == RGN_TYPE_TOOL_HEADER) {
234  if ((sl->spacetype == SPACE_IMAGE) && hide_image_tool_header) {
235  region->flag |= RGN_FLAG_HIDDEN;
236  }
237  else {
238  region->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
239  }
240  }
241  }
242  }
243  }
244 
245  /* 2D animation template. */
246  if (app_template && STREQ(app_template, "2D_Animation")) {
247  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
248  if (area->spacetype == SPACE_ACTION) {
249  SpaceAction *saction = area->spacedata.first;
250  /* Enable Sliders. */
251  saction->flag |= SACTION_SLIDERS;
252  }
253  else if (area->spacetype == SPACE_VIEW3D) {
254  View3D *v3d = area->spacedata.first;
255  /* Set Material Color by default. */
257  /* Enable Annotations. */
258  v3d->flag2 |= V3D_SHOW_ANNOTATION;
259  }
260  }
261  }
262 }
263 
265 {
266  LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
267  if (layout->screen) {
268  blo_update_defaults_screen(layout->screen, app_template, workspace->id.name + 2);
269  }
270  }
271 
273  /* Clear all tools to use default options instead, ignore the tool saved in the file. */
274  while (!BLI_listbase_is_empty(&workspace->tools)) {
275  BKE_workspace_tool_remove(workspace, workspace->tools.first);
276  }
277 
278  /* For 2D animation template. */
279  if (STREQ(workspace->id.name + 2, "Drawing")) {
280  workspace->object_mode = OB_MODE_PAINT_GPENCIL;
281  }
282 
283  /* For Sculpting template. */
284  if (STREQ(workspace->id.name + 2, "Sculpting")) {
285  LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
286  bScreen *screen = layout->screen;
287  if (screen) {
288  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
289  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
290  if (area->spacetype == SPACE_VIEW3D) {
291  View3D *v3d = area->spacedata.first;
293  copy_v3_fl(v3d->shading.single_color, 1.0f);
294  STRNCPY(v3d->shading.matcap, "basic_1");
295  }
296  }
297  }
298  }
299  }
300  }
301  }
302 }
303 
305 {
307 
308  scene->r.cfra = 1.0f;
309 
310  /* Don't enable compositing nodes. */
311  if (scene->nodetree) {
314  scene->nodetree = NULL;
315  scene->use_nodes = false;
316  }
317 
318  /* Rename render layers. */
319  BKE_view_layer_rename(bmain, scene, scene->view_layers.first, "View Layer");
320 
321  /* New EEVEE defaults. */
322  scene->eevee.bloom_intensity = 0.05f;
323  scene->eevee.bloom_clamp = 0.0f;
325 
326  copy_v3_v3(scene->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
327  copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f);
328  copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f);
329 
330  /* Change default cube-map quality. */
331  scene->eevee.gi_filter_quality = 3.0f;
332 
333  /* Enable Soft Shadows by default. */
335 
336  /* Be sure `curfalloff` and primitive are initialized. */
338  if (ts->gp_sculpt.cur_falloff == NULL) {
339  ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
340  CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
341  BKE_curvemapping_init(gp_falloff_curve);
342  BKE_curvemap_reset(gp_falloff_curve->cm,
343  &gp_falloff_curve->clipr,
346  }
347  if (ts->gp_sculpt.cur_primitive == NULL) {
348  ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
349  CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive;
350  BKE_curvemapping_init(gp_primitive_curve);
351  BKE_curvemap_reset(gp_primitive_curve->cm,
352  &gp_primitive_curve->clipr,
355  }
356 
357  if (ts->sculpt) {
359  }
360 
361  /* Correct default startup UV's. */
362  Mesh *me = BLI_findstring(&bmain->meshes, "Cube", offsetof(ID, name) + 2);
363  if (me && (me->totloop == 24) && (me->mloopuv != NULL)) {
364  const float uv_values[24][2] = {
365  {0.625, 0.50}, {0.875, 0.50}, {0.875, 0.75}, {0.625, 0.75}, {0.375, 0.75}, {0.625, 0.75},
366  {0.625, 1.00}, {0.375, 1.00}, {0.375, 0.00}, {0.625, 0.00}, {0.625, 0.25}, {0.375, 0.25},
367  {0.125, 0.50}, {0.375, 0.50}, {0.375, 0.75}, {0.125, 0.75}, {0.375, 0.50}, {0.625, 0.50},
368  {0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50},
369  };
370  for (int i = 0; i < ARRAY_SIZE(uv_values); i++) {
371  copy_v2_v2(me->mloopuv[i].uv, uv_values[i]);
372  }
373  }
374 
375  /* Make sure that the curve profile is initialized */
376  if (ts->custom_bevel_profile_preset == NULL) {
378  }
379 }
380 
391 {
392  /* For all app templates. */
393  for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
395  }
396 
397  /* New grease pencil brushes and vertex paint setup. */
398  {
399  /* Update Grease Pencil brushes. */
400  Brush *brush;
401 
402  /* Pencil brush. */
403  rename_id_for_versioning(bmain, ID_BR, "Draw Pencil", "Pencil");
404 
405  /* Pen brush. */
406  rename_id_for_versioning(bmain, ID_BR, "Draw Pen", "Pen");
407 
408  /* Pen Soft brush. */
409  brush = (Brush *)rename_id_for_versioning(bmain, ID_BR, "Draw Soft", "Pencil Soft");
410  if (brush) {
412  }
413 
414  /* Ink Pen brush. */
415  rename_id_for_versioning(bmain, ID_BR, "Draw Ink", "Ink Pen");
416 
417  /* Ink Pen Rough brush. */
418  rename_id_for_versioning(bmain, ID_BR, "Draw Noise", "Ink Pen Rough");
419 
420  /* Marker Bold brush. */
421  rename_id_for_versioning(bmain, ID_BR, "Draw Marker", "Marker Bold");
422 
423  /* Marker Chisel brush. */
424  rename_id_for_versioning(bmain, ID_BR, "Draw Block", "Marker Chisel");
425 
426  /* Remove useless Fill Area.001 brush. */
427  brush = BLI_findstring(&bmain->brushes, "Fill Area.001", offsetof(ID, name) + 2);
428  if (brush) {
429  BKE_id_delete(bmain, brush);
430  }
431 
432  /* Rename and fix materials and enable default object lights on. */
433  if (app_template && STREQ(app_template, "2D_Animation")) {
434  Material *ma = NULL;
435  rename_id_for_versioning(bmain, ID_MA, "Black", "Solid Stroke");
436  rename_id_for_versioning(bmain, ID_MA, "Red", "Squares Stroke");
437  rename_id_for_versioning(bmain, ID_MA, "Grey", "Solid Fill");
438  rename_id_for_versioning(bmain, ID_MA, "Black Dots", "Dots Stroke");
439 
440  /* Dots Stroke. */
441  ma = BLI_findstring(&bmain->materials, "Dots Stroke", offsetof(ID, name) + 2);
442  if (ma == NULL) {
443  ma = BKE_gpencil_material_add(bmain, "Dots Stroke");
444  }
446 
447  /* Squares Stroke. */
448  ma = BLI_findstring(&bmain->materials, "Squares Stroke", offsetof(ID, name) + 2);
449  if (ma == NULL) {
450  ma = BKE_gpencil_material_add(bmain, "Squares Stroke");
451  }
453 
454  /* Change Solid Stroke settings. */
455  ma = BLI_findstring(&bmain->materials, "Solid Stroke", offsetof(ID, name) + 2);
456  if (ma != NULL) {
457  ma->gp_style->mix_rgba[3] = 1.0f;
458  ma->gp_style->texture_offset[0] = -0.5f;
459  ma->gp_style->mix_factor = 0.5f;
460  }
461 
462  /* Change Solid Fill settings. */
463  ma = BLI_findstring(&bmain->materials, "Solid Fill", offsetof(ID, name) + 2);
464  if (ma != NULL) {
466  ma->gp_style->mix_rgba[3] = 1.0f;
467  ma->gp_style->texture_offset[0] = -0.5f;
468  ma->gp_style->mix_factor = 0.5f;
469  }
470 
471  Object *ob = BLI_findstring(&bmain->objects, "Stroke", offsetof(ID, name) + 2);
472  if (ob && ob->type == OB_GPENCIL) {
473  ob->dtx |= OB_USE_GPENCIL_LIGHTS;
474  }
475  }
476 
477  /* Reset all grease pencil brushes. */
478  Scene *scene = bmain->scenes.first;
483 
484  /* Ensure new Paint modes. */
488 
489  /* Enable cursor. */
490  GpPaint *gp_paint = scene->toolsettings->gp_paint;
491  gp_paint->paint.flags |= PAINT_SHOW_BRUSH;
492 
493  /* Ensure Palette by default. */
495  }
496 
497  /* For builtin templates only. */
499  return;
500  }
501 
502  /* Workspaces. */
503  LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) {
504  LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
505  LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
507  win->workspace_hook, workspace);
508  /* Name all screens by their workspaces (avoids 'Default.###' names). */
509  /* Default only has one window. */
510  if (layout->screen) {
511  bScreen *screen = layout->screen;
512  BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2);
513  BLI_libblock_ensure_unique_name(bmain, screen->id.name);
514  }
515 
516  /* For some reason we have unused screens, needed until re-saving.
517  * Clear unused layouts because they're visible in the outliner & Python API. */
518  LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout_iter, &workspace->layouts) {
519  if (layout != layout_iter) {
520  BKE_workspace_layout_remove(bmain, workspace, layout_iter);
521  }
522  }
523  }
524  }
525  }
526 
527  /* Scenes */
528  for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
530 
531  if (app_template && STREQ(app_template, "Video_Editing")) {
532  /* Filmic is too slow, use standard until it is optimized. */
534  STRNCPY(scene->view_settings.look, "None");
535  }
536  else {
537  /* AV Sync break physics sim caching, disable until that is fixed. */
538  scene->audio.flag &= ~AUDIO_SYNC;
540  }
541 
542  /* Change default selection mode for Grease Pencil. */
543  if (app_template && STREQ(app_template, "2D_Animation")) {
546  }
547  }
548 
549  /* Objects */
550  rename_id_for_versioning(bmain, ID_OB, "Lamp", "Light");
551  rename_id_for_versioning(bmain, ID_LA, "Lamp", "Light");
552 
553  if (app_template && STREQ(app_template, "2D_Animation")) {
554  for (Object *object = bmain->objects.first; object; object = object->id.next) {
555  if (object->type == OB_GPENCIL) {
556  /* Set grease pencil object in drawing mode */
557  bGPdata *gpd = (bGPdata *)object->data;
558  object->mode = OB_MODE_PAINT_GPENCIL;
560  break;
561  }
562  }
563  }
564 
565  for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
566  /* Match default for new meshes. */
567  mesh->smoothresh = DEG2RADF(30);
568 
569  /* For Sculpting template. */
570  if (app_template && STREQ(app_template, "Sculpting")) {
571  mesh->remesh_voxel_size = 0.035f;
574  }
575  }
576 
577  for (Camera *camera = bmain->cameras.first; camera; camera = camera->id.next) {
578  /* Initialize to a useful value. */
579  camera->dof.focus_distance = 10.0f;
580  camera->dof.aperture_fstop = 2.8f;
581  }
582 
583  for (Light *light = bmain->lights.first; light; light = light->id.next) {
584  /* Fix lights defaults. */
585  light->clipsta = 0.05f;
586  light->att_dist = 40.0f;
587  }
588 
589  /* Materials */
590  for (Material *ma = bmain->materials.first; ma; ma = ma->id.next) {
591  /* Update default material to be a bit more rough. */
592  ma->roughness = 0.4f;
593 
594  if (ma->nodetree) {
595  LISTBASE_FOREACH (bNode *, node, &ma->nodetree->nodes) {
596  if (node->type == SH_NODE_BSDF_PRINCIPLED) {
598  bNodeSocketValueFloat *roughness_data = roughness_socket->default_value;
599  roughness_data->value = 0.4f;
600  }
601  }
602  }
603  }
604 
605  /* Brushes */
606  {
607  /* Enable for UV sculpt (other brush types will be created as needed),
608  * without this the grab brush will be active but not selectable from the list. */
609  const char *brush_name = "Grab";
610  Brush *brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
611  if (brush) {
612  brush->ob_mode |= OB_MODE_EDIT;
613  }
614  }
615 
616  for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
617  brush->blur_kernel_radius = 2;
618 
619  /* Use full strength for all non-sculpt brushes,
620  * when painting we want to use full color/weight always.
621  *
622  * Note that sculpt is an exception,
623  * its values are overwritten by #BKE_brush_sculpt_reset below. */
624  brush->alpha = 1.0;
625 
626  /* Enable antialiasing by default */
627  brush->sampling_flag |= BRUSH_PAINT_ANTIALIASING;
628  }
629 
630  {
631  /* Change the spacing of the Smear brush to 3.0% */
632  const char *brush_name;
633  Brush *brush;
634 
635  brush_name = "Smear";
636  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
637  if (brush) {
638  brush->spacing = 3.0;
639  }
640 
641  brush_name = "Draw Sharp";
642  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
643  if (!brush) {
644  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
645  id_us_min(&brush->id);
647  }
648 
649  brush_name = "Elastic Deform";
650  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
651  if (!brush) {
652  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
653  id_us_min(&brush->id);
655  }
656 
657  brush_name = "Pose";
658  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
659  if (!brush) {
660  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
661  id_us_min(&brush->id);
662  brush->sculpt_tool = SCULPT_TOOL_POSE;
663  }
664 
665  brush_name = "Multi-plane Scrape";
666  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
667  if (!brush) {
668  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
669  id_us_min(&brush->id);
671  }
672 
673  brush_name = "Clay Thumb";
674  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
675  if (!brush) {
676  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
677  id_us_min(&brush->id);
679  }
680 
681  brush_name = "Cloth";
682  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
683  if (!brush) {
684  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
685  id_us_min(&brush->id);
687  }
688 
689  brush_name = "Slide Relax";
690  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
691  if (!brush) {
692  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
693  id_us_min(&brush->id);
695  }
696 
697  brush_name = "Paint";
698  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
699  if (!brush) {
700  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
701  id_us_min(&brush->id);
703  }
704 
705  brush_name = "Smear";
706  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
707  if (!brush) {
708  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
709  id_us_min(&brush->id);
711  }
712 
713  brush_name = "Boundary";
714  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
715  if (!brush) {
716  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
717  id_us_min(&brush->id);
719  }
720 
721  brush_name = "Simplify";
722  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
723  if (!brush) {
724  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
725  id_us_min(&brush->id);
727  }
728 
729  brush_name = "Draw Face Sets";
730  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
731  if (!brush) {
732  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
733  id_us_min(&brush->id);
735  }
736 
737  brush_name = "Multires Displacement Eraser";
738  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
739  if (!brush) {
740  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
741  id_us_min(&brush->id);
743  }
744 
745  brush_name = "Multires Displacement Smear";
746  brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
747  if (!brush) {
748  brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
749  id_us_min(&brush->id);
751  }
752 
753  /* Use the same tool icon color in the brush cursor */
754  for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
755  if (brush->ob_mode & OB_MODE_SCULPT) {
756  BLI_assert(brush->sculpt_tool != 0);
757  BKE_brush_sculpt_reset(brush);
758  }
759  }
760  }
761 }
const char * BKE_appdir_folder_default(void)
Definition: appdir.c:157
void BKE_brush_gpencil_paint_presets(struct Main *bmain, struct ToolSettings *ts, const bool reset)
Definition: brush.c:1308
void BKE_brush_gpencil_sculpt_presets(struct Main *bmain, struct ToolSettings *ts, const bool reset)
Definition: brush.c:1459
void BKE_brush_gpencil_weight_presets(struct Main *bmain, struct ToolSettings *ts, const bool reset)
Definition: brush.c:1534
void BKE_brush_sculpt_reset(struct Brush *brush)
Definition: brush.c:1677
struct Brush * BKE_brush_add(struct Main *bmain, const char *name, const eObjectMode ob_mode)
Definition: brush.c:492
void BKE_brush_gpencil_vertex_presets(struct Main *bmain, struct ToolSettings *ts, const bool reset)
Definition: brush.c:1412
void BKE_curvemapping_init(struct CurveMapping *cumap)
Definition: colortools.c:1200
void BKE_curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope)
@ CURVEMAP_SLOPE_POSITIVE
struct CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition: colortools.c:88
struct CurveProfile * BKE_curveprofile_add(eCurveProfilePresets preset)
Definition: curveprofile.c:887
void BKE_gpencil_palette_ensure(struct Main *bmain, struct Scene *scene)
Definition: gpencil.c:2484
void BKE_view_layer_rename(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, const char *name)
Definition: layer.c:522
void id_us_min(struct ID *id)
Definition: lib_id.c:297
void BKE_id_delete(struct Main *bmain, void *idv) ATTR_NONNULL()
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL()
Definition: lib_id.c:2165
struct ListBase * which_libbase(struct Main *bmain, short type)
Definition: main.c:447
General operations, lookup, etc. for materials.
struct Material * BKE_gpencil_material_add(struct Main *bmain, const char *name)
Definition: material.c:310
void BKE_mesh_smooth_flag_set(struct Mesh *me, const bool use_smooth)
Definition: mesh.c:1392
#define SH_NODE_BSDF_PRINCIPLED
Definition: BKE_node.h:1058
void ntreeFreeEmbeddedTree(struct bNodeTree *ntree)
Definition: node.cc:3021
struct bNodeSocket * nodeFindSocket(const struct bNode *node, eNodeSocketInOut in_out, const char *identifier)
bool BKE_paint_ensure_from_paintmode(struct Scene *sce, ePaintMode mode)
Definition: paint.c:306
@ PAINT_MODE_VERTEX_GPENCIL
Definition: BKE_paint.h:90
@ PAINT_MODE_WEIGHT_GPENCIL
Definition: BKE_paint.h:92
@ PAINT_MODE_SCULPT_GPENCIL
Definition: BKE_paint.h:91
void BKE_area_region_panels_free(struct ListBase *panels)
Definition: screen.c:652
void BKE_workspace_layout_remove(struct Main *bmain, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL()
Definition: workspace.c:386
void BKE_workspace_tool_remove(struct WorkSpace *workspace, struct bToolRef *tref) ATTR_NONNULL(1
struct WorkSpaceLayout * BKE_workspace_active_layout_for_workspace_get(const struct WorkSpaceInstanceHook *hook, const struct WorkSpace *workspace) GETTER_ATTRS
#define BLI_assert(a)
Definition: BLI_assert.h:58
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:188
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define DEG2RADF(_deg)
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl(float r[3], float f)
#define STR_ELEM(...)
Definition: BLI_string.h:218
#define STRNCPY(dst, src)
Definition: BLI_string.h:163
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
#define ARRAY_SIZE(arr)
#define ELEM(...)
#define STREQ(a, b)
external readfile function prototypes.
@ ID_LA
Definition: DNA_ID_enums.h:67
@ ID_BR
Definition: DNA_ID_enums.h:81
@ ID_MA
Definition: DNA_ID_enums.h:63
@ ID_OB
Definition: DNA_ID_enums.h:59
@ ADS_FLAG_SUMMARY_COLLAPSED
@ SACTCONT_TIMELINE
@ SACTION_SHOW_MARKERS
@ SACTION_SLIDERS
@ BRUSH_PAINT_ANTIALIASING
@ SCULPT_TOOL_CLOTH
@ SCULPT_TOOL_DRAW_SHARP
@ SCULPT_TOOL_SIMPLIFY
@ SCULPT_TOOL_DRAW_FACE_SETS
@ SCULPT_TOOL_CLAY_THUMB
@ SCULPT_TOOL_BOUNDARY
@ SCULPT_TOOL_PAINT
@ SCULPT_TOOL_POSE
@ SCULPT_TOOL_DISPLACEMENT_ERASER
@ SCULPT_TOOL_SLIDE_RELAX
@ SCULPT_TOOL_SMEAR
@ SCULPT_TOOL_DISPLACEMENT_SMEAR
@ SCULPT_TOOL_MULTIPLANE_SCRAPE
@ SCULPT_TOOL_ELASTIC_DEFORM
@ GP_BRUSH_ICON_PEN
@ CURVE_PRESET_GAUSS
@ CURVE_PRESET_BELL
@ PROF_PRESET_LINE
@ GP_DATA_STROKE_PAINTMODE
@ GP_MATERIAL_STROKE_SHOW
@ GP_MATERIAL_MODE_SQUARE
@ GP_MATERIAL_MODE_DOT
@ ME_REMESH_REPROJECT_VOLUME
@ ME_REMESH_FIX_POLES
@ SOCK_IN
@ OB_MODE_EDIT
@ OB_MODE_SCULPT
@ OB_MODE_PAINT_GPENCIL
Object is a sort of wrapper for general info.
@ OB_USE_GPENCIL_LIGHTS
@ OB_GPENCIL
@ GP_SELECTMODE_STROKE
@ PAINT_SHOW_BRUSH
@ PAINT_SYMMETRY_FEATHER
#define AUDIO_SYNC
@ SCE_EEVEE_SHADOW_SOFT
#define SCE_FRAME_DROP
@ RGN_FLAG_HIDDEN
@ RGN_FLAG_HIDDEN_BY_USER
@ RGN_TYPE_CHANNELS
@ RGN_TYPE_TOOL_HEADER
@ RGN_TYPE_UI
@ RGN_TYPE_TOOLS
@ RGN_TYPE_TOOL_PROPS
@ SEQ_RENDER_SIZE_PROXY_100
@ SPACE_TEXT
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_FILE
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SIPO_SHOW_MARKERS
@ SNLA_SHOW_MARKERS
@ SEQ_SHOW_MARKERS
@ SEQ_SHOW_STRIP_DURATION
@ SEQ_SHOW_FCURVES
@ SEQ_USE_PROXIES
@ SEQ_SHOW_STRIP_NAME
@ SEQ_ZOOM_TO_FIT
@ SEQ_SHOW_STRIP_SOURCE
@ SEQ_SHOW_STRIP_OVERLAY
@ SI_MODE_VIEW
@ SI_MODE_UV
@ V2D_IS_INIT
@ V3D_SHADING_BACKGROUND_VIEWPORT
@ V3D_SHADING_MATERIAL_COLOR
#define V3D_SHOW_ANNOTATION
@ V3D_AROUND_CENTER_MEDIAN
@ V3D_OVERLAY_EDIT_CU_NORMALS
@ V3D_OVERLAY_EDIT_EDGES
@ V3D_SHADING_CAVITY_CURVATURE
#define V3D_GP_SHOW_EDIT_LINES
@ V3D_SHADING_SPECULAR_HIGHLIGHT
@ V3D_SHADING_CAVITY
Read Guarded memory(de)allocation.
OperationNode * node
Scene scene
bNodeSocketValueFloat * roughness_socket
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
static void area(int d1, int d2, int e1, int e2, float weights[2])
const char * RE_engine_id_BLENDER_EEVEE
Definition: scene.c:1742
short ob_mode
struct BrushGpencilSettings * gpencil_settings
char sculpt_tool
CurveMap cm[4]
struct CurveMapping * cur_primitive
struct CurveMapping * cur_falloff
Definition: DNA_ID.h:273
void * next
Definition: DNA_ID.h:274
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
ListBase brushes
Definition: BKE_main.h:171
ListBase scenes
Definition: BKE_main.h:146
ListBase wm
Definition: BKE_main.h:175
ListBase meshes
Definition: BKE_main.h:149
ListBase lights
Definition: BKE_main.h:156
ListBase materials
Definition: BKE_main.h:152
ListBase cameras
Definition: BKE_main.h:157
ListBase workspaces
Definition: BKE_main.h:181
ListBase objects
Definition: BKE_main.h:148
struct MaterialGPencilStyle * gp_style
float smoothresh
float remesh_voxel_size
struct MLoopUV * mloopuv
short flag
int totloop
int symmetry_flags
char engine[32]
float light_direction[3]
float motion_blur_shutter
float bloom_intensity
float gi_filter_quality
struct bNodeTree * nodetree
struct SceneDisplay display
short flag
struct ToolSettings * toolsettings
ColorManagedViewSettings view_settings
struct RenderData r
ListBase view_layers
struct DisplaySafeAreas safe_areas
char use_nodes
struct AudioData audio
struct SceneEEVEE eevee
Paint paint
bDopeSheet ads
FileSelectParams * params
short render_size
struct CurveProfile * custom_bevel_profile_preset
GpPaint * gp_paint
char gpencil_selectmode_edit
struct GP_Sculpt_Settings gp_sculpt
float texture_paint_mode_opacity
float vertex_paint_mode_opacity
float weight_paint_mode_opacity
float background_color[3]
float single_color[3]
float vertex_opacity
View3DOverlay overlay
View3DShading shading
float clip_start
short gp_flag
Wrapper for bScreen.
struct bScreen * screen
ListBase areabase
void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_template)
static void blo_update_defaults_screen(bScreen *screen, const char *app_template, const char *workspace_name)
static void blo_update_defaults_scene(Main *bmain, Scene *scene)
static ID * rename_id_for_versioning(Main *bmain, const short id_type, const char *name_src, const char *name_dst)
void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
static bool blo_is_builtin_template(const char *app_template)
char app_template[64]
Definition: wm_files.c:853