Blender V4.3
versioning_defaults.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
15
16#define DNA_DEPRECATED_ALLOW
17
18#include "MEM_guardedalloc.h"
19
20#include "BLI_listbase.h"
21#include "BLI_math_rotation.h"
22#include "BLI_math_vector.h"
24#include "BLI_mempool.h"
25#include "BLI_string.h"
26#include "BLI_utildefines.h"
27
28#include "DNA_camera_types.h"
30#include "DNA_defaults.h"
32#include "DNA_light_types.h"
33#include "DNA_mask_types.h"
34#include "DNA_material_types.h"
35#include "DNA_mesh_types.h"
36#include "DNA_object_types.h"
37#include "DNA_scene_types.h"
38#include "DNA_screen_types.h"
39#include "DNA_sequence_types.h"
40#include "DNA_space_types.h"
41#include "DNA_userdef_types.h"
43#include "DNA_workspace_types.h"
44#include "DNA_world_types.h"
45
46#include "BKE_appdir.hh"
47#include "BKE_attribute.hh"
48#include "BKE_brush.hh"
49#include "BKE_colortools.hh"
50#include "BKE_curveprofile.h"
51#include "BKE_customdata.hh"
52#include "BKE_gpencil_legacy.h"
53#include "BKE_idprop.hh"
54#include "BKE_layer.hh"
55#include "BKE_lib_id.hh"
56#include "BKE_main.hh"
57#include "BKE_main_namemap.hh"
58#include "BKE_material.h"
59#include "BKE_mesh.hh"
60#include "BKE_node_runtime.hh"
62#include "BKE_paint.hh"
63#include "BKE_screen.hh"
64#include "BKE_workspace.hh"
65
66#include "BLO_readfile.hh"
67
68#include "BLT_translation.hh"
69
70#include "versioning_common.hh"
71
72/* Make preferences read-only, use `versioning_userdef.cc`. */
73#define U (*((const UserDef *)&U))
74
75static bool blo_is_builtin_template(const char *app_template)
76{
77 /* For all builtin templates shipped with Blender. */
78 return (
79 !app_template ||
80 STR_ELEM(app_template, N_("2D_Animation"), N_("Sculpting"), N_("VFX"), N_("Video_Editing")));
81}
82
84 const char *app_template,
85 const char *workspace_name)
86{
87 /* For all app templates. */
88 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
89 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
90 /* Some toolbars have been saved as initialized,
91 * we don't want them to have odd zoom-level or scrolling set, see: #47047 */
92 if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
93 region->v2d.flag &= ~V2D_IS_INIT;
94 }
95 }
96
97 /* Set default folder. */
98 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
99 if (sl->spacetype == SPACE_FILE) {
100 SpaceFile *sfile = (SpaceFile *)sl;
101 if (sfile->params) {
102 const char *dir_default = BKE_appdir_folder_default();
103 if (dir_default) {
104 STRNCPY(sfile->params->dir, dir_default);
105 sfile->params->file[0] = '\0';
106 }
107 }
108 }
109 }
110 }
111
112 /* For builtin templates only. */
114 return;
115 }
116
117 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
118 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
119 /* Remove all stored panels, we want to use defaults
120 * (order, open/closed) as defined by UI code here! */
121 BKE_area_region_panels_free(&region->panels);
122 BLI_freelistN(&region->panels_category_active);
123
124 /* Reset size so it uses consistent defaults from the region types. */
125 region->sizex = 0;
126 region->sizey = 0;
127 }
128
129 if (area->spacetype == SPACE_IMAGE) {
130 if (STREQ(workspace_name, "UV Editing")) {
131 SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
132 if (sima->mode == SI_MODE_VIEW) {
133 sima->mode = SI_MODE_UV;
134 }
135 }
136 }
137 else if (area->spacetype == SPACE_ACTION) {
138 /* Show markers region, hide channels and collapse summary in timelines. */
139 SpaceAction *saction = static_cast<SpaceAction *>(area->spacedata.first);
140 saction->flag |= SACTION_SHOW_MARKERS;
141 if (saction->mode == SACTCONT_TIMELINE) {
143
144 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
145 if (region->regiontype == RGN_TYPE_CHANNELS) {
146 region->flag |= RGN_FLAG_HIDDEN;
147 }
148 }
149 }
150 else {
151 /* Open properties panel by default. */
152 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
153 if (region->regiontype == RGN_TYPE_UI) {
154 region->flag &= ~RGN_FLAG_HIDDEN;
155 }
156 }
157 }
158 }
159 else if (area->spacetype == SPACE_GRAPH) {
160 SpaceGraph *sipo = static_cast<SpaceGraph *>(area->spacedata.first);
161 sipo->flag |= SIPO_SHOW_MARKERS;
162 }
163 else if (area->spacetype == SPACE_NLA) {
164 SpaceNla *snla = static_cast<SpaceNla *>(area->spacedata.first);
165 snla->flag |= SNLA_SHOW_MARKERS;
166 }
167 else if (area->spacetype == SPACE_SEQ) {
168 SpaceSeq *seq = static_cast<SpaceSeq *>(area->spacedata.first);
179 }
180 else if (area->spacetype == SPACE_TEXT) {
181 /* Show syntax and line numbers in Script workspace text editor. */
182 SpaceText *stext = static_cast<SpaceText *>(area->spacedata.first);
183 stext->showsyntax = true;
184 stext->showlinenrs = true;
185 stext->flags |= ST_FIND_WRAP;
186 }
187 else if (area->spacetype == SPACE_VIEW3D) {
188 View3D *v3d = static_cast<View3D *>(area->spacedata.first);
189 /* Screen space cavity by default for faster performance. */
195 /* Clear this deprecated bit for later reuse. */
197 /* grease pencil settings */
198 v3d->vertex_opacity = 1.0f;
200 /* Remove dither pattern in wireframe mode. */
201 v3d->shading.xray_alpha_wire = 0.0f;
202 v3d->clip_start = 0.01f;
203 /* Skip startups that use the viewport color by default. */
206 }
207 /* Disable Curve Normals. */
210
211 /* Level out the 3D Viewport camera rotation, see: #113751. */
212 constexpr float viewports_to_level[][4] = {
213 /* Animation, Modeling, Scripting, Texture Paint, UV Editing. */
214 {0x1.6e7cb8p-1, -0x1.c1747p-2, -0x1.2997dap-2, -0x1.d5d806p-2},
215 /* Layout. */
216 {0x1.6e7cb8p-1, -0x1.c17478p-2, -0x1.2997dcp-2, -0x1.d5d80cp-2},
217 /* Geometry Nodes. */
218 {0x1.6e7cb6p-1, -0x1.c17476p-2, -0x1.2997dep-2, -0x1.d5d80cp-2},
219 };
220
221 constexpr float viewports_to_clear_ofs[][4] = {
222 /* Geometry Nodes. */
223 {0x1.6e7cb6p-1, -0x1.c17476p-2, -0x1.2997dep-2, -0x1.d5d80cp-2},
224 /* Sculpting. */
225 {0x1.885b28p-1, -0x1.2d10cp-1, -0x1.42ae54p-3, -0x1.a486a2p-3},
226 };
227
228 constexpr float unified_viewquat[4] = {
229 0x1.6cbc88p-1, -0x1.c3a5c8p-2, -0x1.26413ep-2, -0x1.db430ap-2};
230
231 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
232 if (region->regiontype == RGN_TYPE_WINDOW) {
233 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
234
235 for (int i = 0; i < ARRAY_SIZE(viewports_to_clear_ofs); i++) {
236 if (equals_v4v4(rv3d->viewquat, viewports_to_clear_ofs[i])) {
237 zero_v3(rv3d->ofs);
238 }
239 }
240
241 for (int i = 0; i < ARRAY_SIZE(viewports_to_level); i++) {
242 if (equals_v4v4(rv3d->viewquat, viewports_to_level[i])) {
243 copy_qt_qt(rv3d->viewquat, unified_viewquat);
244 }
245 }
246 }
247 }
248 }
249 else if (area->spacetype == SPACE_CLIP) {
250 SpaceClip *sclip = static_cast<SpaceClip *>(area->spacedata.first);
252 sclip->mask_info.blend_factor = 0.7f;
254 }
255 }
256
257 /* Show tool-header by default (for most cases at least, hide for others). */
258 const bool hide_image_tool_header = STREQ(workspace_name, "Rendering");
259 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
260 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
261 ListBase *regionbase = (sl == static_cast<SpaceLink *>(area->spacedata.first)) ?
262 &area->regionbase :
263 &sl->regionbase;
264
265 LISTBASE_FOREACH (ARegion *, region, regionbase) {
266 if (region->regiontype == RGN_TYPE_TOOL_HEADER) {
267 if (((sl->spacetype == SPACE_IMAGE) && hide_image_tool_header) ||
268 sl->spacetype == SPACE_SEQ)
269 {
270 region->flag |= RGN_FLAG_HIDDEN;
271 }
272 else {
273 region->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
274 }
275 }
276 }
277 }
278 }
279
280 /* 2D animation template. */
281 if (app_template && STREQ(app_template, "2D_Animation")) {
282 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
283 if (area->spacetype == SPACE_ACTION) {
284 SpaceAction *saction = static_cast<SpaceAction *>(area->spacedata.first);
285 /* Enable Sliders. */
286 saction->flag |= SACTION_SLIDERS;
287 }
288 else if (area->spacetype == SPACE_VIEW3D) {
289 View3D *v3d = static_cast<View3D *>(area->spacedata.first);
290 /* Set Material Color by default. */
292 /* Enable Annotations. */
294 }
295 }
296 }
297}
298
300{
301 LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
302 if (layout->screen) {
303 blo_update_defaults_screen(layout->screen, app_template, workspace->id.name + 2);
304 }
305 }
306
308 /* Clear all tools to use default options instead, ignore the tool saved in the file. */
309 while (!BLI_listbase_is_empty(&workspace->tools)) {
310 BKE_workspace_tool_remove(workspace, static_cast<bToolRef *>(workspace->tools.first));
311 }
312
313 /* For 2D animation template. */
314 if (STREQ(workspace->id.name + 2, "Drawing")) {
316 }
317
318 /* For Sculpting template. */
319 if (STREQ(workspace->id.name + 2, "Sculpting")) {
320 LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
321 bScreen *screen = layout->screen;
322 if (screen) {
323 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
324 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
325 if (area->spacetype == SPACE_VIEW3D) {
326 View3D *v3d = static_cast<View3D *>(area->spacedata.first);
328 copy_v3_fl(v3d->shading.single_color, 1.0f);
329 STRNCPY(v3d->shading.matcap, "basic_1");
330 }
331 }
332 }
333 }
334 }
335 }
336 }
337}
338
339static void blo_update_defaults_scene(Main *bmain, Scene *scene)
340{
342
343 scene->r.cfra = 1.0f;
344
345 /* Don't enable compositing nodes. */
346 if (scene->nodetree) {
348 MEM_freeN(scene->nodetree);
349 scene->nodetree = nullptr;
350 scene->use_nodes = false;
351 }
352
353 /* Rename render layers. */
355 bmain, scene, static_cast<ViewLayer *>(scene->view_layers.first), "ViewLayer");
356
357 /* Disable Z pass by default. */
358 LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
359 view_layer->passflag &= ~SCE_PASS_Z;
360 }
361
362 /* Display missing media by default. */
363 if (scene->ed) {
365 }
366
367 /* New EEVEE defaults. */
368 scene->eevee.motion_blur_shutter_deprecated = 0.5f;
369
371 copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f);
372 copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f);
373
374 /* Default Rotate Increment. */
375 const float default_snap_angle_increment = DEG2RADF(5.0f);
376 scene->toolsettings->snap_angle_increment_2d = default_snap_angle_increment;
377 scene->toolsettings->snap_angle_increment_3d = default_snap_angle_increment;
378 const float default_snap_angle_increment_precision = DEG2RADF(1.0f);
379 scene->toolsettings->snap_angle_increment_2d_precision = default_snap_angle_increment_precision;
380 scene->toolsettings->snap_angle_increment_3d_precision = default_snap_angle_increment_precision;
381
382 /* Be sure `curfalloff` and primitive are initialized. */
383 ToolSettings *ts = scene->toolsettings;
384 if (ts->gp_sculpt.cur_falloff == nullptr) {
385 ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
386 CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
387 BKE_curvemapping_init(gp_falloff_curve);
388 BKE_curvemap_reset(gp_falloff_curve->cm,
389 &gp_falloff_curve->clipr,
392 }
393 if (ts->gp_sculpt.cur_primitive == nullptr) {
394 ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
395 CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive;
396 BKE_curvemapping_init(gp_primitive_curve);
397 BKE_curvemap_reset(gp_primitive_curve->cm,
398 &gp_primitive_curve->clipr,
401 }
402
403 if (ts->sculpt) {
404 ts->sculpt->flags = static_cast<const Sculpt *>(DNA_struct_default_get(Sculpt))->flags;
405 }
406
407 /* Correct default startup UVs. */
408 Mesh *mesh = static_cast<Mesh *>(BLI_findstring(&bmain->meshes, "Cube", offsetof(ID, name) + 2));
409 if (mesh && (mesh->corners_num == 24) &&
411 {
412 const float uv_values[24][2] = {
413 {0.625, 0.50}, {0.875, 0.50}, {0.875, 0.75}, {0.625, 0.75}, {0.375, 0.75}, {0.625, 0.75},
414 {0.625, 1.00}, {0.375, 1.00}, {0.375, 0.00}, {0.625, 0.00}, {0.625, 0.25}, {0.375, 0.25},
415 {0.125, 0.50}, {0.375, 0.50}, {0.375, 0.75}, {0.125, 0.75}, {0.375, 0.50}, {0.625, 0.50},
416 {0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50},
417 };
418 float(*mloopuv)[2] = static_cast<float(*)[2]>(
420 memcpy(mloopuv, uv_values, sizeof(float[2]) * mesh->corners_num);
421 }
422
423 /* Make sure that the curve profile is initialized */
424 if (ts->custom_bevel_profile_preset == nullptr) {
426 }
427
428 /* Clear ID properties so Cycles gets defaults. */
429 IDProperty *idprop = IDP_GetProperties(&scene->id);
430 if (idprop) {
431 IDP_ClearProperty(idprop);
432 }
433
434 if (ts->sculpt) {
436 }
437
438 /* Ensure input_samples has a correct default value of 1. */
441 }
442
444 ts->unified_paint_settings.flag = default_ups.flag;
445 copy_v3_v3(ts->unified_paint_settings.rgb, default_ups.rgb);
447}
448
450{
451 /* For all app templates. */
452 LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
454 }
455
456 /* Grease pencil materials and paint modes setup. */
457 {
458 /* Rename and fix materials and enable default object lights on. */
459 if (app_template && STREQ(app_template, "2D_Animation")) {
460 Material *ma = nullptr;
461 do_versions_rename_id(bmain, ID_MA, "Black", "Solid Stroke");
462 do_versions_rename_id(bmain, ID_MA, "Red", "Squares Stroke");
463 do_versions_rename_id(bmain, ID_MA, "Grey", "Solid Fill");
464 do_versions_rename_id(bmain, ID_MA, "Black Dots", "Dots Stroke");
465
466 /* Dots Stroke. */
467 ma = static_cast<Material *>(
468 BLI_findstring(&bmain->materials, "Dots Stroke", offsetof(ID, name) + 2));
469 if (ma == nullptr) {
470 ma = BKE_gpencil_material_add(bmain, "Dots Stroke");
471 }
473
474 /* Squares Stroke. */
475 ma = static_cast<Material *>(
476 BLI_findstring(&bmain->materials, "Squares Stroke", offsetof(ID, name) + 2));
477 if (ma == nullptr) {
478 ma = BKE_gpencil_material_add(bmain, "Squares Stroke");
479 }
481
482 /* Change Solid Stroke settings. */
483 ma = static_cast<Material *>(
484 BLI_findstring(&bmain->materials, "Solid Stroke", offsetof(ID, name) + 2));
485 if (ma != nullptr) {
486 ma->gp_style->mix_rgba[3] = 1.0f;
487 ma->gp_style->texture_offset[0] = -0.5f;
488 ma->gp_style->mix_factor = 0.5f;
489 }
490
491 /* Change Solid Fill settings. */
492 ma = static_cast<Material *>(
493 BLI_findstring(&bmain->materials, "Solid Fill", offsetof(ID, name) + 2));
494 if (ma != nullptr) {
496 ma->gp_style->mix_rgba[3] = 1.0f;
497 ma->gp_style->texture_offset[0] = -0.5f;
498 ma->gp_style->mix_factor = 0.5f;
499 }
500
501 Object *ob = static_cast<Object *>(
502 BLI_findstring(&bmain->objects, "Stroke", offsetof(ID, name) + 2));
503 if (ob && ob->type == OB_GPENCIL_LEGACY) {
505 }
506 }
507
508 /* Reset grease pencil paint modes. */
509 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
510 ToolSettings *ts = scene->toolsettings;
511
512 /* Ensure new Paint modes. */
516
517 /* Enable cursor. */
518 if (ts->gp_paint) {
520 }
521
522 /* Ensure Palette by default. */
523 if (ts->gp_paint) {
524 BKE_gpencil_palette_ensure(bmain, scene);
525 }
526 }
527 }
528
529 /* For builtin templates only. */
531 return;
532 }
533
534 /* Work-spaces. */
535 LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) {
536 LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
537 LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
539 win->workspace_hook, workspace);
540 /* Name all screens by their workspaces (avoids 'Default.###' names). */
541 /* Default only has one window. */
542 if (layout->screen) {
543 bScreen *screen = layout->screen;
544 if (!STREQ(screen->id.name + 2, workspace->id.name + 2)) {
545 BKE_libblock_rename(*bmain, screen->id, workspace->id.name + 2);
546 }
547 }
548
549 /* For some reason we have unused screens, needed until re-saving.
550 * Clear unused layouts because they're visible in the outliner & Python API. */
551 LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout_iter, &workspace->layouts) {
552 if (layout != layout_iter) {
553 BKE_workspace_layout_remove(bmain, workspace, layout_iter);
554 }
555 }
556 }
557 }
558 }
559
560 /* Scenes */
561 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
562 blo_update_defaults_scene(bmain, scene);
563
564 if (app_template && STR_ELEM(app_template, "Video_Editing", "2D_Animation")) {
565 /* Filmic is too slow, use standard until it is optimized. */
566 STRNCPY(scene->view_settings.view_transform, "Standard");
567 STRNCPY(scene->view_settings.look, "None");
568 }
569 else {
570 /* Default to AgX view transform. */
571 STRNCPY(scene->view_settings.view_transform, "AgX");
572 }
573
574 if (app_template && STREQ(app_template, "Video_Editing")) {
575 /* Pass: no extra tweaks needed. Keep the view settings configured above, and rely on the
576 * default state of enabled AV sync. */
577 }
578 else {
579 /* AV Sync break physics sim caching, disable until that is fixed. */
580 scene->audio.flag &= ~AUDIO_SYNC;
581 scene->flag &= ~SCE_FRAME_DROP;
582 }
583
584 /* Change default selection mode for Grease Pencil. */
585 if (app_template && STREQ(app_template, "2D_Animation")) {
586 ToolSettings *ts = scene->toolsettings;
588 }
589 }
590
591 /* Objects */
592 do_versions_rename_id(bmain, ID_OB, "Lamp", "Light");
593 do_versions_rename_id(bmain, ID_LA, "Lamp", "Light");
594
595 if (app_template && STREQ(app_template, "2D_Animation")) {
596 LISTBASE_FOREACH (Object *, object, &bmain->objects) {
597 if (object->type == OB_GPENCIL_LEGACY) {
598 /* Set grease pencil object in drawing mode */
599 bGPdata *gpd = (bGPdata *)object->data;
600 object->mode = OB_MODE_PAINT_GREASE_PENCIL;
602 break;
603 }
604 }
605 }
606
607 LISTBASE_FOREACH (Mesh *, mesh, &bmain->meshes) {
608 /* Match default for new meshes. */
609 mesh->smoothresh_legacy = DEG2RADF(30);
610 /* Match voxel remesher options for all existing meshes in templates. */
612
613 /* For Sculpting template. */
614 if (app_template && STREQ(app_template, "Sculpting")) {
615 mesh->remesh_voxel_size = 0.035f;
616 blender::bke::mesh_smooth_set(*mesh, false);
617 }
618 else {
619 /* Remove sculpt-mask data in default mesh objects for all non-sculpt templates. */
620 CustomData_free_layers(&mesh->vert_data, CD_PAINT_MASK, mesh->verts_num);
621 CustomData_free_layers(&mesh->corner_data, CD_GRID_PAINT_MASK, mesh->corners_num);
622 }
623 mesh->attributes_for_write().remove(".sculpt_face_set");
624 }
625
626 LISTBASE_FOREACH (Camera *, camera, &bmain->cameras) {
627 /* Initialize to a useful value. */
628 camera->dof.focus_distance = 10.0f;
629 camera->dof.aperture_fstop = 2.8f;
630 }
631
632 LISTBASE_FOREACH (Light *, light, &bmain->lights) {
633 /* Fix lights defaults. */
634 light->clipsta = 0.05f;
635 light->att_dist = 40.0f;
636 }
637
638 /* Materials */
639 LISTBASE_FOREACH (Material *, ma, &bmain->materials) {
640 /* Update default material to be a bit more rough. */
641 ma->roughness = 0.5f;
642 /* Enable transparent shadows. */
643 ma->blend_flag |= MA_BL_TRANSPARENT_SHADOW;
644
645 if (ma->nodetree) {
646 for (bNode *node : ma->nodetree->all_nodes()) {
647 if (node->type == SH_NODE_BSDF_PRINCIPLED) {
649 node, SOCK_IN, "Roughness");
650 *version_cycles_node_socket_float_value(roughness_socket) = 0.5f;
651 bNodeSocket *emission = blender::bke::node_find_socket(node, SOCK_IN, "Emission Color");
653 bNodeSocket *emission_strength = blender::bke::node_find_socket(
654 node, SOCK_IN, "Emission Strength");
655 *version_cycles_node_socket_float_value(emission_strength) = 0.0f;
656
657 node->custom1 = SHD_GLOSSY_MULTI_GGX;
658 node->custom2 = SHD_SUBSURFACE_RANDOM_WALK;
659 BKE_ntree_update_tag_node_property(ma->nodetree, node);
660 }
661 else if (node->type == SH_NODE_SUBSURFACE_SCATTERING) {
662 node->custom1 = SHD_SUBSURFACE_RANDOM_WALK;
663 BKE_ntree_update_tag_node_property(ma->nodetree, node);
664 }
665 }
666 }
667 }
668
669 /* Brushes */
670 {
671 /* Remove default brushes replaced by assets. Also remove outliner `treestore` that may point
672 * to brushes. Normally the treestore is updated properly but it doesn't seem to update during
673 * versioning code. It's not helpful anyway. */
674 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
675 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
676 LISTBASE_FOREACH (SpaceLink *, space_link, &area->spacedata) {
677 if (space_link->spacetype == SPACE_OUTLINER) {
678 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(space_link);
679 if (space_outliner->treestore) {
680 BLI_mempool_destroy(space_outliner->treestore);
681 space_outliner->treestore = nullptr;
682 }
683 }
684 }
685 }
686 }
687 LISTBASE_FOREACH_MUTABLE (Brush *, brush, &bmain->brushes) {
688 BKE_id_delete(bmain, brush);
689 }
690 }
691
692 {
693 LISTBASE_FOREACH (Light *, light, &bmain->lights) {
694 light->shadow_maximum_resolution = 0.001f;
695 light->transmission_fac = 1.0f;
696 SET_FLAG_FROM_TEST(light->mode, false, LA_SHAD_RES_ABSOLUTE);
697 }
698 }
699
700 {
701 LISTBASE_FOREACH (World *, world, &bmain->worlds) {
703 }
704 }
705}
const char * BKE_appdir_folder_default() ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:137
void BKE_curvemapping_init(CurveMapping *cumap)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition colortools.cc:90
void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
@ CURVEMAP_SLOPE_POSITIVE
struct CurveProfile * BKE_curveprofile_add(eCurveProfilePresets preset)
CustomData interface, see also DNA_customdata_types.h.
void CustomData_free_layers(CustomData *data, eCustomDataType type, int totelem)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
void BKE_gpencil_palette_ensure(struct Main *bmain, struct Scene *scene)
void IDP_ClearProperty(IDProperty *prop)
Definition idprop.cc:1233
IDProperty * IDP_GetProperties(ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition idprop.cc:875
void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, const char *newname)
void BKE_id_delete(Main *bmain, void *idv) ATTR_NONNULL()
IDNewNameResult BKE_libblock_rename(Main &bmain, ID &id, blender::StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
Definition lib_id.cc:2316
General operations, lookup, etc. for materials.
struct Material * BKE_gpencil_material_add(struct Main *bmain, const char *name)
#define SH_NODE_BSDF_PRINCIPLED
Definition BKE_node.hh:976
#define SH_NODE_SUBSURFACE_SCATTERING
Definition BKE_node.hh:960
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
bool BKE_paint_ensure_from_paintmode(Scene *sce, PaintMode mode)
Definition paint.cc:320
void BKE_area_region_panels_free(ListBase *panels)
Definition screen.cc:551
void BKE_workspace_tool_remove(WorkSpace *workspace, bToolRef *tref) ATTR_NONNULL(1
void BKE_workspace_layout_remove(Main *bmain, WorkSpace *workspace, WorkSpaceLayout *layout) ATTR_NONNULL()
Definition workspace.cc:397
WorkSpaceLayout * BKE_workspace_active_layout_for_workspace_get(const WorkSpaceInstanceHook *hook, const WorkSpace *workspace) GETTER_ATTRS
Definition workspace.cc:591
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:496
#define M_SQRT1_3
#define DEG2RADF(_deg)
void copy_qt_qt(float q[4], const float a[4])
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool equals_v4v4(const float v1[4], const float v2[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void copy_v4_fl(float r[4], float f)
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
#define STR_ELEM(...)
Definition BLI_string.h:653
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define ARRAY_SIZE(arr)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define STREQ(a, b)
external readfile function prototypes.
@ ID_LA
@ ID_MA
@ ID_OB
@ ADS_FLAG_SUMMARY_COLLAPSED
@ SACTCONT_TIMELINE
@ SACTION_SHOW_MARKERS
@ SACTION_SLIDERS
@ CURVE_PRESET_GAUSS
@ CURVE_PRESET_BELL
@ PROF_PRESET_LINE
@ CD_PROP_FLOAT2
@ CD_GRID_PAINT_MASK
#define DNA_struct_default_get(struct_name)
@ GP_DATA_STROKE_PAINTMODE
@ LA_SHAD_RES_ABSOLUTE
@ MASK_DRAWFLAG_SPLINE
@ MA_BL_TRANSPARENT_SHADOW
@ GP_MATERIAL_STROKE_SHOW
@ GP_MATERIAL_MODE_SQUARE
@ GP_MATERIAL_MODE_DOT
@ ME_REMESH_REPROJECT_ATTRIBUTES
@ ME_REMESH_REPROJECT_VOLUME
@ SHD_SUBSURFACE_RANDOM_WALK
@ SOCK_IN
@ SHD_GLOSSY_MULTI_GGX
@ OB_MODE_PAINT_GREASE_PENCIL
Object is a sort of wrapper for general info.
@ OB_USE_GPENCIL_LIGHTS
@ OB_GPENCIL_LEGACY
@ GP_SELECTMODE_STROKE
@ PAINT_SHOW_BRUSH
@ AUDIO_SYNC
@ SCE_FRAME_DROP
@ SCE_PASS_Z
@ RGN_FLAG_HIDDEN
@ RGN_FLAG_HIDDEN_BY_USER
@ RGN_TYPE_CHANNELS
@ RGN_TYPE_TOOL_HEADER
@ RGN_TYPE_UI
@ RGN_TYPE_WINDOW
@ RGN_TYPE_TOOLS
@ RGN_TYPE_TOOL_PROPS
@ SEQ_EDIT_SHOW_MISSING_MEDIA
@ SEQ_RENDER_SIZE_PROXY_100
@ SPACE_TEXT
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_OUTLINER
@ SPACE_FILE
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SEQ_TIMELINE_SHOW_STRIP_DURATION
@ SEQ_TIMELINE_SHOW_THUMBNAILS
@ SEQ_TIMELINE_SHOW_STRIP_RETIMING
@ SEQ_TIMELINE_WAVEFORMS_HALF
@ SEQ_TIMELINE_SHOW_STRIP_SOURCE
@ SEQ_TIMELINE_SHOW_STRIP_NAME
@ SEQ_TIMELINE_SHOW_GRID
@ SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG
@ SIPO_SHOW_MARKERS
@ SEQ_PREVIEW_SHOW_OUTLINE_SELECTED
@ SNLA_SHOW_MARKERS
@ SEQ_DRAW_TRANSFORM_PREVIEW
@ ST_FIND_WRAP
@ SEQ_CACHE_SHOW
@ SEQ_CACHE_SHOW_FINAL_OUT
@ SEQ_SHOW_MARKERS
@ SEQ_USE_PROXIES
@ SEQ_ZOOM_TO_FIT
@ SEQ_SHOW_OVERLAY
@ SI_MODE_VIEW
@ SI_MODE_UV
@ V2D_IS_INIT
@ V3D_SHADING_BACKGROUND_VIEWPORT
@ V3D_SHADING_MATERIAL_COLOR
@ V3D_OVERLAY_EDIT_CU_NORMALS
@ V3D_OVERLAY_EDIT_EDGES_DEPRECATED
@ V3D_SHADING_CAVITY_CURVATURE
@ V3D_SHADING_SPECULAR_HIGHLIGHT
@ V3D_SHADING_CAVITY
@ V3D_SHOW_ANNOTATION
@ V3D_GP_SHOW_EDIT_LINES
@ V3D_AROUND_CENTER_MEDIAN
@ WO_USE_SUN_SHADOW
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between world
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
#define offsetof(t, d)
draw_view in_light_buf[] float
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
bNodeSocket * node_find_socket(bNode *node, eNodeSocketInOut in_out, StringRef identifier)
Definition node.cc:1829
void node_tree_free_embedded_tree(bNodeTree *ntree)
Definition node.cc:3632
VecBase< float, 3 > float3
const char * RE_engine_id_BLENDER_EEVEE_NEXT
Definition scene.cc:1610
CurveMap cm[4]
int show_missing_media_flag
struct CurveMapping * cur_primitive
struct CurveMapping * cur_falloff
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
void * first
ListBase brushes
Definition BKE_main.hh:235
ListBase scenes
Definition BKE_main.hh:210
ListBase wm
Definition BKE_main.hh:239
ListBase meshes
Definition BKE_main.hh:213
ListBase lights
Definition BKE_main.hh:220
ListBase materials
Definition BKE_main.hh:216
ListBase cameras
Definition BKE_main.hh:221
ListBase worlds
Definition BKE_main.hh:224
ListBase screens
Definition BKE_main.hh:225
ListBase workspaces
Definition BKE_main.hh:246
ListBase objects
Definition BKE_main.hh:212
struct MaterialGPencilStyle * gp_style
int corners_num
CustomData corner_data
char engine[32]
float light_direction[3]
struct bNodeTree * nodetree
struct SceneDisplay display
struct ToolSettings * toolsettings
struct Editing * ed
struct RenderData r
ListBase view_layers
struct DisplaySafeAreas safe_areas
struct SceneEEVEE eevee
int automasking_boundary_edges_propagation_steps
MaskSpaceInfo mask_info
FileSelectParams * params
struct BLI_mempool * treestore
struct SequencerCacheOverlay cache_overlay
struct SequencerTimelineOverlay timeline_overlay
short render_size
struct SequencerPreviewOverlay preview_overlay
struct CurveProfile * custom_bevel_profile_preset
float snap_angle_increment_3d_precision
float snap_angle_increment_2d_precision
struct UnifiedPaintSettings unified_paint_settings
float snap_angle_increment_3d
float snap_angle_increment_2d
struct GP_Sculpt_Settings gp_sculpt
float normals_constant_screen_size
float texture_paint_mode_opacity
float vertex_paint_mode_opacity
float weight_paint_mode_opacity
float background_color[3]
float vertex_opacity
View3DOverlay overlay
View3DShading shading
float clip_start
Wrapper for bScreen.
struct bScreen * screen
ListBase areabase
ID * do_versions_rename_id(Main *bmain, const short id_type, const char *name_src, const char *name_dst)
float * version_cycles_node_socket_float_value(bNodeSocket *socket)
float * version_cycles_node_socket_rgba_value(bNodeSocket *socket)
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)
void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
static bool blo_is_builtin_template(const char *app_template)
#define N_(msgid)
char app_template[64]
Definition wm_files.cc:1166