Blender V5.3
versioning_280.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
8
9/* allow readfile to use deprecated functionality */
10#define DNA_DEPRECATED_ALLOW
11
12#include <algorithm>
13#include <cfloat>
14#include <cstring>
15
16#include "BLI_enum_flags.hh"
17#include "BLI_listbase.hh"
19#include "BLI_mempool.hh"
20#include "BLI_string.hh"
21#include "BLI_string_utf8.hh"
22
23/* Define macros in `DNA_genfile.h`. */
24#define DNA_GENFILE_VERSIONING_MACROS
25
26#include "DNA_anim_types.h"
27#include "DNA_armature_types.h"
28#include "DNA_brush_types.h"
29#include "DNA_camera_types.h"
30#include "DNA_cloth_types.h"
33#include "DNA_curve_types.h"
35#include "DNA_fluid_types.h"
36#include "DNA_freestyle_types.h"
37#include "DNA_genfile.h"
39#include "DNA_gpu_types.h"
41#include "DNA_key_types.h"
42#include "DNA_layer_types.h"
43#include "DNA_light_types.h"
45#include "DNA_linestyle_types.h"
46#include "DNA_material_types.h"
47#include "DNA_mesh_types.h"
48#include "DNA_modifier_types.h"
49#include "DNA_object_types.h"
50#include "DNA_particle_types.h"
51#include "DNA_rigidbody_types.h"
52#include "DNA_scene_types.h"
53#include "DNA_screen_types.h"
54#include "DNA_sequence_types.h"
55#include "DNA_shader_fx_types.h"
56#include "DNA_text_types.h"
57#include "DNA_texture_types.h"
58#include "DNA_view3d_types.h"
60#include "DNA_workspace_types.h"
61#include "DNA_world_types.h"
62
63#undef DNA_GENFILE_VERSIONING_MACROS
64
65#include "BKE_anim_data.hh"
67#include "BKE_blender.hh"
68#include "BKE_collection.hh"
69#include "BKE_colortools.hh"
70#include "BKE_constraint.h"
71#include "BKE_curveprofile.h"
72#include "BKE_customdata.hh"
73#include "BKE_fcurve.hh"
74#include "BKE_fcurve_driver.h"
75#include "BKE_freestyle.h"
76#include "BKE_idprop.hh"
77#include "BKE_key.hh"
78#include "BKE_layer.hh"
79#include "BKE_lib_id.hh"
80#include "BKE_main.hh"
81#include "BKE_mesh.hh"
83#include "BKE_node.hh"
85#include "BKE_paint.hh"
86#include "BKE_paint_types.hh"
87#include "BKE_pointcache.h"
88#include "BKE_report.hh"
89#include "BKE_rigidbody.h"
90#include "BKE_screen.hh"
91#include "BKE_studiolight.h"
92#include "BKE_unit.hh"
93#include "BKE_workspace.hh"
94
95#include "SEQ_iterator.hh"
96#include "SEQ_modifier.hh"
97#include "SEQ_utils.hh"
98
99#include "NOD_shader.h"
100
101#include "ANIM_versioning.hh"
102
103#include "IMB_colormanagement.hh"
104#include "IMB_imbuf.hh"
105
106#include "BLT_translation.hh"
107
108#include "BLO_read_write.hh"
109#include "BLO_readfile.hh"
110#include "readfile.hh"
111
112#include "versioning_common.hh"
113
114#include "MEM_guardedalloc.h"
115
116namespace blender {
117
118/* Make preferences read-only, use `versioning_userdef.cc`. */
119#define U (*((const UserDef *)&U))
120
121static bScreen *screen_parent_find(const bScreen *screen)
122{
123 /* Can avoid lookup if screen state isn't maximized/full
124 * (parent and child store the same state). */
125 if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) {
126 for (const ScrArea &area : screen->areabase) {
127 if (area.full && area.full != screen) {
128 BLI_assert(area.full->state == screen->state);
129 return area.full;
130 }
131 }
132 }
133
134 return nullptr;
135}
136
138{
139 bmain->is_locked_for_linking = false;
140
141 for (bScreen &screen : bmain->screens) {
142 const bScreen *screen_parent = screen_parent_find(&screen);
143 WorkSpace *workspace;
144 if (screen.temp) {
145 continue;
146 }
147
148 if (screen_parent) {
149 /* Full-screen with "Back to Previous" option, don't create
150 * a new workspace, add layout workspace containing parent. */
151 workspace = static_cast<WorkSpace *>(
152 BLI_findstring(&bmain->workspaces, screen_parent->id.name + 2, offsetof(ID, name) + 2));
153 }
154 else {
155 workspace = BKE_workspace_add(bmain, screen.id.name + 2);
156 }
157 if (workspace == nullptr) {
158 continue; /* Not much we can do. */
159 }
160 BKE_workspace_layout_add(bmain, *workspace, screen, screen.id.name + 2);
161 }
162
163 bmain->is_locked_for_linking = true;
164}
165
167{
169 SpaceAction *saction = reinterpret_cast<SpaceAction *>(stype->create(area, scene));
170 ARegion *region_channels;
171
172 /* Properly free current regions */
173 for (ARegion &region : area->regionbase) {
174 BKE_area_region_free(area->type, &region);
175 }
176 area->regionbase.free_no_destruct();
177
178 area->type = stype;
179 area->spacetype = stype->spaceid;
180
181 BLI_addhead(&area->spacedata, saction);
182 area->regionbase = saction->regionbase;
183 saction->regionbase.clear_no_delete();
184
185 /* Different defaults for timeline */
186 region_channels = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
187 region_channels->flag |= RGN_FLAG_HIDDEN;
188
189 saction->mode = SACTCONT_TIMELINE;
192}
193
207{
208 BLI_assert(bmain->workspaces.is_empty());
209
211
212 for (wmWindowManager &wm : bmain->wm) {
213 for (wmWindow &win : wm.windows) {
214 bScreen *screen_parent = screen_parent_find(win.screen);
215 bScreen *screen = screen_parent ? screen_parent : win.screen;
216
217 if (screen->temp) {
218 /* We do not generate a new workspace for those screens...
219 * still need to set some data in win. */
221 win.scene = screen->scene;
222 /* Deprecated from now on! */
223 win.screen = nullptr;
224 continue;
225 }
226
227 WorkSpace *workspace = static_cast<WorkSpace *>(
228 BLI_findstring(&bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2));
229 BLI_assert(workspace != nullptr);
230 WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, win.screen);
231 BLI_assert(layout != nullptr);
232
234
236 BKE_workspace_active_layout_set(win.workspace_hook, win.winid, workspace, layout);
237
238 /* Move scene and view layer to window. */
239 Scene *scene = screen->scene;
240 ViewLayer *layer = static_cast<ViewLayer *>(
241 BLI_findlink(&scene->view_layers, scene->r.actlay));
242 if (!layer) {
244 }
245
246 win.scene = scene;
248
249 /* Deprecated from now on! */
250 win.screen = nullptr;
251 }
252 }
253
254 for (bScreen &screen : bmain->screens) {
255 /* Deprecated from now on! */
256 screen.scene->transform_spaces.free_no_destruct();
257 screen.scene = nullptr;
258 }
259}
260
261static void do_version_layers_to_collections(Main *bmain, Scene *scene)
262{
263 /* Since we don't have access to FileData we check the (always valid) first
264 * render layer instead. */
265 if (!scene->master_collection) {
267 }
268
269 if (scene->view_layers.first()) {
270 return;
271 }
272
273 /* Create collections from layers. */
274 Collection *collection_master = scene->master_collection;
275 Collection *collections[20] = {nullptr};
276
277 for (int layer = 0; layer < 20; layer++) {
278 for (Base &base : scene->base) {
279 if (base.lay & (1 << layer)) {
280 /* Create collections when needed only. */
281 if (collections[layer] == nullptr) {
282 char name[MAX_ID_NAME - 2];
283
284 SNPRINTF_UTF8(name, DATA_("Collection %d"), layer + 1);
285
286 Collection *collection = BKE_collection_add(bmain, collection_master, name);
287 collection->id.lib = scene->id.lib;
288 if (ID_IS_LINKED(collection)) {
289 collection->id.tag |= ID_TAG_INDIRECT;
290 }
291 collections[layer] = collection;
292
293 if (!(scene->lay & (1 << layer))) {
295 }
296 }
297
298 /* Note usually this would do slow collection syncing for view layers,
299 * but since no view layers exists yet at this point it's fast. */
300 BKE_collection_object_add_notest(bmain, collections[layer], base.object);
301 }
302
303 if (base.flag & SELECT) {
304 base.object->flag |= OB_SELECT;
305 }
306 else {
307 base.object->flag &= ~OB_SELECT;
308 }
309 }
310 }
311
312 /* Handle legacy render layers. */
313 bool have_override = false;
314 const bool need_default_renderlayer = scene->r.layers.first() == nullptr;
315
316 for (SceneRenderLayer &srl : scene->r.layers) {
317 ViewLayer *view_layer = BKE_view_layer_add(bmain, scene, srl.name, nullptr, VIEWLAYER_ADD_NEW);
318
319 if (srl.layflag & SCE_LAY_DISABLE) {
320 view_layer->flag &= ~VIEW_LAYER_RENDER;
321 }
322
323 if ((srl.layflag & SCE_LAY_FRS) == 0) {
324 view_layer->flag &= ~VIEW_LAYER_FREESTYLE;
325 }
326
327 view_layer->layflag = srl.layflag;
328 view_layer->passflag = srl.passflag;
329 view_layer->pass_alpha_threshold = srl.pass_alpha_threshold;
330 view_layer->samples = srl.samples;
331 view_layer->mat_override = srl.mat_override;
332 view_layer->world_override = srl.world_override;
333
335 view_layer->freestyle_config = srl.freestyleConfig;
336 view_layer->id_properties = srl.prop;
337
338 /* Set exclusion and overrides. */
339 for (int layer = 0; layer < 20; layer++) {
340 Collection *collection = collections[layer];
341 if (collection) {
343 collection);
344
345 if (srl.lay_exclude & (1 << layer)) {
346 /* Disable excluded layer. */
347 have_override = true;
349 for (LayerCollection &nlc : lc->layer_collections) {
351 }
352 }
353 else {
354 if (srl.lay_zmask & (1 << layer)) {
355 have_override = true;
357 }
358
359 if ((srl.lay & (1 << layer)) == 0) {
360 have_override = true;
362 }
363 }
364 }
365 }
366
367 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
368 /* for convenience set the same active object in all the layers */
369 if (scene->basact) {
370 view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
371 }
372
373 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
374 if ((base.flag & BASE_SELECTABLE) && (base.object->flag & SELECT)) {
375 base.flag |= BASE_SELECTED;
376 }
377 }
378 }
379
380 scene->r.layers.free_no_destruct();
381
382 /* If render layers included overrides, or there are no render layers,
383 * we also create a vanilla viewport layer. */
384 if (have_override || need_default_renderlayer) {
385 ViewLayer *view_layer = BKE_view_layer_add(
386 bmain, scene, "Viewport", nullptr, VIEWLAYER_ADD_NEW);
387
388 /* If we ported all the original render layers,
389 * we don't need to make the viewport layer renderable. */
390 if (!scene->view_layers.is_single()) {
391 view_layer->flag &= ~VIEW_LAYER_RENDER;
392 }
393
394 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
395 /* convert active base */
396 if (scene->basact) {
397 view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
398 }
399
400 /* convert selected bases */
401 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
402 if ((base.flag & BASE_SELECTABLE) && (base.object->flag & SELECT)) {
403 base.flag |= BASE_SELECTED;
404 }
405
406 /* keep lay around for forward compatibility (open those files in 2.79) */
407 base.lay = base.object->lay;
408 }
409 }
410
411 /* remove bases once and for all */
412 for (Base &base : scene->base) {
413 id_us_min(&base.object->id);
414 }
415
416 scene->base.free_no_destruct();
417 scene->basact = nullptr;
418}
419
421{
422 if (ID_IS_LINKED(collection)) {
423 for (CollectionChild &collection_child : collection->children) {
424 if (!ID_IS_LINKED(collection_child.collection)) {
425 collection_child.collection->id.lib = collection->id.lib;
426 }
428 }
429 }
430}
431
434{
435 for (const bGPDpalette &palette : gpd->palettes) {
436 for (bGPDpalettecolor &palcolor : palette.colors) {
437 /* fix layers */
438 for (bGPDlayer &gpl : gpd->layers) {
439 /* unlock/unhide layer */
440 gpl.flag &= ~GP_LAYER_LOCKED;
441 gpl.flag &= ~GP_LAYER_HIDE;
442 /* set opacity to 1 */
443 gpl.opacity = 1.0f;
444 /* disable tint */
445 gpl.tintcolor[3] = 0.0f;
446
447 for (bGPDframe &gpf : gpl.frames) {
448 for (bGPDstroke &gps : gpf.strokes) {
449 if ((gps.colorname[0] != '\0') && STREQ(gps.colorname, palcolor.info)) {
450 /* copy color settings */
451 copy_v4_v4(gpl.color, palcolor.color);
452 }
453 }
454 }
455 }
456 }
457 }
458}
459
460static void do_versions_remove_region(ListBaseT<ARegion> *regionbase, ARegion *region)
461{
462 MEM_delete(region->runtime);
463 BLI_freelinkN(regionbase, region);
464}
465
466static void do_versions_remove_regions_by_type(ListBaseT<ARegion> *regionbase, int regiontype)
467{
468 ARegion *region, *region_next;
469 for (region = regionbase->first(); region; region = region_next) {
470 region_next = static_cast<ARegion *>(region->next);
471 if (region->regiontype == regiontype) {
472 do_versions_remove_region(regionbase, region);
473 }
474 }
475}
476
477static ARegion *do_versions_find_region_or_null(ListBaseT<ARegion> *regionbase, int regiontype)
478{
479 for (ARegion &region : *regionbase) {
480 if (region.regiontype == regiontype) {
481 return &region;
482 }
483 }
484 return nullptr;
485}
486
487static ARegion *do_versions_find_region(ListBaseT<ARegion> *regionbase, int regiontype)
488{
489 ARegion *region = do_versions_find_region_or_null(regionbase, regiontype);
490 if (region == nullptr) {
491 BLI_assert_msg(0, "Did not find expected region in versioning");
492 }
493 return region;
494}
495
497 const short space_type,
498 const short region_flag)
499{
500 for (bScreen &screen : bmain->screens) {
501 for (ScrArea &area : screen.areabase) {
502 for (SpaceLink &sl : area.spacedata) {
503 if (sl.spacetype == space_type) {
504 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
505 &sl.regionbase;
507 if (!region) {
509 region = do_versions_add_region(RGN_TYPE_TOOLS, "tools region");
510 BLI_insertlinkafter(regionbase, header, region);
511 region->alignment = RGN_ALIGN_LEFT;
512 region->flag = eRegion_Flag(region_flag);
513 }
514 }
515 }
516 }
517 }
518}
519
520static void do_version_bones_split_bbone_scale(ListBaseT<Bone> *lb)
521{
522 for (Bone &bone : *lb) {
523 bone.scale_in_z = bone.scale_in_x;
524 bone.scale_out_z = bone.scale_out_x;
525
526 do_version_bones_split_bbone_scale(&bone.childbase);
527 }
528}
529
530static void do_version_bones_inherit_scale(ListBaseT<Bone> *lb)
531{
532 for (Bone &bone : *lb) {
533 if (bone.flag & BONE_NO_SCALE) {
534 bone.inherit_scale_mode = BONE_INHERIT_SCALE_NONE_LEGACY;
535 bone.flag &= ~BONE_NO_SCALE;
536 }
537
538 do_version_bones_inherit_scale(&bone.childbase);
539 }
540}
541
545static char *replace_bbone_scale_rnapath(const char *old_path)
546{
547 if (old_path == nullptr) {
548 return nullptr;
549 }
550
551 if (BLI_str_endswith(old_path, "bbone_scalein") || BLI_str_endswith(old_path, "bbone_scaleout"))
552 {
553 return BLI_strdupcat(old_path, "x");
554 }
555
556 return nullptr;
557}
558
559static void do_version_bbone_scale_fcurve_fix(ListBaseT<FCurve> *curves, FCurve *fcu)
560{
561 /* Update driver variable paths. */
562 if (fcu->driver) {
563 for (DriverVar &dvar : fcu->driver->variables) {
565 if (char *new_path = replace_bbone_scale_rnapath(dtar->rna_path)) {
566 MEM_delete(dtar->rna_path);
567 dtar->rna_path = new_path;
568 }
569 }
571 }
572 }
573
574 /* Update F-Curve's path. */
575 if (char *new_path = replace_bbone_scale_rnapath(fcu->rna_path().c_str())) {
576 fcu->rna_path_set_move(new_path);
577
578 /* If matched, duplicate the curve and tweak name. */
579 FCurve *second = BKE_fcurve_copy(fcu);
580
581 char *second_path = BLI_strdup(second->rna_path().c_str());
582 second_path[strlen(second_path) - 1] = 'y';
583 second->rna_path_set_move(second_path);
584
585 BLI_insertlinkafter(curves, fcu, second);
586
587 /* Add to the curve group. */
588 second->grp = fcu->grp;
589
590 if (fcu->grp != nullptr && fcu->grp->channels.last() == fcu) {
591 fcu->grp->channels.last_ = second;
592 }
593 }
594}
595
596static void do_version_constraints_maintain_volume_mode_uniform(ListBaseT<bConstraint> *lb)
597{
598 for (bConstraint &con : *lb) {
599 if (con.type == CONSTRAINT_TYPE_SAMEVOL) {
600 bSameVolumeConstraint *data = static_cast<bSameVolumeConstraint *>(con.data);
601 data->mode = SAMEVOL_UNIFORM;
602 }
603 }
604}
605
606static void do_version_constraints_copy_scale_power(ListBaseT<bConstraint> *lb)
607{
608 for (bConstraint &con : *lb) {
609 if (con.type == CONSTRAINT_TYPE_SIZELIKE) {
610 bSizeLikeConstraint *data = static_cast<bSizeLikeConstraint *>(con.data);
611 data->power = 1.0f;
612 }
613 }
614}
615
616static void do_version_constraints_copy_rotation_mix_mode(ListBaseT<bConstraint> *lb)
617{
618 for (bConstraint &con : *lb) {
619 if (con.type == CONSTRAINT_TYPE_ROTLIKE) {
620 bRotateLikeConstraint *data = static_cast<bRotateLikeConstraint *>(con.data);
621 data->mix_mode = (data->flag & ROTLIKE_OFFSET) ? ROTLIKE_MIX_OFFSET : ROTLIKE_MIX_REPLACE;
622 data->flag &= ~ROTLIKE_OFFSET;
623 }
624 }
625}
626
627static void do_versions_seq_alloc_transform_and_crop(ListBaseT<Strip> *seqbase)
628{
629 for (Strip &strip : *seqbase) {
630 if (ELEM(strip.type, STRIP_TYPE_SOUND, STRIP_TYPE_SOUND_HD) == 0) {
631 if (strip.data->transform == nullptr) {
632 strip.data->transform = MEM_new<StripTransform>("StripTransform");
633 }
634
635 if (strip.data->crop == nullptr) {
636 strip.data->crop = MEM_new<StripCrop>("StripCrop");
637 }
638
639 if (strip.seqbase.first() != nullptr) {
641 }
642 }
643 }
644}
645
646/* Return true if there is something to convert. */
647static void do_versions_material_convert_legacy_blend_mode(bNodeTree *ntree, char blend_method)
648{
649 bool need_update = false;
650
651 /* Iterate backwards from end so we don't encounter newly added links. */
652 bNodeLink *prevlink;
653 for (bNodeLink *link = ntree->links.last(); link; link = prevlink) {
654 prevlink = static_cast<bNodeLink *>(link->prev);
655
656 /* Detect link to replace. */
657 bNode *fromnode = link->fromnode;
658 bNodeSocket *fromsock = link->fromsock;
659 bNode *tonode = link->tonode;
660 bNodeSocket *tosock = link->tosock;
661
662 if (!(tonode->type_legacy == SH_NODE_OUTPUT_MATERIAL && STREQ(tosock->identifier, "Surface")))
663 {
664 continue;
665 }
666
667 /* Only do outputs that are enabled for EEVEE */
669 continue;
670 }
671
672 enum {
673 MA_BM_ADD = 1,
674 MA_BM_MULTIPLY = 2,
675 };
676 if (blend_method == MA_BM_ADD) {
677 bke::node_remove_link(ntree, *link);
678
679 bNode *add_node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_ADD_SHADER);
680 add_node->locx_legacy = 0.5f * (fromnode->locx_legacy + tonode->locx_legacy);
681 add_node->locy_legacy = 0.5f * (fromnode->locy_legacy + tonode->locy_legacy);
682
683 bNodeSocket *shader1_socket = add_node->inputs.first();
684 bNodeSocket *shader2_socket = add_node->inputs.last();
685 bNodeSocket *add_socket = bke::node_find_socket(*add_node, SOCK_OUT, "Shader"_ustr);
686
687 bNode *transp_node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_BSDF_TRANSPARENT);
688 transp_node->locx_legacy = add_node->locx_legacy;
689 transp_node->locy_legacy = add_node->locy_legacy - 110.0f;
690
691 bNodeSocket *transp_socket = bke::node_find_socket(*transp_node, SOCK_OUT, "BSDF"_ustr);
692
693 /* Link to input and material output node. */
694 bke::node_add_link(*ntree, *fromnode, *fromsock, *add_node, *shader1_socket);
695 bke::node_add_link(*ntree, *transp_node, *transp_socket, *add_node, *shader2_socket);
696 bke::node_add_link(*ntree, *add_node, *add_socket, *tonode, *tosock);
697
698 need_update = true;
699 }
700 else if (blend_method == MA_BM_MULTIPLY) {
701 bke::node_remove_link(ntree, *link);
702
703 bNode *transp_node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_BSDF_TRANSPARENT);
704
705 bNodeSocket *color_socket = bke::node_find_socket(*transp_node, SOCK_IN, "Color"_ustr);
706 bNodeSocket *transp_socket = bke::node_find_socket(*transp_node, SOCK_OUT, "BSDF"_ustr);
707
708 /* If incoming link is from a closure socket, we need to convert it. */
709 if (fromsock->type == SOCK_SHADER) {
710 transp_node->locx_legacy = 0.33f * fromnode->locx_legacy + 0.66f * tonode->locx_legacy;
711 transp_node->locy_legacy = 0.33f * fromnode->locy_legacy + 0.66f * tonode->locy_legacy;
712
713 bNode *shtorgb_node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_SHADERTORGB);
714 shtorgb_node->locx_legacy = 0.66f * fromnode->locx_legacy + 0.33f * tonode->locx_legacy;
715 shtorgb_node->locy_legacy = 0.66f * fromnode->locy_legacy + 0.33f * tonode->locy_legacy;
716
717 bNodeSocket *shader_socket = bke::node_find_socket(*shtorgb_node, SOCK_IN, "Shader"_ustr);
718 bNodeSocket *rgba_socket = bke::node_find_socket(*shtorgb_node, SOCK_OUT, "Color"_ustr);
719
720 bke::node_add_link(*ntree, *fromnode, *fromsock, *shtorgb_node, *shader_socket);
721 bke::node_add_link(*ntree, *shtorgb_node, *rgba_socket, *transp_node, *color_socket);
722 }
723 else {
724 transp_node->locx_legacy = 0.5f * (fromnode->locx_legacy + tonode->locx_legacy);
725 transp_node->locy_legacy = 0.5f * (fromnode->locy_legacy + tonode->locy_legacy);
726
727 bke::node_add_link(*ntree, *fromnode, *fromsock, *transp_node, *color_socket);
728 }
729
730 /* Link to input and material output node. */
731 bke::node_add_link(*ntree, *transp_node, *transp_socket, *tonode, *tosock);
732
733 need_update = true;
734 }
735 }
736
737 if (need_update) {
739 }
740}
741
743{
744 layer_collection->local_collections_bits = ~0;
745 for (LayerCollection &child : layer_collection->layer_collections) {
747 }
748}
749
751{
752 if (cumap == nullptr) {
753 return;
754 }
755
756#define CUMA_EXTEND_EXTRAPOLATE_OLD 1
757 for (int curve_map_index = 0; curve_map_index < 4; curve_map_index++) {
758 CurveMap *cuma = &cumap->cm[curve_map_index];
759 if (cuma->flag & CUMA_EXTEND_EXTRAPOLATE_OLD) {
761 return;
762 }
763 }
764#undef CUMA_EXTEND_EXTRAPOLATE_OLD
765}
766
767/* Util version to walk over all CurveMappings in the given `bmain` */
768static void do_version_curvemapping_walker(Main *bmain, void (*callback)(CurveMapping *cumap))
769{
770 for (Scene &scene : bmain->scenes) {
771 callback(&scene.r.mblur_shutter_curve);
772
773 if (scene.view_settings.curve_mapping) {
774 callback(scene.view_settings.curve_mapping);
775 }
776
777 if (scene.ed != nullptr) {
778 for (Strip &strip : scene.ed->seqbase) {
779 for (StripModifierData &smd : strip.modifiers) {
781
782 if (smti) {
783 if (smd.type == eSeqModifierType_Curves) {
784 CurvesModifierData *cmd = reinterpret_cast<CurvesModifierData *>(&smd);
785 callback(&cmd->curve_mapping);
786 }
787 else if (smd.type == eSeqModifierType_HueCorrect) {
788 HueCorrectModifierData *hcmd = reinterpret_cast<HueCorrectModifierData *>(&smd);
789 callback(&hcmd->curve_mapping);
790 }
791 }
792 }
793 }
794 }
795
796 /* toolsettings */
797 ToolSettings *ts = scene.toolsettings;
798 if (ts->vpaint) {
799 callback(ts->vpaint->paint.cavity_curve);
800 }
801 if (ts->wpaint) {
802 callback(ts->wpaint->paint.cavity_curve);
803 }
804 if (ts->sculpt) {
805 callback(ts->sculpt->paint.cavity_curve);
806 }
807 if (ts->gp_paint) {
808 callback(ts->gp_paint->paint.cavity_curve);
809 }
810 if (ts->gp_interpolate.custom_ipo) {
811 callback(ts->gp_interpolate.custom_ipo);
812 }
813 if (ts->gp_sculpt.cur_falloff) {
814 callback(ts->gp_sculpt.cur_falloff);
815 }
816 if (ts->gp_sculpt.cur_primitive) {
817 callback(ts->gp_sculpt.cur_primitive);
818 }
819 callback(ts->imapaint.paint.cavity_curve);
820 }
821
822 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
823 for (bNode &node : node_tree->nodes) {
824 if (ELEM(node.type_legacy,
833 {
835 callback(static_cast<CurveMapping *>(node.storage));
836 }
837 }
838 }
839 }
841
842 for (Brush &brush : bmain->brushes) {
843 if (brush.curve_distance_falloff) {
844 callback(brush.curve_distance_falloff);
845 }
846 if (brush.gpencil_settings) {
847 if (brush.gpencil_settings->curve_sensitivity) {
848 callback(brush.gpencil_settings->curve_sensitivity);
849 }
850 if (brush.gpencil_settings->curve_strength) {
851 callback(brush.gpencil_settings->curve_strength);
852 }
853 if (brush.gpencil_settings->curve_jitter) {
854 callback(brush.gpencil_settings->curve_jitter);
855 }
856 }
857 }
858
859 for (ParticleSettings &part : bmain->particles) {
860 if (part.clumpcurve) {
861 callback(part.clumpcurve);
862 }
863 if (part.roughcurve) {
864 callback(part.roughcurve);
865 }
866 if (part.twistcurve) {
867 callback(part.twistcurve);
868 }
869 }
870
871 /* Object */
872 for (Object &ob : bmain->objects) {
873 /* Object modifiers */
874 for (ModifierData &md : ob.modifiers) {
875 if (md.type == eModifierType_Hook) {
876 HookModifierData *hmd = reinterpret_cast<HookModifierData *>(&md);
877
878 if (hmd->curfalloff) {
879 callback(hmd->curfalloff);
880 }
881 }
882 else if (md.type == eModifierType_Warp) {
883 WarpModifierData *tmd = reinterpret_cast<WarpModifierData *>(&md);
884 if (tmd->curfalloff) {
885 callback(tmd->curfalloff);
886 }
887 }
888 else if (md.type == eModifierType_WeightVGEdit) {
889 WeightVGEditModifierData *wmd = reinterpret_cast<WeightVGEditModifierData *>(&md);
890
891 if (wmd->cmap_curve) {
892 callback(wmd->cmap_curve);
893 }
894 }
895 }
896 /* Grease pencil modifiers.
897 * No ListBaseT iterator because the type does not match current DNA. */
898 for (ModifierData *md = ob.greasepencil_modifiers.first_as<ModifierData>(); md; md = md->next)
899 {
901 ThickGpencilModifierData *gpmd = reinterpret_cast<ThickGpencilModifierData *>(md);
902
903 if (gpmd->curve_thickness) {
904 callback(gpmd->curve_thickness);
905 }
906 }
908 HookGpencilModifierData *gpmd = reinterpret_cast<HookGpencilModifierData *>(md);
909
910 if (gpmd->curfalloff) {
911 callback(gpmd->curfalloff);
912 }
913 }
915 NoiseGpencilModifierData *gpmd = reinterpret_cast<NoiseGpencilModifierData *>(md);
916
917 if (gpmd->curve_intensity) {
918 callback(gpmd->curve_intensity);
919 }
920 }
922 TintGpencilModifierData *gpmd = reinterpret_cast<TintGpencilModifierData *>(md);
923
924 if (gpmd->curve_intensity) {
925 callback(gpmd->curve_intensity);
926 }
927 }
929 SmoothGpencilModifierData *gpmd = reinterpret_cast<SmoothGpencilModifierData *>(md);
930
931 if (gpmd->curve_intensity) {
932 callback(gpmd->curve_intensity);
933 }
934 }
936 ColorGpencilModifierData *gpmd = reinterpret_cast<ColorGpencilModifierData *>(md);
937
938 if (gpmd->curve_intensity) {
939 callback(gpmd->curve_intensity);
940 }
941 }
943 OpacityGpencilModifierData *gpmd = reinterpret_cast<OpacityGpencilModifierData *>(md);
944
945 if (gpmd->curve_intensity) {
946 callback(gpmd->curve_intensity);
947 }
948 }
949 }
950 }
951
952 /* Free Style */
953 for (FreestyleLineStyle &linestyle : bmain->linestyles) {
954 for (LineStyleModifier &m : linestyle.alpha_modifiers) {
955 switch (m.type) {
957 callback((reinterpret_cast<LineStyleAlphaModifier_AlongStroke *>(&m))->curve);
958 break;
960 callback((reinterpret_cast<LineStyleAlphaModifier_DistanceFromCamera *>(&m))->curve);
961 break;
963 callback((reinterpret_cast<LineStyleAlphaModifier_DistanceFromObject *>(&m))->curve);
964 break;
966 callback((reinterpret_cast<LineStyleAlphaModifier_Material *>(&m))->curve);
967 break;
969 callback((reinterpret_cast<LineStyleAlphaModifier_Tangent *>(&m))->curve);
970 break;
972 callback((reinterpret_cast<LineStyleAlphaModifier_Noise *>(&m))->curve);
973 break;
975 callback((reinterpret_cast<LineStyleAlphaModifier_CreaseAngle *>(&m))->curve);
976 break;
978 callback((reinterpret_cast<LineStyleAlphaModifier_Curvature_3D *>(&m))->curve);
979 break;
980 default:
981 break;
982 }
983 }
984
985 for (LineStyleModifier &m : linestyle.thickness_modifiers) {
986 switch (m.type) {
988 callback((reinterpret_cast<LineStyleThicknessModifier_AlongStroke *>(&m))->curve);
989 break;
991 callback((reinterpret_cast<LineStyleThicknessModifier_DistanceFromCamera *>(&m))->curve);
992 break;
994 callback((reinterpret_cast<LineStyleThicknessModifier_DistanceFromObject *>(&m))->curve);
995 break;
997 callback((reinterpret_cast<LineStyleThicknessModifier_Material *>(&m))->curve);
998 break;
1000 callback((reinterpret_cast<LineStyleThicknessModifier_Tangent *>(&m))->curve);
1001 break;
1003 callback((reinterpret_cast<LineStyleThicknessModifier_CreaseAngle *>(&m))->curve);
1004 break;
1006 callback((reinterpret_cast<LineStyleThicknessModifier_Curvature_3D *>(&m))->curve);
1007 break;
1008 default:
1009 break;
1010 }
1011 }
1012 }
1013}
1014
1016{
1017 bool need_update = false;
1018
1019 /* Iterate backwards from end so we don't encounter newly added links. */
1020 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1021 /* Detect link to replace. */
1022 bNode *fromnode = link.fromnode;
1023 bNodeSocket *fromsock = link.fromsock;
1024 bNode *tonode = link.tonode;
1025 bNodeSocket *tosock = link.tosock;
1026
1027 if (!(tonode->type_legacy == SH_NODE_OUTPUT_MATERIAL &&
1028 fromnode->type_legacy != SH_NODE_DISPLACEMENT &&
1029 STREQ(tosock->identifier, "Displacement")))
1030 {
1031 continue;
1032 }
1033
1034 /* Replace link with displacement node. */
1035 bke::node_remove_link(ntree, link);
1036
1037 /* Add displacement node. */
1039 node->locx_legacy = 0.5f * (fromnode->locx_legacy + tonode->locx_legacy);
1040 node->locy_legacy = 0.5f * (fromnode->locy_legacy + tonode->locy_legacy);
1041
1042 bNodeSocket *scale_socket = bke::node_find_socket(*node, SOCK_IN, "Scale"_ustr);
1043 bNodeSocket *midlevel_socket = bke::node_find_socket(*node, SOCK_IN, "Midlevel"_ustr);
1044 bNodeSocket *height_socket = bke::node_find_socket(*node, SOCK_IN, "Height"_ustr);
1045 bNodeSocket *displacement_socket = bke::node_find_socket(*node, SOCK_OUT, "Displacement"_ustr);
1046
1047 /* Set default values for compatibility. */
1048 *version_cycles_node_socket_float_value(scale_socket) = 0.1f;
1049 *version_cycles_node_socket_float_value(midlevel_socket) = 0.0f;
1050
1051 /* Link to input and material output node. */
1052 bke::node_add_link(*ntree, *fromnode, *fromsock, *node, *height_socket);
1053 bke::node_add_link(*ntree, *node, *displacement_socket, *tonode, *tosock);
1054
1055 need_update = true;
1056 }
1057
1058 if (need_update) {
1060 }
1061}
1062
1064{
1065 if (node->type_legacy == SH_NODE_DISPLACEMENT) {
1066 if (node->custom1 != SHD_SPACE_WORLD) {
1067 node->custom1 = SHD_SPACE_OBJECT;
1068 }
1069 }
1070 else if (node->type_legacy == SH_NODE_BSDF_PRINCIPLED) {
1071 if (node->custom2 != SHD_SUBSURFACE_RANDOM_WALK_SKIN) {
1072 node->custom2 = SHD_SUBSURFACE_BURLEY;
1073 }
1074 }
1075}
1076
1078{
1079 auto check_node = [](const bNode *node) {
1080 return ELEM(node->type_legacy,
1085 };
1086 auto update_input = [](const bNode *, bNodeSocket *input) {
1087 float *value = version_cycles_node_socket_float_value(input);
1088 *value = sqrtf(max_ff(*value, 0.0f));
1089 };
1090 auto update_input_link =
1091 [ntree](bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock) {
1092 /* Add `sqrt` node. */
1093 bNode *node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
1094 node->custom1 = NODE_MATH_POWER;
1095 node->locx_legacy = 0.5f * (fromnode->locx_legacy + tonode->locx_legacy);
1096 node->locy_legacy = 0.5f * (fromnode->locy_legacy + tonode->locy_legacy);
1097
1098 /* Link to input and material output node. */
1099 *version_cycles_node_socket_float_value(node->inputs.last()) = 0.5f;
1100 bke::node_add_link(*ntree, *fromnode, *fromsock, *node, *node->inputs.first());
1101 bke::node_add_link(*ntree, *node, *node->outputs.first(), *tonode, *tosock);
1102 };
1103
1104 version_update_node_input(ntree, check_node, "Roughness", update_input, update_input_link);
1105}
1106
1108{
1109 /* Flip euler order of mapping shader node */
1110 if (node->type_legacy == SH_NODE_MAPPING && node->storage) {
1111 TexMapping *texmap = static_cast<TexMapping *>(node->storage);
1112
1113 float quat[4];
1114 eulO_to_quat(quat, texmap->rot, EULER_ORDER_ZYX);
1115 quat_to_eulO(texmap->rot, EULER_ORDER_XYZ, quat);
1116 }
1117}
1118
1120{
1121 /* Remap values of vector curve node from normalized to absolute values */
1122 if (node->type_legacy == SH_NODE_CURVE_VEC && node->storage) {
1123 CurveMapping *mapping = static_cast<CurveMapping *>(node->storage);
1124 mapping->flag &= ~CUMA_DO_CLIP;
1125
1126 for (int curve_index = 0; curve_index < CM_TOT; curve_index++) {
1127 CurveMap *cm = &mapping->cm[curve_index];
1128 if (cm->curve) {
1129 for (int i = 0; i < cm->totpoint; i++) {
1130 cm->curve[i].x = (cm->curve[i].x * 2.0f) - 1.0f;
1131 cm->curve[i].y = (cm->curve[i].y - 0.5f) * 2.0f;
1132 }
1133 }
1134 }
1135
1137 }
1138}
1139
1141{
1142 bool need_update = false;
1143
1144 /* Set default values. */
1145 for (bNode &node : ntree->nodes) {
1146 if (node.type_legacy == SH_NODE_AMBIENT_OCCLUSION) {
1147 node.custom1 = 1; /* samples */
1148 node.custom2 &= ~SHD_AO_LOCAL;
1149
1150 bNodeSocket *distance_socket = bke::node_find_socket(node, SOCK_IN, "Distance"_ustr);
1151 *version_cycles_node_socket_float_value(distance_socket) = 0.0f;
1152 }
1153 }
1154
1155 /* Iterate backwards from end so we don't encounter newly added links. */
1156 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1157 /* Detect link to replace. */
1158 bNode *fromnode = link.fromnode;
1159 bNode *tonode = link.tonode;
1160 bNodeSocket *tosock = link.tosock;
1161
1162 if (!(fromnode->type_legacy == SH_NODE_AMBIENT_OCCLUSION)) {
1163 continue;
1164 }
1165
1166 /* Replace links with color socket. */
1167 bke::node_remove_link(ntree, link);
1168 bNodeSocket *color_socket = bke::node_find_socket(*fromnode, SOCK_OUT, "Color"_ustr);
1169 bke::node_add_link(*ntree, *fromnode, *color_socket, *tonode, *tosock);
1170
1171 need_update = true;
1172 }
1173
1174 if (need_update) {
1176 }
1177}
1178
1180{
1181 if (node->id == nullptr) {
1182 return;
1183 }
1184
1185 int color_space;
1186 if (node->type_legacy == SH_NODE_TEX_IMAGE && node->storage) {
1187 NodeTexImage *tex = static_cast<NodeTexImage *>(node->storage);
1188 color_space = tex->color_space;
1189 }
1190 else if (node->type_legacy == SH_NODE_TEX_ENVIRONMENT && node->storage) {
1191 NodeTexEnvironment *tex = static_cast<NodeTexEnvironment *>(node->storage);
1192 color_space = tex->color_space;
1193 }
1194 else {
1195 return;
1196 }
1197
1198 enum { SHD_COLORSPACE_NONE = 0 };
1199 Image *image = id_cast<Image *>(node->id);
1200 if (color_space == SHD_COLORSPACE_NONE) {
1201 STRNCPY_UTF8(image->colorspace_settings.name,
1203 }
1204}
1205
1206static void light_emission_node_to_energy(Light *light, float *energy, float color[3])
1207{
1208 *energy = 1.0;
1209 copy_v3_fl(color, 1.0f);
1210
1211 /* If nodetree has animation or drivers, don't try to convert. */
1212 bNodeTree *ntree = light->nodetree;
1213 if (ntree == nullptr || ntree->adt) {
1214 return;
1215 }
1216
1217 /* Find emission node */
1218 bNode *output_node = ntreeShaderOutputNode(ntree, SHD_OUTPUT_CYCLES);
1219 if (output_node == nullptr) {
1220 return;
1221 }
1222
1223 bNode *emission_node = nullptr;
1224 for (bNodeLink &link : ntree->links) {
1225 if (link.tonode == output_node && link.fromnode->type_legacy == SH_NODE_EMISSION) {
1226 emission_node = link.fromnode;
1227 break;
1228 }
1229 }
1230
1231 if (emission_node == nullptr) {
1232 return;
1233 }
1234
1235 /* Don't convert if anything is linked */
1236 bNodeSocket *strength_socket = bke::node_find_socket(*emission_node, SOCK_IN, "Strength"_ustr);
1237 bNodeSocket *color_socket = bke::node_find_socket(*emission_node, SOCK_IN, "Color"_ustr);
1238
1239 if ((strength_socket->flag & SOCK_IS_LINKED) || (color_socket->flag & SOCK_IS_LINKED)) {
1240 return;
1241 }
1242
1243 float *strength_value = version_cycles_node_socket_float_value(strength_socket);
1244 float *color_value = version_cycles_node_socket_rgba_value(color_socket);
1245
1246 *energy = *strength_value;
1247 copy_v3_v3(color, color_value);
1248
1249 *strength_value = 1.0f;
1250 copy_v4_fl(color_value, 1.0f);
1251 light->use_nodes = false;
1252}
1253
1254static void light_emission_unify(Light *light, const char *engine)
1255{
1256 if (light->type != LA_SUN) {
1257 light->energy_deprecated *= 100.0f;
1258 }
1259
1260 /* Attempt to extract constant energy and color from nodes. */
1261 bool use_nodes = light->use_nodes;
1262 float energy, color[3];
1263 light_emission_node_to_energy(light, &energy, color);
1264
1265 if (STREQ(engine, "CYCLES")) {
1266 if (use_nodes) {
1267 /* Energy extracted from nodes */
1268 light->energy_deprecated = energy;
1269 copy_v3_v3(&light->r, color);
1270 }
1271 else {
1272 /* Default cycles multipliers if there are no nodes */
1273 if (light->type == LA_SUN) {
1274 light->energy_deprecated = 1.0f;
1275 }
1276 else {
1277 light->energy_deprecated = 100.0f;
1278 }
1279 }
1280 }
1281 else {
1282 /* Disable nodes if scene was configured for Eevee */
1283 light->use_nodes = false;
1284 }
1285}
1286
1287/* The B input of the Math node is no longer used for single-operand operators.
1288 * Previously, if the B input was linked and the A input was not, the B input
1289 * was used as the input of the operator. To correct this, we move the link
1290 * from B to A if B is linked and A is not.
1291 */
1293{
1294 bool need_update = false;
1295
1296 for (bNode &node : ntree->nodes) {
1297 if (node.type_legacy == SH_NODE_MATH) {
1298 if (ELEM(node.custom1,
1311 {
1312 bNodeSocket *sockA = static_cast<bNodeSocket *>(BLI_findlink(&node.inputs, 0));
1313 bNodeSocket *sockB = static_cast<bNodeSocket *>(BLI_findlink(&node.inputs, 1));
1314 if (!sockA->link && sockB->link) {
1315 bke::node_add_link(*ntree, *sockB->link->fromnode, *sockB->link->fromsock, node, *sockA);
1316 bke::node_remove_link(ntree, *sockB->link);
1317 need_update = true;
1318 }
1319 }
1320 }
1321 }
1322
1323 if (need_update) {
1325 }
1326}
1327
1328/* The Value output of the Vector Math node is no longer available in the Add
1329 * and Subtract operators. Previously, this Value output was computed from the
1330 * Vector output V as follows:
1331 *
1332 * Value = (abs(V.x) + abs(V.y) + abs(V.z)) / 3
1333 *
1334 * Or more compactly using vector operators:
1335 *
1336 * Value = dot(abs(V), (1 / 3, 1 / 3, 1 / 3))
1337 *
1338 * To correct this, if the Value output was used, we are going to compute
1339 * it using the second equation by adding an absolute and a dot node, and
1340 * then connect them appropriately.
1341 */
1343{
1344 bool need_update = false;
1345
1346 for (bNode &node : ntree->nodes) {
1347 if (node.type_legacy == SH_NODE_VECTOR_MATH) {
1348 bNodeSocket *sockOutValue = bke::node_find_socket(node, SOCK_OUT, "Value"_ustr);
1349 if (version_node_socket_is_used(sockOutValue) &&
1351 {
1352
1353 bNode *absNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1355 absNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1356 absNode->locy_legacy = node.locy_legacy;
1357
1358 bNode *dotNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1360 dotNode->locx_legacy = absNode->locx_legacy + absNode->width + 20.0f;
1361 dotNode->locy_legacy = absNode->locy_legacy;
1362 bNodeSocket *sockDotB = static_cast<bNodeSocket *>(BLI_findlink(&dotNode->inputs, 1));
1363 bNodeSocket *sockDotOutValue = bke::node_find_socket(*dotNode, SOCK_OUT, "Value"_ustr);
1365
1366 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1367 if (link.fromsock == sockOutValue) {
1368 bke::node_add_link(*ntree, *dotNode, *sockDotOutValue, *link.tonode, *link.tosock);
1369 bke::node_remove_link(ntree, link);
1370 }
1371 }
1372
1373 bNodeSocket *sockAbsA = static_cast<bNodeSocket *>(BLI_findlink(&absNode->inputs, 0));
1374 bNodeSocket *sockDotA = static_cast<bNodeSocket *>(BLI_findlink(&dotNode->inputs, 0));
1375 bNodeSocket *sockOutVector = bke::node_find_socket(node, SOCK_OUT, "Vector"_ustr);
1376 bNodeSocket *sockAbsOutVector = bke::node_find_socket(*absNode, SOCK_OUT, "Vector"_ustr);
1377
1378 bke::node_add_link(*ntree, node, *sockOutVector, *absNode, *sockAbsA);
1379 bke::node_add_link(*ntree, *absNode, *sockAbsOutVector, *dotNode, *sockDotA);
1380
1381 need_update = true;
1382 }
1383 }
1384 }
1385
1386 if (need_update) {
1388 }
1389}
1390
1391/* The Vector output of the Vector Math node is no longer available in the Dot
1392 * Product operator. Previously, this Vector was always zero initialized. To
1393 * correct this, we zero out any socket the Vector Output was connected to.
1394 */
1396{
1397 bool need_update = false;
1398
1399 for (bNode &node : ntree->nodes) {
1400 if (node.type_legacy == SH_NODE_VECTOR_MATH) {
1401 bNodeSocket *sockOutVector = bke::node_find_socket(node, SOCK_OUT, "Vector"_ustr);
1402 if (version_node_socket_is_used(sockOutVector) &&
1404 {
1405 for (bNodeLink &link : ntree->links.items_mutable()) {
1406 if (link.fromsock == sockOutVector) {
1407 switch (link.tosock->type) {
1408 case SOCK_FLOAT:
1409 *version_cycles_node_socket_float_value(link.tosock) = 0.0f;
1410 break;
1411 case SOCK_VECTOR:
1413 break;
1414 case SOCK_RGBA:
1416 break;
1417 default:
1418 break;
1419 }
1420 bke::node_remove_link(ntree, link);
1421 }
1422 }
1423 need_update = true;
1424 }
1425 }
1426 }
1427
1428 if (need_update) {
1430 }
1431}
1432
1433/* Previously, the Vector output of the cross product operator was normalized.
1434 * To correct this, a Normalize node is added to normalize the output if used.
1435 * Moreover, the Value output was removed. This Value was equal to the length
1436 * of the cross product. To correct this, a Length node is added if needed.
1437 */
1439{
1440 bool need_update = false;
1441
1442 for (bNode &node : ntree->nodes) {
1443 if (node.type_legacy == SH_NODE_VECTOR_MATH) {
1444 if (node.custom1 == NODE_VECTOR_MATH_CROSS_PRODUCT) {
1445 bNodeSocket *sockOutVector = bke::node_find_socket(node, SOCK_OUT, "Vector"_ustr);
1446 if (version_node_socket_is_used(sockOutVector)) {
1447 bNode *normalizeNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1448 normalizeNode->custom1 = NODE_VECTOR_MATH_NORMALIZE;
1449 normalizeNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1450 normalizeNode->locy_legacy = node.locy_legacy;
1451 bNodeSocket *sockNormalizeOut = bke::node_find_socket(
1452 *normalizeNode, SOCK_OUT, "Vector"_ustr);
1453
1454 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1455 if (link.fromsock == sockOutVector) {
1457 *ntree, *normalizeNode, *sockNormalizeOut, *link.tonode, *link.tosock);
1458 bke::node_remove_link(ntree, link);
1459 }
1460 }
1461 bNodeSocket *sockNormalizeA = static_cast<bNodeSocket *>(
1462 BLI_findlink(&normalizeNode->inputs, 0));
1463 bke::node_add_link(*ntree, node, *sockOutVector, *normalizeNode, *sockNormalizeA);
1464
1465 need_update = true;
1466 }
1467
1468 bNodeSocket *sockOutValue = bke::node_find_socket(node, SOCK_OUT, "Value"_ustr);
1469 if (version_node_socket_is_used(sockOutValue)) {
1470 bNode *lengthNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1471 lengthNode->custom1 = NODE_VECTOR_MATH_LENGTH;
1472 lengthNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1473 if (version_node_socket_is_used(sockOutVector)) {
1474 lengthNode->locy_legacy = node.locy_legacy - lengthNode->height - 20.0f;
1475 }
1476 else {
1477 lengthNode->locy_legacy = node.locy_legacy;
1478 }
1479 bNodeSocket *sockLengthOut = bke::node_find_socket(*lengthNode, SOCK_OUT, "Value"_ustr);
1480
1481 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1482 if (link.fromsock == sockOutValue) {
1483 bke::node_add_link(*ntree, *lengthNode, *sockLengthOut, *link.tonode, *link.tosock);
1484 bke::node_remove_link(ntree, link);
1485 }
1486 }
1487 bNodeSocket *sockLengthA = static_cast<bNodeSocket *>(
1488 BLI_findlink(&lengthNode->inputs, 0));
1489 bke::node_add_link(*ntree, node, *sockOutVector, *lengthNode, *sockLengthA);
1490
1491 need_update = true;
1492 }
1493 }
1494 }
1495 }
1496
1497 if (need_update) {
1499 }
1500}
1501
1502/* The Value output of the Vector Math node is no longer available in the
1503 * Normalize operator. This Value output was equal to the length of the
1504 * the input vector A. To correct this, we either add a Length node or
1505 * convert the Normalize node into a Length node, depending on if the
1506 * Vector output is needed.
1507 */
1509{
1510 bool need_update = false;
1511
1512 for (bNode &node : ntree->nodes) {
1513 if (node.type_legacy == SH_NODE_VECTOR_MATH) {
1514 bNodeSocket *sockOutValue = bke::node_find_socket(node, SOCK_OUT, "Value"_ustr);
1515 if (node.custom1 == NODE_VECTOR_MATH_NORMALIZE && version_node_socket_is_used(sockOutValue))
1516 {
1517 bNodeSocket *sockOutVector = bke::node_find_socket(node, SOCK_OUT, "Vector"_ustr);
1518 if (version_node_socket_is_used(sockOutVector)) {
1519 bNode *lengthNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1520 lengthNode->custom1 = NODE_VECTOR_MATH_LENGTH;
1521 lengthNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1522 lengthNode->locy_legacy = node.locy_legacy;
1523 bNodeSocket *sockLengthValue = bke::node_find_socket(
1524 *lengthNode, SOCK_OUT, "Value"_ustr);
1525
1526 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1527 if (link.fromsock == sockOutValue) {
1529 *ntree, *lengthNode, *sockLengthValue, *link.tonode, *link.tosock);
1530 bke::node_remove_link(ntree, link);
1531 }
1532 }
1533 bNodeSocket *sockA = static_cast<bNodeSocket *>(BLI_findlink(&node.inputs, 0));
1534 bNodeSocket *sockLengthA = static_cast<bNodeSocket *>(
1535 BLI_findlink(&lengthNode->inputs, 0));
1536 if (sockA->link) {
1537 bNodeLink *link = sockA->link;
1539 *ntree, *link->fromnode, *link->fromsock, *lengthNode, *sockLengthA);
1540 }
1541 else {
1544 }
1545
1546 need_update = true;
1547 }
1548 else {
1549 node.custom1 = NODE_VECTOR_MATH_LENGTH;
1550 }
1551 }
1552 }
1553 }
1554 if (need_update) {
1556 }
1557}
1558
1559/* The Vector Math operator types didn't have an enum, but rather, their
1560 * values were hard coded into the code. After the enum was created and
1561 * after more vector operators were added, the hard coded values needs
1562 * to be remapped to their correct enum values. To fix this, we remap
1563 * the values according to the following rules:
1564 *
1565 * Dot Product Operator : 3 -> 7
1566 * Normalize Operator : 5 -> 11
1567 *
1568 * Additionally, since the Average operator was removed, it is assigned
1569 * a value of -1 just to be identified later in the versioning code:
1570 *
1571 * Average Operator : 2 -> -1
1572 */
1574{
1575 for (bNode &node : ntree->nodes) {
1576 if (node.type_legacy == SH_NODE_VECTOR_MATH) {
1577 switch (node.custom1) {
1578 case 2:
1579 node.custom1 = -1;
1580 break;
1581 case 3:
1582 node.custom1 = 7;
1583 break;
1584 case 5:
1585 node.custom1 = 11;
1586 break;
1587 }
1588 }
1589 }
1590}
1591
1592/* The Average operator is no longer available in the Vector Math node.
1593 * The Vector output was equal to the normalized sum of input vectors while
1594 * the Value output was equal to the length of the sum of input vectors.
1595 * To correct this, we convert the node into an Add node and add a length
1596 * node or a normalize node if needed.
1597 */
1599{
1600 bool need_update = false;
1601
1602 for (bNode &node : ntree->nodes) {
1603 if (node.type_legacy == SH_NODE_VECTOR_MATH) {
1604 /* See update_vector_math_node_operators_enum_mapping. */
1605 if (node.custom1 == -1) {
1606 node.custom1 = NODE_VECTOR_MATH_ADD;
1607 bNodeSocket *sockOutVector = bke::node_find_socket(node, SOCK_OUT, "Vector"_ustr);
1608 if (version_node_socket_is_used(sockOutVector)) {
1609 bNode *normalizeNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1610 normalizeNode->custom1 = NODE_VECTOR_MATH_NORMALIZE;
1611 normalizeNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1612 normalizeNode->locy_legacy = node.locy_legacy;
1613 bNodeSocket *sockNormalizeOut = bke::node_find_socket(
1614 *normalizeNode, SOCK_OUT, "Vector"_ustr);
1615
1616 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1617 if (link.fromsock == sockOutVector) {
1619 *ntree, *normalizeNode, *sockNormalizeOut, *link.tonode, *link.tosock);
1620 bke::node_remove_link(ntree, link);
1621 }
1622 }
1623 bNodeSocket *sockNormalizeA = static_cast<bNodeSocket *>(
1624 BLI_findlink(&normalizeNode->inputs, 0));
1625 bke::node_add_link(*ntree, node, *sockOutVector, *normalizeNode, *sockNormalizeA);
1626
1627 need_update = true;
1628 }
1629
1630 bNodeSocket *sockOutValue = bke::node_find_socket(node, SOCK_OUT, "Value"_ustr);
1631 if (version_node_socket_is_used(sockOutValue)) {
1632 bNode *lengthNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1633 lengthNode->custom1 = NODE_VECTOR_MATH_LENGTH;
1634 lengthNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1635 if (version_node_socket_is_used(sockOutVector)) {
1636 lengthNode->locy_legacy = node.locy_legacy - lengthNode->height - 20.0f;
1637 }
1638 else {
1639 lengthNode->locy_legacy = node.locy_legacy;
1640 }
1641 bNodeSocket *sockLengthOut = bke::node_find_socket(*lengthNode, SOCK_OUT, "Value"_ustr);
1642
1643 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1644 if (link.fromsock == sockOutValue) {
1645 bke::node_add_link(*ntree, *lengthNode, *sockLengthOut, *link.tonode, *link.tosock);
1646 bke::node_remove_link(ntree, link);
1647 }
1648 }
1649 bNodeSocket *sockLengthA = static_cast<bNodeSocket *>(
1650 BLI_findlink(&lengthNode->inputs, 0));
1651 bke::node_add_link(*ntree, node, *sockOutVector, *lengthNode, *sockLengthA);
1652
1653 need_update = true;
1654 }
1655 }
1656 }
1657 }
1658
1659 if (need_update) {
1661 }
1662}
1663
1664/* The Noise node now have a dimension property. This property should be
1665 * initialized to 3 by default.
1666 */
1668{
1669 for (bNode &node : ntree->nodes) {
1670 if (node.type_legacy == SH_NODE_TEX_NOISE && node.storage) {
1671 NodeTexNoise *tex = static_cast<NodeTexNoise *>(node.storage);
1672 tex->dimensions = 3;
1673 }
1674 }
1675}
1676
1677/* This callback function is used by update_mapping_node_inputs_and_properties.
1678 * It is executed on every fcurve in the nodetree id updating its RNA paths. The
1679 * paths needs to be updated because the node properties became inputs.
1680 *
1681 * nodes["Mapping"].translation --> nodes["Mapping"].inputs[1].default_value
1682 * nodes["Mapping"].rotation --> nodes["Mapping"].inputs[2].default_value
1683 * nodes["Mapping"].scale --> nodes["Mapping"].inputs[3].default_value
1684 * nodes["Mapping"].max --> nodes["Maximum"].inputs[1].default_value
1685 * nodes["Mapping"].min --> nodes["Minimum"].inputs[1].default_value
1686 *
1687 * The fcurve can be that of any node or property in the nodetree, so we only
1688 * update if the rna path starts with the rna path of the mapping node and
1689 * doesn't end with "default_value", that is, not the Vector input.
1690 */
1692 const char *nodePath,
1693 const bNode *minimumNode,
1694 const bNode *maximumNode)
1695{
1696 if (!STRPREFIX(fcurve->rna_path().c_str(), nodePath) ||
1697 BLI_str_endswith(fcurve->rna_path().c_str(), "default_value"))
1698 {
1699 return;
1700 }
1701 const char *old_fcurve_rna_path = fcurve->rna_path().c_str();
1702
1703 if (BLI_str_endswith(old_fcurve_rna_path, "translation")) {
1704 fcurve->rna_path_set_move(BLI_sprintfN("%s.%s", nodePath, "inputs[1].default_value"));
1705 }
1706 else if (BLI_str_endswith(old_fcurve_rna_path, "rotation")) {
1707 fcurve->rna_path_set_move(BLI_sprintfN("%s.%s", nodePath, "inputs[2].default_value"));
1708 }
1709 else if (BLI_str_endswith(old_fcurve_rna_path, "scale")) {
1710 fcurve->rna_path_set_move(BLI_sprintfN("%s.%s", nodePath, "inputs[3].default_value"));
1711 }
1712 else if (minimumNode && BLI_str_endswith(old_fcurve_rna_path, "max")) {
1713 char node_name_esc[sizeof(minimumNode->name) * 2];
1714 BLI_str_escape(node_name_esc, minimumNode->name, sizeof(node_name_esc));
1715 fcurve->rna_path_set_move(
1716 BLI_sprintfN("nodes[\"%s\"].%s", node_name_esc, "inputs[1].default_value"));
1717 }
1718 else if (maximumNode && BLI_str_endswith(old_fcurve_rna_path, "min")) {
1719 char node_name_esc[sizeof(maximumNode->name) * 2];
1720 BLI_str_escape(node_name_esc, maximumNode->name, sizeof(node_name_esc));
1721 fcurve->rna_path_set_move(
1722 BLI_sprintfN("nodes[\"%s\"].%s", node_name_esc, "inputs[1].default_value"));
1723 }
1724}
1725
1726/* The Mapping node has been rewritten to support dynamic inputs. Previously,
1727 * the transformation information was stored in a TexMapping struct in the
1728 * node->storage member of bNode. Currently, the transformation information
1729 * is stored in input sockets. To correct this, we transfer the information
1730 * from the TexMapping struct to the input sockets.
1731 *
1732 * Additionally, the Minimum and Maximum properties are no longer available
1733 * in the node. To correct this, a Vector Minimum and/or a Vector Maximum
1734 * nodes are added if needed.
1735 *
1736 * Finally, the #TexMapping struct is freed and `node->storage` is set to null.
1737 *
1738 * Since the RNA paths of the properties changed, we also have to update the
1739 * rna_path of the FCurves if they exist. To do that, we loop over FCurves
1740 * and check if they control a property of the node, if they do, we update
1741 * the path to be that of the corresponding socket in the node or the added
1742 * minimum/maximum node.
1743 */
1745{
1746 bool need_update = false;
1747
1748 for (bNode &node : ntree->nodes) {
1749 /* If `node->storage` is null, then conversion has already taken place.
1750 * This can happen if a file with the new mapping node [saved from (2, 81, 8) or newer]
1751 * is opened in a blender version prior to (2, 81, 8) and saved from there again. */
1752 if (node.type_legacy == SH_NODE_MAPPING && node.storage) {
1753 TexMapping *mapping = static_cast<TexMapping *>(node.storage);
1754 node.custom1 = mapping->type;
1755 node.width = 140.0f;
1756
1757 bNodeSocket *sockLocation = bke::node_find_socket(node, SOCK_IN, "Location"_ustr);
1759 bNodeSocket *sockRotation = bke::node_find_socket(node, SOCK_IN, "Rotation"_ustr);
1761 bNodeSocket *sockScale = bke::node_find_socket(node, SOCK_IN, "Scale"_ustr);
1763
1764 bNode *maximumNode = nullptr;
1765 if (mapping->flag & TEXMAP_CLIP_MIN) {
1766 maximumNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1767 maximumNode->custom1 = NODE_VECTOR_MATH_MAXIMUM;
1768 if (mapping->flag & TEXMAP_CLIP_MAX) {
1769 maximumNode->locx_legacy = node.locx_legacy + (node.width + 20.0f) * 2.0f;
1770 }
1771 else {
1772 maximumNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1773 }
1774 maximumNode->locy_legacy = node.locy_legacy;
1775 bNodeSocket *sockMaximumB = static_cast<bNodeSocket *>(
1776 BLI_findlink(&maximumNode->inputs, 1));
1778 bNodeSocket *sockMappingResult = bke::node_find_socket(node, SOCK_OUT, "Vector"_ustr);
1779
1780 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1781 if (link.fromsock == sockMappingResult) {
1782 bNodeSocket *sockMaximumResult = bke::node_find_socket(
1783 *maximumNode, SOCK_OUT, "Vector"_ustr);
1785 *ntree, *maximumNode, *sockMaximumResult, *link.tonode, *link.tosock);
1786 bke::node_remove_link(ntree, link);
1787 }
1788 }
1789 if (!(mapping->flag & TEXMAP_CLIP_MAX)) {
1790 bNodeSocket *sockMaximumA = static_cast<bNodeSocket *>(
1791 BLI_findlink(&maximumNode->inputs, 0));
1792 bke::node_add_link(*ntree, node, *sockMappingResult, *maximumNode, *sockMaximumA);
1793 }
1794
1795 need_update = true;
1796 }
1797
1798 bNode *minimumNode = nullptr;
1799 if (mapping->flag & TEXMAP_CLIP_MAX) {
1800 minimumNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECTOR_MATH);
1801 minimumNode->custom1 = NODE_VECTOR_MATH_MINIMUM;
1802 minimumNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1803 minimumNode->locy_legacy = node.locy_legacy;
1804 bNodeSocket *sockMinimumB = static_cast<bNodeSocket *>(
1805 BLI_findlink(&minimumNode->inputs, 1));
1807
1808 bNodeSocket *sockMinimumResult = bke::node_find_socket(
1809 *minimumNode, SOCK_OUT, "Vector"_ustr);
1810 bNodeSocket *sockMappingResult = bke::node_find_socket(node, SOCK_OUT, "Vector"_ustr);
1811
1812 if (maximumNode) {
1813 bNodeSocket *sockMaximumA = static_cast<bNodeSocket *>(
1814 BLI_findlink(&maximumNode->inputs, 0));
1816 *ntree, *minimumNode, *sockMinimumResult, *maximumNode, *sockMaximumA);
1817 }
1818 else {
1819 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
1820 if (link.fromsock == sockMappingResult) {
1822 *ntree, *minimumNode, *sockMinimumResult, *link.tonode, *link.tosock);
1823 bke::node_remove_link(ntree, link);
1824 }
1825 }
1826 }
1827 bNodeSocket *sockMinimumA = static_cast<bNodeSocket *>(
1828 BLI_findlink(&minimumNode->inputs, 0));
1829 bke::node_add_link(*ntree, node, *sockMappingResult, *minimumNode, *sockMinimumA);
1830
1831 need_update = true;
1832 }
1833
1834 MEM_delete(mapping);
1835 node.storage = nullptr;
1836
1837 char node_name_esc[sizeof(node.name) * 2];
1838 BLI_str_escape(node_name_esc, node.name, sizeof(node_name_esc));
1839
1840 char *nodePath = BLI_sprintfN("nodes[\"%s\"]", node_name_esc);
1841 animrig::versioning::fcurves_id_cb(&ntree->id, [&](ID * /*id*/, FCurve *fcu) {
1842 update_mapping_node_fcurve_rna_path_callback(fcu, nodePath, minimumNode, maximumNode);
1843 });
1844 MEM_delete(nodePath);
1845 }
1846 }
1847
1848 if (need_update) {
1850 }
1851}
1852
1853/* The Musgrave node now has a dimension property. This property should
1854 * be initialized to 3 by default.
1855 */
1857{
1858 for (bNode &node : ntree->nodes) {
1859 if (node.type_legacy == SH_NODE_TEX_MUSGRAVE_DEPRECATED && node.storage) {
1860 NodeTexMusgrave *tex = static_cast<NodeTexMusgrave *>(node.storage);
1861 tex->dimensions = 3;
1862 }
1863 }
1864}
1865
1866/* The Color output of the Musgrave node has been removed. Previously, this
1867 * output was just equal to the `Fac` output. To correct this, we move links
1868 * from the Color output to the `Fac` output if they exist.
1869 */
1871{
1872 for (bNodeLink &link : ntree->links) {
1874 if (link.fromsock->type == SOCK_RGBA) {
1875 link.fromsock = link.fromsock->next;
1876 }
1877 }
1878 }
1879}
1880
1881/* The Voronoi node now have a dimension property. This property should be
1882 * initialized to 3 by default.
1883 */
1885{
1886 for (bNode &node : ntree->nodes) {
1887 if (node.type_legacy == SH_NODE_TEX_VORONOI && node.storage) {
1888 NodeTexVoronoi *tex = static_cast<NodeTexVoronoi *>(node.storage);
1889 tex->dimensions = 3;
1890 }
1891 }
1892}
1893
1894/* The F3 and F4 features of the Voronoi node have been removed.
1895 * To correct this, we set the feature type to be F2 if it is F3
1896 * or F4. The SHD_VORONOI_F3 and SHD_VORONOI_F4 enum values were
1897 * 2 and 3 respectively.
1898 */
1900{
1901 for (bNode &node : ntree->nodes) {
1902 if (node.type_legacy == SH_NODE_TEX_VORONOI && node.storage) {
1903 NodeTexVoronoi *tex = static_cast<NodeTexVoronoi *>(node.storage);
1904 if (ELEM(tex->feature, 2, 3)) {
1905 tex->feature = SHD_VORONOI_F2;
1906 }
1907 }
1908 }
1909}
1910
1911/* The `Fac` output of the Voronoi node has been removed. Previously, this
1912 * output was the voronoi distance in the Intensity mode and the Cell ID
1913 * in the Cell mode. To correct this, we update the identifier and name
1914 * of the `Fac` socket such that it gets mapped to the Distance socket.
1915 * This is supposed to work with update_voronoi_node_coloring.
1916 */
1918{
1919 for (bNode &node : ntree->nodes) {
1920 if (node.type_legacy == SH_NODE_TEX_VORONOI) {
1921 bNodeSocket *facOutput = static_cast<bNodeSocket *>(BLI_findlink(&node.outputs, 1));
1922 version_node_socket_identifier_set(*facOutput, "Distance");
1923 STRNCPY_UTF8(facOutput->name, "Distance");
1924 }
1925 }
1926}
1927
1928/* The Crackle feature of the Voronoi node has been removed. Previously,
1929 * this feature returned the F2 distance minus the F1 distance. The
1930 * crackle feature had an enum value of 4. To fix this we do the
1931 * following:
1932 *
1933 * 1. The node feature is set to F1.
1934 * 2. A new Voronoi node is added and its feature is set to F2.
1935 * 3. The properties, input values, and connections are copied
1936 * from the node to the new Voronoi node so that they match
1937 * exactly.
1938 * 4. A Subtract node is added.
1939 * 5. The outputs of the F1 and F2 voronoi are connected to
1940 * the inputs of the subtract node.
1941 * 6. The output of the subtract node is connected to the
1942 * appropriate sockets.
1943 */
1945{
1946 bool need_update = false;
1947
1948 for (bNode &node : ntree->nodes) {
1949 if (node.type_legacy == SH_NODE_TEX_VORONOI && node.storage) {
1950 NodeTexVoronoi *tex = static_cast<NodeTexVoronoi *>(node.storage);
1951 bNodeSocket *sockDistance = bke::node_find_socket(node, SOCK_OUT, "Distance"_ustr);
1952 bNodeSocket *sockColor = bke::node_find_socket(node, SOCK_OUT, "Color"_ustr);
1953 if (tex->feature == 4 &&
1954 (version_node_socket_is_used(sockDistance) || version_node_socket_is_used(sockColor)))
1955 {
1956 tex->feature = SHD_VORONOI_F1;
1957
1958 bNode *voronoiNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_TEX_VORONOI);
1959 NodeTexVoronoi *texVoronoi = static_cast<NodeTexVoronoi *>(voronoiNode->storage);
1960 texVoronoi->feature = SHD_VORONOI_F2;
1961 texVoronoi->distance = tex->distance;
1962 texVoronoi->dimensions = 3;
1963 voronoiNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
1964 voronoiNode->locy_legacy = node.locy_legacy;
1965
1966 bNodeSocket *sockVector = bke::node_find_socket(node, SOCK_IN, "Vector"_ustr);
1967 bNodeSocket *sockScale = bke::node_find_socket(node, SOCK_IN, "Scale"_ustr);
1968 bNodeSocket *sockExponent = bke::node_find_socket(node, SOCK_IN, "Exponent"_ustr);
1969 bNodeSocket *sockVoronoiVector = bke::node_find_socket(
1970 *voronoiNode, SOCK_IN, "Vector"_ustr);
1971 bNodeSocket *sockVoronoiScale = bke::node_find_socket(*voronoiNode, SOCK_IN, "Scale"_ustr);
1972 bNodeSocket *sockVoronoiExponent = bke::node_find_socket(
1973 *voronoiNode, SOCK_IN, "Exponent"_ustr);
1974 if (sockVector->link) {
1975 bke::node_add_link(*ntree,
1976 *sockVector->link->fromnode,
1977 *sockVector->link->fromsock,
1978 *voronoiNode,
1979 *sockVoronoiVector);
1980 }
1982 sockVoronoiScale) = *version_cycles_node_socket_float_value(sockScale);
1983 if (sockScale->link) {
1984 bke::node_add_link(*ntree,
1985 *sockScale->link->fromnode,
1986 *sockScale->link->fromsock,
1987 *voronoiNode,
1988 *sockVoronoiScale);
1989 }
1991 sockVoronoiExponent) = *version_cycles_node_socket_float_value(sockExponent);
1992 if (sockExponent->link) {
1993 bke::node_add_link(*ntree,
1994 *sockExponent->link->fromnode,
1995 *sockExponent->link->fromsock,
1996 *voronoiNode,
1997 *sockVoronoiExponent);
1998 }
1999
2000 bNode *subtractNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
2001 subtractNode->custom1 = NODE_MATH_SUBTRACT;
2002 subtractNode->locx_legacy = voronoiNode->locx_legacy + voronoiNode->width + 20.0f;
2003 subtractNode->locy_legacy = voronoiNode->locy_legacy;
2004 bNodeSocket *sockSubtractOutValue = bke::node_find_socket(
2005 *subtractNode, SOCK_OUT, "Value"_ustr);
2006
2007 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
2008 if (link.fromnode == &node) {
2010 *ntree, *subtractNode, *sockSubtractOutValue, *link.tonode, *link.tosock);
2011 bke::node_remove_link(ntree, link);
2012 }
2013 }
2014
2015 bNodeSocket *sockDistanceF1 = bke::node_find_socket(node, SOCK_OUT, "Distance"_ustr);
2016 bNodeSocket *sockDistanceF2 = bke::node_find_socket(
2017 *voronoiNode, SOCK_OUT, "Distance"_ustr);
2018 bNodeSocket *sockSubtractA = static_cast<bNodeSocket *>(
2019 BLI_findlink(&subtractNode->inputs, 0));
2020 bNodeSocket *sockSubtractB = static_cast<bNodeSocket *>(
2021 BLI_findlink(&subtractNode->inputs, 1));
2022
2023 bke::node_add_link(*ntree, node, *sockDistanceF1, *subtractNode, *sockSubtractB);
2024 bke::node_add_link(*ntree, *voronoiNode, *sockDistanceF2, *subtractNode, *sockSubtractA);
2025
2026 need_update = true;
2027 }
2028 }
2029 }
2030
2031 if (need_update) {
2033 }
2034}
2035
2045{
2046 bool need_update = false;
2047
2048 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
2049 bNode *node = link.fromnode;
2050 if (node && node->type_legacy == SH_NODE_TEX_VORONOI && node->storage) {
2051 NodeTexVoronoi *tex = static_cast<NodeTexVoronoi *>(node->storage);
2052 if (tex->coloring == 0) {
2053 bNodeSocket *sockColor = bke::node_find_socket(*node, SOCK_OUT, "Color"_ustr);
2054 if (link.fromsock == sockColor) {
2055 bNodeSocket *sockDistance = bke::node_find_socket(*node, SOCK_OUT, "Distance"_ustr);
2056 bke::node_add_link(*ntree, *node, *sockDistance, *link.tonode, *link.tosock);
2057 bke::node_remove_link(ntree, link);
2058 need_update = true;
2059 }
2060 }
2061 else {
2062 bNodeSocket *sockDistance = bke::node_find_socket(*node, SOCK_OUT, "Distance"_ustr);
2063 if (link.fromsock == sockDistance) {
2064 bNodeSocket *sockColor = bke::node_find_socket(*node, SOCK_OUT, "Color"_ustr);
2065 bke::node_add_link(*ntree, *node, *sockColor, *link.tonode, *link.tosock);
2066 bke::node_remove_link(ntree, link);
2067 need_update = true;
2068 }
2069 }
2070 }
2071 }
2072
2073 if (need_update) {
2075 }
2076}
2077
2078/* Previously, the output euclidean distance was actually the squared
2079 * euclidean distance. To fix this, we square the output distance
2080 * socket if the distance metric is set to SHD_VORONOI_EUCLIDEAN.
2081 */
2083{
2084 bool need_update = false;
2085
2086 for (bNode &node : ntree->nodes) {
2087 if (node.type_legacy == SH_NODE_TEX_VORONOI && node.storage) {
2088 NodeTexVoronoi *tex = static_cast<NodeTexVoronoi *>(node.storage);
2089 bNodeSocket *sockDistance = bke::node_find_socket(node, SOCK_OUT, "Distance"_ustr);
2090 if (tex->distance == SHD_VORONOI_EUCLIDEAN &&
2092 version_node_socket_is_used(sockDistance))
2093 {
2094 bNode *multiplyNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
2095 multiplyNode->custom1 = NODE_MATH_MULTIPLY;
2096 multiplyNode->locx_legacy = node.locx_legacy + node.width + 20.0f;
2097 multiplyNode->locy_legacy = node.locy_legacy;
2098
2099 bNodeSocket *sockValue = bke::node_find_socket(*multiplyNode, SOCK_OUT, "Value"_ustr);
2100 for (bNodeLink &link : ntree->links.items_reversed_mutable()) {
2101 if (link.fromsock == sockDistance) {
2102 bke::node_add_link(*ntree, *multiplyNode, *sockValue, *link.tonode, *link.tosock);
2103 bke::node_remove_link(ntree, link);
2104 }
2105 }
2106
2107 bNodeSocket *sockMultiplyA = static_cast<bNodeSocket *>(
2108 BLI_findlink(&multiplyNode->inputs, 0));
2109 bNodeSocket *sockMultiplyB = static_cast<bNodeSocket *>(
2110 BLI_findlink(&multiplyNode->inputs, 1));
2111
2112 bke::node_add_link(*ntree, node, *sockDistance, *multiplyNode, *sockMultiplyA);
2113 bke::node_add_link(*ntree, node, *sockDistance, *multiplyNode, *sockMultiplyB);
2114
2115 need_update = true;
2116 }
2117 }
2118 }
2119
2120 if (need_update) {
2122 }
2123}
2124
2131{
2132 bool need_update = false;
2133
2134 for (bNode &node : ntree->nodes) {
2135 if (ELEM(node.type_legacy, SH_NODE_TEX_NOISE, SH_NODE_TEX_WAVE)) {
2136
2137 bNodeSocket *sockDistortion = bke::node_find_socket(node, SOCK_IN, "Distortion"_ustr);
2138 float *distortion = version_cycles_node_socket_float_value(sockDistortion);
2139
2140 if (version_node_socket_is_used(sockDistortion) && sockDistortion->link != nullptr) {
2141 bNode *distortionInputNode = sockDistortion->link->fromnode;
2142 bNodeSocket *distortionInputSock = sockDistortion->link->fromsock;
2143
2144 bNode *mulNode = bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
2145 mulNode->custom1 = NODE_MATH_MULTIPLY;
2146 mulNode->locx_legacy = node.locx_legacy;
2147 mulNode->locy_legacy = node.locy_legacy - 240.0f;
2148 mulNode->flag |= NODE_COLLAPSED;
2149 bNodeSocket *mulSockA = static_cast<bNodeSocket *>(BLI_findlink(&mulNode->inputs, 0));
2150 bNodeSocket *mulSockB = static_cast<bNodeSocket *>(BLI_findlink(&mulNode->inputs, 1));
2152 bNodeSocket *mulSockOut = bke::node_find_socket(*mulNode, SOCK_OUT, "Value"_ustr);
2153
2154 bke::node_remove_link(ntree, *sockDistortion->link);
2156 *ntree, *distortionInputNode, *distortionInputSock, *mulNode, *mulSockA);
2157 bke::node_add_link(*ntree, *mulNode, *mulSockOut, node, *sockDistortion);
2158
2159 need_update = true;
2160 }
2161 else if (*distortion != 0.0f) {
2162 *distortion = *distortion * 0.5f;
2163 }
2164 }
2165 }
2166
2167 if (need_update) {
2169 }
2170}
2171
2183{
2184 for (bNode &node : ntree->nodes) {
2185 if (node.type_legacy == SH_NODE_TEX_WAVE) {
2187 NodeTexWave *tex = static_cast<NodeTexWave *>(node.storage);
2190
2191 if (tex->wave_profile == SHD_WAVE_PROFILE_SIN) {
2192 bNodeSocket *sockPhaseOffset = bke::node_find_socket(node, SOCK_IN, "Phase Offset"_ustr);
2194 }
2195 }
2196 }
2197 }
2198}
2199
2201{
2202 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0)) {
2203 /* Convert group layer visibility flags to hidden nested collection. */
2204 for (Collection &collection : bmain->collections) {
2205 /* Add fake user for all existing groups. */
2206 id_fake_user_set(&collection.id);
2207
2209 continue;
2210 }
2211
2212 Collection *hidden_collection_array[20] = {nullptr};
2213 for (CollectionObject *cob = collection.gobject.first(), *cob_next = nullptr; cob;
2214 cob = cob_next)
2215 {
2216 cob_next = cob->next;
2217 Object *ob = cob->ob;
2218
2219 if (!(ob->lay & collection.layer)) {
2220 /* Find or create hidden collection matching object's first layer. */
2221 Collection **collection_hidden = nullptr;
2222 int coll_idx = 0;
2223 for (; coll_idx < 20; coll_idx++) {
2224 if (ob->lay & (1 << coll_idx)) {
2225 collection_hidden = &hidden_collection_array[coll_idx];
2226 break;
2227 }
2228 }
2229 if (collection_hidden == nullptr) {
2230 /* This should never happen (objects are always supposed to be instantiated in a
2231 * scene), but it does sometimes, see e.g. #81168.
2232 * Just put them in first hidden collection in those cases. */
2233 collection_hidden = &hidden_collection_array[0];
2234 }
2235
2236 if (*collection_hidden == nullptr) {
2237 char name[MAX_ID_NAME];
2238 SNPRINTF_UTF8(name, DATA_("Hidden %d"), coll_idx + 1);
2239 *collection_hidden = BKE_collection_add(bmain, &collection, name);
2240 (*collection_hidden)->flag |= COLLECTION_HIDE_VIEWPORT | COLLECTION_HIDE_RENDER;
2241 }
2242
2243 BKE_collection_object_add_notest(bmain, *collection_hidden, ob);
2244 BKE_collection_object_remove(bmain, &collection, ob, true);
2245 }
2246 }
2247 }
2248
2249 /* We need to assign lib pointer to generated hidden collections *after* all have been
2250 * created, otherwise we'll end up with several data-blocks sharing same name/library,
2251 * which is FORBIDDEN! NOTE: we need this to be recursive, since a child collection may be
2252 * sorted before its parent in bmain. */
2253 for (Collection &collection : bmain->collections) {
2255 }
2256
2257 /* Convert layers to collections. */
2258 for (Scene &scene : bmain->scenes) {
2259 do_version_layers_to_collections(bmain, &scene);
2260 }
2261 }
2262
2263 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0)) {
2264 for (bScreen &screen : bmain->screens) {
2265 BLO_read_assert_message(screen.scene == nullptr,
2266 ,
2267 (BlendHandle *)fd,
2268 bmain,
2269 "No Screen data-block should ever have a nullptr `scene` pointer");
2270
2271 /* same render-layer as do_version_workspaces_after_lib_link will activate,
2272 * so same layer as BKE_view_layer_default_view would return */
2273 ViewLayer *layer = screen.scene->view_layers.first();
2274
2275 for (ScrArea &area : screen.areabase) {
2276 for (SpaceLink &space : area.spacedata) {
2277 if (space.spacetype == SPACE_OUTLINER) {
2278 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&space);
2279
2280 space_outliner->outlinevis = SO_VIEW_LAYER;
2281
2282 if (layer->layer_collections.is_single()) {
2283 if (space_outliner->treestore == nullptr) {
2284 space_outliner->treestore = BLI_mempool_create(
2285 sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
2286 }
2287
2288 /* Create a tree store element for the collection. This is normally
2289 * done in check_persistent `outliner_tree.cc`, but we need to access
2290 * it here :/ (expand element if it's the only one) */
2291 TreeStoreElem *tselem = static_cast<TreeStoreElem *>(
2292 BLI_mempool_calloc(space_outliner->treestore));
2293 tselem->type = TSE_LAYER_COLLECTION;
2294 tselem->id = &(layer->layer_collections.first())->collection->id;
2295 tselem->nr = tselem->used = 0;
2296 tselem->flag &= ~TSE_CLOSED;
2297 }
2298 }
2299 }
2300 }
2301 }
2302 }
2303
2304 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0)) {
2305 for (bScreen &screen : bmain->screens) {
2306 for (ScrArea &area : screen.areabase) {
2307 for (SpaceLink &space : area.spacedata) {
2308 if (space.spacetype == SPACE_IMAGE) {
2309 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&space);
2310 if ((sima) && (sima->gpd)) {
2311 sima->gpd->flag |= GP_DATA_ANNOTATIONS;
2313 }
2314 }
2315 if (space.spacetype == SPACE_CLIP) {
2316 SpaceClip *spclip = reinterpret_cast<SpaceClip *>(&space);
2317 MovieClip *clip = spclip->clip;
2318 if ((clip) && (clip->gpd)) {
2319 clip->gpd->flag |= GP_DATA_ANNOTATIONS;
2321 }
2322 }
2323 }
2324 }
2325 }
2326 }
2327
2328 /* New workspace design. */
2329 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 1)) {
2331 }
2332
2333 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 2)) {
2334 /* Cleanup any remaining SceneRenderLayer data for files that were created
2335 * with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */
2336 for (Scene &scene : bmain->scenes) {
2337 for (SceneRenderLayer &srl : scene.r.layers) {
2338 if (srl.prop) {
2339 IDP_FreeProperty(srl.prop);
2340 }
2341 BKE_freestyle_config_free(&srl.freestyleConfig, true);
2342 }
2343 scene.r.layers.free_no_destruct();
2344 }
2345 }
2346
2347 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 3)) {
2348 /* Due to several changes to particle RNA and draw code particles from older files may
2349 * no longer be visible.
2350 * Here we correct this by setting a default draw size for those files. */
2351 for (Object &object : bmain->objects) {
2352 for (ParticleSystem &psys : object.particlesystem) {
2353 if (psys.part->draw_size == 0.0f) {
2354 psys.part->draw_size = 0.1f;
2355 }
2356 }
2357 }
2358 }
2359
2360 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 4)) {
2361 for (Object &object : bmain->objects) {
2362 if (object.particlesystem.first_) {
2363 object.duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
2364 for (ParticleSystem &psys : object.particlesystem) {
2365 if (psys.part->draw & PART_DRAW_EMITTER) {
2366 object.duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER;
2367 break;
2368 }
2369 }
2370 }
2371 else if (object.transflag & OB_DUPLI) {
2372 object.duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
2373 }
2374 else {
2375 object.duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT | OB_DUPLI_FLAG_RENDER;
2376 }
2377 }
2378
2379 /* Cleanup deprecated flag from particle-settings data-blocks. */
2380 for (ParticleSettings &part : bmain->particles) {
2381 part.draw &= ~PART_DRAW_EMITTER;
2382 }
2383 }
2384
2385 /* SpaceTime & SpaceLogic removal/replacing */
2386 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 9)) {
2387 const wmWindowManager *wm = bmain->wm.first();
2388 const Scene *scene = bmain->scenes.first();
2389
2390 if (wm != nullptr) {
2391 /* Action editors need a scene for creation. First, update active
2392 * screens using the active scene of the window they're displayed in.
2393 * Next, update remaining screens using first scene in main listbase. */
2394
2395 for (wmWindow &win : wm->windows) {
2397 for (ScrArea &area : screen->areabase) {
2398 if (ELEM(area.butspacetype, SPACE_TIME, SPACE_LOGIC)) {
2400
2401 /* Don't forget to unset! */
2403 }
2404 }
2405 }
2406 }
2407 if (scene != nullptr) {
2408 for (bScreen &screen : bmain->screens) {
2409 for (ScrArea &area : screen.areabase) {
2410 if (ELEM(area.butspacetype, SPACE_TIME, SPACE_LOGIC)) {
2411 /* Areas that were already handled won't be handled again */
2413
2414 /* Don't forget to unset! */
2416 }
2417 }
2418 }
2419 }
2420 }
2421
2422 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 14)) {
2423 /* This code fixes crashes when loading early 2.80 development files, due to the lack of a
2424 * master collection after removal of the versioning code handling the 'SceneCollection' data
2425 * that was part of the very early 2.80 development (commit 23835a393c).
2426 *
2427 * NOTE: This code only ensures that there is no crash, since the whole collection hierarchy
2428 * from these files remain lost, these files will still need a lot of manual work if one want
2429 * to get them working properly again. Or just open and save them with an older release of
2430 * Blender (up to 3.6 included). */
2431 for (Scene &scene : bmain->scenes) {
2432 if (scene.master_collection == nullptr) {
2434 /* #BKE_layer_collection_sync accepts missing view-layer in a scene, but not invalid ones
2435 * where the first view-layer's layer-collection would not be for the Scene's master
2436 * collection. */
2437 for (ViewLayer &view_layer : scene.view_layers) {
2438 if (LayerCollection *first_layer_collection = static_cast<LayerCollection *>(
2439 view_layer.layer_collections.first_))
2440 {
2441 first_layer_collection->collection = scene.master_collection;
2442 }
2443 }
2444 }
2445 }
2446 }
2447
2448 /* Update Curve object Shape Key data layout to include the Radius property */
2449 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 23)) {
2450 for (Curve &cu : bmain->curves) {
2451 if (!cu.key || cu.key->elemsize != sizeof(float[4])) {
2452 continue;
2453 }
2454
2455 cu.key->elemstr[0] = 3; /*KEYELEM_ELEM_SIZE_CURVE*/
2456 cu.key->elemsize = sizeof(float[3]);
2457
2458 int new_count = BKE_keyblock_curve_element_count(&cu.nurb);
2459
2460 for (KeyBlock &block : cu.key->block) {
2461 int old_count = block.totelem;
2462 void *old_data = block.data;
2463
2464 if (!old_data || old_count <= 0) {
2465 continue;
2466 }
2467
2468 block.totelem = new_count;
2469 block.data = MEM_new_array_zeroed<float[3]>(new_count, __func__);
2470
2471 float *oldptr = static_cast<float *>(old_data);
2472 float (*newptr)[3] = static_cast<float (*)[3]>(block.data);
2473
2474 for (Nurb &nu : cu.nurb) {
2475 if (nu.bezt) {
2476 BezTriple *bezt = nu.bezt;
2477
2478 for (int a = 0; a < nu.pntsu; a++, bezt++) {
2479 if ((old_count -= 3) < 0) {
2480 memcpy(newptr, bezt->vec, sizeof(float[3][3]));
2481 newptr[3][0] = bezt->tilt;
2482 }
2483 else {
2484 memcpy(newptr, oldptr, sizeof(float[3][4]));
2485 }
2486
2487 newptr[3][1] = bezt->radius;
2488
2489 oldptr += 3 * 4;
2490 newptr += 4; /*KEYELEM_ELEM_LEN_BEZTRIPLE*/
2491 }
2492 }
2493 else if (nu.bp) {
2494 BPoint *bp = nu.bp;
2495
2496 for (int a = 0; a < nu.pntsu * nu.pntsv; a++, bp++) {
2497 if (--old_count < 0) {
2498 copy_v3_v3(newptr[0], bp->vec);
2499 newptr[1][0] = bp->tilt;
2500 }
2501 else {
2502 memcpy(newptr, oldptr, sizeof(float[4]));
2503 }
2504
2505 newptr[1][1] = bp->radius;
2506
2507 oldptr += 4;
2508 newptr += 2; /*KEYELEM_ELEM_LEN_BPOINT*/
2509 }
2510 }
2511 }
2512
2513 MEM_delete_void(old_data);
2514 }
2515 }
2516 }
2517
2518 /* Move B-Bone custom handle settings from bPoseChannel to Bone. */
2519 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 25)) {
2520 for (Object &ob : bmain->objects) {
2521 /* If it is an armature from the same file. */
2522 if (ob.pose && ob.data && ob.data->lib == ob.id.lib) {
2523 bArmature *arm = id_cast<bArmature *>(ob.data);
2524 bool rebuild = false;
2525
2526 for (bPoseChannel &pchan : ob.pose->chanbase) {
2527 /* If the 2.7 flag is enabled, processing is needed. */
2528 Bone *pchan_bone = pchan.bone_get(ob);
2529 if (pchan_bone && (pchan.bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) {
2530 /* If the settings in the Bone are not set, copy. */
2531 if (pchan_bone->bbone_prev_type == BBONE_HANDLE_AUTO &&
2532 pchan_bone->bbone_next_type == BBONE_HANDLE_AUTO &&
2533 pchan_bone->bbone_prev == nullptr && pchan_bone->bbone_next == nullptr)
2534 {
2535 pchan_bone->bbone_prev_type = (pchan.bboneflag & PCHAN_BBONE_CUSTOM_START_REL) ?
2536 BBONE_HANDLE_RELATIVE :
2538 pchan_bone->bbone_next_type = (pchan.bboneflag & PCHAN_BBONE_CUSTOM_END_REL) ?
2539 BBONE_HANDLE_RELATIVE :
2541
2542 if (pchan.bbone_prev) {
2543 pchan_bone->bbone_prev = pchan.bbone_prev->bone_get(ob);
2544 }
2545 if (pchan.bbone_next) {
2546 pchan_bone->bbone_next = pchan.bbone_next->bone_get(ob);
2547 }
2548 }
2549
2550 rebuild = true;
2551 pchan.bboneflag = 0;
2552 }
2553 }
2554
2555 /* Tag pose rebuild for all objects that use this armature. */
2556 if (rebuild) {
2557 for (Object &ob2 : bmain->objects) {
2558 if (ob2.pose && ob2.data == id_cast<ID *>(arm)) {
2559 ob2.pose->flag |= POSE_RECALC;
2560 }
2561 }
2562 }
2563 }
2564 }
2565 }
2566
2567 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 30)) {
2568 for (Brush &brush : bmain->brushes) {
2569 if (brush.gpencil_settings != nullptr) {
2570 brush.gpencil_brush_type = eBrushGPaintType(brush.gpencil_settings->brush_type);
2571 }
2572 }
2573 }
2574
2575 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 38)) {
2576 /* Ensure we get valid rigidbody object/constraint data in relevant collections' objects.
2577 */
2578 for (Scene &scene : bmain->scenes) {
2579 RigidBodyWorld *rbw = scene.rigidbody_world;
2580
2581 if (rbw == nullptr) {
2582 continue;
2583 }
2584
2587 }
2588 }
2589
2590 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 69)) {
2591 /* Unify DOF settings (EEVEE part only) */
2592 constexpr eSceneEEVEE_Flag SCE_EEVEE_DOF_ENABLED_V = eSceneEEVEE_Flag(1 << 7);
2593 for (Scene &scene : bmain->scenes) {
2594 if (STREQ(scene.r.engine, RE_engine_id_BLENDER_EEVEE)) {
2595 if (scene.eevee.flag & SCE_EEVEE_DOF_ENABLED_V) {
2596 Object *cam_ob = scene.camera;
2597 if (cam_ob && cam_ob->type == OB_CAMERA) {
2598 Camera *cam = id_cast<Camera *>(cam_ob->data);
2599 cam->dof.flag |= CAM_DOF_ENABLED;
2600 }
2601 }
2602 }
2603 }
2604
2605 for (Camera &camera : bmain->cameras) {
2606 camera.dof.focus_object = camera.dof_ob;
2607 camera.dof.focus_distance = camera.dof_distance;
2608 camera.dof.aperture_fstop = camera.gpu_dof.fstop;
2609 camera.dof.aperture_rotation = camera.gpu_dof.rotation;
2610 camera.dof.aperture_ratio = camera.gpu_dof.ratio;
2611 camera.dof.aperture_blades = camera.gpu_dof.num_blades;
2612 camera.dof_ob = nullptr;
2613 }
2614 }
2615
2616 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 66)) {
2617 /* Shader node tree changes. After lib linking so we have all the type-info
2618 * pointers and updated sockets and we can use the high level node API to
2619 * manipulate nodes. */
2620 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2621 if (ntree->type != NTREE_SHADER) {
2622 continue;
2623 }
2624
2625 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 273, 5)) {
2626 /* Euler order was ZYX in previous versions. */
2627 for (bNode &node : ntree->nodes) {
2629 }
2630 }
2631
2632 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 276, 6)) {
2633 for (bNode &node : ntree->nodes) {
2635 }
2636 }
2637
2638 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 279, 2) ||
2639 (MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_FILE_ATLEAST(bmain, 280, 4)))
2640 {
2642 }
2643
2644 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 279, 3)) {
2645 for (bNode &node : ntree->nodes) {
2647 }
2648 }
2649
2650 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 279, 4) ||
2651 (MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_FILE_ATLEAST(bmain, 280, 5)))
2652 {
2653 /* Switch to squared roughness convention */
2655 }
2656
2657 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 279, 5)) {
2659 }
2660
2661 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 66)) {
2662 for (bNode &node : ntree->nodes) {
2664 }
2665 }
2666 }
2668 }
2669
2670 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 64)) {
2671 /* Unify Cycles and Eevee settings. */
2672 Scene *scene = bmain->scenes.first();
2673 const char *engine = (scene) ? scene->r.engine : "CYCLES";
2674
2675 for (Light &light : bmain->lights) {
2676 light_emission_unify(&light, engine);
2677 }
2678 }
2679
2680 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 69)) {
2681 /* Unify Cycles and Eevee depth of field. */
2682 Scene *scene = bmain->scenes.first();
2683 const char *engine = (scene) ? scene->r.engine : "CYCLES";
2684
2685 if (STREQ(engine, RE_engine_id_CYCLES)) {
2686 for (Camera &camera : bmain->cameras) {
2687 IDProperty *ccamera = version_cycles_properties_from_ID(&camera.id);
2688 if (ccamera) {
2689 const bool is_fstop = version_cycles_property_int(ccamera, "aperture_type", 0) == 1;
2690
2691 camera.dof.aperture_fstop = version_cycles_property_float(
2692 ccamera, "aperture_fstop", 5.6f);
2693 camera.dof.aperture_blades = version_cycles_property_int(ccamera, "aperture_blades", 0);
2694 camera.dof.aperture_rotation = version_cycles_property_float(
2695 ccamera, "aperture_rotation", 0.0);
2696 camera.dof.aperture_ratio = version_cycles_property_float(
2697 ccamera, "aperture_ratio", 1.0f);
2698 camera.dof.flag |= CAM_DOF_ENABLED;
2699
2700 float aperture_size = version_cycles_property_float(ccamera, "aperture_size", 0.0f);
2701
2702 if (is_fstop) {
2703 continue;
2704 }
2705 if (aperture_size > 0.0f) {
2706 if (camera.type == CAM_ORTHO) {
2707 camera.dof.aperture_fstop = 1.0f / (2.0f * aperture_size);
2708 }
2709 else {
2710 camera.dof.aperture_fstop = (camera.lens * 1e-3f) / (2.0f * aperture_size);
2711 }
2712
2713 continue;
2714 }
2715 }
2716
2717 /* No depth of field, set default settings. */
2718 camera.dof.aperture_fstop = 2.8f;
2719 camera.dof.aperture_blades = 0;
2720 camera.dof.aperture_rotation = 0.0f;
2721 camera.dof.aperture_ratio = 1.0f;
2722 camera.dof.flag &= ~CAM_DOF_ENABLED;
2723 }
2724 }
2725 }
2726
2727 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 2)) {
2728 /* Replace Multiply and Additive blend mode by Alpha Blend
2729 * now that we use dual-source blending. */
2730 /* We take care of doing only node-trees that are always part of materials
2731 * with old blending modes. */
2732 constexpr eMaterial_BlendMethod MA_BM_ADD = eMaterial_BlendMethod(1);
2733 constexpr eMaterial_BlendMethod MA_BM_MULTIPLY = eMaterial_BlendMethod(2);
2734 for (Material &ma : bmain->materials) {
2735 bNodeTree *ntree = ma.nodetree;
2736 if (ma.blend_method == MA_BM_ADD) {
2737 if (ma.use_nodes) {
2739 }
2740 ma.blend_method = MA_BM_BLEND;
2741 }
2742 else if (ma.blend_method == MA_BM_MULTIPLY) {
2743 if (ma.use_nodes) {
2745 }
2746 ma.blend_method = MA_BM_BLEND;
2747 }
2748 }
2749
2750 /* Update all ruler layers to set new flag. */
2751 for (Scene &scene : bmain->scenes) {
2752 bGPdata *gpd = scene.gpd;
2753 if (gpd == nullptr) {
2754 continue;
2755 }
2756 for (bGPDlayer &gpl : gpd->layers) {
2757 if (STREQ(gpl.info, "RulerData3D")) {
2758 gpl.flag |= GP_LAYER_IS_RULER;
2759 break;
2760 }
2761 }
2762 }
2763
2764 /* This versioning could probably be done only on earlier versions, not sure however
2765 * which exact version fully deprecated tessfaces, so think we can keep that one here, no
2766 * harm to be expected anyway for being over-conservative. */
2767 for (Mesh &me : bmain->meshes) {
2768 /* Check if we need to convert mfaces to polys. */
2769 if (me.totface_legacy && !me.faces_num) {
2770 /* temporarily switch main so that reading from
2771 * external CustomData works */
2772 Main *orig_gmain = BKE_blender_globals_main_swap(bmain);
2773
2775
2776 Main *tmp_gmain = BKE_blender_globals_main_swap(orig_gmain);
2777 BLI_assert(tmp_gmain == bmain);
2778 UNUSED_VARS_NDEBUG(tmp_gmain);
2779 }
2780
2781 /* Deprecated, only kept for conversion. */
2783 }
2784 }
2785
2786 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 2)) {
2787 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2788 if (ntree->type == NTREE_SHADER) {
2790 }
2791 }
2793 }
2794
2795 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 3)) {
2796 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2797 if (ntree->type == NTREE_SHADER) {
2803 }
2804 }
2806 }
2807
2808 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 7)) {
2809 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2810 if (ntree->type == NTREE_SHADER) {
2812 }
2813 }
2815 }
2816
2817 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 8)) {
2818 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2819 if (ntree->type == NTREE_SHADER) {
2821 }
2822 }
2824 }
2825
2826 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 10)) {
2827 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2828 if (ntree->type == NTREE_SHADER) {
2830 }
2831 }
2833 }
2834
2835 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 11)) {
2836 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2837 if (ntree->type == NTREE_SHADER) {
2842 }
2843 }
2845 }
2846
2847 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 282, 2)) {
2848 /* Init all Vertex/Sculpt and Weight Paint brushes. */
2849 Material *ma;
2850 /* Pen Soft brush. */
2851 do_versions_rename_id(bmain, ID_BR, "Draw Soft", "Pencil Soft");
2852 do_versions_rename_id(bmain, ID_BR, "Draw Pencil", "Pencil");
2853 do_versions_rename_id(bmain, ID_BR, "Draw Pen", "Pen");
2854 do_versions_rename_id(bmain, ID_BR, "Draw Ink", "Ink Pen");
2855 do_versions_rename_id(bmain, ID_BR, "Draw Noise", "Ink Pen Rough");
2856 do_versions_rename_id(bmain, ID_BR, "Draw Marker", "Marker Bold");
2857 do_versions_rename_id(bmain, ID_BR, "Draw Block", "Marker Chisel");
2858
2859 ma = static_cast<Material *>(
2860 BLI_findstring(&bmain->materials, "Black", offsetof(ID, name) + 2));
2861 if (ma && ma->gp_style) {
2862 do_versions_rename_id(bmain, ID_MA, "Black", "Solid Stroke");
2863 }
2864 ma = static_cast<Material *>(BLI_findstring(&bmain->materials, "Red", offsetof(ID, name) + 2));
2865 if (ma && ma->gp_style) {
2866 do_versions_rename_id(bmain, ID_MA, "Red", "Squares Stroke");
2867 }
2868 ma = static_cast<Material *>(
2869 BLI_findstring(&bmain->materials, "Grey", offsetof(ID, name) + 2));
2870 if (ma && ma->gp_style) {
2871 do_versions_rename_id(bmain, ID_MA, "Grey", "Solid Fill");
2872 }
2873 ma = static_cast<Material *>(
2874 BLI_findstring(&bmain->materials, "Black Dots", offsetof(ID, name) + 2));
2875 if (ma && ma->gp_style) {
2876 do_versions_rename_id(bmain, ID_MA, "Black Dots", "Dots Stroke");
2877 }
2878
2879 for (Scene &scene : bmain->scenes) {
2880 ToolSettings *ts = scene.toolsettings;
2881
2882 /* Ensure new Paint modes. */
2883 BKE_paint_ensure_from_paintmode(&scene, PaintMode::GPencil);
2884 BKE_paint_ensure_from_paintmode(&scene, PaintMode::VertexGPencil);
2885 BKE_paint_ensure_from_paintmode(&scene, PaintMode::SculptGPencil);
2886 BKE_paint_ensure_from_paintmode(&scene, PaintMode::WeightGPencil);
2887
2888 /* Enable cursor by default. */
2889 Paint *paint = &ts->gp_paint->paint;
2890 paint->flags |= PAINT_SHOW_BRUSH;
2891 }
2892 }
2893
2894 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 282, 4)) {
2895 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2896 if (ntree->type == NTREE_SHADER) {
2898 }
2899 }
2901 }
2902
2903 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 4)) {
2904 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2905 if (ntree->type == NTREE_SHADER) {
2907 }
2908 }
2910 }
2911
2912 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 8)) {
2913
2914 /* During development of Blender 2.80 the "Object.hide" property was
2915 * removed, and reintroduced in 5e968a996a53 as "Object.hide_viewport". */
2916 for (Object &ob : bmain->objects) {
2917 animrig::versioning::fcurves_id_cb(&ob.id, [&](ID * /*id*/, FCurve *fcu) {
2918 if (fcu->rna_path() != "hide") {
2919 return;
2920 }
2921
2922 fcu->rna_path_set("hide_viewport");
2923 });
2924 }
2925
2926 /* Reset all grease pencil brushes. */
2927 for (Scene &scene : bmain->scenes) {
2928 /* Ensure new Paint modes. */
2929 BKE_paint_ensure_from_paintmode(&scene, PaintMode::VertexGPencil);
2930 BKE_paint_ensure_from_paintmode(&scene, PaintMode::SculptGPencil);
2931 BKE_paint_ensure_from_paintmode(&scene, PaintMode::WeightGPencil);
2932 }
2933 }
2934
2935 /* Old forgotten versioning code. */
2936 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 300, 39)) {
2937 /* Paint Brush. This ensure that the brush paints by default. Used during the development and
2938 * patch review of the initial Sculpt Vertex Colors implementation (D5975) */
2939 for (Brush &brush : bmain->brushes) {
2940 if (brush.ob_mode & OB_MODE_SCULPT && brush.sculpt_brush_type == SCULPT_BRUSH_TYPE_PAINT) {
2941 brush.tip_roundness = 1.0f;
2942 brush.flow = 1.0f;
2943 brush.density = 1.0f;
2944 brush.tip_scale_x = 1.0f;
2945 }
2946 }
2947
2948 /* Pose Brush with support for loose parts. */
2949 for (Brush &brush : bmain->brushes) {
2950 if (brush.sculpt_brush_type == SCULPT_BRUSH_TYPE_POSE &&
2951 brush.disconnected_distance_max == 0.0f)
2952 {
2953 brush.flag2 |= BRUSH_USE_CONNECTED_ONLY;
2954 brush.disconnected_distance_max = 0.1f;
2955 }
2956 }
2957
2958 /* 2.8x dropped support for non-empty dupli instances. but proper do-versioning was never
2959 * done correctly. So added here as a 'safe' place version wise, always better than in
2960 * readfile lib-linking code! */
2961 for (Object &ob : bmain->objects) {
2962 if (ob.type != OB_EMPTY && ob.instance_collection != nullptr) {
2963 BLO_reportf_wrap(fd->reports,
2964 RPT_INFO,
2965 RPT_("Non-Empty object '%s' cannot duplicate collection '%s' "
2966 "anymore in Blender 2.80 and later, removed instancing"),
2967 ob.id.name + 2,
2968 ob.instance_collection->id.name + 2);
2969 ob.instance_collection = nullptr;
2970 ob.transflag &= ~OB_DUPLICOLLECTION;
2971 }
2972 }
2973 }
2974
2981}
2982
2983/* NOTE: This version patch is intended for versions < 2.52.2,
2984 * but was initially introduced in 2.27 already.
2985 * But in 2.79 another case generating non-unique names was discovered
2986 * (see #55668, involving Meta strips). */
2987static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBaseT<Strip> *seqbasep)
2988{
2989 for (Strip &strip : *seqbasep) {
2990 seq::strip_unique_name_set(sce, &sce->ed->seqbase, &strip);
2991 if (strip.seqbase.first() != nullptr) {
2992 do_versions_seq_unique_name_all_strips(sce, &strip.seqbase);
2993 }
2994 }
2995}
2996
2998{
2999 ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
3000}
3001
3002static bool strip_update_flags_cb(Strip *strip, void * /*user_data*/)
3003{
3004 strip->flag &= ~eStripFlag((1 << 6) | (1 << 18) | (1 << 19) | (1 << 21));
3005 if (strip->type == STRIP_TYPE_SPEED) {
3006 SpeedControlVars *s = static_cast<SpeedControlVars *>(strip->effectdata);
3008 }
3009 return true;
3010}
3011
3015 NTREE_DOVERSION_TRANSPARENCY_EMISSION = (1 << 1),
3016};
3018
3019/* NOLINTNEXTLINE: readability-function-size */
3020void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain)
3021{
3022 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0)) {
3023 for (Scene &scene : bmain->scenes) {
3024 scene.r.gauss = 1.5f;
3025 }
3026 }
3027
3028 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 1)) {
3029 if (!DNA_struct_member_exists(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
3030 for (Camera &ca : bmain->cameras) {
3031 ca.gpu_dof.ratio = 1.0f;
3032 }
3033 }
3034
3035 /* MTexPoly now removed. */
3036 if (DNA_struct_exists(fd->filesdna, "MTexPoly")) {
3037 for (Mesh &me : bmain->meshes) {
3038 /* If we have UVs, so this file will have MTexPoly layers too! */
3039 if (CustomData_has_layer(&me.corner_data, CD_MLOOPUV) ||
3041 {
3043 CustomData_free_layers(&me.face_data, CD_MTEXPOLY);
3044 }
3045 }
3046 }
3047 }
3048
3049 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 2)) {
3050 if (!DNA_struct_member_exists(fd->filesdna, "Light", "float", "cascade_max_dist")) {
3051 for (Light &la : bmain->lights) {
3052 la.cascade_max_dist = 1000.0f;
3053 la.cascade_count = 4;
3054 la.cascade_exponent = 0.8f;
3055 la.cascade_fade = 0.1f;
3056 }
3057 }
3058
3059 if (!DNA_struct_member_exists(fd->filesdna, "LightProbe", "float", "vis_bias")) {
3060 for (LightProbe &probe : bmain->lightprobes) {
3061 probe.vis_bias = 1.0f;
3062 probe.vis_blur = 0.2f;
3063 }
3064 }
3065
3066 /* Eevee shader nodes renamed because of the output node system.
3067 * Note that a new output node is not being added here, because it would be overkill
3068 * to handle this case in lib_verify_nodetree.
3069 *
3070 * Also, metallic node is now unified into the principled node. */
3072
3073 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3074 if (ntree->type == NTREE_SHADER) {
3075 for (bNode &node : ntree->nodes) {
3076 if (node.type_legacy == 194 /* SH_NODE_EEVEE_METALLIC */ &&
3077 STREQ(node.idname, "ShaderNodeOutputMetallic"))
3078 {
3079 STRNCPY_UTF8(node.idname, "ShaderNodeEeveeMetallic");
3081 }
3082
3083 else if (node.type_legacy == SH_NODE_EEVEE_SPECULAR &&
3084 STREQ(node.idname, "ShaderNodeOutputSpecular"))
3085 {
3086 STRNCPY_UTF8(node.idname, "ShaderNodeEeveeSpecular");
3088 }
3089
3090 else if (node.type_legacy == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ &&
3091 STREQ(node.idname, "ShaderNodeOutputEeveeMaterial"))
3092 {
3093 node.type_legacy = SH_NODE_OUTPUT_MATERIAL;
3094 STRNCPY_UTF8(node.idname, "ShaderNodeOutputMaterial");
3095 }
3096
3097 else if (node.type_legacy == 194 /* SH_NODE_EEVEE_METALLIC */ &&
3098 STREQ(node.idname, "ShaderNodeEeveeMetallic"))
3099 {
3100 node.type_legacy = SH_NODE_BSDF_PRINCIPLED;
3101 STRNCPY_UTF8(node.idname, "ShaderNodeBsdfPrincipled");
3102 node.custom1 = SHD_GLOSSY_MULTI_GGX;
3104 }
3105 }
3106 }
3107 }
3109
3111 BKE_report(fd->reports != nullptr ? fd->reports->reports : nullptr,
3112 RPT_ERROR,
3113 "EEVEE material conversion problem. Error in console");
3114 printf(
3115 "You need to connect Principled and EEVEE Specular shader nodes to new material "
3116 "output "
3117 "nodes.\n");
3118 }
3119
3121 BKE_report(fd->reports != nullptr ? fd->reports->reports : nullptr,
3122 RPT_ERROR,
3123 "EEVEE material conversion problem. Error in console");
3124 printf(
3125 "You need to combine transparency and emission shaders to the converted Principled "
3126 "shader nodes.\n");
3127 }
3128
3129 {
3130 /* Init grease pencil edit line color */
3131 if (!DNA_struct_member_exists(fd->filesdna, "bGPdata", "float", "line_color[4]")) {
3132 for (bGPdata &gpd : bmain->gpencils) {
3133 ARRAY_SET_ITEMS(gpd.line_color, 0.6f, 0.6f, 0.6f, 0.5f);
3134 }
3135 }
3136
3137 /* Init grease pencil pixel size factor */
3138 if (!DNA_struct_member_exists(fd->filesdna, "bGPdata", "float", "pixfactor")) {
3139 for (bGPdata &gpd : bmain->gpencils) {
3141 }
3142 }
3143
3144 /* Grease pencil multi-frame falloff curve. */
3145 if (!DNA_struct_member_exists(
3146 fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_falloff"))
3147 {
3148 for (Scene &scene : bmain->scenes) {
3149 /* sculpt brushes */
3151 if (gset.cur_falloff == nullptr) {
3152 gset.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
3155 &gset.cur_falloff->clipr,
3158 }
3159 }
3160 }
3161 }
3162
3163 /* 2.79 style Maintain Volume mode. */
3164 for (Object &ob : bmain->objects) {
3166 if (ob.pose) {
3167 for (bPoseChannel &pchan : ob.pose->chanbase) {
3169 }
3170 }
3171 }
3172 }
3173
3174 /* Files from this version included do get a valid `win->screen` pointer written for backward
3175 * compatibility, however this should never be used nor needed, so clear these pointers here. */
3176 if (MAIN_VERSION_FILE_ATLEAST(bmain, 280, 1)) {
3177 for (wmWindowManager &wm : bmain->wm) {
3178 for (wmWindow &win : wm.windows) {
3179 win.screen = nullptr;
3180 }
3181 }
3182 }
3183
3184 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 3)) {
3185 /* init grease pencil grids and paper */
3186 if (!DNA_struct_member_exists(
3187 fd->filesdna, "View3DOverlay", "float", "gpencil_paper_color[3]"))
3188 {
3189 for (bScreen &screen : bmain->screens) {
3190 for (ScrArea &area : screen.areabase) {
3191 for (SpaceLink &sl : area.spacedata) {
3192 if (sl.spacetype == SPACE_VIEW3D) {
3193 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3194 v3d->overlay.gpencil_paper_opacity = 0.5f;
3195 v3d->overlay.gpencil_grid_opacity = 0.9f;
3196 }
3197 }
3198 }
3199 }
3200 }
3201 }
3202
3203 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 6)) {
3204 if (DNA_struct_member_exists(fd->filesdna, "SpaceOutliner", "int", "filter") == false) {
3205 /* Update files using invalid (outdated) outlinevis Outliner values. */
3206 for (bScreen &screen : bmain->screens) {
3207 for (ScrArea &area : screen.areabase) {
3208 for (SpaceLink &sl : area.spacedata) {
3209 if (sl.spacetype == SPACE_OUTLINER) {
3210 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&sl);
3211
3212 if (!ELEM(space_outliner->outlinevis,
3213 SO_SCENES,
3218 {
3219 space_outliner->outlinevis = SO_VIEW_LAYER;
3220 }
3221 }
3222 }
3223 }
3224 }
3225 }
3226
3227 if (!DNA_struct_member_exists(fd->filesdna, "LightProbe", "float", "intensity")) {
3228 for (LightProbe &probe : bmain->lightprobes) {
3229 probe.intensity = 1.0f;
3230 }
3231 }
3232
3233 for (bScreen &screen : bmain->screens) {
3234 for (ScrArea &area : screen.areabase) {
3235 for (SpaceLink &sl : area.spacedata) {
3236 if (sl.spacetype == SPACE_VIEW3D) {
3237 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3240
3241 /* Assume (demo) files written with 2.8 want to show
3242 * Eevee renders in the viewport. */
3243 if (MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0)) {
3244 v3d->drawtype = OB_MATERIAL;
3245 }
3246 }
3247 }
3248 }
3249 }
3250 }
3251
3252 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 7)) {
3253 /* Render engine storage moved elsewhere and back during 2.8
3254 * development, we assume any files saved in 2.8 had Eevee set
3255 * as scene render engine. */
3256 if (MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0)) {
3257 for (Scene &scene : bmain->scenes) {
3259 }
3260 }
3261 }
3262
3263 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 8)) {
3264 /* Blender Internal removal */
3265 for (Scene &scene : bmain->scenes) {
3266 if (STR_ELEM(scene.r.engine, "BLENDER_RENDER", "BLENDER_GAME")) {
3268 }
3269 }
3270
3271 for (Tex &tex : bmain->textures) {
3272 /* Removed environment map, point-density, voxel-data, ocean textures. */
3273 if (ELEM(tex.type, 10, 14, 15, 16)) {
3274 tex.type = {};
3275 }
3276 }
3277 }
3278
3279 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 11)) {
3280
3281 /* Remove info editor, but only if at the top of the window. */
3282 for (bScreen &screen : bmain->screens) {
3283 /* Calculate window width/height from screen vertices */
3284 int win_width = 0, win_height = 0;
3285 for (ScrVert &vert : screen.vertbase) {
3286 win_width = std::max<int>(win_width, vert.vec.x);
3287 win_height = std::max<int>(win_height, vert.vec.y);
3288 }
3289
3290 for (ScrArea *area = screen.areabase.first(), *area_next; area; area = area_next) {
3291 area_next = static_cast<ScrArea *>(area->next);
3292
3293 if (area->spacetype == SPACE_INFO) {
3294 if ((area->v2->vec.y == win_height) && (area->v1->vec.x == 0) &&
3295 (area->v4->vec.x == win_width))
3296 {
3298
3299 BLI_remlink(&screen.areabase, area);
3300
3304
3305 MEM_delete(area);
3306 }
3307 }
3308 /* AREA_TEMP_INFO is deprecated from now on, it should only be set for info areas
3309 * which are deleted above, so don't need to unset it. Its slot/bit can be reused */
3310 }
3311 }
3312 }
3313
3314 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 11)) {
3315 for (Light &la : bmain->lights) {
3316 if (la.mode & (1 << 13)) { /* LA_SHAD_RAY */
3317 la.mode |= LA_SHADOW;
3318 la.mode &= ~eLight_Mode(1 << 13);
3319 }
3320 }
3321 }
3322
3323 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 12)) {
3324 /* Remove tool property regions. */
3325 for (bScreen &screen : bmain->screens) {
3326 for (ScrArea &area : screen.areabase) {
3327 for (SpaceLink &sl : area.spacedata) {
3329 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
3330 &sl.regionbase;
3331
3332 for (ARegion *region = regionbase->first(), *region_next; region; region = region_next)
3333 {
3334 region_next = static_cast<ARegion *>(region->next);
3335
3336 if (region->regiontype == RGN_TYPE_TOOL_PROPS) {
3337 BKE_area_region_free(nullptr, region);
3338 BLI_freelinkN(regionbase, region);
3339 }
3340 }
3341 }
3342 }
3343 }
3344 }
3345 }
3346
3347 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 13)) {
3348 /* Initialize specular factor. */
3349 if (!DNA_struct_member_exists(fd->filesdna, "Light", "float", "spec_fac")) {
3350 for (Light &la : bmain->lights) {
3351 la.spec_fac = 1.0f;
3352 }
3353 }
3354
3355 /* Initialize new view3D options. */
3356 for (bScreen &screen : bmain->screens) {
3357 for (ScrArea &area : screen.areabase) {
3358 for (SpaceLink &sl : area.spacedata) {
3359 if (sl.spacetype == SPACE_VIEW3D) {
3360 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3363 copy_v3_fl(v3d->shading.single_color, 0.8f);
3364 v3d->shading.shadow_intensity = 0.5;
3365
3366 v3d->overlay.normals_length = 0.1f;
3368 }
3369 }
3370 }
3371 }
3372 }
3373
3374 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 14)) {
3375 if (!DNA_struct_member_exists(fd->filesdna, "Scene", "SceneDisplay", "display")) {
3376 /* Initialize new scene.SceneDisplay */
3377 for (Scene &scene : bmain->scenes) {
3378 const float vector[3] = {-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3};
3379 copy_v3_v3(scene.display.light_direction, vector);
3380 }
3381 }
3382 if (!DNA_struct_member_exists(fd->filesdna, "SceneDisplay", "float", "shadow_shift")) {
3383 for (Scene &scene : bmain->scenes) {
3384 scene.display.shadow_shift = 0.1;
3385 }
3386 }
3387
3388 if (!DNA_struct_member_exists(fd->filesdna, "ToolSettings", "char", "transform_pivot_point")) {
3389 for (Scene &scene : bmain->scenes) {
3391 }
3392 }
3393
3394 if (!DNA_struct_exists(fd->filesdna, "SceneEEVEE")) {
3395 for (Scene &scene : bmain->scenes) {
3396 /* First set the default for all the properties. */
3397
3398 scene.eevee.gi_diffuse_bounces = 3;
3399 scene.eevee.gi_cubemap_resolution = 512;
3401
3402 scene.eevee.taa_samples = 16;
3403 scene.eevee.taa_render_samples = 64;
3404
3405 scene.eevee.volumetric_start = 0.1f;
3406 scene.eevee.volumetric_end = 100.0f;
3407 scene.eevee.volumetric_tile_size = 8;
3408 scene.eevee.volumetric_samples = 64;
3410 scene.eevee.volumetric_light_clamp = 0.0f;
3412
3413 scene.eevee.gtao_distance = 0.2f;
3414 scene.eevee.fast_gi_quality = 0.25f;
3415
3416 scene.eevee.bokeh_max_size = 100.0f;
3417 scene.eevee.bokeh_threshold = 1.0f;
3418
3419 scene.eevee.motion_blur_samples = 8;
3421
3423
3425
3426 /* If the file is pre-2.80 move on. */
3427 if (scene.layer_properties == nullptr) {
3428 continue;
3429 }
3430
3431 /* Now we handle eventual properties that may be set in the file. */
3432#define EEVEE_GET_BOOL(_props, _name, _flag) \
3433 { \
3434 IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
3435 if (_idprop != nullptr) { \
3436 const int _value = IDP_int_get(_idprop); \
3437 if (_value) { \
3438 scene.eevee.flag |= _flag; \
3439 } \
3440 else { \
3441 scene.eevee.flag &= ~_flag; \
3442 } \
3443 } \
3444 } \
3445 ((void)0)
3446
3447#define EEVEE_GET_INT(_props, _name) \
3448 { \
3449 IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
3450 if (_idprop != nullptr) { \
3451 scene.eevee._name = IDP_int_get(_idprop); \
3452 } \
3453 } \
3454 ((void)0)
3455
3456#define EEVEE_GET_FLOAT(_props, _name) \
3457 { \
3458 IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
3459 if (_idprop != nullptr) { \
3460 scene.eevee._name = IDP_float_get(_idprop); \
3461 } \
3462 } \
3463 ((void)0)
3464
3465#define EEVEE_GET_FLOAT_ARRAY(_props, _name, _length) \
3466 { \
3467 IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
3468 if (_idprop != nullptr) { \
3469 const float *_values = static_cast<float *>(IDP_Array(_idprop)); \
3470 for (int _i = 0; _i < _length; _i++) { \
3471 scene.eevee._name[_i] = _values[_i]; \
3472 } \
3473 } \
3474 } \
3475 ((void)0)
3476 constexpr eSceneEEVEE_Flag SCE_EEVEE_DOF_ENABLED = eSceneEEVEE_Flag(1 << 7);
3479 // EEVEE_GET_BOOL(props, volumetric_enable, SCE_EEVEE_VOLUMETRIC_ENABLED);
3480 // EEVEE_GET_BOOL(props, volumetric_lights, SCE_EEVEE_VOLUMETRIC_LIGHTS);
3481 // EEVEE_GET_BOOL(props, volumetric_shadows, SCE_EEVEE_VOLUMETRIC_SHADOWS);
3482 EEVEE_GET_BOOL(props, gtao_enable, SCE_EEVEE_GTAO_ENABLED);
3483 // EEVEE_GET_BOOL(props, gtao_use_bent_normals, SCE_EEVEE_GTAO_BENT_NORMALS);
3484 // EEVEE_GET_BOOL(props, gtao_bounce, SCE_EEVEE_GTAO_BOUNCE);
3485 EEVEE_GET_BOOL(props, dof_enable, SCE_EEVEE_DOF_ENABLED);
3486 // EEVEE_GET_BOOL(props, bloom_enable, SCE_EEVEE_BLOOM_ENABLED);
3487 EEVEE_GET_BOOL(props, motion_blur_enable, SCE_EEVEE_MOTION_BLUR_ENABLED_DEPRECATED);
3488 // EEVEE_GET_BOOL(props, shadow_high_bitdepth, SCE_EEVEE_SHADOW_HIGH_BITDEPTH);
3489 EEVEE_GET_BOOL(props, taa_reprojection, SCE_EEVEE_TAA_REPROJECTION);
3490 // EEVEE_GET_BOOL(props, sss_enable, SCE_EEVEE_SSS_ENABLED);
3491 // EEVEE_GET_BOOL(props, sss_separate_albedo, SCE_EEVEE_SSS_SEPARATE_ALBEDO);
3492 EEVEE_GET_BOOL(props, ssr_enable, SCE_EEVEE_SSR_ENABLED);
3493 // EEVEE_GET_BOOL(props, ssr_refraction, SCE_EEVEE_SSR_REFRACTION);
3494 // EEVEE_GET_BOOL(props, ssr_halfres, SCE_EEVEE_SSR_HALF_RESOLUTION);
3495
3496 EEVEE_GET_INT(props, gi_diffuse_bounces);
3497 EEVEE_GET_INT(props, gi_diffuse_bounces);
3498 EEVEE_GET_INT(props, gi_cubemap_resolution);
3499 EEVEE_GET_INT(props, gi_visibility_resolution);
3500
3501 EEVEE_GET_INT(props, taa_samples);
3502 EEVEE_GET_INT(props, taa_render_samples);
3503
3504 // EEVEE_GET_INT(props, sss_samples);
3505 // EEVEE_GET_FLOAT(props, sss_jitter_threshold);
3506
3507 // EEVEE_GET_FLOAT(props, ssr_quality);
3508 // EEVEE_GET_FLOAT(props, ssr_max_roughness);
3509 // EEVEE_GET_FLOAT(props, ssr_thickness);
3510 // EEVEE_GET_FLOAT(props, ssr_border_fade);
3511 // EEVEE_GET_FLOAT(props, ssr_firefly_fac);
3512
3513 EEVEE_GET_FLOAT(props, volumetric_start);
3514 EEVEE_GET_FLOAT(props, volumetric_end);
3515 EEVEE_GET_INT(props, volumetric_tile_size);
3516 EEVEE_GET_INT(props, volumetric_samples);
3517 EEVEE_GET_FLOAT(props, volumetric_sample_distribution);
3518 EEVEE_GET_FLOAT(props, volumetric_light_clamp);
3519 EEVEE_GET_INT(props, volumetric_shadow_samples);
3520
3521 // EEVEE_GET_FLOAT(props, gtao_distance);
3522 // EEVEE_GET_FLOAT(props, gtao_factor);
3523 EEVEE_GET_FLOAT(props, fast_gi_quality);
3524
3525 EEVEE_GET_FLOAT(props, bokeh_max_size);
3526 EEVEE_GET_FLOAT(props, bokeh_threshold);
3527
3528 // EEVEE_GET_FLOAT_ARRAY(props, bloom_color, 3);
3529 // EEVEE_GET_FLOAT(props, bloom_threshold);
3530 // EEVEE_GET_FLOAT(props, bloom_knee);
3531 // EEVEE_GET_FLOAT(props, bloom_intensity);
3532 // EEVEE_GET_FLOAT(props, bloom_radius);
3533 // EEVEE_GET_FLOAT(props, bloom_clamp);
3534
3535 EEVEE_GET_INT(props, motion_blur_samples);
3536 EEVEE_GET_FLOAT(props, motion_blur_shutter_deprecated);
3537
3538 // EEVEE_GET_INT(props, shadow_method);
3539 EEVEE_GET_INT(props, shadow_cube_size_deprecated);
3540 // EEVEE_GET_INT(props, shadow_cascade_size);
3541
3542 /* Cleanup. */
3544 scene.layer_properties = nullptr;
3545
3546#undef EEVEE_GET_FLOAT_ARRAY
3547#undef EEVEE_GET_FLOAT
3548#undef EEVEE_GET_INT
3549#undef EEVEE_GET_BOOL
3550 }
3551 }
3552
3553 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 15)) {
3554 for (Scene &scene : bmain->scenes) {
3555 scene.display.matcap_ssao_distance = 0.2f;
3556 scene.display.matcap_ssao_attenuation = 1.0f;
3557 scene.display.matcap_ssao_samples = 16;
3558 }
3559
3560 for (bScreen &screen : bmain->screens) {
3561 for (ScrArea &area : screen.areabase) {
3562 for (SpaceLink &sl : area.spacedata) {
3563 if (sl.spacetype == SPACE_OUTLINER) {
3564 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&sl);
3565 space_outliner->filter_id_type = ID_GR;
3566 space_outliner->outlinevis = SO_VIEW_LAYER;
3567 }
3568 }
3569 }
3570 }
3571
3572 for (Scene &scene : bmain->scenes) {
3573 switch (int(scene.toolsettings->snap_mode)) {
3574 case 0:
3575 scene.toolsettings->snap_mode = eSnapMode(1 << 4); /* SCE_SNAP_TO_INCREMENT */
3576 break;
3577 case 1:
3578 scene.toolsettings->snap_mode = eSnapMode(1 << 0); /* SCE_SNAP_TO_VERTEX */
3579 break;
3580 case 2:
3581 scene.toolsettings->snap_mode = eSnapMode(1 << 1); /* SCE_SNAP_TO_EDGE */
3582 break;
3583 case 3:
3584 scene.toolsettings->snap_mode = eSnapMode(1 << 2); /* SCE_SNAP_INDIVIDUAL_PROJECT */
3585 break;
3586 case 4:
3587 scene.toolsettings->snap_mode = eSnapMode(1 << 3); /* SCE_SNAP_TO_VOLUME */
3588 break;
3589 }
3590 switch (scene.toolsettings->snap_node_mode) {
3591 case 5:
3592 scene.toolsettings->snap_node_mode = (1 << 5); /* SCE_SNAP_TO_NODE_X */
3593 break;
3594 case 6:
3595 scene.toolsettings->snap_node_mode = (1 << 6); /* SCE_SNAP_TO_NODE_Y */
3596 break;
3597 case 7:
3599 (1 << 5) | (1 << 6); /* SCE_SNAP_TO_NODE_X | SCE_SNAP_TO_NODE_Y */
3600 break;
3601 case 8:
3602 scene.toolsettings->snap_node_mode = (1 << 7); /* SCE_SNAP_TO_GRID */
3603 break;
3604 }
3605 switch (int(scene.toolsettings->snap_uv_mode)) {
3606 case 0:
3607 scene.toolsettings->snap_uv_mode = eSnapMode(1 << 4); /* SCE_SNAP_TO_INCREMENT */
3608 break;
3609 case 1:
3610 scene.toolsettings->snap_uv_mode = eSnapMode(1 << 0); /* SCE_SNAP_TO_VERTEX */
3611 break;
3612 }
3613 }
3614
3615 for (ParticleSettings &part : bmain->particles) {
3617 part.shape = 0.0f;
3618 part.rad_root = 1.0f;
3619 part.rad_tip = 0.0f;
3620 part.rad_scale = 0.01f;
3621 }
3622 }
3623 }
3624
3625 /* Particle shape shared with Eevee. */
3626 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 16)) {
3627 for (ParticleSettings &part : bmain->particles) {
3629
3630 if (cpart) {
3631 part.shape = version_cycles_property_float(cpart, "shape", 0.0);
3632 part.rad_root = version_cycles_property_float(cpart, "root_width", 1.0);
3633 part.rad_tip = version_cycles_property_float(cpart, "tip_width", 0.0);
3634 part.rad_scale = version_cycles_property_float(cpart, "radius_scale", 0.01);
3635 if (version_cycles_property_boolean(cpart, "use_closetip", true)) {
3637 }
3638 }
3639 }
3640 }
3641
3642 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 18)) {
3643 if (!DNA_struct_member_exists(fd->filesdna, "Material", "float", "roughness")) {
3644 for (Material &mat : bmain->materials) {
3645 if (mat.use_nodes) {
3646 if (MAIN_VERSION_FILE_ATLEAST(bmain, 280, 0)) {
3647 mat.roughness = mat.gloss_mir;
3648 }
3649 else {
3650 mat.roughness = 0.25f;
3651 }
3652 }
3653 else {
3654 mat.roughness = 1.0f - mat.gloss_mir;
3655 }
3656 mat.metallic = mat.ray_mirror;
3657 }
3658 }
3659
3660 /* Specular highlight was introduced in 2.4x, but its default changed in 2.80. During 2.80
3661 * many viewport migrations were merged into a single subversion. Result: we always enable
3662 * specular highlights. */
3663 for (bScreen &screen : bmain->screens) {
3664 for (ScrArea &area : screen.areabase) {
3665 for (SpaceLink &sl : area.spacedata) {
3666 if (sl.spacetype == SPACE_VIEW3D) {
3667 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3669 }
3670 }
3671 }
3672 }
3673
3674 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "float", "xray_alpha")) {
3675 for (bScreen &screen : bmain->screens) {
3676 for (ScrArea &area : screen.areabase) {
3677 for (SpaceLink &sl : area.spacedata) {
3678 if (sl.spacetype == SPACE_VIEW3D) {
3679 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3680 v3d->shading.xray_alpha = 0.5f;
3681 }
3682 }
3683 }
3684 }
3685 }
3686 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "char", "matcap[256]")) {
3688 /* when loading the internal file is loaded before the matcaps */
3689 if (default_matcap) {
3690 for (bScreen &screen : bmain->screens) {
3691 for (ScrArea &area : screen.areabase) {
3692 for (SpaceLink &sl : area.spacedata) {
3693 if (sl.spacetype == SPACE_VIEW3D) {
3694 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3695 STRNCPY(v3d->shading.matcap, default_matcap->name);
3696 }
3697 }
3698 }
3699 }
3700 }
3701 }
3702 if (!DNA_struct_member_exists(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) {
3703 for (bScreen &screen : bmain->screens) {
3704 for (ScrArea &area : screen.areabase) {
3705 for (SpaceLink &sl : area.spacedata) {
3706 if (sl.spacetype == SPACE_VIEW3D) {
3707 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3708 v3d->overlay.wireframe_threshold = 0.5f;
3709 }
3710 }
3711 }
3712 }
3713 }
3714 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "float", "cavity_valley_factor"))
3715 {
3716 for (bScreen &screen : bmain->screens) {
3717 for (ScrArea &area : screen.areabase) {
3718 for (SpaceLink &sl : area.spacedata) {
3719 if (sl.spacetype == SPACE_VIEW3D) {
3720 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3721 v3d->shading.cavity_valley_factor = 1.0f;
3722 v3d->shading.cavity_ridge_factor = 1.0f;
3723 }
3724 }
3725 }
3726 }
3727 }
3728 if (!DNA_struct_member_exists(fd->filesdna, "View3DOverlay", "float", "xray_alpha_bone")) {
3729 for (bScreen &screen : bmain->screens) {
3730 for (ScrArea &area : screen.areabase) {
3731 for (SpaceLink &sl : area.spacedata) {
3732 if (sl.spacetype == SPACE_VIEW3D) {
3733 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3734 v3d->overlay.xray_alpha_bone = 0.5f;
3735 }
3736 }
3737 }
3738 }
3739 }
3740 }
3741
3742 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 19)) {
3743 if (!DNA_struct_member_exists(fd->filesdna, "Image", "ListBase", "renderslot")) {
3744 for (Image &ima : bmain->images) {
3745 if (ima.type == IMA_TYPE_R_RESULT) {
3746 for (int i = 0; i < 8; i++) {
3747 RenderSlot *slot = MEM_new<RenderSlot>("Image Render Slot Init");
3748 SNPRINTF_UTF8(slot->name, "Slot %d", i + 1);
3749 BLI_addtail(&ima.renderslots, slot);
3750 }
3751 }
3752 }
3753 }
3754 if (!DNA_struct_member_exists(fd->filesdna, "SpaceAction", "char", "mode_prev")) {
3755 for (bScreen &screen : bmain->screens) {
3756 for (ScrArea &area : screen.areabase) {
3757 for (SpaceLink &sl : area.spacedata) {
3758 if (sl.spacetype == SPACE_ACTION) {
3759 SpaceAction *saction = reinterpret_cast<SpaceAction *>(&sl);
3760 /* "Dope-sheet" should be default here,
3761 * unless it looks like the Action Editor was active instead. */
3762 if ((saction->mode_prev == 0) && (saction->action == nullptr)) {
3763 saction->mode_prev = SACTCONT_DOPESHEET;
3764 }
3765 }
3766 }
3767 }
3768 }
3769 }
3770
3771 for (bScreen &screen : bmain->screens) {
3772 for (ScrArea &area : screen.areabase) {
3773 for (SpaceLink &sl : area.spacedata) {
3774 if (sl.spacetype == SPACE_VIEW3D) {
3775 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3776 if (v3d->drawtype == OB_TEXTURE) {
3777 v3d->drawtype = OB_SOLID;
3780 }
3781 }
3782 }
3783 }
3784 }
3785 }
3786
3787 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 21)) {
3788 for (Scene &sce : bmain->scenes) {
3789 if (sce.ed != nullptr && sce.ed->seqbase.first() != nullptr) {
3791 }
3792 }
3793
3794 if (!DNA_struct_member_exists(
3795 fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity"))
3796 {
3797 for (bScreen &screen : bmain->screens) {
3798 for (ScrArea &area : screen.areabase) {
3799 for (SpaceLink &sl : area.spacedata) {
3800 if (sl.spacetype == SPACE_VIEW3D) {
3801 constexpr eView3D_Flag2 V3D_SHOW_MODE_SHADE_OVERRIDE = eView3D_Flag2(1 << 15);
3802 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3803 float alpha = (v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) ? 0.0f : 1.0f;
3807 }
3808 }
3809 }
3810 }
3811 }
3812
3813 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "char", "background_type")) {
3814 for (bScreen &screen : bmain->screens) {
3815 for (ScrArea &area : screen.areabase) {
3816 for (SpaceLink &sl : area.spacedata) {
3817 if (sl.spacetype == SPACE_VIEW3D) {
3818 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3819 copy_v3_fl(v3d->shading.background_color, 0.05f);
3820 }
3821 }
3822 }
3823 }
3824 }
3825
3826 if (!DNA_struct_member_exists(
3827 fd->filesdna, "RigidBodyWorld", "RigidBodyWorld_Shared", "*shared"))
3828 {
3829 for (Scene &scene : bmain->scenes) {
3830 RigidBodyWorld *rbw = scene.rigidbody_world;
3831
3832 if (rbw == nullptr) {
3833 continue;
3834 }
3835
3836 if (rbw->shared == nullptr) {
3837 rbw->shared = MEM_new<RigidBodyWorld_Shared>("RigidBodyWorld_Shared");
3839 }
3840
3841 /* Move shared pointers from deprecated location to current location */
3842 rbw->shared->pointcache = rbw->pointcache;
3843 rbw->shared->ptcaches = rbw->ptcaches;
3844
3845 rbw->pointcache = nullptr;
3846 rbw->ptcaches.clear_no_delete();
3847
3848 if (rbw->shared->pointcache == nullptr) {
3850 }
3851 }
3852 }
3853
3854 if (!DNA_struct_member_exists(fd->filesdna, "SoftBody", "SoftBody_Shared", "*shared")) {
3855 for (Object &ob : bmain->objects) {
3856 SoftBody *sb = ob.soft;
3857 if (sb == nullptr) {
3858 continue;
3859 }
3860 if (sb->shared == nullptr) {
3861 sb->shared = MEM_new<SoftBody_Shared>("SoftBody_Shared");
3862 }
3863
3864 /* Move shared pointers from deprecated location to current location */
3865 sb->shared->pointcache = sb->pointcache;
3866 sb->shared->ptcaches = sb->ptcaches;
3867
3868 sb->pointcache = nullptr;
3869 sb->ptcaches.clear_no_delete();
3870 }
3871 }
3872
3873 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "short", "type")) {
3874 for (bScreen &screen : bmain->screens) {
3875 for (ScrArea &area : screen.areabase) {
3876 for (SpaceLink &sl : area.spacedata) {
3877 if (sl.spacetype == SPACE_VIEW3D) {
3878 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3879 if (v3d->drawtype == OB_RENDER) {
3880 v3d->drawtype = OB_SOLID;
3881 }
3882 v3d->shading.type = eDrawType(v3d->drawtype);
3883 v3d->shading.prev_type = OB_SOLID;
3884 }
3885 }
3886 }
3887 }
3888 }
3889
3890 if (!DNA_struct_member_exists(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) {
3891 for (Scene &scene : bmain->scenes) {
3893 }
3894 }
3895 /* initialize grease pencil view data */
3896 if (!DNA_struct_member_exists(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) {
3897 for (bScreen &screen : bmain->screens) {
3898 for (ScrArea &area : screen.areabase) {
3899 for (SpaceLink &sl : area.spacedata) {
3900 if (sl.spacetype == SPACE_VIEW3D) {
3901 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3902 v3d->vertex_opacity = 1.0f;
3904 }
3905 }
3906 }
3907 }
3908 }
3909 }
3910
3911 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 22)) {
3912 if (!DNA_struct_member_exists(fd->filesdna, "ToolSettings", "char", "annotate_v3d_align")) {
3913 for (Scene &scene : bmain->scenes) {
3916 }
3917 }
3918 if (!DNA_struct_member_exists(fd->filesdna, "bGPDlayer", "short", "line_change")) {
3919 for (bGPdata &gpd : bmain->gpencils) {
3920 for (bGPDlayer &gpl : gpd.layers) {
3921 gpl.line_change = gpl.thickness;
3922 if ((gpl.thickness < 1) || (gpl.thickness > 10)) {
3923 gpl.thickness = 3;
3924 }
3925 }
3926 }
3927 }
3928 if (!DNA_struct_member_exists(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity"))
3929 {
3930 for (bScreen &screen : bmain->screens) {
3931 for (ScrArea &area : screen.areabase) {
3932 for (SpaceLink &sl : area.spacedata) {
3933 if (sl.spacetype == SPACE_VIEW3D) {
3934 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3935 v3d->overlay.gpencil_paper_opacity = 0.5f;
3936 }
3937 }
3938 }
3939 }
3940 }
3941 if (!DNA_struct_member_exists(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity"))
3942 {
3943 for (bScreen &screen : bmain->screens) {
3944 for (ScrArea &area : screen.areabase) {
3945 for (SpaceLink &sl : area.spacedata) {
3946 if (sl.spacetype == SPACE_VIEW3D) {
3947 View3D *v3d = reinterpret_cast<View3D *>(&sl);
3948 v3d->overlay.gpencil_grid_opacity = 0.5f;
3949 }
3950 }
3951 }
3952 }
3953 }
3954
3955 /* default loc axis */
3956 if (!DNA_struct_member_exists(fd->filesdna, "GP_Sculpt_Settings", "int", "lock_axis")) {
3957 for (Scene &scene : bmain->scenes) {
3958 /* lock axis */
3960 gset.lock_axis = GP_LOCKAXIS_Y;
3961 }
3962 }
3963
3964 /* Versioning code for Subsurf modifier. */
3965 if (!DNA_struct_member_exists(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) {
3966 for (Object &object : bmain->objects) {
3967 for (ModifierData &md : object.modifiers) {
3968 if (md.type == eModifierType_Subsurf) {
3969 SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData *>(&md);
3972 }
3973 else {
3975 }
3976 }
3977 }
3978 }
3979 }
3980
3981 if (!DNA_struct_member_exists(fd->filesdna, "SubsurfModifier", "short", "quality")) {
3982 for (Object &object : bmain->objects) {
3983 for (ModifierData &md : object.modifiers) {
3984 if (md.type == eModifierType_Subsurf) {
3985 SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData *>(&md);
3986 smd->quality = min_ii(smd->renderLevels, 3);
3987 }
3988 }
3989 }
3990 }
3991 /* Versioning code for Multires modifier. */
3992 if (!DNA_struct_member_exists(fd->filesdna, "MultiresModifier", "short", "quality")) {
3993 for (Object &object : bmain->objects) {
3994 for (ModifierData &md : object.modifiers) {
3995 if (md.type == eModifierType_Multires) {
3996 MultiresModifierData *mmd = reinterpret_cast<MultiresModifierData *>(&md);
3997 mmd->quality = 3;
4000 }
4001 else {
4003 }
4004 }
4005 }
4006 }
4007 }
4008
4009 if (!DNA_struct_member_exists(fd->filesdna, "ClothSimSettings", "short", "bending_model")) {
4010 for (Object &ob : bmain->objects) {
4011 for (ModifierData &md : ob.modifiers) {
4012 ClothModifierData *clmd = nullptr;
4013 if (md.type == eModifierType_Cloth) {
4014 clmd = reinterpret_cast<ClothModifierData *>(&md);
4015 }
4016 else if (md.type == eModifierType_ParticleSystem) {
4017 ParticleSystemModifierData *psmd = reinterpret_cast<ParticleSystemModifierData *>(&md);
4018 ParticleSystem *psys = psmd->psys;
4019 clmd = psys->clmd;
4020 }
4021 if (clmd != nullptr) {
4023 clmd->sim_parms->tension = clmd->sim_parms->structural;
4024 clmd->sim_parms->compression = clmd->sim_parms->structural;
4025 clmd->sim_parms->shear = clmd->sim_parms->structural;
4026 clmd->sim_parms->max_tension = clmd->sim_parms->max_struct;
4028 clmd->sim_parms->max_shear = clmd->sim_parms->max_struct;
4030 clmd->sim_parms->tension_damp = clmd->sim_parms->Cdis;
4031 clmd->sim_parms->compression_damp = clmd->sim_parms->Cdis;
4032 clmd->sim_parms->shear_damp = clmd->sim_parms->Cdis;
4033 }
4034 }
4035 }
4036 }
4037
4038 if (!DNA_struct_member_exists(fd->filesdna, "BrushGpencilSettings", "float", "era_strength_f"))
4039 {
4040 for (Brush &brush : bmain->brushes) {
4041 if (brush.gpencil_settings != nullptr) {
4042 BrushGpencilSettings *gp = brush.gpencil_settings;
4044 gp->era_strength_f = 100.0f;
4045 gp->era_thickness_f = 10.0f;
4046 }
4047 }
4048 }
4049 }
4050
4051 for (Object &ob : bmain->objects) {
4052 for (ModifierData &md : ob.modifiers) {
4053 if (md.type == eModifierType_Cloth) {
4054 ClothModifierData *clmd = reinterpret_cast<ClothModifierData *>(&md);
4055
4057 clmd->sim_parms->vgroup_mass = 0;
4058 }
4059
4061 clmd->sim_parms->vgroup_struct = 0;
4062 clmd->sim_parms->vgroup_shear = 0;
4063 clmd->sim_parms->vgroup_bend = 0;
4064 }
4065
4066 if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW)) {
4067 clmd->sim_parms->shrink_min = 0.0f;
4068 clmd->sim_parms->vgroup_shrink = 0;
4069 }
4070
4073 }
4074 }
4075 }
4076 }
4077 }
4078
4079 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 24)) {
4080 for (bScreen &screen : bmain->screens) {
4081 for (ScrArea &area : screen.areabase) {
4082 for (SpaceLink &sl : area.spacedata) {
4083 if (sl.spacetype == SPACE_VIEW3D) {
4084 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4089 }
4090 }
4091 }
4092 }
4093
4094 if (!DNA_struct_member_exists(fd->filesdna, "ShrinkwrapModifierData", "char", "shrinkMode")) {
4095 for (Object &ob : bmain->objects) {
4096 for (ModifierData &md : ob.modifiers) {
4097 if (md.type == eModifierType_Shrinkwrap) {
4098 ShrinkwrapModifierData *smd = reinterpret_cast<ShrinkwrapModifierData *>(&md);
4099 if (smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
4101 smd->shrinkOpts &= ~MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE;
4102 }
4103 }
4104 }
4105 }
4106 }
4107
4108 if (!DNA_struct_member_exists(fd->filesdna, "PartDeflect", "float", "pdef_cfrict")) {
4109 for (Object &ob : bmain->objects) {
4110 if (ob.pd) {
4111 ob.pd->pdef_cfrict = 5.0f;
4112 }
4113
4114 for (ModifierData &md : ob.modifiers) {
4115 if (md.type == eModifierType_Cloth) {
4116 ClothModifierData *clmd = reinterpret_cast<ClothModifierData *>(&md);
4117
4118 clmd->coll_parms->selfepsilon = 0.015f;
4119 }
4120 }
4121 }
4122 }
4123
4124 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) {
4125 for (bScreen &screen : bmain->screens) {
4126 for (ScrArea &area : screen.areabase) {
4127 for (SpaceLink &sl : area.spacedata) {
4128 if (sl.spacetype == SPACE_VIEW3D) {
4129 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4131 }
4132 }
4133 }
4134 }
4135 }
4136 }
4137
4138 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 25)) {
4139 for (Scene &scene : bmain->scenes) {
4140 UnitSettings *unit = &scene.unit;
4141 if (unit->system != USER_UNIT_NONE) {
4144 }
4146 }
4147
4148 /* gpencil grid settings */
4149 for (bGPdata &gpd : bmain->gpencils) {
4150 ARRAY_SET_ITEMS(gpd.grid.color, 0.5f, 0.5f, 0.5f); /* Color */
4151 ARRAY_SET_ITEMS(gpd.grid.scale, 1.0f, 1.0f); /* Scale */
4152 gpd.grid.lines = GP_DEFAULT_GRID_LINES; /* Number of lines */
4153 }
4154 }
4155
4156 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 29)) {
4157 for (bScreen &screen : bmain->screens) {
4158 for (ScrArea &area : screen.areabase) {
4159 for (SpaceLink &sl : area.spacedata) {
4160 if (sl.spacetype == SPACE_VIEW3D) {
4161 constexpr eView3D_Flag2 V3D_OCCLUDE_WIRE = eView3D_Flag2(1 << 14);
4162 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4163 if (v3d->flag2 & V3D_OCCLUDE_WIRE) {
4165 v3d->flag2 &= ~V3D_OCCLUDE_WIRE;
4166 }
4167 }
4168 }
4169 }
4170 }
4171
4172 /* Files stored pre 2.5 (possibly re-saved with newer versions) may have non-visible
4173 * spaces without a header (visible/active ones are properly versioned).
4174 * Multiple version patches below assume there's always a header though. So inserting this
4175 * patch in-between older ones to add a header when needed.
4176 *
4177 * From here on it should be fine to assume there always is a header.
4178 */
4179 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 1)) {
4180 for (bScreen &screen : bmain->screens) {
4181 for (ScrArea &area : screen.areabase) {
4182 for (SpaceLink &sl : area.spacedata) {
4183 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
4184 &sl.regionbase;
4185 ARegion *region_header = do_versions_find_region_or_null(regionbase, RGN_TYPE_HEADER);
4186
4187 if (!region_header) {
4188 /* Headers should always be first in the region list, except if there's also a
4189 * tool-header. These were only introduced in later versions though, so should be
4190 * fine to always insert headers first. */
4192
4194 "header 2.83.1 versioning");
4195 region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM :
4197 BLI_addhead(regionbase, region);
4198 }
4199 }
4200 }
4201 }
4202 }
4203
4204 for (bScreen &screen : bmain->screens) {
4205 for (ScrArea &area : screen.areabase) {
4206 for (SpaceLink &sl : area.spacedata) {
4207 if (sl.spacetype == SPACE_PROPERTIES) {
4208 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
4209 &sl.regionbase;
4210 ARegion *region = BKE_area_region_new();
4211 ARegion *region_header = nullptr;
4212
4213 for (region_header = regionbase->first(); region_header != nullptr;
4214 region_header = static_cast<ARegion *>(region_header->next))
4215 {
4216 if (region_header->regiontype == RGN_TYPE_HEADER) {
4217 break;
4218 }
4219 }
4220 BLI_assert(region_header);
4221
4222 BLI_insertlinkafter(regionbase, region_header, region);
4223
4224 region->regiontype = RGN_TYPE_NAV_BAR;
4225 region->alignment = RGN_ALIGN_LEFT;
4226 }
4227 }
4228 }
4229 }
4230
4231 /* grease pencil fade layer opacity */
4232 if (!DNA_struct_member_exists(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) {
4233 for (bScreen &screen : bmain->screens) {
4234 for (ScrArea &area : screen.areabase) {
4235 for (SpaceLink &sl : area.spacedata) {
4236 if (sl.spacetype == SPACE_VIEW3D) {
4237 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4238 v3d->overlay.gpencil_fade_layer = 0.5f;
4239 }
4240 }
4241 }
4242 }
4243 }
4244 }
4245
4246 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 30)) {
4247 /* grease pencil main material show switches */
4248 for (Material &mat : bmain->materials) {
4249 if (mat.gp_style) {
4250 mat.gp_style->flag |= GP_MATERIAL_STROKE_SHOW;
4251 mat.gp_style->flag |= GP_MATERIAL_FILL_SHOW;
4252 }
4253 }
4254 }
4255
4256 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 33)) {
4257
4258 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "float", "overscan")) {
4259 for (Scene &scene : bmain->scenes) {
4260 scene.eevee.overscan = 3.0f;
4261 }
4262 }
4263
4264 for (Light &la : bmain->lights) {
4265 /* Removed Hemi lights. */
4266 if (!ELEM(la.type, LA_LOCAL, LA_SUN, LA_SPOT, LA_AREA)) {
4267 la.type = LA_SUN;
4268 }
4269 }
4270
4271 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "float", "light_threshold")) {
4272 for (Scene &scene : bmain->scenes) {
4273 scene.eevee.light_threshold = 0.01f;
4274 }
4275 }
4276
4277 if (!DNA_struct_member_exists(fd->filesdna, "Light", "float", "att_dist")) {
4278 for (Light &la : bmain->lights) {
4279 la.att_dist = la.clipend_deprecated;
4280 }
4281 }
4282
4283 if (!DNA_struct_member_exists(fd->filesdna, "Brush", "char", "weight_brush_type")) {
4284 /* Magic defines from old files (2.7x) */
4285
4286#define PAINT_BLEND_MIX 0
4287#define PAINT_BLEND_ADD 1
4288#define PAINT_BLEND_SUB 2
4289#define PAINT_BLEND_MUL 3
4290#define PAINT_BLEND_BLUR 4
4291#define PAINT_BLEND_LIGHTEN 5
4292#define PAINT_BLEND_DARKEN 6
4293#define PAINT_BLEND_AVERAGE 7
4294#define PAINT_BLEND_SMEAR 8
4295#define PAINT_BLEND_COLORDODGE 9
4296#define PAINT_BLEND_DIFFERENCE 10
4297#define PAINT_BLEND_SCREEN 11
4298#define PAINT_BLEND_HARDLIGHT 12
4299#define PAINT_BLEND_OVERLAY 13
4300#define PAINT_BLEND_SOFTLIGHT 14
4301#define PAINT_BLEND_EXCLUSION 15
4302#define PAINT_BLEND_LUMINOSITY 16
4303#define PAINT_BLEND_SATURATION 17
4304#define PAINT_BLEND_HUE 18
4305#define PAINT_BLEND_ALPHA_SUB 19
4306#define PAINT_BLEND_ALPHA_ADD 20
4307
4308 for (Brush &brush : bmain->brushes) {
4310 const char tool_init = brush.vertex_brush_type;
4311 bool is_blend = false;
4312
4313 {
4314 char tool;
4315 switch (tool_init) {
4316 case PAINT_BLEND_MIX:
4318 break;
4319 case PAINT_BLEND_BLUR:
4321 break;
4324 break;
4325 case PAINT_BLEND_SMEAR:
4327 break;
4328 default:
4330 is_blend = true;
4331 break;
4332 }
4333 brush.vertex_brush_type = eBrushVertexPaintType(tool);
4334 }
4335
4336 if (is_blend == false) {
4337 brush.blend = IMB_BLEND_MIX;
4338 }
4339 else {
4340 short blend = IMB_BLEND_MIX;
4341 switch (tool_init) {
4342 case PAINT_BLEND_ADD:
4343 blend = IMB_BLEND_ADD;
4344 break;
4345 case PAINT_BLEND_SUB:
4346 blend = IMB_BLEND_SUB;
4347 break;
4348 case PAINT_BLEND_MUL:
4349 blend = IMB_BLEND_MUL;
4350 break;
4352 blend = IMB_BLEND_LIGHTEN;
4353 break;
4354 case PAINT_BLEND_DARKEN:
4355 blend = IMB_BLEND_DARKEN;
4356 break;
4358 blend = IMB_BLEND_COLORDODGE;
4359 break;
4361 blend = IMB_BLEND_DIFFERENCE;
4362 break;
4363 case PAINT_BLEND_SCREEN:
4364 blend = IMB_BLEND_SCREEN;
4365 break;
4367 blend = IMB_BLEND_HARDLIGHT;
4368 break;
4370 blend = IMB_BLEND_OVERLAY;
4371 break;
4373 blend = IMB_BLEND_SOFTLIGHT;
4374 break;
4376 blend = IMB_BLEND_EXCLUSION;
4377 break;
4379 blend = IMB_BLEND_LUMINOSITY;
4380 break;
4382 blend = IMB_BLEND_SATURATION;
4383 break;
4384 case PAINT_BLEND_HUE:
4385 blend = IMB_BLEND_HUE;
4386 break;
4388 blend = IMB_BLEND_ERASE_ALPHA;
4389 break;
4391 blend = IMB_BLEND_ADD_ALPHA;
4392 break;
4393 }
4394 brush.blend = blend;
4395 }
4396 }
4397 /* For now these match, in the future new items may not. */
4398 brush.weight_brush_type = eBrushWeightPaintType(int(brush.vertex_brush_type));
4399 }
4400
4401#undef PAINT_BLEND_MIX
4402#undef PAINT_BLEND_ADD
4403#undef PAINT_BLEND_SUB
4404#undef PAINT_BLEND_MUL
4405#undef PAINT_BLEND_BLUR
4406#undef PAINT_BLEND_LIGHTEN
4407#undef PAINT_BLEND_DARKEN
4408#undef PAINT_BLEND_AVERAGE
4409#undef PAINT_BLEND_SMEAR
4410#undef PAINT_BLEND_COLORDODGE
4411#undef PAINT_BLEND_DIFFERENCE
4412#undef PAINT_BLEND_SCREEN
4413#undef PAINT_BLEND_HARDLIGHT
4414#undef PAINT_BLEND_OVERLAY
4415#undef PAINT_BLEND_SOFTLIGHT
4416#undef PAINT_BLEND_EXCLUSION
4417#undef PAINT_BLEND_LUMINOSITY
4418#undef PAINT_BLEND_SATURATION
4419#undef PAINT_BLEND_HUE
4420#undef PAINT_BLEND_ALPHA_SUB
4421#undef PAINT_BLEND_ALPHA_ADD
4422 }
4423 }
4424
4425 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 34)) {
4426 for (bScreen &screen : bmain->screens) {
4427 for (ScrArea &area : screen.areabase) {
4428 for (SpaceLink &slink : area.spacedata) {
4429 if (slink.spacetype == SPACE_USERPREF) {
4430 ARegion *navigation_region = BKE_spacedata_find_region_type(
4431 &slink, &area, RGN_TYPE_NAV_BAR);
4432
4433 if (!navigation_region) {
4435 &slink, &area, RGN_TYPE_WINDOW);
4436 ListBaseT<ARegion> *regionbase = (&slink == area.spacedata.first_) ?
4437 &area.regionbase :
4438 &slink.regionbase;
4439
4440 navigation_region = BKE_area_region_new();
4441
4442 /* Order matters, addhead not addtail! */
4443 BLI_insertlinkbefore(regionbase, main_region, navigation_region);
4444
4445 navigation_region->regiontype = RGN_TYPE_NAV_BAR;
4446 navigation_region->alignment = RGN_ALIGN_LEFT;
4447 }
4448 }
4449 }
4450 }
4451 }
4452 }
4453
4454 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 36)) {
4455 if (!DNA_struct_member_exists(
4456 fd->filesdna, "View3DShading", "float", "curvature_ridge_factor"))
4457 {
4458 for (bScreen &screen : bmain->screens) {
4459 for (ScrArea &area : screen.areabase) {
4460 for (SpaceLink &sl : area.spacedata) {
4461 if (sl.spacetype == SPACE_VIEW3D) {
4462 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4463 v3d->shading.curvature_ridge_factor = 1.0f;
4464 v3d->shading.curvature_valley_factor = 1.0f;
4465 }
4466 }
4467 }
4468 }
4469 }
4470
4471 /* Rename OpenGL to Workbench. */
4472 for (Scene &scene : bmain->scenes) {
4473 if (STREQ(scene.r.engine, "BLENDER_OPENGL")) {
4475 }
4476 }
4477
4478 /* init Annotations onion skin */
4479 if (!DNA_struct_member_exists(fd->filesdna, "bGPDlayer", "int", "gstep")) {
4480 for (bGPdata &gpd : bmain->gpencils) {
4481 for (bGPDlayer &gpl : gpd.layers) {
4482 ARRAY_SET_ITEMS(gpl.gcolor_prev, 0.302f, 0.851f, 0.302f);
4483 ARRAY_SET_ITEMS(gpl.gcolor_next, 0.250f, 0.1f, 1.0f);
4484 }
4485 }
4486 }
4487
4488 /* Move studio_light selection to lookdev_light. */
4489 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) {
4490 for (bScreen &screen : bmain->screens) {
4491 for (ScrArea &area : screen.areabase) {
4492 for (SpaceLink &sl : area.spacedata) {
4493 if (sl.spacetype == SPACE_VIEW3D) {
4494 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4495 memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char[256]));
4496 }
4497 }
4498 }
4499 }
4500 }
4501
4502 /* Change Solid mode shadow orientation. */
4503 if (!DNA_struct_member_exists(fd->filesdna, "SceneDisplay", "float", "shadow_focus")) {
4504 for (Scene &scene : bmain->scenes) {
4505 float *dir = scene.display.light_direction;
4506 std::swap(dir[2], dir[1]);
4507 dir[2] = -dir[2];
4508 dir[0] = -dir[0];
4509 }
4510 }
4511 }
4512
4513 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 37)) {
4514 for (Camera &ca : bmain->cameras) {
4515 ca.drawsize *= 2.0f;
4516 }
4517
4518 /* Grease pencil primitive curve */
4519 if (!DNA_struct_member_exists(
4520 fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_primitive"))
4521 {
4522 for (Scene &scene : bmain->scenes) {
4524 if (gset.cur_primitive == nullptr) {
4525 gset.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
4528 &gset.cur_primitive->clipr,
4531 }
4532 }
4533 }
4534 }
4535
4536 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 38)) {
4537 if (DNA_struct_member_exists(fd->filesdna, "Object", "char", "empty_image_visibility_flag")) {
4538 for (Object &ob : bmain->objects) {
4542 }
4543 }
4544
4545 for (bScreen &screen : bmain->screens) {
4546 for (ScrArea &area : screen.areabase) {
4547 for (SpaceLink &sl : area.spacedata) {
4548 switch (sl.spacetype) {
4549 case SPACE_IMAGE: {
4550 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&sl);
4555 break;
4556 }
4557 case SPACE_VIEW3D: {
4558 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4563 break;
4564 }
4565 case SPACE_OUTLINER: {
4566 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&sl);
4567 space_outliner->filter &= ~(SO_FILTER_CLEARED_1 | SO_FILTER_UNUSED_5 |
4569 space_outliner->storeflag &= ~SO_TREESTORE_UNUSED_1;
4570 break;
4571 }
4572 case SPACE_FILE: {
4573 SpaceFile *sfile = reinterpret_cast<SpaceFile *>(&sl);
4574 if (sfile->params) {
4577 }
4578 break;
4579 }
4580 case SPACE_NODE: {
4581 SpaceNode *snode = reinterpret_cast<SpaceNode *>(&sl);
4583 break;
4584 }
4585 case SPACE_PROPERTIES: {
4586 SpaceProperties *sbuts = reinterpret_cast<SpaceProperties *>(&sl);
4587 sbuts->flag &= ~(SB_FLAG_UNUSED_2 | SB_FLAG_UNUSED_3);
4588 break;
4589 }
4590 case SPACE_NLA: {
4591 SpaceNla *snla = reinterpret_cast<SpaceNla *>(&sl);
4593 break;
4594 }
4595 }
4596 }
4597 }
4598 }
4599
4600 for (Scene &scene : bmain->scenes) {
4606
4609
4610 if (scene.toolsettings->sculpt) {
4613 }
4614
4615 if (scene.ed) {
4617 }
4618 }
4619
4620 for (World &world : bmain->worlds) {
4623 }
4624
4625 for (Image &image : bmain->images) {
4629 }
4630
4631 for (Object &ob : bmain->objects) {
4634 ob.shapeflag &= ~OB_SHAPE_FLAG_UNUSED_1;
4635 }
4636
4637 for (Mesh &me : bmain->meshes) {
4641 }
4642
4643 for (Material &mat : bmain->materials) {
4644 mat.blend_flag &= ~eMaterial_BlendFlag(1 << 2); /* UNUSED */
4645 }
4646 }
4647
4648 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 40)) {
4649 if (!DNA_struct_member_exists(
4650 fd->filesdna, "ToolSettings", "char", "snap_transform_mode_flag"))
4651 {
4652 for (Scene &scene : bmain->scenes) {
4654 }
4655 }
4656
4657 for (bScreen &screen : bmain->screens) {
4658 for (ScrArea &area : screen.areabase) {
4659 for (SpaceLink &sl : area.spacedata) {
4660 switch (sl.spacetype) {
4661 case SPACE_VIEW3D: {
4662 constexpr eView3D_Flag2 V3D_BACKFACE_CULLING = eView3D_Flag2(1 << 10);
4663 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4664 if (v3d->flag2 & V3D_BACKFACE_CULLING) {
4665 v3d->flag2 &= ~V3D_BACKFACE_CULLING;
4667 }
4668 break;
4669 }
4670 }
4671 }
4672 }
4673 }
4674
4675 if (!DNA_struct_exists(fd->filesdna, "TransformOrientationSlot")) {
4676 for (Scene &scene : bmain->scenes) {
4677 for (int i = 0; i < ARRAY_SIZE(scene.orientation_slots); i++) {
4678 scene.orientation_slots[i].index_custom = -1;
4679 }
4680 }
4681 }
4682
4683 /* Grease pencil cutter/select segment intersection threshold. */
4684 if (!DNA_struct_member_exists(fd->filesdna, "GP_Sculpt_Settings", "float", "isect_threshold"))
4685 {
4686 for (Scene &scene : bmain->scenes) {
4688 gset.isect_threshold = 0.1f;
4689 }
4690 }
4691
4692 /* Fix anamorphic bokeh eevee rna limits. */
4693 for (Camera &ca : bmain->cameras) {
4694 ca.gpu_dof.ratio = std::max(ca.gpu_dof.ratio, 0.01f);
4695 }
4696
4697 for (bScreen &screen : bmain->screens) {
4698 for (ScrArea &area : screen.areabase) {
4699 for (SpaceLink &sl : area.spacedata) {
4700 if (sl.spacetype == SPACE_USERPREF) {
4701 ARegion *execute_region = BKE_spacedata_find_region_type(&sl, &area, RGN_TYPE_EXECUTE);
4702
4703 if (!execute_region) {
4704 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
4705 &sl.regionbase;
4706 ARegion *region_navbar = BKE_spacedata_find_region_type(
4707 &sl, &area, RGN_TYPE_NAV_BAR);
4708
4709 execute_region = BKE_area_region_new();
4710
4711 BLI_assert(region_navbar);
4712
4713 BLI_insertlinkafter(regionbase, region_navbar, execute_region);
4714
4715 execute_region->regiontype = RGN_TYPE_EXECUTE;
4716 execute_region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
4717 execute_region->flag |= RGN_FLAG_DYNAMIC_SIZE;
4718 }
4719 }
4720 }
4721 }
4722 }
4723 }
4724
4725 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 43)) {
4726 ListBaseT<ID> *lb = which_libbase(bmain, ID_BR);
4728 }
4729
4730 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 44)) {
4731 if (!DNA_struct_member_exists(fd->filesdna, "Material", "float", "a")) {
4732 for (Material &mat : bmain->materials) {
4733 mat.a = 1.0f;
4734 }
4735 }
4736
4737 for (Scene &scene : bmain->scenes) {
4738 enum {
4739 R_ALPHAKEY = 2,
4740 };
4743 if (scene.r.alphamode == R_ALPHAKEY) {
4744 scene.r.alphamode = R_ADDSKY;
4745 }
4746 ToolSettings *ts = scene.toolsettings;
4747 ts->particle.flag &= ~PE_UNUSED_6;
4748 if (ts->sculpt != nullptr) {
4750 }
4751 }
4752 }
4753
4754 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 46)) {
4755 /* Add wireframe color. */
4756 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "char", "wire_color_type")) {
4757 for (bScreen &screen : bmain->screens) {
4758 for (ScrArea &area : screen.areabase) {
4759 for (SpaceLink &sl : area.spacedata) {
4760 if (sl.spacetype == SPACE_VIEW3D) {
4761 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4763 }
4764 }
4765 }
4766 }
4767 }
4768
4769 if (!DNA_struct_member_exists(fd->filesdna, "View3DCursor", "short", "rotation_mode")) {
4770 for (Scene &scene : bmain->scenes) {
4771 if (is_zero_v3(scene.cursor.rotation_axis)) {
4773 scene.cursor.rotation_quaternion[0] = 1.0f;
4774 scene.cursor.rotation_axis[1] = 1.0f;
4775 }
4776 }
4777 }
4778 }
4779
4780 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 47)) {
4781 for (Scene &scene : bmain->scenes) {
4783 if (pset->brushtype < 0) {
4784 pset->brushtype = PE_BRUSH_COMB;
4785 }
4786 }
4787
4788 for (Object &ob : bmain->objects) {
4789 {
4790 constexpr eObject_Partype PARCURVE_V = eObject_Partype(1);
4791 constexpr eObject_Partype PARKEY_V = eObject_Partype(2);
4792 constexpr eObject_Partype PAR_DEPRECATED_V = eObject_Partype(16);
4793 if (ELEM(ob.partype, PARCURVE_V, PARKEY_V, PAR_DEPRECATED_V)) {
4794 ob.partype = PAROBJECT;
4795 }
4796 }
4797
4798 {
4799 enum { OB_WAVE = 21, OB_LIFE = 23, OB_SECTOR = 24 };
4800 if (ELEM(int(ob.type), OB_WAVE, OB_LIFE, OB_SECTOR)) {
4801 ob.type = OB_EMPTY;
4802 }
4803 }
4804
4807
4809 }
4810
4811 for (bArmature &arm : bmain->armatures) {
4814 }
4815
4816 for (Text &text : bmain->texts) {
4817 text.flags &= ~(TXT_FLAG_UNUSED_8 | TXT_FLAG_UNUSED_9);
4818 }
4819 }
4820
4821 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 48)) {
4822 for (Scene &scene : bmain->scenes) {
4823 /* Those are not currently used, but are accessible through RNA API and were not
4824 * properly initialized previously. This is mere copy of #scene_init_data code. */
4825 if (scene.r.im_format.view_settings.look[0] == '\0') {
4828 &scene.r.im_format.view_settings, &scene.r.im_format.display_settings, "Filmic");
4829 }
4830
4831 if (scene.r.bake.im_format.view_settings.look[0] == '\0') {
4835 "Filmic");
4836 }
4837 }
4838 }
4839
4840 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 49)) {
4841 /* All tool names changed, reset to defaults. */
4842 for (WorkSpace &workspace : bmain->workspaces) {
4843 while (!workspace.tools.is_empty()) {
4844 BKE_workspace_tool_remove(&workspace, workspace.tools.first());
4845 }
4846 }
4847 }
4848
4849 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 52)) {
4850 for (ParticleSettings &part : bmain->particles) {
4851 /* Replace deprecated PART_DRAW_BB by PART_DRAW_NOT */
4852 if (part.ren_as == PART_DRAW_BB) {
4853 part.ren_as = PART_DRAW_NOT;
4854 }
4855 if (part.draw_as == PART_DRAW_BB) {
4856 part.draw_as = PART_DRAW_NOT;
4857 }
4858 }
4859
4860 if (!DNA_struct_member_exists(fd->filesdna, "TriangulateModifierData", "int", "min_vertices"))
4861 {
4862 for (Object &ob : bmain->objects) {
4863 for (ModifierData &md : ob.modifiers) {
4864 if (md.type == eModifierType_Triangulate) {
4865 TriangulateModifierData *smd = reinterpret_cast<TriangulateModifierData *>(&md);
4866 smd->min_vertices = 4;
4867 }
4868 }
4869 }
4870 }
4871
4872 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
4873 if (ntree->type == NTREE_SHADER) {
4874 for (bNode &node : ntree->nodes) {
4875 /* Fix missing version patching from earlier changes. */
4876 if (STREQ(node.idname, "ShaderNodeOutputLamp")) {
4877 STRNCPY_UTF8(node.idname, "ShaderNodeOutputLight");
4878 }
4879 if (node.type_legacy == SH_NODE_BSDF_PRINCIPLED && node.custom2 == 0) {
4880 node.custom2 = SHD_SUBSURFACE_BURLEY;
4881 }
4882 }
4883 }
4884 }
4886 }
4887
4888 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 53)) {
4889 for (Material &mat : bmain->materials) {
4890 /* Eevee: Keep material appearance consistent with previous behavior. */
4891 if (!mat.use_nodes || !mat.nodetree || mat.blend_method == MA_BM_SOLID) {
4892 mat.blend_shadow = MA_BS_SOLID;
4893 }
4894 }
4895
4896 /* grease pencil default animation channel color */
4897 {
4898 for (bGPdata &gpd : bmain->gpencils) {
4899 if (gpd.flag & GP_DATA_ANNOTATIONS) {
4900 continue;
4901 }
4902 for (bGPDlayer &gpl : gpd.layers) {
4903 /* default channel color */
4904 ARRAY_SET_ITEMS(gpl.color, 0.2f, 0.2f, 0.2f);
4905 }
4906 }
4907 }
4908 }
4909
4910 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 54)) {
4911 for (Object &ob : bmain->objects) {
4912 bool is_first_subdiv = true;
4913 for (ModifierData &md : ob.modifiers) {
4914 if (md.type == eModifierType_Subsurf) {
4915 SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData *>(&md);
4916 if (is_first_subdiv) {
4918 }
4919 else {
4921 }
4922 is_first_subdiv = false;
4923 }
4924 else if (md.type == eModifierType_Multires) {
4925 MultiresModifierData *mmd = reinterpret_cast<MultiresModifierData *>(&md);
4926 if (is_first_subdiv) {
4928 }
4929 else {
4931 }
4932 is_first_subdiv = false;
4933 }
4934 }
4935 }
4936 }
4937
4938 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 55)) {
4939 for (bScreen &screen : bmain->screens) {
4940 for (ScrArea &area : screen.areabase) {
4941 for (SpaceLink &sl : area.spacedata) {
4942 if (sl.spacetype == SPACE_TEXT) {
4943 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
4944 &sl.regionbase;
4945
4946 /* Remove multiple footers that were added by mistake. */
4948
4949 /* Add footer. */
4950 ARegion *region = do_versions_add_region(RGN_TYPE_FOOTER, "footer for text");
4952
4953 ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
4954 BLI_insertlinkafter(regionbase, region_header, region);
4955 }
4956 }
4957 }
4958 }
4959 }
4960
4961 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 56)) {
4962 for (bScreen &screen : bmain->screens) {
4963 for (ScrArea &area : screen.areabase) {
4964 for (SpaceLink &sl : area.spacedata) {
4965 if (sl.spacetype == SPACE_VIEW3D) {
4966 View3D *v3d = reinterpret_cast<View3D *>(&sl);
4972 }
4973 }
4974 }
4975 }
4976 }
4977
4978 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 57)) {
4979 /* Enable Show Interpolation in dope-sheet by default. */
4980 for (bScreen &screen : bmain->screens) {
4981 for (ScrArea &area : screen.areabase) {
4982 for (SpaceLink &sl : area.spacedata) {
4983 if (sl.spacetype == SPACE_ACTION) {
4984 SpaceAction *saction = reinterpret_cast<SpaceAction *>(&sl);
4985 if ((saction->flag & SACTION_SHOW_EXTREMES) == 0) {
4986 saction->flag |= SACTION_SHOW_INTERPOLATION;
4987 }
4988 }
4989 }
4990 }
4991 }
4992
4993 /* init grease pencil brush gradients */
4994 if (!DNA_struct_member_exists(fd->filesdna, "BrushGpencilSettings", "float", "hardness")) {
4995 for (Brush &brush : bmain->brushes) {
4996 if (brush.gpencil_settings != nullptr) {
4997 BrushGpencilSettings *gp = brush.gpencil_settings;
4998 gp->hardness = 1.0f;
4999 copy_v2_fl(gp->aspect_ratio, 1.0f);
5000 }
5001 }
5002 }
5003
5004 /* init grease pencil stroke gradients */
5005 if (!DNA_struct_member_exists(fd->filesdna, "bGPDstroke", "float", "hardness")) {
5006 for (bGPdata &gpd : bmain->gpencils) {
5007 for (bGPDlayer &gpl : gpd.layers) {
5008 for (bGPDframe &gpf : gpl.frames) {
5009 for (bGPDstroke &gps : gpf.strokes) {
5010 gps.hardness = 1.0f;
5011 copy_v2_fl(gps.aspect_ratio, 1.0f);
5012 }
5013 }
5014 }
5015 }
5016 }
5017
5018 /* enable the axis aligned ortho grid by default */
5019 for (bScreen &screen : bmain->screens) {
5020 for (ScrArea &area : screen.areabase) {
5021 for (SpaceLink &sl : area.spacedata) {
5022 if (sl.spacetype == SPACE_VIEW3D) {
5023 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5025 }
5026 }
5027 }
5028 }
5029 }
5030
5031 /* Keep un-versioned until we're finished adding space types. */
5032 {
5033 for (bScreen &screen : bmain->screens) {
5034 for (ScrArea &area : screen.areabase) {
5035 for (SpaceLink &sl : area.spacedata) {
5036 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
5037 &sl.regionbase;
5038 /* All spaces that use tools must be eventually added. */
5039 ARegion *region = nullptr;
5041 ((region = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) ==
5042 nullptr))
5043 {
5044 /* Add tool header. */
5045 region = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
5047
5048 ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
5049 BLI_insertlinkbefore(regionbase, region_header, region);
5050 /* Hide by default, enable for painting workspaces (startup only). */
5052 }
5053 if (region != nullptr) {
5055 region->flag, region->flag & RGN_FLAG_HIDDEN_BY_USER, RGN_FLAG_HIDDEN);
5056 }
5057 }
5058 }
5059 }
5060 }
5061
5062 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 60)) {
5063 if (!DNA_struct_member_exists(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) {
5064 for (Object &ob : bmain->objects) {
5065 if (ob.pose) {
5066 for (bPoseChannel &pchan : ob.pose->chanbase) {
5067 for (bConstraint &con : pchan.constraints) {
5068 if (con.type == CONSTRAINT_TYPE_SPLINEIK) {
5069 bSplineIKConstraint *data = static_cast<bSplineIKConstraint *>(con.data);
5070 if ((data->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) == 0) {
5072 }
5073 }
5074 }
5075 }
5076 }
5077 }
5078 }
5079
5080 if (!DNA_struct_member_exists(
5081 fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity"))
5082 {
5083 for (bScreen &screen : bmain->screens) {
5084 for (ScrArea &area : screen.areabase) {
5085 for (SpaceLink &sl : area.spacedata) {
5086 if (sl.spacetype == SPACE_VIEW3D) {
5087 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5088 v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
5089 }
5090 }
5091 }
5092 }
5093 }
5094 if (!DNA_struct_member_exists(fd->filesdna, "SceneDisplay", "char", "render_aa")) {
5095 for (Scene &scene : bmain->scenes) {
5098 }
5099 }
5100
5101 /* Split bbone_scalein/bbone_scaleout into x and y fields. */
5102 if (!DNA_struct_member_exists(fd->filesdna, "bPoseChannel", "float", "scale_out_z")) {
5103 /* Update armature data and pose channels. */
5104 for (bArmature &arm : bmain->armatures) {
5106 }
5107
5108 for (Object &ob : bmain->objects) {
5109 if (ob.pose) {
5110 for (bPoseChannel &pchan : ob.pose->chanbase) {
5111 pchan.scale_in_z = pchan.scale_in_x;
5112 pchan.scale_out_z = pchan.scale_out_x;
5113 }
5114 }
5115 }
5116
5117 /* Update action curves and drivers. */
5118 for (bAction &act : bmain->actions) {
5119 for (FCurve &fcu : act.curves.items_mutable()) {
5121 }
5122 }
5123
5124 BKE_animdata_main_cb(bmain, [](ID * /*id*/, AnimData *adt) {
5125 for (FCurve &fcu : adt->drivers.items_mutable()) {
5127 }
5128 });
5129 }
5130
5131 for (Scene &sce : bmain->scenes) {
5132 if (sce.ed != nullptr) {
5134 }
5135 }
5136 }
5137
5138 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 61)) {
5139 /* Added a power option to Copy Scale. */
5140 if (!DNA_struct_member_exists(fd->filesdna, "bSizeLikeConstraint", "float", "power")) {
5141 for (Object &ob : bmain->objects) {
5143 if (ob.pose) {
5144 for (bPoseChannel &pchan : ob.pose->chanbase) {
5146 }
5147 }
5148 }
5149 }
5150
5151 for (bScreen &screen : bmain->screens) {
5152 for (ScrArea &area : screen.areabase) {
5153 for (SpaceLink &sl : area.spacedata) {
5155 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
5156 &sl.regionbase;
5157
5158 ARegion *region = nullptr;
5159 if (sl.spacetype == SPACE_CLIP) {
5160 if ((reinterpret_cast<SpaceClip *>(&sl))->view == SC_VIEW_GRAPH) {
5162 }
5163 }
5164 else {
5166 }
5167
5168 if (region != nullptr) {
5169 region->v2d.scroll &= ~V2D_SCROLL_LEFT;
5170 region->v2d.scroll |= V2D_SCROLL_RIGHT;
5171 }
5172 }
5173 }
5174 }
5175 }
5176
5177 for (bScreen &screen : bmain->screens) {
5178 for (ScrArea &area : screen.areabase) {
5179 for (SpaceLink &sl : area.spacedata) {
5180 if (sl.spacetype != SPACE_OUTLINER) {
5181 continue;
5182 }
5183 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&sl);
5186 }
5187 }
5188 }
5189 }
5190
5191 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 68)) {
5192 /* Unify Cycles and Eevee film transparency. */
5193 for (Scene &scene : bmain->scenes) {
5194 if (STREQ(scene.r.engine, RE_engine_id_CYCLES)) {
5196 if (cscene) {
5197 bool cycles_film_transparency = version_cycles_property_boolean(
5198 cscene, "film_transparent", false);
5199 scene.r.alphamode = cycles_film_transparency ? R_ALPHAPREMUL : R_ADDSKY;
5200 }
5201 }
5202 }
5203 }
5204
5205 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 69)) {
5206 for (bArmature &arm : bmain->armatures) {
5208 }
5209
5210 /* Initializes sun lights with the new angular diameter property */
5211 if (!DNA_struct_member_exists(fd->filesdna, "Light", "float", "sun_angle")) {
5212 for (Light &light : bmain->lights) {
5213 light.sun_angle = 2.0f * atanf(light.area_size);
5214 }
5215 }
5216 }
5217
5218 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 70)) {
5219 /* New image alpha modes. */
5220 for (Image &image : bmain->images) {
5221 enum { IMA_IGNORE_ALPHA = (1 << 12) };
5222 if (int(image.flag) & IMA_IGNORE_ALPHA) {
5223 image.alpha_mode = IMA_ALPHA_IGNORE;
5224 image.flag &= ~eImage_Flag(IMA_IGNORE_ALPHA);
5225 }
5226 }
5227 }
5228
5229 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 71)) {
5230 /* This assumes the Blender builtin config. Depending on the OCIO
5231 * environment variable for versioning is weak, and these deprecated view
5232 * transforms and look names don't seem to exist in other commonly used
5233 * OCIO configs so .blend files created for those would be unaffected. */
5234 for (Scene &scene : bmain->scenes) {
5235 ColorManagedViewSettings *view_settings;
5236 view_settings = &scene.view_settings;
5237
5238 if (STREQ(view_settings->view_transform, "Default")) {
5239 STRNCPY_UTF8(view_settings->view_transform, "Standard");
5240 }
5241 else if (STR_ELEM(view_settings->view_transform, "RRT", "Film")) {
5242 STRNCPY_UTF8(view_settings->view_transform, "Filmic");
5243 }
5244 else if (STREQ(view_settings->view_transform, "Log")) {
5245 STRNCPY_UTF8(view_settings->view_transform, "Filmic Log");
5246 }
5247
5248 if (STREQ(view_settings->look, "Filmic - Base Contrast")) {
5249 STRNCPY_UTF8(view_settings->look, "None");
5250 }
5251 }
5252 }
5253
5254 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 74)) {
5255 for (Scene &scene : bmain->scenes) {
5256 if (scene.ed != nullptr) {
5258 }
5259 }
5260 }
5261
5262 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 280, 75)) {
5263 for (Scene &scene : bmain->scenes) {
5264 if (scene.master_collection != nullptr) {
5267 }
5268
5269 UnitSettings *unit = &scene.unit;
5270 if (unit->system == USER_UNIT_NONE) {
5271 unit->length_unit = char(USER_UNIT_ADAPTIVE);
5272 unit->mass_unit = char(USER_UNIT_ADAPTIVE);
5273 }
5274
5275 RenderData *render_data = &scene.r;
5276 switch (render_data->ffcodecdata.ffmpeg_preset) {
5277 case FFM_PRESET_ULTRAFAST:
5278 case FFM_PRESET_SUPERFAST:
5280 break;
5281 case FFM_PRESET_VERYFAST:
5282 case FFM_PRESET_FASTER:
5283 case FFM_PRESET_FAST:
5284 case FFM_PRESET_MEDIUM:
5286 break;
5287 case FFM_PRESET_SLOW:
5288 case FFM_PRESET_SLOWER:
5289 case FFM_PRESET_VERYSLOW:
5291 break;
5292 default:
5293 break;
5294 }
5295 }
5296
5297 for (bArmature &arm : bmain->armatures) {
5299 }
5300 }
5301
5302 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 1)) {
5303 for (Object &ob : bmain->objects) {
5304 for (ModifierData &md : ob.modifiers) {
5305 if (md.type == eModifierType_DataTransfer) {
5306 /* Now data-transfer's mix factor is multiplied with weights when any,
5307 * instead of being ignored,
5308 * we need to take care of that to keep 'old' files compatible. */
5309 DataTransferModifierData *dtmd = reinterpret_cast<DataTransferModifierData *>(&md);
5310 if (dtmd->defgrp_name[0] != '\0') {
5311 dtmd->mix_factor = 1.0f;
5312 }
5313 }
5314 }
5315 }
5316 }
5317
5318 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 3)) {
5319 for (bScreen &screen : bmain->screens) {
5320 for (ScrArea &area : screen.areabase) {
5321 for (SpaceLink &sl : area.spacedata) {
5322 if (sl.spacetype == SPACE_TEXT) {
5323 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
5324 &sl.regionbase;
5326 if (region) {
5327 region->alignment = RGN_ALIGN_RIGHT;
5328 }
5329 }
5330 /* Mark outliners as dirty for syncing and enable synced selection */
5331 if (sl.spacetype == SPACE_OUTLINER) {
5332 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&sl);
5334 space_outliner->flag |= SO_SYNC_SELECT;
5335 }
5336 }
5337 }
5338 }
5339 for (Mesh &mesh : bmain->meshes) {
5340 if (mesh.remesh_voxel_size == 0.0f) {
5341 mesh.remesh_voxel_size = 0.1f;
5342 }
5343 }
5344 }
5345
5346 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 3)) {
5347 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
5348 if (ntree->type == NTREE_SHADER) {
5350 }
5351 }
5353 }
5354
5355 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 4)) {
5356 ID *id;
5357 FOREACH_MAIN_ID_BEGIN (bmain, id) {
5358 bNodeTree *ntree = bke::node_tree_from_id(id);
5359 if (ntree) {
5360 ntree->id.flag |= ID_FLAG_EMBEDDED_DATA;
5361 }
5362 }
5364 }
5365
5366 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 5)) {
5367 for (Brush &br : bmain->brushes) {
5368 if (br.ob_mode & OB_MODE_SCULPT && br.normal_radius_factor == 0.0f) {
5369 br.normal_radius_factor = 0.5f;
5370 }
5371 }
5372
5373 for (Scene &scene : bmain->scenes) {
5374 /* Older files do not have a master collection, which is then added through
5375 * `BKE_collection_master_add()`, so everything is fine. */
5376 if (scene.master_collection != nullptr) {
5378 }
5379 }
5380 }
5381
5382 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 6)) {
5383 for (bScreen &screen : bmain->screens) {
5384 for (ScrArea &area : screen.areabase) {
5385 for (SpaceLink &sl : area.spacedata) {
5386 if (sl.spacetype == SPACE_VIEW3D) {
5387 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5389
5390 /* files by default don't have studio lights selected unless interacted
5391 * with the shading popover. When no studio-light could be read, we will
5392 * select the default world one. */
5395 if (studio_light != nullptr) {
5396 STRNCPY(v3d->shading.lookdev_light, studio_light->name);
5397 }
5398 }
5399 }
5400 }
5401 }
5402 }
5403
5404 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 9)) {
5405 for (bScreen &screen : bmain->screens) {
5406 for (ScrArea &area : screen.areabase) {
5407 for (SpaceLink &sl : area.spacedata) {
5408 if (sl.spacetype == SPACE_FILE) {
5409 SpaceFile *sfile = reinterpret_cast<SpaceFile *>(&sl);
5410 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
5411 &sl.regionbase;
5412 ARegion *region_ui = do_versions_find_region(regionbase, RGN_TYPE_UI);
5413 ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
5414 ARegion *region_toolprops = do_versions_find_region_or_null(regionbase,
5416
5417 /* Check, even though this is expected to be valid. */
5418 if (region_ui) {
5419 /* Reinsert UI region so that it spawns entire area width. */
5420 BLI_remlink(regionbase, region_ui);
5421 BLI_insertlinkafter(regionbase, region_header, region_ui);
5422
5423 region_ui->flag |= RGN_FLAG_DYNAMIC_SIZE;
5424 }
5425
5426 if (region_toolprops &&
5427 (region_toolprops->alignment == (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV)))
5428 {
5430
5431 /* Remove empty region at old location. */
5432 BLI_assert(sfile->op == nullptr);
5433 BKE_area_region_free(stype, region_toolprops);
5434 BLI_freelinkN(regionbase, region_toolprops);
5435 }
5436
5437 if (sfile->params) {
5439 }
5440 }
5441 }
5442 }
5443 }
5444
5445 /* Convert the BONE_NO_SCALE flag to inherit_scale_mode enum. */
5446 if (!DNA_struct_member_exists(fd->filesdna, "Bone", "char", "inherit_scale_mode")) {
5447 for (bArmature &arm : bmain->armatures) {
5449 }
5450 }
5451
5452 /* Convert the Offset flag to the mix mode enum. */
5453 if (!DNA_struct_member_exists(fd->filesdna, "bRotateLikeConstraint", "char", "mix_mode")) {
5454 for (Object &ob : bmain->objects) {
5456 if (ob.pose) {
5457 for (bPoseChannel &pchan : ob.pose->chanbase) {
5459 }
5460 }
5461 }
5462 }
5463
5464 /* Added studio-light intensity. */
5465 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "float", "studiolight_intensity"))
5466 {
5467 for (bScreen &screen : bmain->screens) {
5468 for (ScrArea &area : screen.areabase) {
5469 for (SpaceLink &sl : area.spacedata) {
5470 if (sl.spacetype == SPACE_VIEW3D) {
5471 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5472 v3d->shading.studiolight_intensity = 1.0f;
5473 }
5474 }
5475 }
5476 }
5477 }
5478
5479 /* Elastic deform brush */
5480 for (Brush &br : bmain->brushes) {
5483 }
5484 }
5485 }
5486
5487 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 10)) {
5488 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
5489 if (ntree->type == NTREE_SHADER) {
5491 }
5492 }
5494 }
5495
5496 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 11)) {
5497 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
5498 if (ntree->type == NTREE_SHADER) {
5501 }
5502 }
5504 }
5505
5506 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 281, 15)) {
5507 for (Scene &scene : bmain->scenes) {
5508 constexpr char SCE_SNAP_TO_NODE_X = (1 << 1);
5509 if (scene.toolsettings->snap_node_mode == SCE_SNAP_TO_NODE_X) {
5511 }
5512 }
5513
5514 if (!DNA_struct_member_exists(
5515 fd->filesdna, "LayerCollection", "short", "local_collections_bits"))
5516 {
5517 for (Scene &scene : bmain->scenes) {
5518 for (ViewLayer &view_layer : scene.view_layers) {
5519 for (LayerCollection &layer_collection : view_layer.layer_collections) {
5520 do_versions_local_collection_bits_set(&layer_collection);
5521 }
5522 }
5523 }
5524 }
5525
5526 for (bScreen &screen : bmain->screens) {
5527 for (ScrArea &area : screen.areabase) {
5528 for (SpaceLink &sl : area.spacedata) {
5529 if (sl.spacetype == SPACE_VIEW3D) {
5530 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5531
5532 for (ScrArea &area_other : screen.areabase) {
5533 for (SpaceLink &sl_other : area_other.spacedata) {
5534 if (&sl != &sl_other && sl_other.spacetype == SPACE_VIEW3D) {
5535 View3D *v3d_other = reinterpret_cast<View3D *>(&sl_other);
5536
5537 if (v3d->shading.prop == v3d_other->shading.prop) {
5538 v3d_other->shading.prop = nullptr;
5539 }
5540 }
5541 }
5542 }
5543 }
5544 else if (sl.spacetype == SPACE_FILE) {
5545 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
5546 &sl.regionbase;
5547 ARegion *region_tools = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOLS);
5548 ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
5549
5550 if (region_tools) {
5551 ARegion *region_next = region_tools->next;
5552
5553 /* We temporarily had two tools regions, get rid of the second one. */
5554 if (region_next && region_next->regiontype == RGN_TYPE_TOOLS) {
5555 do_versions_remove_region(regionbase, region_next);
5556 }
5557
5558 BLI_remlink(regionbase, region_tools);
5559 BLI_insertlinkafter(regionbase, region_header, region_tools);
5560 }
5561 else {
5563 "versioning file tools region");
5564 BLI_insertlinkafter(regionbase, region_header, region_tools);
5565 region_tools->alignment = RGN_ALIGN_LEFT;
5566 }
5567 }
5568 }
5569 }
5570 }
5571
5572 for (Brush &br : bmain->brushes) {
5573 if (br.ob_mode & OB_MODE_SCULPT && br.area_radius_factor == 0.0f) {
5574 br.area_radius_factor = 0.5f;
5575 }
5576 }
5577 }
5578
5579 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 282, 2)) {
5581
5582 for (bScreen &screen : bmain->screens) {
5583 for (ScrArea &area : screen.areabase) {
5584 area.flag &= ~AREA_FLAG_UNUSED_6;
5585 }
5586 }
5587
5588 /* Add custom curve profile to toolsettings for bevel tool */
5589 if (!DNA_struct_member_exists(fd->filesdna, "ToolSettings", "CurveProfile", "custom_profile"))
5590 {
5591 for (Scene &scene : bmain->scenes) {
5592 ToolSettings *ts = scene.toolsettings;
5593 if ((ts) && (ts->custom_bevel_profile_preset == nullptr)) {
5595 }
5596 }
5597 }
5598
5599 /* Add custom curve profile to bevel modifier */
5600 if (!DNA_struct_member_exists(fd->filesdna, "BevelModifier", "CurveProfile", "custom_profile"))
5601 {
5602 for (Object &ob : bmain->objects) {
5603 for (ModifierData &md : ob.modifiers) {
5604 if (md.type == eModifierType_Bevel) {
5605 BevelModifierData *bmd = reinterpret_cast<BevelModifierData *>(&md);
5606 if (!bmd->custom_profile) {
5608 }
5609 }
5610 }
5611 }
5612 }
5613
5614 /* Dash Ratio and Dash Samples */
5615 if (!DNA_struct_member_exists(fd->filesdna, "Brush", "float", "dash_ratio")) {
5616 for (Brush &br : bmain->brushes) {
5617 br.dash_ratio = 1.0f;
5618 br.dash_samples = 20;
5619 }
5620 }
5621
5622 /* Pose brush smooth iterations */
5623 if (!DNA_struct_member_exists(fd->filesdna, "Brush", "float", "pose_smooth_iterations")) {
5624 for (Brush &br : bmain->brushes) {
5626 }
5627 }
5628
5629 /* Cloth pressure */
5630 for (Object &ob : bmain->objects) {
5631 for (ModifierData &md : ob.modifiers) {
5632 if (md.type == eModifierType_Cloth) {
5633 ClothModifierData *clmd = reinterpret_cast<ClothModifierData *>(&md);
5634
5635 clmd->sim_parms->pressure_factor = 1;
5636 }
5637 }
5638 }
5639 }
5640
5641 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 282, 3)) {
5642 /* Remove Unified pressure/size and pressure/alpha */
5643 for (Scene &scene : bmain->scenes) {
5644 ToolSettings *ts = scene.toolsettings;
5647 }
5648
5649 /* Set the default render pass in the viewport to Combined. */
5650 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "int", "render_pass")) {
5651 for (Scene &scene : bmain->scenes) {
5653 }
5654
5655 for (bScreen &screen : bmain->screens) {
5656 for (ScrArea &area : screen.areabase) {
5657 for (SpaceLink &sl : area.spacedata) {
5658 if (sl.spacetype == SPACE_VIEW3D) {
5659 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5661 }
5662 }
5663 }
5664 }
5665 }
5666
5667 /* Make markers region visible by default. */
5668 for (bScreen &screen : bmain->screens) {
5669 for (ScrArea &area : screen.areabase) {
5670 for (SpaceLink &sl : area.spacedata) {
5671 switch (sl.spacetype) {
5672 case SPACE_SEQ: {
5673 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
5674 sseq->flag |= SEQ_SHOW_MARKERS;
5675 break;
5676 }
5677 case SPACE_ACTION: {
5678 SpaceAction *saction = reinterpret_cast<SpaceAction *>(&sl);
5679 saction->flag |= SACTION_SHOW_MARKERS;
5680 break;
5681 }
5682 case SPACE_GRAPH: {
5683 SpaceGraph *sipo = reinterpret_cast<SpaceGraph *>(&sl);
5684 sipo->flag |= SIPO_SHOW_MARKERS;
5685 break;
5686 }
5687 case SPACE_NLA: {
5688 SpaceNla *snla = reinterpret_cast<SpaceNla *>(&sl);
5689 snla->flag |= SNLA_SHOW_MARKERS;
5690 break;
5691 }
5692 }
5693 }
5694 }
5695 }
5696 }
5697
5698 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 3)) {
5699 /* Color Management Look. */
5700 for (Scene &scene : bmain->scenes) {
5701 ColorManagedViewSettings *view_settings;
5702 view_settings = &scene.view_settings;
5703 if (BLI_str_startswith(view_settings->look, "Filmic - ")) {
5704 char *src = view_settings->look + strlen("Filmic - ");
5705 memmove(view_settings->look, src, strlen(src) + 1);
5706 }
5707 else if (BLI_str_startswith(view_settings->look, "Standard - ")) {
5708 char *src = view_settings->look + strlen("Standard - ");
5709 memmove(view_settings->look, src, strlen(src) + 1);
5710 }
5711 }
5712
5713 /* Sequencer Tool region */
5715
5716 /* Cloth internal springs */
5717 for (Object &ob : bmain->objects) {
5718 for (ModifierData &md : ob.modifiers) {
5719 if (md.type == eModifierType_Cloth) {
5720 ClothModifierData *clmd = reinterpret_cast<ClothModifierData *>(&md);
5721
5722 clmd->sim_parms->internal_tension = 15.0f;
5723 clmd->sim_parms->max_internal_tension = 15.0f;
5724 clmd->sim_parms->internal_compression = 15.0f;
5725 clmd->sim_parms->max_internal_compression = 15.0f;
5727 }
5728 }
5729 }
5730
5731 /* Add primary tile to images. */
5732 if (!DNA_struct_member_exists(fd->filesdna, "Image", "ListBase", "tiles")) {
5733 for (Image &ima : bmain->images) {
5734 ImageTile *tile = MEM_new<ImageTile>("Image Tile");
5735 tile->tile_number = 1001;
5736 BLI_addtail(&ima.tiles, tile);
5737 }
5738 }
5739
5740 /* UDIM Image Editor change. */
5741 if (!DNA_struct_member_exists(fd->filesdna, "SpaceImage", "int", "tile_grid_shape[2]")) {
5742 for (bScreen &screen : bmain->screens) {
5743 for (ScrArea &area : screen.areabase) {
5744 for (SpaceLink &sl : area.spacedata) {
5745 if (sl.spacetype == SPACE_IMAGE) {
5746 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&sl);
5747 sima->tile_grid_shape[0] = 1;
5748 sima->tile_grid_shape[1] = 1;
5749 }
5750 }
5751 }
5752 }
5753 }
5754
5755 for (Brush &br : bmain->brushes) {
5756 br.add_col[3] = 0.9f;
5757 br.sub_col[3] = 0.9f;
5758 }
5759
5760 /* Pose brush IK segments. */
5761 for (Brush &br : bmain->brushes) {
5762 if (br.pose_ik_segments == 0) {
5763 br.pose_ik_segments = 1;
5764 }
5765 }
5766
5767 /* Pose brush keep anchor point. */
5768 for (Brush &br : bmain->brushes) {
5771 }
5772 }
5773
5774 /* Tip Roundness. */
5775 if (!DNA_struct_member_exists(fd->filesdna, "Brush", "float", "tip_roundness")) {
5776 for (Brush &br : bmain->brushes) {
5778 br.tip_roundness = 0.18f;
5779 }
5780 }
5781 }
5782 }
5783
5784 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 5)) {
5785 /* Alembic Transform Cache changed from world to local space. */
5786 for (Object &ob : bmain->objects) {
5787 for (bConstraint &con : ob.constraints) {
5790 }
5791 }
5792 }
5793
5794 /* Add 2D transform to UV Warp modifier. */
5795 if (!DNA_struct_member_exists(fd->filesdna, "UVWarpModifierData", "float", "scale[2]")) {
5796 for (Object &ob : bmain->objects) {
5797 for (ModifierData &md : ob.modifiers) {
5798 if (md.type == eModifierType_UVWarp) {
5799 UVWarpModifierData *umd = reinterpret_cast<UVWarpModifierData *>(&md);
5800 copy_v2_fl(umd->scale, 1.0f);
5801 }
5802 }
5803 }
5804 }
5805
5806 /* Add Lookdev blur property. */
5807 if (!DNA_struct_member_exists(fd->filesdna, "View3DShading", "float", "studiolight_blur")) {
5808 for (bScreen &screen : bmain->screens) {
5809 for (ScrArea &area : screen.areabase) {
5810 for (SpaceLink &sl : area.spacedata) {
5811 if (sl.spacetype == SPACE_VIEW3D) {
5812 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5813 v3d->shading.studiolight_blur = 0.5f;
5814 }
5815 }
5816 }
5817 }
5818 }
5819 }
5820
5821 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 7)) {
5822 /* Init default Grease Pencil Vertex paint mix factor for Viewport. */
5823 if (!DNA_struct_member_exists(
5824 fd->filesdna, "View3DOverlay", "float", "gpencil_vertex_paint_opacity"))
5825 {
5826 for (bScreen &screen : bmain->screens) {
5827 for (ScrArea &area : screen.areabase) {
5828 for (SpaceLink &sl : area.spacedata) {
5829 if (sl.spacetype == SPACE_VIEW3D) {
5830 View3D *v3d = reinterpret_cast<View3D *>(&sl);
5832 }
5833 }
5834 }
5835 }
5836 }
5837
5838 /* Update Grease Pencil after drawing engine and code refactor.
5839 * It uses the seed variable of Array modifier to avoid double patching for
5840 * files created with a development version. */
5841 if (!DNA_struct_member_exists(fd->filesdna, "ArrayGpencilModifierData", "int", "seed")) {
5842 /* Init new Grease Pencil Paint tools. */
5843 {
5844 for (Brush &brush : bmain->brushes) {
5845 if (brush.gpencil_settings != nullptr) {
5846 brush.gpencil_vertex_brush_type = eBrushGPVertexType(
5847 brush.gpencil_settings->brush_type);
5848 brush.gpencil_sculpt_brush_type = eBrushGPSculptType(
5849 brush.gpencil_settings->brush_type);
5850 brush.gpencil_weight_brush_type = eBrushGPWeightType(
5851 brush.gpencil_settings->brush_type);
5852 }
5853 }
5854 }
5855
5856 for (Material &mat : bmain->materials) {
5857 MaterialGPencilStyle *gp_style = mat.gp_style;
5858 if (gp_style == nullptr) {
5859 continue;
5860 }
5861 /* Fix Grease Pencil Material colors to Linear. */
5862 srgb_to_linearrgb_v4(gp_style->stroke_rgba, gp_style->stroke_rgba);
5863 srgb_to_linearrgb_v4(gp_style->fill_rgba, gp_style->fill_rgba);
5864
5865 /* Move old gradient variables to texture. */
5867 gp_style->texture_angle = gp_style->gradient_angle;
5868 copy_v2_v2(gp_style->texture_scale, gp_style->gradient_scale);
5869 copy_v2_v2(gp_style->texture_offset, gp_style->gradient_shift);
5870 }
5871 /* Set Checker material as Solid. This fill mode has been removed and replaced
5872 * by textures. */
5873 if (gp_style->fill_style == GP_MATERIAL_FILL_STYLE_CHECKER) {
5875 }
5876 /* Update Alpha channel for texture opacity. */
5877 if (gp_style->fill_style == GP_MATERIAL_FILL_STYLE_TEXTURE) {
5878 gp_style->fill_rgba[3] *= gp_style->texture_opacity;
5879 }
5880 /* Stroke stencil mask to mix = 1. */
5881 if (gp_style->flag & GP_MATERIAL_STROKE_PATTERN) {
5882 gp_style->mix_stroke_factor = 1.0f;
5883 gp_style->flag &= ~GP_MATERIAL_STROKE_PATTERN;
5884 }
5885 /* Mix disabled, set mix factor to 0. */
5886 else if ((gp_style->flag & GP_MATERIAL_STROKE_TEX_MIX) == 0) {
5887 gp_style->mix_stroke_factor = 0.0f;
5888 }
5889 }
5890
5891 /* Fix Grease Pencil VFX and modifiers. */
5892 for (Object &ob : bmain->objects) {
5893 if (ob.type != OB_GPENCIL_LEGACY) {
5894 continue;
5895 }
5896
5897 /* VFX. */
5898 for (ShaderFxData &fx : ob.shader_fx) {
5899 switch (fx.type) {
5901 ColorizeShaderFxData *vfx = reinterpret_cast<ColorizeShaderFxData *>(&fx);
5903 vfx->factor = 1.0f;
5904 }
5907 break;
5908 }
5909 case eShaderFxType_Pixel: {
5910 PixelShaderFxData *vfx = reinterpret_cast<PixelShaderFxData *>(&fx);
5911 srgb_to_linearrgb_v4(vfx->rgba, vfx->rgba);
5912 break;
5913 }
5914 case eShaderFxType_Rim: {
5915 RimShaderFxData *vfx = reinterpret_cast<RimShaderFxData *>(&fx);
5918 break;
5919 }
5920 case eShaderFxType_Shadow: {
5921 ShadowShaderFxData *vfx = reinterpret_cast<ShadowShaderFxData *>(&fx);
5923 break;
5924 }
5925 case eShaderFxType_Glow: {
5926 GlowShaderFxData *vfx = reinterpret_cast<GlowShaderFxData *>(&fx);
5928 vfx->glow_color[3] = 1.0f;
5930 vfx->blur[1] = vfx->blur[0];
5931 break;
5932 }
5933 default:
5934 break;
5935 }
5936 }
5937
5938 /* Modifiers. */
5940 switch (GpencilModifierType(md.type)) {
5942 ArrayGpencilModifierData *mmd = reinterpret_cast<ArrayGpencilModifierData *>(&md);
5943 mmd->seed = 1;
5944 if ((mmd->offset[0] != 0.0f) || (mmd->offset[1] != 0.0f) || (mmd->offset[2] != 0.0f))
5945 {
5946 mmd->flag |= GP_ARRAY_USE_OFFSET;
5947 }
5948 if ((mmd->shift[0] != 0.0f) || (mmd->shift[1] != 0.0f) || (mmd->shift[2] != 0.0f)) {
5949 mmd->flag |= GP_ARRAY_USE_OFFSET;
5950 }
5951 if (mmd->object != nullptr) {
5953 }
5954 break;
5955 }
5957 NoiseGpencilModifierData *mmd = reinterpret_cast<NoiseGpencilModifierData *>(&md);
5958 float factor = mmd->factor / 25.0f;
5959 mmd->factor = (mmd->flag & GP_NOISE_MOD_LOCATION) ? factor : 0.0f;
5960 mmd->factor_thickness = (mmd->flag & GP_NOISE_MOD_STRENGTH) ? factor : 0.0f;
5961 mmd->factor_strength = (mmd->flag & GP_NOISE_MOD_THICKNESS) ? factor : 0.0f;
5962 mmd->factor_uvs = (mmd->flag & GP_NOISE_MOD_UV) ? factor : 0.0f;
5963
5964 mmd->noise_scale = (mmd->flag & GP_NOISE_FULL_STROKE) ? 0.0f : 1.0f;
5965
5966 if (mmd->curve_intensity == nullptr) {
5967 mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
5968 if (mmd->curve_intensity) {
5970 }
5971 }
5972 break;
5973 }
5975 TintGpencilModifierData *mmd = reinterpret_cast<TintGpencilModifierData *>(&md);
5976 srgb_to_linearrgb_v3_v3(mmd->rgb, mmd->rgb);
5977 if (mmd->curve_intensity == nullptr) {
5978 mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
5979 if (mmd->curve_intensity) {
5981 }
5982 }
5983 break;
5984 }
5986 SmoothGpencilModifierData *mmd = reinterpret_cast<SmoothGpencilModifierData *>(&md);
5987 if (mmd->curve_intensity == nullptr) {
5988 mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
5989 if (mmd->curve_intensity) {
5991 }
5992 }
5993 break;
5994 }
5996 OpacityGpencilModifierData *mmd = reinterpret_cast<OpacityGpencilModifierData *>(
5997 &md);
5998 if (mmd->curve_intensity == nullptr) {
5999 mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
6000 if (mmd->curve_intensity) {
6002 }
6003 }
6004 break;
6005 }
6007 ColorGpencilModifierData *mmd = reinterpret_cast<ColorGpencilModifierData *>(&md);
6008 if (mmd->curve_intensity == nullptr) {
6009 mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
6010 if (mmd->curve_intensity) {
6012 }
6013 }
6014 break;
6015 }
6017 if (!DNA_struct_member_exists(
6018 fd->filesdna, "ThickGpencilModifierData", "float", "thickness_fac"))
6019 {
6020 ThickGpencilModifierData *mmd = reinterpret_cast<ThickGpencilModifierData *>(&md);
6021 mmd->thickness_fac = mmd->thickness;
6022 }
6023 break;
6024 }
6027 &md);
6028 mmd->fading_opacity = 1.0 - mmd->fading_opacity;
6029 break;
6030 }
6032 const short simple = (1 << 0);
6033 SubdivGpencilModifierData *mmd = reinterpret_cast<SubdivGpencilModifierData *>(&md);
6034 if (mmd->flag & simple) {
6035 mmd->flag &= ~eSubdivGpencil_Flag(simple);
6036 mmd->type = GP_SUBDIV_SIMPLE;
6037 }
6038 break;
6039 }
6040 default:
6041 break;
6042 }
6043 }
6044 }
6045
6046 /* Fix Layers Colors and Vertex Colors to Linear.
6047 * Also set lights to on for layers. */
6048 for (bGPdata &gpd : bmain->gpencils) {
6049 if (gpd.flag & GP_DATA_ANNOTATIONS) {
6050 continue;
6051 }
6052 /* Onion colors. */
6055 /* Z-depth Offset. */
6056 gpd.zdepth_offset = 0.150f;
6057
6058 for (bGPDlayer &gpl : gpd.layers) {
6061 gpl.vertex_paint_opacity = 1.0f;
6062
6063 for (bGPDframe &gpf : gpl.frames) {
6064 for (bGPDstroke &gps : gpf.strokes) {
6065 /* Set initial opacity for fill color. */
6066 gps.fill_opacity_fac = 1.0f;
6067
6068 /* Calc geometry data because in old versions this data was not saved. */
6070
6072 int i;
6073 bGPDspoint *pt;
6074 for (i = 0, pt = gps.points; i < gps.totpoints; i++, pt++) {
6076 }
6077 }
6078 }
6079 }
6080 }
6081 }
6082 }
6083
6084 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 8)) {
6085 if (!DNA_struct_member_exists(
6086 fd->filesdna, "View3DOverlay", "float", "sculpt_mode_face_sets_opacity"))
6087 {
6088 for (bScreen &screen : bmain->screens) {
6089 for (ScrArea &area : screen.areabase) {
6090 for (SpaceLink &sl : area.spacedata) {
6091 if (sl.spacetype == SPACE_VIEW3D) {
6092 View3D *v3d = reinterpret_cast<View3D *>(&sl);
6094 }
6095 }
6096 }
6097 }
6098 }
6099
6100 /* Alembic Transform Cache changed from local to world space. */
6101 for (Object &ob : bmain->objects) {
6102 for (bConstraint &con : ob.constraints) {
6105 }
6106 }
6107 }
6108
6109 /* Boundary Edges Auto-masking. */
6110 if (!DNA_struct_member_exists(
6111 fd->filesdna, "Brush", "int", "automasking_boundary_edges_propagation_steps"))
6112 {
6113 for (Brush &br : bmain->brushes) {
6115 }
6116 }
6117
6118 /* Corrective smooth modifier scale. */
6119 if (!DNA_struct_member_exists(fd->filesdna, "CorrectiveSmoothModifierData", "float", "scale"))
6120 {
6121 for (Object &ob : bmain->objects) {
6122 for (ModifierData &md : ob.modifiers) {
6125 &md);
6126 csmd->scale = 1.0f;
6127 }
6128 }
6129 }
6130 }
6131
6132 /* Default Face Set Color. */
6133 for (Mesh &me : bmain->meshes) {
6134 if (me.faces_num > 0) {
6135 const int *face_sets = static_cast<const int *>(
6136 CustomData_get_layer(&me.face_data, CD_SCULPT_FACE_SETS));
6137 if (face_sets) {
6138 me.face_sets_color_default = abs(face_sets[0]);
6139 }
6140 }
6141 }
6142 }
6143
6144 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 11)) {
6145 if (!DNA_struct_member_exists(fd->filesdna, "OceanModifierData", "float", "fetch_jonswap")) {
6146 for (Object &object : bmain->objects) {
6147 for (ModifierData &md : object.modifiers) {
6148 if (md.type == eModifierType_Ocean) {
6149 OceanModifierData *omd = reinterpret_cast<OceanModifierData *>(&md);
6150 omd->fetch_jonswap = 120.0f;
6151 }
6152 }
6153 }
6154 }
6155
6156 if (!DNA_struct_exists(fd->filesdna, "XrSessionSettings")) {
6157 for (wmWindowManager &wm : bmain->wm) {
6158 const View3D v3d_default = {};
6159
6160 wm.xr.session_settings.shading = v3d_default.shading;
6161 wm.xr.session_settings.draw_flags = (V3D_OFSDRAW_SHOW_GRIDFLOOR |
6163 wm.xr.session_settings.clip_start = v3d_default.clip_start;
6164 wm.xr.session_settings.clip_end = v3d_default.clip_end;
6165
6166 wm.xr.session_settings.flag = XR_SESSION_USE_POSITION_TRACKING;
6167 }
6168 }
6169
6170 /* Surface deform modifier strength. */
6171 if (!DNA_struct_member_exists(fd->filesdna, "SurfaceDeformModifierData", "float", "strength"))
6172 {
6173 for (Object &ob : bmain->objects) {
6174 for (ModifierData &md : ob.modifiers) {
6176 SurfaceDeformModifierData *sdmd = reinterpret_cast<SurfaceDeformModifierData *>(&md);
6177 sdmd->strength = 1.0f;
6178 }
6179 }
6180 }
6181 }
6182 }
6183
6184 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 12)) {
6185 /* Activate f-curve drawing in the sequencer. */
6186 for (bScreen &screen : bmain->screens) {
6187 for (ScrArea &area : screen.areabase) {
6188 for (SpaceLink &sl : area.spacedata) {
6189 if (sl.spacetype == SPACE_SEQ) {
6190 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
6192 }
6193 }
6194 }
6195 }
6196
6197 /* Remesh Modifier Voxel Mode. */
6198 if (!DNA_struct_member_exists(fd->filesdna, "RemeshModifierData", "float", "voxel_size")) {
6199 for (Object &ob : bmain->objects) {
6200 for (ModifierData &md : ob.modifiers) {
6201 if (md.type == eModifierType_Remesh) {
6202 RemeshModifierData *rmd = reinterpret_cast<RemeshModifierData *>(&md);
6203 rmd->voxel_size = 0.1f;
6204 rmd->adaptivity = 0.0f;
6205 }
6206 }
6207 }
6208 }
6209 }
6210
6211 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 14)) {
6212 /* Solidify modifier merge tolerance. */
6213 if (!DNA_struct_member_exists(
6214 fd->filesdna, "SolidifyModifierData", "float", "merge_tolerance"))
6215 {
6216 for (Object &ob : bmain->objects) {
6217 for (ModifierData &md : ob.modifiers) {
6218 if (md.type == eModifierType_Solidify) {
6219 SolidifyModifierData *smd = reinterpret_cast<SolidifyModifierData *>(&md);
6220 /* set to 0.0003 since that is what was used before, default now is 0.0001 */
6221 smd->merge_tolerance = 0.0003f;
6222 }
6223 }
6224 }
6225 }
6226
6227 /* Enumerator was incorrect for a time in 2.83 development.
6228 * Note that this only corrects values known to be invalid. */
6229 for (Object &ob : bmain->objects) {
6231 if (rbc != nullptr) {
6232 enum {
6233 INVALID_RBC_TYPE_SLIDER = 2,
6234 INVALID_RBC_TYPE_6DOF_SPRING = 4,
6235 INVALID_RBC_TYPE_MOTOR = 7,
6236 };
6237 switch (int(rbc->type)) {
6238 case INVALID_RBC_TYPE_SLIDER:
6239 rbc->type = RBC_TYPE_SLIDER;
6240 break;
6241 case INVALID_RBC_TYPE_6DOF_SPRING:
6243 break;
6244 case INVALID_RBC_TYPE_MOTOR:
6245 rbc->type = RBC_TYPE_MOTOR;
6246 break;
6247 }
6248 }
6249 }
6250 }
6251
6252 /* Match scale of fluid modifier gravity with scene gravity. */
6253 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 15)) {
6254 for (Object &ob : bmain->objects) {
6255 for (ModifierData &md : ob.modifiers) {
6256 if (md.type == eModifierType_Fluid) {
6257 FluidModifierData *fmd = reinterpret_cast<FluidModifierData *>(&md);
6258 if (fmd->domain != nullptr) {
6259 mul_v3_fl(fmd->domain->gravity, 9.81f);
6260 }
6261 }
6262 }
6263 }
6264 }
6265
6266 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 16)) {
6267 /* Init SMAA threshold for grease pencil render. */
6268 for (Scene &scene : bmain->scenes) {
6270 }
6271 }
6272
6273 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 283, 17)) {
6274 /* Reset the cloth mass to 1.0 in brushes with an invalid value. */
6275 for (Brush &br : bmain->brushes) {
6277 if (br.cloth_mass == 0.0f) {
6278 br.cloth_mass = 1.0f;
6279 }
6280 }
6281 }
6282
6283 /* Set Brush default color for grease pencil. */
6284 for (Brush &brush : bmain->brushes) {
6285 if (brush.gpencil_settings) {
6286 brush.rgb[0] = 0.498f;
6287 brush.rgb[1] = 1.0f;
6288 brush.rgb[2] = 0.498f;
6289 }
6290 }
6291 }
6292
6293 /* Old forgotten versioning code. */
6294 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 300, 39)) {
6295 /* Set the cloth wind factor to 1 for old forces. */
6296 if (!DNA_struct_member_exists(fd->filesdna, "PartDeflect", "float", "f_wind_factor")) {
6297 for (Object &ob : bmain->objects) {
6298 if (ob.pd) {
6299 ob.pd->f_wind_factor = 1.0f;
6300 }
6301 }
6302 for (ParticleSettings &part : bmain->particles) {
6303 if (part.pd) {
6304 part.pd->f_wind_factor = 1.0f;
6305 }
6306 if (part.pd2) {
6307 part.pd2->f_wind_factor = 1.0f;
6308 }
6309 }
6310 }
6311
6312 for (wmWindowManager &wm : bmain->wm) {
6313 /* Don't rotate light with the viewer by default, make it fixed. Shading settings can't be
6314 * edited and this flag should always be set. */
6315 wm.xr.session_settings.shading.flag |= V3D_SHADING_WORLD_ORIENTATION;
6316 }
6317 }
6318
6325}
6326
6327} // namespace blender
Versioning of old animation data. Most animation versioning code lives in the versioning_xxx....
Blender util stuff.
CustomData interface, see also DNA_customdata_types.h.
#define DRIVER_TARGETS_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
#define FOREACH_MAIN_ID_END
Definition BKE_main.hh:735
#define MAIN_VERSION_FILE_ATLEAST(main, ver, subver)
Definition BKE_main.hh:949
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
Definition BKE_main.hh:729
#define SELECT
Definition BKE_mask.hh:19
#define FOREACH_NODETREE_END
Definition BKE_node.hh:936
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:926
#define SH_NODE_TEX_NOISE
#define CMP_NODE_TIME
#define SH_NODE_TEX_WAVE
#define SH_NODE_TEX_IMAGE
#define SH_NODE_BSDF_PRINCIPLED
#define SH_NODE_EMISSION
#define SH_NODE_ADD_SHADER
#define SH_NODE_VECTOR_MATH
#define SH_NODE_TEX_ENVIRONMENT
#define SH_NODE_CURVE_VEC
#define CMP_NODE_HUECORRECT
#define SH_NODE_MATH
#define SH_NODE_BSDF_TRANSPARENT
#define SH_NODE_AMBIENT_OCCLUSION
#define SH_NODE_SHADERTORGB
#define SH_NODE_OUTPUT_MATERIAL
#define CMP_NODE_CURVE_RGB
#define SH_NODE_TEX_VORONOI
#define SH_NODE_BSDF_GLOSSY
#define SH_NODE_TEX_MUSGRAVE_DEPRECATED
#define SH_NODE_MAPPING
#define SH_NODE_CURVE_RGB
#define SH_NODE_EEVEE_SPECULAR
#define TEX_NODE_CURVE_TIME
#define SH_NODE_BSDF_GLASS
#define SH_NODE_DISPLACEMENT
#define SH_NODE_BSDF_GLOSSY_LEGACY
#define SH_NODE_BSDF_REFRACTION
#define CMP_NODE_CURVE_VEC_DEPRECATED
#define TEX_NODE_CURVE_RGB
API for Blender-side Rigid Body stuff.
#define M_SQRT1_3
#define M_PI_2
#define M_PI_4
#define STR_ELEM(...)
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
external readfile function prototypes.
#define BLO_read_assert_message(_check_expr, _ret_value, _bh, _bmain, _message)
#define RPT_(msgid)
#define DATA_(msgid)
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define MAX_ID_NAME
Definition DNA_ID.h:367
Object groups, one object can be in many groups at once.
#define CM_TOT
blenloader genfile private function prototypes
#define GP_DEFAULT_PIX_FACTOR
#define GP_DEFAULT_GRID_LINES
Object is a sort of wrapper for general info.
Types and defines for representing Rigid Body entities.
#define USER_UNIT_ADAPTIVE
#define WM_OUTLINER_SYNC_SELECT_FROM_ALL
Read Blender memory allocation and freeing.
#define STRPREFIX(a, b)
#define ARRAY_SET_ITEMS(...)
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define BLI_assert(a)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
Definition scene.h:133
Camera * camera
Definition scene.h:145
#define offsetof(t, d)
#define layer
#define abs
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
const ccl_global KernelWorkTile * tile
ccl_device_inline int4 srl(const int4 a, const int i)
Definition math_int4.h:205
void fcurves_id_cb(ID *id, const FunctionRef< void(ID *, FCurve *)> func)
ENUM_OPERATORS(Layer::Flags)
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
Definition node.cc:4676
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:4283
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:4638
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
Definition node.cc:3036
bNodeTree * node_tree_from_id(ID *id)
Definition node.cc:5337
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:60
void strip_unique_name_set(Scene *scene, ListBaseT< Strip > *seqbasep, Strip *strip)
const StripModifierTypeInfo * modifier_type_info_get(eStripModifierType type)
BMesh Iterators.
static void do_version_layers_to_collections(Main *bmain, Scene *scene)
bool version_node_ensure_storage_or_invalidate(bNode &node)
static bool strip_update_flags_cb(Strip *strip, void *)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition colortools.cc:99
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool version_node_socket_is_used(bNodeSocket *sock)
@ SO_FILTER_OB_STATE_SELECTABLE
static void ambient_occlusion_node_relink(bNodeTree *ntree)
@ SHD_WAVE_BANDS_DIRECTION_DIAGONAL
static void do_versions_material_convert_legacy_blend_mode(bNodeTree *ntree, char blend_method)
@ STUDIOLIGHT_TYPE_MATCAP
@ STUDIOLIGHT_TYPE_WORLD
struct bNode * ntreeShaderOutputNode(struct bNodeTree *ntree, int target)
void BKE_workspace_active_set(WorkSpaceInstanceHook *hook, WorkSpace *workspace) SETTER_ATTRS
Definition workspace.cc:637
char * STRNCPY(char(&dst)[N], const char *src)
static void do_versions_seq_set_cache_defaults(Editing *ed)
static void do_version_constraints_copy_scale_power(ListBaseT< bConstraint > *lb)
static void displacement_node_insert(bNodeTree *ntree)
static void do_versions_fix_annotations(bGPdata *gpd)
@ SEQ_TIMELINE_SHOW_FCURVES
MINLINE void copy_v2_fl(float r[2], float f)
void BKE_screen_area_free(ScrArea *area)
Definition screen.cc:783
static void displacement_principled_nodes(bNode *node)
static void mapping_node_order_flip(bNode *node)
@ ADS_FLAG_SUMMARY_COLLAPSED
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ CLOTH_BENDING_LINEAR
static void update_mapping_node_inputs_and_properties(bNodeTree *ntree)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
static char * replace_bbone_scale_rnapath(const char *old_path)
bool CustomData_free_layers(CustomData *data, eCustomDataType type)
@ CONSTRAINT_TYPE_TRANSFORM_CACHE
int bool bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(1
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
void BKE_screen_view3d_shading_init(View3DShading *shading)
Definition screen.cc:1262
void BKE_screen_remove_unused_scredges(bScreen *screen)
Definition screen.cc:917
@ VIEWLAYER_ADD_NEW
Definition BKE_layer.hh:40
void BKE_screen_remove_unused_scrverts(bScreen *screen)
Definition screen.cc:962
MINLINE void copy_v2_v2(float r[2], const float a[2])
float version_cycles_property_float(IDProperty *idprop, const char *name, float default_value)
static void do_version_bones_inherit_scale(ListBaseT< Bone > *lb)
char * BLI_strdupcat(const char *__restrict str1, const char *__restrict str2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void BKE_rigidbody_world_init_runtime(struct RigidBodyWorld *rbw)
Definition rigidbody.cc:98
void version_update_node_input(bNodeTree *ntree, FunctionRef< bool(bNode *)> check_node, const char *socket_identifier, FunctionRef< void(bNode *, bNodeSocket *)> update_input, FunctionRef< void(bNode *, bNodeSocket *, bNode *, bNodeSocket *)> update_input_link)
WorkSpaceLayout * BKE_workspace_layout_add(Main *bmain, WorkSpace &workspace, bScreen &screen, const char *name)
Definition workspace.cc:426
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
@ OB_FLAG_ACTIVE_CLIPBOARD
@ OB_FLAG_USE_SIMULATION_CACHE
@ SUBSURF_UV_SMOOTH_PRESERVE_CORNERS
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:818
void BKE_area_region_free(SpaceType *st, ARegion *region)
Definition screen.cc:736
static void do_versions_remove_regions_by_type(ListBaseT< ARegion > *regionbase, int regiontype)
@ IMB_BLEND_HARDLIGHT
Definition IMB_imbuf.hh:213
@ IMB_BLEND_SOFTLIGHT
Definition IMB_imbuf.hh:218
@ IMB_BLEND_SCREEN
Definition IMB_imbuf.hh:217
@ IMB_BLEND_DARKEN
Definition IMB_imbuf.hh:209
@ IMB_BLEND_ADD_ALPHA
Definition IMB_imbuf.hh:211
@ IMB_BLEND_MUL
Definition IMB_imbuf.hh:207
@ IMB_BLEND_COLORDODGE
Definition IMB_imbuf.hh:216
@ IMB_BLEND_DIFFERENCE
Definition IMB_imbuf.hh:222
@ IMB_BLEND_HUE
Definition IMB_imbuf.hh:224
@ IMB_BLEND_SUB
Definition IMB_imbuf.hh:206
@ IMB_BLEND_OVERLAY
Definition IMB_imbuf.hh:212
@ IMB_BLEND_SATURATION
Definition IMB_imbuf.hh:225
@ IMB_BLEND_EXCLUSION
Definition IMB_imbuf.hh:223
@ IMB_BLEND_MIX
Definition IMB_imbuf.hh:204
@ IMB_BLEND_ERASE_ALPHA
Definition IMB_imbuf.hh:210
@ IMB_BLEND_LIGHTEN
Definition IMB_imbuf.hh:208
@ IMB_BLEND_LUMINOSITY
Definition IMB_imbuf.hh:226
@ IMB_BLEND_ADD
Definition IMB_imbuf.hh:205
@ eModifierType_ParticleSystem
@ eModifierType_WeightVGEdit
@ eModifierType_DataTransfer
@ eModifierType_Triangulate
@ eModifierType_CorrectiveSmooth
@ eModifierType_SurfaceDeform
static void do_version_curvemapping_flag_extend_extrapolate(CurveMapping *cumap)
@ V3D_AROUND_CENTER_MEDIAN
void BKE_color_managed_view_settings_init(ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, const char *view_transform)
void BKE_annotation_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps)
void BKE_animdata_main_cb(struct Main *bmain, FunctionRef< void(ID *, AnimData *)> func)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
static void do_version_curvemapping_walker(Main *bmain, void(*callback)(CurveMapping *cumap))
@ NODE_MATH_ARCCOSINE
@ NODE_MATH_ARCTANGENT
@ V3D_OFSDRAW_SHOW_ANNOTATION
@ V3D_OFSDRAW_SHOW_GRIDFLOOR
static void update_musgrave_node_color_output(bNodeTree *ntree)
@ FILE_DETAILS_DATETIME
MINLINE void copy_v4_fl(float r[4], float f)
static void light_emission_unify(Light *light, const char *engine)
void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settings)
@ V3D_LOCAL_COLLECTIONS
ARegion * do_versions_add_region(int regiontype, const char *)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
const char * RE_engine_id_CYCLES
Definition scene.cc:1720
@ BRUSH_POSE_IK_ANCHORED
@ BRUSH_USE_CONNECTED_ONLY
static void update_voronoi_node_coloring(bNodeTree *ntree)
void BKE_mesh_tessface_clear(Mesh *mesh)
static void update_musgrave_node_dimensions(bNodeTree *ntree)
bScreen * BKE_workspace_active_screen_get(const WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition workspace.cc:684
static void do_version_workspaces_create_from_screens(Main *bmain)
void BKE_main_id_repair_duplicate_names_listbase(Main *bmain, ListBaseT< ID > *lb)
Definition lib_id.cc:1348
int BKE_unit_base_of_type_get(int system, int type)
Definition unit.cc:2594
@ ARM_DRAW_RELATION_FROM_HEAD
float * version_cycles_node_socket_float_value(bNodeSocket *socket)
static bScreen * screen_parent_find(const bScreen *screen)
float * version_cycles_node_socket_vector_value(bNodeSocket *socket)
void id_fake_user_set(ID *id)
Definition lib_id.cc:471
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
@ V3D_SHADING_WORLD_ORIENTATION
@ V3D_SHADING_BACKFACE_CULLING
@ V3D_SHADING_XRAY_WIREFRAME
@ V3D_SHADING_SCENE_LIGHTS_RENDER
@ V3D_SHADING_OBJECT_OUTLINE
@ V3D_SHADING_SPECULAR_HIGHLIGHT
@ V3D_SHADING_SCENE_WORLD_RENDER
static void light_emission_node_to_energy(Light *light, float *energy, float color[3])
void MEM_delete_void(void *vmemh)
const char * RE_engine_id_BLENDER_WORKBENCH
Definition scene.cc:1719
@ GP_MATERIAL_STROKE_PATTERN
@ GP_MATERIAL_STROKE_TEX_MIX
ARegion * BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *area, int region_type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition screen.cc:572
ViewLayer * BKE_view_layer_default_view(const Scene *scene)
MINLINE void mul_v3_fl(float r[3], float f)
static void update_wave_node_directions_and_offset(bNodeTree *ntree)
@ SCULPT_BRUSH_TYPE_CLOTH
@ SCULPT_BRUSH_TYPE_CLAY_STRIPS
@ SCULPT_BRUSH_TYPE_POSE
const char * RE_engine_id_BLENDER_EEVEE
Definition scene.cc:1717
int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value)
static void update_math_node_single_operand_operators(bNodeTree *ntree)
void version_socket_update_is_used(bNodeTree *ntree)
struct StudioLight * BKE_studiolight_find(const char *name, int flag)
bool BKE_collection_object_add_notest(Main *bmain, Collection *collection, Object *ob)
void do_versions_after_linking_280(FileData *fd, Main *bmain)
static void update_vector_math_node_normalize_operator(bNodeTree *ntree)
@ SCE_EEVEE_TAA_REPROJECTION
@ SCE_EEVEE_MOTION_BLUR_ENABLED_DEPRECATED
void version_node_socket_identifier_set(bNodeSocket &socket, const StringRefNull identifier)
void BKE_curvemapping_init(CurveMapping *cumap)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
static void do_version_bones_split_bbone_scale(ListBaseT< Bone > *lb)
@ GPAINT_BRUSH_TYPE_ERASE
float * version_cycles_node_socket_rgba_value(bNodeSocket *socket)
@ SHD_WAVE_PROFILE_SIN
@ eSubsurfModifierFlag_UseCrease
@ eSubsurfModifierFlag_SubsurfUv_DEPRECATED
ID * do_versions_rename_id(Main *bmain, const short id_type, const char *name_src, const char *name_dst)
@ FFM_PRESET_REALTIME
@ MOD_SHRINKWRAP_ABOVE_SURFACE
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
static void do_version_constraints_maintain_volume_mode_uniform(ListBaseT< bConstraint > *lb)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:339
WorkSpace * BKE_workspace_add(Main *bmain, const char *name)
Definition workspace.cc:369
@ R_COLOR_MANAGEMENT_UNUSED_1
@ LAYER_COLLECTION_INDIRECT_ONLY
@ LAYER_COLLECTION_EXCLUDE
@ LAYER_COLLECTION_HOLDOUT
void BKE_workspace_active_layout_set(WorkSpaceInstanceHook *hook, int winid, WorkSpace *workspace, WorkSpaceLayout *layout) SETTER_ATTRS
Activate a layout.
Definition workspace.cc:675
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapSlopeType slope)
static void update_voronoi_node_dimensions(bNodeTree *ntree)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
@ CONSTRAINT_SPLINEIK_YS_FIT_CURVE
@ SHD_WAVE_RINGS_DIRECTION_SPHERICAL
void quat_to_eulO(float e[3], short order, const float q[4])
static void do_versions_remove_region(ListBaseT< ARegion > *regionbase, ARegion *region)
void BKE_rigidbody_objects_collection_validate(struct Main *bmain, struct Scene *scene, struct RigidBodyWorld *rbw)
@ FILE_PARAMS_FLAG_UNUSED_3
@ FILE_PARAMS_FLAG_UNUSED_1
@ FILE_PARAMS_FLAG_UNUSED_2
@ V3D_GIZMO_SHOW_CAMERA_DOF_DIST
@ V3D_GIZMO_SHOW_CAMERA_LENS
FCurve * BKE_fcurve_copy(const FCurve *fcu)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:277
void BKE_freestyle_config_free(struct FreestyleConfig *config, bool do_id_user)
Definition freestyle.cc:46
static void do_versions_area_ensure_tool_region(Main *bmain, const short space_type, const short region_flag)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
LayerCollection * BKE_layer_collection_first_from_scene_collection(const ViewLayer *view_layer, const Collection *collection)
static void do_version_constraints_copy_rotation_mix_mode(ListBaseT< bConstraint > *lb)
static void do_version_collection_propagate_lib_to_children(Collection *collection)
@ V3D_GIZMO_SHOW_LIGHT_LOOK_AT
@ V3D_GIZMO_SHOW_LIGHT_SIZE
static void update_vector_math_node_operators_enum_mapping(bNodeTree *ntree)
@ LS_MODIFIER_DISTANCE_FROM_CAMERA
@ LS_MODIFIER_DISTANCE_FROM_OBJECT
static void image_node_colorspace(bNode *node)
SpaceType * BKE_spacetype_from_id(int spaceid)
Definition screen.cc:354
static void update_vector_math_node_dot_product_operator(bNodeTree *ntree)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
static void update_mapping_node_fcurve_rna_path_callback(FCurve *fcurve, const char *nodePath, const bNode *minimumNode, const bNode *maximumNode)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition readfile.cc:237
@ V3D_GIZMO_SHOW_ARMATURE_BBONE
@ V3D_GIZMO_SHOW_ARMATURE_ROLL
ARegion * BKE_area_region_new()
Definition screen.cc:522
@ V3D_GIZMO_SHOW_EMPTY_FORCE_FIELD
@ V3D_GIZMO_SHOW_EMPTY_IMAGE
@ V3D_SHADING_SINGLE_COLOR
@ V3D_SHADING_MATERIAL_COLOR
@ V3D_SHADING_TEXTURE_COLOR
@ ME_REMESH_REPROJECT_ATTRIBUTES
@ ME_FLAG_UV_SELECT_SYNC_VALID
void BKE_curvemapping_changed_all(CurveMapping *cumap)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:378
@ SHD_VORONOI_EUCLIDEAN
@ eShaderFxColorizeMode_GrayScale
@ eShaderFxColorizeMode_Sepia
@ OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK
static void update_voronoi_node_crackle(bNodeTree *ntree)
bool version_cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition screen.cc:1024
WorkSpaceInstanceHook * BKE_workspace_instance_hook_create(const Main *bmain, int winid)
Definition workspace.cc:387
static ARegion * do_versions_find_region_or_null(ListBaseT< ARegion > *regionbase, int regiontype)
struct StudioLight * BKE_studiolight_find_default(int flag)
@ CLOTH_SIMSETTINGS_FLAG_SCALING
@ CLOTH_SIMSETTINGS_FLAG_GOAL
@ CLOTH_SIMSETTINGS_FLAG_SEW
static void update_noise_node_dimensions(bNodeTree *ntree)
bool BKE_collection_object_remove(Main *bmain, Collection *collection, Object *ob, bool free_us)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
@ BONE_INHERIT_SCALE_NONE_LEGACY
static void square_roughness_node_insert(bNodeTree *ntree)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
MINLINE void copy_v3_fl(float r[3], float f)
static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBaseT< Strip > *seqbasep)
@ SHD_SUBSURFACE_RANDOM_WALK_SKIN
@ SHD_SUBSURFACE_BURLEY
int BKE_keyblock_curve_element_count(const ListBaseT< Nurb > *nurb)
Definition key.cc:1528
void IDP_FreeProperty(IDProperty *prop)
Definition idprop.cc:1403
static void update_vector_math_node_add_and_subtract_operators(bNodeTree *ntree)
static void do_version_workspaces_after_lib_link(Main *bmain)
After lib-link versioning for new workspace design.
void CustomData_update_typemap(CustomData *data)
@ BLI_MEMPOOL_ALLOW_ITER
MINLINE float max_ff(float a, float b)
Collection * BKE_collection_master_add(Scene *scene)
int bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void eulO_to_quat(float q[4], const float e[3], short order)
static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene)
static void update_noise_and_wave_distortion(bNodeTree *ntree)
struct CurveProfile * BKE_curveprofile_add(eCurveProfilePresets preset)
void * BLI_mempool_calloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
static void update_vector_math_node_cross_product_operator(bNodeTree *ntree)
IDProperty * version_cycles_properties_from_ID(ID *id)
@ eMultiresModifierFlag_UseCrease
@ eMultiresModifierFlag_PlainUv_DEPRECATED
@ OB_EMPTY_IMAGE_HIDE_BACK
@ OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC
@ OB_EMPTY_IMAGE_HIDE_PERSPECTIVE
@ SCE_SNAP_TRANSFORM_MODE_TRANSLATE
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
@ ID_TAG_INDIRECT
Definition DNA_ID.h:851
void BKE_rigidbody_constraints_collection_validate(struct Scene *scene, struct RigidBodyWorld *rbw)
struct PointCache * BKE_ptcache_add(ListBaseT< PointCache > *ptcaches)
@ V3D_OVERLAY_EDIT_BWEIGHTS
@ V3D_OVERLAY_EDIT_CREASES
@ V3D_OVERLAY_EDIT_FREESTYLE_EDGE
@ V3D_OVERLAY_EDIT_RETOPOLOGY
@ V3D_OVERLAY_EDIT_FREESTYLE_FACE
@ NODE_VECTOR_MATH_MAXIMUM
@ NODE_VECTOR_MATH_MINIMUM
@ NODE_VECTOR_MATH_CROSS_PRODUCT
@ NODE_VECTOR_MATH_NORMALIZE
@ NODE_VECTOR_MATH_SUBTRACT
@ NODE_VECTOR_MATH_DOT_PRODUCT
@ NODE_VECTOR_MATH_LENGTH
@ NODE_VECTOR_MATH_ADD
@ NODE_VECTOR_MATH_ABSOLUTE
ViewLayer * BKE_view_layer_add(const Main *bmain, Scene *scene, const char *name, ViewLayer *view_layer_source, int type)
@ ID_FLAG_EMBEDDED_DATA
Definition DNA_ID.h:775
MINLINE void copy_v4_v4(float r[4], const float a[4])
@ SACTION_SHOW_INTERPOLATION
static void update_voronoi_node_square_distance(bNodeTree *ntree)
@ RGN_FLAG_HIDDEN_BY_USER
static void do_version_bbone_scale_fcurve_fix(ListBaseT< FCurve > *curves, FCurve *fcu)
@ SCE_DISPLAY_AA_SAMPLES_8
@ UNIFIED_PAINT_FLAG_UNUSED_0
@ UNIFIED_PAINT_FLAG_UNUSED_1
bool BKE_paint_ensure_from_paintmode(Scene *sce, PaintMode mode)
void BKE_workspace_tool_remove(WorkSpace *workspace, bToolRef *tref) ATTR_NONNULL(1
Definition workspace.cc:569
static ARegion * do_versions_find_region(ListBaseT< ARegion > *regionbase, int regiontype)
@ SHD_GLOSSY_MULTI_GGX
@ B_UNIT_MASS
Definition BKE_unit.hh:169
@ B_UNIT_LENGTH
Definition BKE_unit.hh:166
@ B_UNIT_TIME
Definition BKE_unit.hh:171
@ CLOTH_COLLSETTINGS_FLAG_ENABLED
@ CLOTH_COLLSETTINGS_FLAG_SELF
static void update_voronoi_node_fac_output(bNodeTree *ntree)
@ eSeqModifierType_HueCorrect
MINLINE int min_ii(int a, int b)
void blo_do_versions_280(FileData *fd, Library *lib, Main *bmain)
static void update_vector_math_node_average_operator(bNodeTree *ntree)
void id_us_min(ID *id)
Definition lib_id.cc:441
static void vector_curve_node_remap(bNode *node)
static void do_versions_local_collection_bits_set(LayerCollection *layer_collection)
static void update_voronoi_node_f3_and_f4(bNodeTree *ntree)
static void do_versions_seq_alloc_transform_and_crop(ListBaseT< Strip > *seqbase)
@ TXT_FLAG_UNUSED_9
@ TXT_FLAG_UNUSED_8
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
WorkSpaceLayout * BKE_workspace_layout_find(const WorkSpace *workspace, const bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition workspace.cc:499
signed char int8_t
Definition BKE_text.h:76
void BKE_screen_remove_double_scredges(bScreen *screen)
Definition screen.cc:901
@ SO_TREESTORE_UNUSED_1
@ XR_SESSION_USE_POSITION_TRACKING
Main * BKE_blender_globals_main_swap(Main *new_gmain)
Definition blender.cc:234
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
ListBaseT< ID > * which_libbase(Main *bmain, short type)
Definition main.cc:1073
@ CUMA_EXTEND_EXTRAPOLATE
@ GP_MATERIAL_FILL_STYLE_CHECKER
@ GP_MATERIAL_FILL_STYLE_TEXTURE
@ GP_MATERIAL_FILL_STYLE_SOLID
@ GP_MATERIAL_FILL_STYLE_GRADIENT
@ VPAINT_BRUSH_TYPE_DRAW
@ VPAINT_BRUSH_TYPE_SMEAR
@ VPAINT_BRUSH_TYPE_AVERAGE
@ VPAINT_BRUSH_TYPE_BLUR
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
#define sqrtf
#define atanf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const NodeType * type
Definition graph/node.h:179
ustring name
Definition graph/node.h:178
struct ARegion * next
bke::ARegionRuntime * runtime
eRegion_Alignment alignment
eRegion_Type regiontype
ListBaseT< FCurve > drivers
ImageFormatData im_format
struct Object * object
DNA_DEPRECATED unsigned int lay
struct CurveProfile * custom_profile
DNA_DEPRECATED int automasking_boundary_edges_propagation_steps
float elastic_deform_volume_preservation
eBrushSculptType sculpt_brush_type
eBrushFlags2 flag2
ListBaseT< DriverVar > variables
CLOTH_COLLISIONSETTINGS_FLAGS flags
struct ClothSimSettings * sim_parms
struct ClothCollSettings * coll_parms
DNA_DEPRECATED float Cdis
DNA_DEPRECATED float structural
DNA_DEPRECATED float max_struct
CLOTH_SIMSETTINGS_FLAGS flags
CLOTH_BENDING_MODEL bending_model
DNA_DEPRECATED unsigned int layer
ListBaseT< CollectionChild > children
ListBaseT< CollectionObject > gobject
struct CurveMapping * curve_mapping
CurveMapPoint * curve
DNA_DEPRECATED short flag
eCurveMappingFlags flag
ListBaseT< Nurb > nurb
struct Key * key
struct CurveMapping curve_mapping
ListBaseT< Strip > seqbase
bActionGroup * grp
ChannelDriver * driver
BlendFileReadReport * reports
Definition readfile.hh:208
std::unique_ptr< SDNA > filesdna
Definition readfile.hh:111
eFileSel_Params_Flag flag
struct FluidDomainSettings * domain
ListBaseT< LineStyleModifier > alpha_modifiers
ListBaseT< LineStyleModifier > thickness_modifiers
struct CurveMapping * cur_falloff
struct CurveMapping * cur_primitive
struct CurveMapping * curfalloff
char name[258]
Definition DNA_ID.h:433
struct Library * lib
Definition DNA_ID.h:421
short flag
Definition DNA_ID.h:439
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
char elemstr[32]
ListBaseT< KeyBlock > block
eLayerCollection_Flag flag
ListBaseT< LayerCollection > layer_collections
unsigned short local_collections_bits
eLineStyleModifier_Type type
ListBaseT< wmWindowManager > wm
Definition BKE_main.hh:415
ListBaseT< Collection > collections
Definition BKE_main.hh:406
ListBaseT< bArmature > armatures
Definition BKE_main.hh:407
ListBaseT< bGPdata > gpencils
Definition BKE_main.hh:417
ListBaseT< Camera > cameras
Definition BKE_main.hh:397
ListBaseT< FreestyleLineStyle > linestyles
Definition BKE_main.hh:421
ListBaseT< Text > texts
Definition BKE_main.hh:402
bool is_locked_for_linking
Definition BKE_main.hh:313
ListBaseT< Light > lights
Definition BKE_main.hh:396
ListBaseT< World > worlds
Definition BKE_main.hh:399
ListBaseT< Brush > brushes
Definition BKE_main.hh:410
ListBaseT< Material > materials
Definition BKE_main.hh:392
ListBaseT< Object > objects
Definition BKE_main.hh:388
ListBaseT< Curve > curves
Definition BKE_main.hh:390
ListBaseT< Mesh > meshes
Definition BKE_main.hh:389
ListBaseT< WorkSpace > workspaces
Definition BKE_main.hh:423
ListBaseT< ParticleSettings > particles
Definition BKE_main.hh:411
ListBaseT< Image > images
Definition BKE_main.hh:394
ListBaseT< bAction > actions
Definition BKE_main.hh:408
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
ListBaseT< LightProbe > lightprobes
Definition BKE_main.hh:404
ListBaseT< Tex > textures
Definition BKE_main.hh:393
ListBaseT< bScreen > screens
Definition BKE_main.hh:400
eMaterialGPencilStyle_Flag flag
DNA_DEPRECATED float gradient_shift[2]
DNA_DEPRECATED float gradient_scale[2]
DNA_DEPRECATED float texture_opacity
eMaterialGPencilStyle_FillStyle fill_style
DNA_DEPRECATED float gradient_angle
CustomData corner_data
eMesh_Flag flag
CustomData face_data
struct ModifierData * next
DNA_DEPRECATED int color_space
DNA_DEPRECATED int color_space
DNA_DEPRECATED int dimensions
DNA_DEPRECATED int coloring
struct PartDeflect * pd
ListBaseT< ModifierData > modifiers
ListBaseT< ShaderFxData > shader_fx
ListBaseT< GpencilModifierData > greasepencil_modifiers
eObject_Partype partype
ListBaseT< bConstraint > constraints
eObject_ShapeFlag shapeflag
DNA_DEPRECATED unsigned int lay
eObject_NlaFlag nlaflag
eObject_EmptyImageVisibilityFlag empty_image_visibility_flag
eObject_TransFlag transflag
struct bPose * pose
struct RigidBodyCon * rigidbody_constraint
struct SoftBody * soft
struct CurveMapping * cavity_curve
struct CurveMapping * twistcurve
struct CurveMapping * clumpcurve
struct CurveMapping * roughcurve
struct ClothModifierData * clmd
ListBaseT< SceneRenderLayer > layers
DNA_DEPRECATED short actlay
struct CurveMapping mblur_shutter_curve
ImageFormatData im_format
struct FFMpegCodecData ffcodecdata
DNA_DEPRECATED struct PointCache * pointcache
struct RigidBodyWorld_Shared * shared
ListBaseT< PointCache > ptcaches
eSceneDisplay_AA render_aa
eSceneDisplay_AA viewport_aa
DNA_DEPRECATED int motion_blur_samples
DNA_DEPRECATED float gtao_distance
DNA_DEPRECATED int shadow_cube_size_deprecated
eSceneEEVEE_Flag flag
DNA_DEPRECATED float motion_blur_shutter_deprecated
ListBaseT< ViewLayer > view_layers
struct Editing * ed
TransformOrientationSlot orientation_slots[4]
struct SceneDisplay display
struct Collection * master_collection
DNA_DEPRECATED struct Base * basact
ColorManagedViewSettings view_settings
struct UnitSettings unit
ListBaseT< TransformOrientation > transform_spaces
ListBaseT< Base > base
View3DCursor cursor
IDProperty * layer_properties
DNA_DEPRECATED unsigned int lay
struct RenderData r
struct SceneEEVEE eevee
struct ToolSettings * toolsettings
struct SceneGpencil grease_pencil_settings
struct RigidBodyWorld * rigidbody_world
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
struct SpaceType * type
ListBaseT< PointCache > ptcaches
struct SoftBody_Shared * shared
DNA_DEPRECATED struct PointCache * pointcache
ListBaseT< PointCache > ptcaches
DNA_DEPRECATED bAction * action
eAnimEdit_Context mode
ListBaseT< struct ARegion > regionbase
struct MovieClip * clip
FileSelectParams * params
struct wmOperator * op
eGraphEdit_Flag flag
struct bGPdata * gpd
eSpaceImage_Flag flag
eSpaceNla_Flag flag
eSpaceNode_Flag flag
eSpaceOutliner_Mode outlinevis
eSpaceOutliner_Flag flag
eSpaceOutliner_Filter filter
eSpaceOutliner_StoreFlag storeflag
eSpaceOutliner_ShowRestrictFlag show_restrict_flags
struct BLI_mempool * treestore
eSpaceButtons_Flag flag
eSpaceSeq_Flag flag
SpaceLink *(*) create(const ScrArea *area, const Scene *scene)
eEffectSpeedControlFlags flags
char name[FILE_MAXFILE]
eTexMapping_Type type
eTexMapping_Flag flag
DNA_DEPRECATED struct UnifiedPaintSettings unified_paint_settings
struct ParticleEditSettings particle
struct CurveProfile * custom_bevel_profile_preset
struct ImagePaintSettings imapaint
struct GP_Interpolate_Settings gp_interpolate
eGPencil_Placement_Flags annotate_v3d_align
struct GP_Sculpt_Settings gp_sculpt
eSnapTransformMode snap_transform_mode_flag
eTreeStoreElem_Flag flag
eUnifiedPaintSettingsFlags flag
eView2D_Scroll scroll
eView3DOverlay_Flag flag
eView3DOverlay_EditFlag edit_flag
eV3DShadingColorType color_type
eView3DShading_Flag flag
struct IDProperty * prop
eV3DShadingColorType wire_color_type
eV3DShadingLightingMode light
eView3D_GridFlag gridflag
View3DOverlay overlay
eView3D_Flag2 flag2
eView3D_GizmoShowArmature gizmo_show_armature
eView3D_GizmoShowCamera gizmo_show_camera
eView3D_GPFlag gp_flag
eView3D_GizmoShowLight gizmo_show_light
eView3D_GizmoShowEmpty gizmo_show_empty
View3DShading shading
DNA_DEPRECATED char drawtype
struct FreestyleConfig freestyle_config
ListBaseT< LayerCollection > layer_collections
struct IDProperty * id_properties
eViewLayer_Flag flag
struct World * world_override
struct Material * mat_override
struct CurveMapping * curfalloff
ListBaseT< bToolRef > tools
ListBaseT< FCurve > channels
ListBaseT< FCurve > curves
ListBaseT< Bone > bonebase
eBConstraint_SpaceTypes ownspace
eDopeSheet_FilterFlag filterflag
ListBaseT< bGPDstroke > strokes
ListBaseT< bGPDframe > frames
ListBaseT< bGPDpalettecolor > colors
DNA_DEPRECATED char colorname[128]
ListBaseT< bGPDpalette > palettes
ListBaseT< bGPDlayer > layers
eNodeSocketDatatype type
struct bNodeLink * link
struct bNodeSocket * next
ListBaseT< bNodeLink > links
struct AnimData * adt
ListBaseT< bNode > nodes
ListBaseT< bNodeSocket > inputs
DNA_DEPRECATED float scale_out_x
DNA_DEPRECATED float scale_in_x
ListBaseT< struct bConstraint > constraints
DNA_DEPRECATED float scale_out_z
DNA_DEPRECATED float scale_in_z
ListBaseT< bPoseChannel > chanbase
eScreen_State state
ListBaseT< struct ScrVert > vertbase
ListBaseT< struct ScrArea > areabase
DNA_DEPRECATED struct Scene * scene
DNA_DEPRECATED struct bScreen * screen
struct WorkSpaceInstanceHook * workspace_hook
#define PAINT_BLEND_DIFFERENCE
#define PAINT_BLEND_EXCLUSION
#define PAINT_BLEND_COLORDODGE
#define PAINT_BLEND_SATURATION
#define EEVEE_GET_FLOAT(_props, _name)
#define PAINT_BLEND_SUB
#define PAINT_BLEND_LUMINOSITY
#define PAINT_BLEND_HARDLIGHT
#define PAINT_BLEND_AVERAGE
#define EEVEE_GET_BOOL(_props, _name, _flag)
#define PAINT_BLEND_BLUR
#define EEVEE_GET_INT(_props, _name)
#define PAINT_BLEND_ALPHA_ADD
#define PAINT_BLEND_OVERLAY
#define PAINT_BLEND_ALPHA_SUB
#define CUMA_EXTEND_EXTRAPOLATE_OLD
#define PAINT_BLEND_SOFTLIGHT
#define PAINT_BLEND_SMEAR
#define PAINT_BLEND_SCREEN
#define PAINT_BLEND_LIGHTEN
#define PAINT_BLEND_MIX
#define PAINT_BLEND_DARKEN
#define PAINT_BLEND_MUL
#define PAINT_BLEND_ADD
#define PAINT_BLEND_HUE