Blender V5.3
versioning_500.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#define DNA_DEPRECATED_ALLOW
10
11#include <fmt/format.h>
12
13#include "MEM_guardedalloc.h"
14
15/* Define macros in `DNA_genfile.h`. */
16#define DNA_GENFILE_VERSIONING_MACROS
17
18#include "DNA_ID.h"
19#include "DNA_brush_types.h"
20#include "DNA_camera_types.h"
21#include "DNA_curves_types.h"
22#include "DNA_genfile.h"
24#include "DNA_layer_types.h"
25#include "DNA_material_types.h"
26#include "DNA_mesh_types.h"
27#include "DNA_modifier_types.h"
28#include "DNA_node_types.h"
29#include "DNA_rigidbody_types.h"
30#include "DNA_scene_types.h"
31#include "DNA_screen_types.h"
32#include "DNA_sequence_types.h"
34#include "DNA_workspace_types.h"
35#include "DNA_world_types.h"
36
37#include "BLI_function_ref.hh"
38#include "BLI_listbase.hh"
39#include "BLI_math_color_c.hh"
40#include "BLI_math_vector.hh"
41#include "BLI_math_vector_c.hh"
43#include "BLI_set.hh"
44#include "BLI_string_ref.hh"
45#include "BLI_string_utf8.hh"
46#include "BLI_string_utils.hh"
47#include "BLI_sys_types.hh"
48
49#include "BKE_anim_data.hh"
50#include "BKE_animsys.hh"
51#include "BKE_armature.hh"
53#include "BKE_colortools.hh"
54#include "BKE_curves.hh"
55#include "BKE_grease_pencil.hh"
56#include "BKE_idprop.hh"
57#include "BKE_image_format.hh"
58#include "BKE_lib_id.hh"
59#include "BKE_main.hh"
61#include "BKE_node.hh"
63#include "BKE_node_runtime.hh"
64#include "BKE_paint.hh"
65#include "BKE_pointcache.h"
66#include "BKE_report.hh"
67
68#include "RNA_path.hh"
69
70#include "BLT_translation.hh"
71
72#include "BLO_read_write.hh"
73
74#include "SEQ_edit.hh"
75#include "SEQ_effects.hh"
76#include "SEQ_iterator.hh"
77#include "SEQ_modifier.hh"
78#include "SEQ_relations.hh"
79#include "SEQ_sequencer.hh"
80#include "SEQ_utils.hh"
81
82#include "WM_api.hh"
83
84#include "AS_asset_library.hh"
85
86#include "readfile.hh"
87
88#include "versioning_common.hh"
89
90// #include "CLG_log.h"
91
92namespace blender {
93
94// static CLG_LogRef LOG = {"blend.doversion"};
95
96static void idprops_process(IDProperty *idprops, IDProperty **system_idprops)
97{
98 BLI_assert(*system_idprops == nullptr);
99 if (idprops) {
100 /* Other ID pointers have not yet been relinked, do not try to access them for refcounting. */
101 *system_idprops = IDP_CopyProperty_ex(idprops, LIB_ID_CREATE_NO_USER_REFCOUNT);
102 }
103}
104
106{
107 ID *id_iter;
108 FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
109 idprops_process(id_iter->properties, &id_iter->system_properties);
110 }
112
113 for (Scene &scene : bmain->scenes) {
114 for (ViewLayer &view_layer : scene.view_layers) {
115 idprops_process(view_layer.id_properties, &view_layer.system_properties);
116 }
117
118 if (scene.ed != nullptr) {
119 seq::foreach_strip(&scene.ed->seqbase, [](Strip *strip) -> bool {
120 idprops_process(strip->prop, &strip->system_properties);
121 return true;
122 });
123 }
124 }
125
126 for (Object &object : bmain->objects) {
127 if (!object.pose) {
128 continue;
129 }
130 for (bPoseChannel &pchan : object.pose->chanbase) {
131 idprops_process(pchan.prop, &pchan.system_properties);
132 }
133 }
134
135 for (bArmature &armature : bmain->armatures) {
136 for (BoneCollection *bcoll : armature.collections_span()) {
137 idprops_process(bcoll->prop, &bcoll->system_properties);
138 }
139 /* There is no way to iterate directly over all bones of an armature currently, use a recursive
140 * approach instead. */
141 auto process_bone_recursive = [](const auto &process_bone_recursive, Bone *bone) -> void {
142 idprops_process(bone->prop, &bone->system_properties);
143 for (Bone &bone_it : bone->childbase) {
144 process_bone_recursive(process_bone_recursive, &bone_it);
145 }
146 };
147 for (Bone &bone_it : armature.bonebase) {
148 process_bone_recursive(process_bone_recursive, &bone_it);
149 }
150 }
151}
153{
154 /* Separate callback for nodes,
155 * because they had the split implemented later. */
156
157 FOREACH_NODETREE_BEGIN (bmain, node_tree, id_owner) {
158 for (bNode &node : node_tree->nodes) {
159 idprops_process(node.prop, &node.system_properties);
160 }
161 }
163}
165{
166 /* Separate callback for non-root bones,
167 * because they were missed in the initial implementation. */
168
169 for (bArmature &armature : bmain->armatures) {
170 /* There is no way to iterate directly over all bones of an armature currently, use a recursive
171 * approach instead. */
172 auto process_bone_recursive = [](const auto &process_bone_recursive, Bone *bone) -> void {
173 /* Do not overwrite children bones' system properties if they were already defined by some
174 * scripts or add-on e.g. */
175 if (bone->system_properties == nullptr) {
176 idprops_process(bone->prop, &bone->system_properties);
177 }
178 for (Bone &bone_it : bone->childbase) {
179 process_bone_recursive(process_bone_recursive, &bone_it);
180 }
181 };
182 for (Bone &bone_it : armature.bonebase) {
183 for (Bone &bone_child_it : bone_it.childbase) {
184 process_bone_recursive(process_bone_recursive, &bone_child_it);
185 }
186 }
187 }
188}
189
191{
192 for (CustomDataLayer &layer : MutableSpan(custom_data.layers, custom_data.totlayer)) {
193 if (layer.name == name) {
194 return &layer;
195 }
196 }
197 return nullptr;
198}
199
201{
202 CustomDataLayer *old_seam_layer = find_old_seam_layer(mesh.edge_data, ".uv_seam");
203 if (!old_seam_layer) {
204 return;
205 }
206 Set<StringRef> names;
207 for (const CustomDataLayer &layer : Span(mesh.vert_data.layers, mesh.vert_data.totlayer)) {
208 if (layer.type & CD_MASK_PROP_ALL) {
209 names.add(layer.name);
210 }
211 }
212 for (const CustomDataLayer &layer : Span(mesh.edge_data.layers, mesh.edge_data.totlayer)) {
213 if (layer.type & CD_MASK_PROP_ALL) {
214 names.add(layer.name);
215 }
216 }
217 for (const CustomDataLayer &layer : Span(mesh.face_data.layers, mesh.face_data.totlayer)) {
218 if (layer.type & CD_MASK_PROP_ALL) {
219 names.add(layer.name);
220 }
221 }
222 for (const CustomDataLayer &layer : Span(mesh.corner_data.layers, mesh.corner_data.totlayer)) {
223 if (layer.type & CD_MASK_PROP_ALL) {
224 names.add(layer.name);
225 }
226 }
227 for (const bDeformGroup &vertex_group : mesh.vertex_group_names) {
228 names.add(vertex_group.name);
229 }
230
231 /* If the new UV name is already taken, still rename the attribute so it becomes visible in the
232 * list. Then the user can deal with the name conflict themselves. */
233 const std::string new_name = BLI_uniquename_cb(
234 [&](const StringRef name) { return names.contains(name); }, '.', "uv_seam");
235 STRNCPY_UTF8(old_seam_layer->name, new_name.c_str());
236}
237
238static void update_brush_sizes(Main &bmain)
239{
240 /* This conversion was originally done in 582c7d94b8, between subversion 1 (84bee96757) and
241 * subversion 2 (fa03c53d4a). The original change should have come with a subversion bump to be
242 * filled in later, but since it didn't, the best we can do is use subversion 1 for this check.
243 * Thankfully, this only results in a single day window in which a user would have had to
244 * download the build where this versioning was not correctly applied. */
245 for (Brush &brush : bmain.brushes) {
246 brush.size *= 2;
247 brush.unprojected_size *= 2.0f;
248 }
249
250 auto apply_to_paint = [&](Paint *paint) {
251 if (paint == nullptr) {
252 return;
253 }
254 UnifiedPaintSettings &ups = paint->unified_paint_settings;
255
256 ups.size *= 2;
257 ups.unprojected_size *= 2.0f;
258 };
259
260 for (Scene &scene : bmain.scenes) {
263 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->vpaint));
264 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->wpaint));
265 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->sculpt));
266 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_paint));
267 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_vertexpaint));
268 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_sculptpaint));
269 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_weightpaint));
270 apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->curves_sculpt));
271 apply_to_paint(reinterpret_cast<Paint *>(&scene.toolsettings->imapaint));
272 }
273}
274
276{
277 for (bNode &node : ntree.nodes) {
278 if (node.type_legacy == NODE_EVALUATE_CLOSURE) {
279 auto *storage = static_cast<NodeEvaluateClosure *>(node.storage);
280 if (!storage) {
281 /* Can happen with certain files saved in 4.5 which did not officially support closures
282 * yet. */
283 continue;
284 }
285 for (const int i : IndexRange(storage->input_items.items_num)) {
286 NodeEvaluateClosureInputItem &item = storage->input_items.items[i];
289 }
290 }
291 for (const int i : IndexRange(storage->output_items.items_num)) {
292 NodeEvaluateClosureOutputItem &item = storage->output_items.items[i];
295 }
296 }
297 }
298 }
299}
300
302{
303 /* In geometry nodes, replace shader combine/separate color nodes with function nodes */
304 if (ntree->type == NTREE_GEOMETRY) {
309
314
315 for (bNode &node : ntree->nodes) {
316 switch (node.type_legacy) {
318 node.type_legacy = FN_NODE_COMBINE_COLOR;
319 NodeCombSepColor *storage = MEM_new<NodeCombSepColor>(__func__);
321 STRNCPY_UTF8(node.idname, "FunctionNodeCombineColor");
322 node.storage = storage;
323 break;
324 }
326 node.type_legacy = FN_NODE_SEPARATE_COLOR;
327 NodeCombSepColor *storage = MEM_new<NodeCombSepColor>(__func__);
329 STRNCPY_UTF8(node.idname, "FunctionNodeSeparateColor");
330
331 node.storage = storage;
332 break;
333 }
334 }
335 }
336 }
337
338 /* In compositing nodes, replace combine/separate RGBA/HSVA/YCbCrA/YCCA nodes with
339 * combine/separate color */
340 if (ntree->type == NTREE_COMPOSIT) {
345
350
355
360
365
370
375
380
381 for (bNode &node : ntree->nodes) {
382 switch (node.type_legacy) {
384 node.type_legacy = CMP_NODE_COMBINE_COLOR;
385 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
387 STRNCPY_UTF8(node.idname, "CompositorNodeCombineColor");
388 node.storage = storage;
389 break;
390 }
392 node.type_legacy = CMP_NODE_COMBINE_COLOR;
393 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
395 STRNCPY_UTF8(node.idname, "CompositorNodeCombineColor");
396 node.storage = storage;
397 break;
398 }
400 node.type_legacy = CMP_NODE_COMBINE_COLOR;
401 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
403 storage->ycc_mode = node.custom1;
404 STRNCPY_UTF8(node.idname, "CompositorNodeCombineColor");
405 node.storage = storage;
406 break;
407 }
409 node.type_legacy = CMP_NODE_COMBINE_COLOR;
410 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
412 STRNCPY_UTF8(node.idname, "CompositorNodeCombineColor");
413 node.storage = storage;
414 break;
415 }
417 node.type_legacy = CMP_NODE_SEPARATE_COLOR;
418 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
420 STRNCPY_UTF8(node.idname, "CompositorNodeSeparateColor");
421 node.storage = storage;
422 break;
423 }
425 node.type_legacy = CMP_NODE_SEPARATE_COLOR;
426 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
428 STRNCPY_UTF8(node.idname, "CompositorNodeSeparateColor");
429 node.storage = storage;
430 break;
431 }
433 node.type_legacy = CMP_NODE_SEPARATE_COLOR;
434 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
436 storage->ycc_mode = node.custom1;
437 STRNCPY_UTF8(node.idname, "CompositorNodeSeparateColor");
438 node.storage = storage;
439 break;
440 }
442 node.type_legacy = CMP_NODE_SEPARATE_COLOR;
443 NodeCMPCombSepColor *storage = MEM_new<NodeCMPCombSepColor>(__func__);
445 STRNCPY_UTF8(node.idname, "CompositorNodeSeparateColor");
446 node.storage = storage;
447 break;
448 }
449 }
450 }
451 }
452
453 /* In texture nodes, replace combine/separate RGBA with combine/separate color */
454 if (ntree->type == NTREE_TEXTURE) {
455 for (bNode &node : ntree->nodes) {
456 switch (node.type_legacy) {
458 node.type_legacy = TEX_NODE_COMBINE_COLOR;
460 STRNCPY_UTF8(node.idname, "TextureNodeCombineColor");
461 break;
462 }
464 node.type_legacy = TEX_NODE_SEPARATE_COLOR;
466 STRNCPY_UTF8(node.idname, "TextureNodeSeparateColor");
467 break;
468 }
469 }
470 }
471 }
472
473 /* In shader nodes, replace combine/separate RGB/HSV with combine/separate color */
474 if (ntree->type == NTREE_SHADER) {
479
483
488
492
493 for (bNode &node : ntree->nodes) {
494 switch (node.type_legacy) {
496 node.type_legacy = SH_NODE_COMBINE_COLOR;
497 NodeCombSepColor *storage = MEM_new<NodeCombSepColor>(__func__);
499 STRNCPY_UTF8(node.idname, "ShaderNodeCombineColor");
500 node.storage = storage;
501 break;
502 }
504 node.type_legacy = SH_NODE_COMBINE_COLOR;
505 NodeCombSepColor *storage = MEM_new<NodeCombSepColor>(__func__);
507 STRNCPY_UTF8(node.idname, "ShaderNodeCombineColor");
508 node.storage = storage;
509 break;
510 }
512 node.type_legacy = SH_NODE_SEPARATE_COLOR;
513 NodeCombSepColor *storage = MEM_new<NodeCombSepColor>(__func__);
515 STRNCPY_UTF8(node.idname, "ShaderNodeSeparateColor");
516 node.storage = storage;
517 break;
518 }
520 node.type_legacy = SH_NODE_SEPARATE_COLOR;
521 NodeCombSepColor *storage = MEM_new<NodeCombSepColor>(__func__);
523 STRNCPY_UTF8(node.idname, "ShaderNodeSeparateColor");
524 node.storage = storage;
525 break;
526 }
527 }
528 }
529 }
530}
531
532/* "Use Nodes" was removed. */
534{
535 if (scene->nodetree == nullptr && scene->compositing_node_group == nullptr) {
536 /* scene->use_nodes is set to false by default. Files saved without compositing node trees
537 * should not disable compositing. */
538 return;
539 }
540 if (scene->use_nodes == false && scene->r.scemode & R_DOCOMP) {
541 /* A compositing node tree exists but users explicitly disabled compositing. */
542 scene->r.scemode &= ~R_DOCOMP;
543 }
544 /* Ignore use_nodes otherwise. */
545}
546
547/* The Dot output of the Normal node was removed, so replace it with a dot product vector math
548 * node, noting that the Dot output was actually negative the dot product of the normalized
549 * node vector with the input. */
551{
552 bNodeSocket *normal_input = bke::node_find_socket(*node, SOCK_IN, "Normal"_ustr);
553 bNodeSocket *normal_output = bke::node_find_socket(*node, SOCK_OUT, "Normal"_ustr);
554 bNodeSocket *dot_output = bke::node_find_socket(*node, SOCK_OUT, "Dot"_ustr);
555
556 /* Find the links going into and out from the node. */
557 bNodeLink *normal_input_link = nullptr;
558 bool is_normal_ontput_needed = false;
559 bool is_dot_output_used = false;
560 for (bNodeLink &link : node_tree->links) {
561 if (link.tosock == normal_input) {
562 normal_input_link = &link;
563 }
564
565 if (link.fromsock == normal_output) {
566 is_normal_ontput_needed = true;
567 }
568
569 if (link.fromsock == dot_output) {
570 is_dot_output_used = true;
571 }
572 }
573
574 /* The dot output is unused, nothing to do. */
575 if (!is_dot_output_used) {
576 return;
577 }
578
579 /* Take the dot product with negative the node normal. */
580 bNode *dot_product_node = bke::node_add_node(nullptr, *node_tree, "ShaderNodeVectorMath"_ustr);
581 dot_product_node->custom1 = NODE_VECTOR_MATH_DOT_PRODUCT;
582 dot_product_node->flag |= NODE_COLLAPSED;
583 dot_product_node->parent = node->parent;
584 dot_product_node->location[0] = node->location[0];
585 dot_product_node->location[1] = node->location[1];
586
587 bNodeSocket *dot_product_a_input = bke::node_find_socket(
588 *dot_product_node, SOCK_IN, "Vector"_ustr);
589 bNodeSocket *dot_product_b_input = bke::node_find_socket(
590 *dot_product_node, SOCK_IN, "Vector_001"_ustr);
591 bNodeSocket *dot_product_output = bke::node_find_socket(
592 *dot_product_node, SOCK_OUT, "Value"_ustr);
593
594 copy_v3_v3(static_cast<bNodeSocketValueVector *>(dot_product_a_input->default_value)->value,
595 static_cast<bNodeSocketValueVector *>(normal_input->default_value)->value);
596
597 if (normal_input_link) {
598 version_node_add_link(*node_tree,
599 *normal_input_link->fromnode,
600 *normal_input_link->fromsock,
601 *dot_product_node,
602 *dot_product_a_input);
603 bke::node_remove_link(node_tree, *normal_input_link);
604 }
605
606 /* Notice that we normalize and take the negative to reproduce the same behavior as the old
607 * Normal node. */
608 const float3 node_normal = normal_output->default_value_typed<bNodeSocketValueVector>()->value;
609 const float3 normalized_node_normal = -math::normalize(node_normal);
610 copy_v3_v3(static_cast<bNodeSocketValueVector *>(dot_product_b_input->default_value)->value,
611 normalized_node_normal);
612
613 for (bNodeLink &link : node_tree->links.items_mutable()) {
614 if (link.fromsock != dot_output) {
615 continue;
616 }
617
619 *node_tree, *dot_product_node, *dot_product_output, *link.tonode, *link.tosock);
620 bke::node_remove_link(node_tree, link);
621 }
622
623 /* If only the Dot output was used, remove the node, making sure to initialize the node types to
624 * allow removal. */
625 if (!is_normal_ontput_needed) {
626 bke::node_tree_set_type(*node_tree);
627 version_node_remove(*node_tree, *node);
628 }
629}
630
632{
633 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
634 return;
635 }
636 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
637 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
638}
639
641{
642 if (bke::node_find_socket(node, SOCK_IN, "Resolution Mode"_ustr)) {
643 return;
644 }
646 return;
647 }
649 node.storage);
651 ntree, node, SOCK_IN, "NodeSocketMenu", "Resolution Mode");
652 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.resolution_mode;
653}
654
656{
657 if (!bke::node_find_socket(node, SOCK_IN, "Quad Method"_ustr)) {
659 ntree, node, SOCK_IN, "NodeSocketMenu", "Quad Method");
660 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
661 }
662 if (!bke::node_find_socket(node, SOCK_IN, "N-gon Method"_ustr)) {
664 ntree, node, SOCK_IN, "NodeSocketMenu", "N-gon Method");
665 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2;
666 }
667}
668
670{
671 if (bke::node_find_socket(node, SOCK_IN, "Resolution Mode"_ustr)) {
672 return;
673 }
675 return;
676 }
677 const NodeGeometryVolumeToMesh &storage = *static_cast<NodeGeometryVolumeToMesh *>(node.storage);
679 ntree, node, SOCK_IN, "NodeSocketMenu", "Resolution Mode");
680 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.resolution_mode;
681}
682
684{
685 if (bke::node_find_socket(node, SOCK_IN, "Operation"_ustr)) {
686 return;
687 }
689 ntree, node, SOCK_IN, "NodeSocketMenu", "Operation");
690 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
691}
692
694{
695 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
696 return;
697 }
699 return;
700 }
701 const auto &storage = *static_cast<NodeGeometryCurveFill *>(node.storage);
702 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
703 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.mode;
704}
705
707{
708 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
709 return;
710 }
712 return;
713 }
714 const auto &storage = *static_cast<NodeGeometryCurveFillet *>(node.storage);
715 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
716 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.mode;
717}
718
720{
721 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
722 return;
723 }
725 return;
726 }
727 const auto &storage = *static_cast<NodeGeometryCurveResample *>(node.storage);
728 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
729 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.mode;
730}
731
733{
734 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
735 return;
736 }
738 return;
739 }
740 const auto &storage = *static_cast<NodeGeometryDistributePointsInVolume *>(node.storage);
741 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
742 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.mode;
743}
744
746{
747 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
748 return;
749 }
751 return;
752 }
753 const auto &storage = *static_cast<NodeGeometryMergeByDistance *>(node.storage);
754 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
755 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.mode;
756}
757
759{
760 if (bke::node_find_socket(node, SOCK_IN, "Resolution Mode"_ustr)) {
761 return;
762 }
764 return;
765 }
766 const auto &storage = *static_cast<NodeGeometryMeshToVolume *>(node.storage);
768 ntree, node, SOCK_IN, "NodeSocketMenu", "Resolution Mode");
769 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.resolution_mode;
770}
771
773{
774 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
775 return;
776 }
778 return;
779 }
780 const auto &storage = *static_cast<NodeGeometryRaycast *>(node.storage);
782 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
783 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.mapping;
784}
785
787{
788 if (bke::node_find_socket(node, SOCK_IN, "Pattern Mode"_ustr)) {
789 return;
790 }
792 ntree, node, SOCK_IN, "NodeSocketMenu", "Pattern Mode");
793 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
794}
795
797{
798 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
799 return;
800 }
802 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
803 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2;
804}
805
807{
808 if (bke::node_find_socket(node, SOCK_IN, "Scale Mode"_ustr)) {
809 return;
810 }
812 ntree, node, SOCK_IN, "NodeSocketMenu", "Scale Mode");
813 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2;
814}
815
817{
818 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
819 return;
820 }
821 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
822 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
823}
824
826{
828 return;
829 }
830 auto &storage = *static_cast<NodeGeometrySubdivisionSurface *>(node.storage);
831 if (!bke::node_find_socket(node, SOCK_IN, "UV Smooth"_ustr)) {
833 ntree, node, SOCK_IN, "NodeSocketMenu", "UV Smooth");
834 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.uv_smooth;
835 }
836 if (!bke::node_find_socket(node, SOCK_IN, "Boundary Smooth"_ustr)) {
838 ntree, node, SOCK_IN, "NodeSocketMenu", "Boundary Smooth");
839 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.boundary_smooth;
840 }
841}
842
844{
845 if (bke::node_find_socket(node, SOCK_IN, "Method"_ustr)) {
846 return;
847 }
848 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Method");
849 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
850}
851
853{
854 if (bke::node_find_socket(node, SOCK_IN, "Method"_ustr)) {
855 return;
856 }
858 return;
859 }
860 const auto &storage = *static_cast<NodeGeometryUVUnwrap *>(node.storage);
861 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Method");
862 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.method;
863}
864
866{
867 for (Scene &scene : bmain->scenes) {
868 if (scene.ed != nullptr) {
869 seq::foreach_strip(&scene.ed->seqbase, [&](Strip *strip) -> bool {
870 if (strip->type == STRIP_TYPE_TEXT && strip->effectdata != nullptr) {
871 TextVars *data = static_cast<TextVars *>(strip->effectdata);
872 if (data->text_ptr == nullptr) {
873 data->text_ptr = BLI_strdup(data->text_legacy);
874 data->text_len_bytes = strlen(data->text_ptr);
875 }
876 }
877 return true;
878 });
879 }
880 }
881}
882
884 FunctionRef<void(Scene &scene, Paint *paint)> func)
885{
886 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->vpaint));
887 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->wpaint));
888 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->sculpt));
889 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->gp_paint));
890 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->gp_vertexpaint));
891 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->gp_sculptpaint));
892 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->gp_weightpaint));
893 func(scene, reinterpret_cast<Paint *>(scene.toolsettings->curves_sculpt));
894 func(scene, reinterpret_cast<Paint *>(&scene.toolsettings->imapaint));
895}
896
898{
899 if (paint == nullptr) {
900 return;
901 }
902
904 UnifiedPaintSettings &ups = paint->unified_paint_settings;
905
906 ups.size = scene_ups.size;
907 ups.unprojected_size = scene_ups.unprojected_size;
908 ups.alpha = scene_ups.alpha;
909 ups.weight = scene_ups.weight;
910 copy_v3_v3(ups.color, scene_ups.color);
911 copy_v3_v3(ups.rgb, scene_ups.rgb);
913 copy_v3_v3(ups.secondary_rgb, scene_ups.secondary_rgb);
914 ups.color_jitter_flag = scene_ups.color_jitter_flag;
915 copy_v3_v3(ups.hsv_jitter, scene_ups.hsv_jitter);
916
917 BLI_assert(ups.curve_rand_hue == nullptr);
918 BLI_assert(ups.curve_rand_saturation == nullptr);
919 BLI_assert(ups.curve_rand_value == nullptr);
923 ups.flag = scene_ups.flag;
924}
925
926/* The Use Alpha option is does not exist in the new generic Mix node, it essentially just
927 * multiplied the factor by the alpha of the second input. */
929{
930 if (!(node->custom2 & SHD_MIXRGB_USE_ALPHA)) {
931 return;
932 }
933
934 bke::node_tree_set_type(*node_tree);
935
936 bNodeSocket *factor_input = bke::node_find_socket(*node, SOCK_IN, "Factor_Float"_ustr);
937 bNodeSocket *b_input = bke::node_find_socket(*node, SOCK_IN, "B_Color"_ustr);
938
939 /* Find the links going into the factor and B input of the Mix node. */
940 bNodeLink *factor_link = nullptr;
941 bNodeLink *b_link = nullptr;
942 for (bNodeLink &link : node_tree->links) {
943 if (link.tosock == factor_input) {
944 factor_link = &link;
945 }
946 else if (link.tosock == b_input) {
947 b_link = &link;
948 }
949 }
950
951 /* If neither sockets are connected, just multiply the factor by the alpha of the B input. */
952 if (!factor_link && !b_link) {
953 static_cast<bNodeSocketValueFloat *>(factor_input->default_value)->value *=
954 static_cast<bNodeSocketValueRGBA *>(b_input->default_value)->value[3];
955 return;
956 }
957
958 /* Otherwise, add a multiply node to do the multiplication. */
959 bNode *multiply_node = bke::node_add_static_node(nullptr, *node_tree, SH_NODE_MATH);
960 multiply_node->parent = node->parent;
961 multiply_node->custom1 = NODE_MATH_MULTIPLY;
962 multiply_node->location[0] = node->location[0] - node->width - 20.0f;
963 multiply_node->location[1] = node->location[1];
964 multiply_node->flag |= NODE_COLLAPSED;
965
966 bNodeSocket *multiply_input_a = static_cast<bNodeSocket *>(
967 BLI_findlink(&multiply_node->inputs, 0));
968 bNodeSocket *multiply_input_b = static_cast<bNodeSocket *>(
969 BLI_findlink(&multiply_node->inputs, 1));
970 bNodeSocket *multiply_output = bke::node_find_socket(*multiply_node, SOCK_OUT, "Value"_ustr);
971
972 /* Connect the output of the multiply node to the math node. */
973 version_node_add_link(*node_tree, *multiply_node, *multiply_output, *node, *factor_input);
974
975 if (factor_link) {
976 /* The factor input is linked, so connect its origin to the first input of the multiply and
977 * remove the original link. */
978 version_node_add_link(*node_tree,
979 *factor_link->fromnode,
980 *factor_link->fromsock,
981 *multiply_node,
982 *multiply_input_a);
983 bke::node_remove_link(node_tree, *factor_link);
984 }
985 else {
986 /* Otherwise, the factor is unlinked and we just copy the factor value to the first input in
987 * the multiply. */
988 static_cast<bNodeSocketValueFloat *>(multiply_input_a->default_value)->value =
989 static_cast<bNodeSocketValueFloat *>(factor_input->default_value)->value;
990 }
991
992 if (b_link) {
993 /* The B input is linked, so extract the alpha of its origin and connect it to the second input
994 * of the multiply and remove the original link. */
995 bNode *separate_color_node = bke::node_add_static_node(
996 nullptr, *node_tree, CMP_NODE_SEPARATE_COLOR);
997 separate_color_node->parent = node->parent;
998 separate_color_node->location[0] = multiply_node->location[0] - multiply_node->width - 20.0f;
999 separate_color_node->location[1] = multiply_node->location[1];
1000 separate_color_node->flag |= NODE_COLLAPSED;
1001
1002 bNodeSocket *image_input = bke::node_find_socket(*separate_color_node, SOCK_IN, "Image"_ustr);
1003 bNodeSocket *alpha_output = bke::node_find_socket(
1004 *separate_color_node, SOCK_OUT, "Alpha"_ustr);
1005
1007 *node_tree, *b_link->fromnode, *b_link->fromsock, *separate_color_node, *image_input);
1009 *node_tree, *separate_color_node, *alpha_output, *multiply_node, *multiply_input_b);
1010 }
1011 else {
1012 /* Otherwise, the B input is unlinked and we just copy the alpha value to the second input in
1013 * the multiply. */
1014 static_cast<bNodeSocketValueFloat *>(multiply_input_b->default_value)->value =
1015 static_cast<bNodeSocketValueRGBA *>(b_input->default_value)->value[3];
1016 }
1017
1019}
1020
1021/* The Map Value node is now deprecated and should be replaced by other nodes. The node essentially
1022 * just computes (value + offset) * size and clamps based on min and max. */
1024{
1025 bke::node_tree_set_type(*node_tree);
1026
1028 return;
1029 }
1030 const TexMapping &texture_mapping = *static_cast<TexMapping *>(node->storage);
1031 const bool use_min = texture_mapping.flag & TEXMAP_CLIP_MIN;
1032 const bool use_max = texture_mapping.flag & TEXMAP_CLIP_MAX;
1033 const float offset = texture_mapping.loc[0];
1034 const float size = texture_mapping.size[0];
1035 const float min = texture_mapping.min[0];
1036 const float max = texture_mapping.max[0];
1037
1038 bNodeSocket *value_input = bke::node_find_socket(*node, SOCK_IN, "Value"_ustr);
1039
1040 /* Find the link going into the value input Map Value node. */
1041 bNodeLink *value_link = nullptr;
1042 for (bNodeLink &link : node_tree->links) {
1043 if (link.tosock == value_input) {
1044 value_link = &link;
1045 }
1046 }
1047
1048 bNode *frame = bke::node_add_static_node(nullptr, *node_tree, NODE_FRAME);
1049 frame->parent = node->parent;
1050 STRNCPY(frame->label, RPT_("Versioning: Map Value node was removed"));
1051 NodeFrame *frame_data = static_cast<NodeFrame *>(frame->storage);
1052 frame_data->label_size = 10;
1053
1054 /* If the value input is not connected, add a value node with the computed value. */
1055 if (!value_link) {
1056 const float value = static_cast<bNodeSocketValueFloat *>(value_input->default_value)->value;
1057 const float mapped_value = (value + offset) * size;
1058 const float min_clamped_value = use_min ? math::max(mapped_value, min) : mapped_value;
1059 const float clamped_value = use_max ? math::min(min_clamped_value, max) : min_clamped_value;
1060
1061 bNode &value_node = version_node_add_empty(*node_tree, "ShaderNodeValue");
1062 bNodeSocket &value_output = version_node_add_socket(
1063 *node_tree, value_node, SOCK_OUT, "NodeSocketFloat", "Value");
1064
1065 value_node.parent = frame;
1066 value_node.location[0] = node->location[0];
1067 value_node.location[1] = node->location[1];
1068
1069 static_cast<bNodeSocketValueFloat *>(value_output.default_value)->value = clamped_value;
1070
1071 /* Relink from the Map Value node to the value node. */
1072 for (bNodeLink &link : node_tree->links.items_reversed_mutable()) {
1073 if (link.fromnode != node) {
1074 continue;
1075 }
1076
1077 version_node_add_link(*node_tree, value_node, value_output, *link.tonode, *link.tosock);
1078 bke::node_remove_link(node_tree, link);
1079 }
1080
1081 MEM_delete(&texture_mapping);
1082 node->storage = nullptr;
1083 version_node_remove(*node_tree, *node);
1084
1086 return;
1087 }
1088
1089 /* Otherwise, add math nodes to do the computation, starting with an add node to add the offset
1090 * of the range. */
1091 bNode &add_node = version_node_add_empty(*node_tree, "ShaderNodeMath");
1092 bNodeSocket &add_input_a = version_node_add_socket(
1093 *node_tree, add_node, SOCK_IN, "NodeSocketFloat", "Value");
1094 bNodeSocket &add_input_b = version_node_add_socket(
1095 *node_tree, add_node, SOCK_IN, "NodeSocketFloat", "Value_001");
1096 version_node_add_socket(*node_tree, add_node, SOCK_IN, "NodeSocketFloat", "Value_002");
1097
1099 *node_tree, add_node, SOCK_OUT, "NodeSocketFloat", "Value");
1100
1101 add_node.parent = frame;
1102 add_node.custom1 = NODE_MATH_ADD;
1103 add_node.location[0] = node->location[0];
1104 add_node.location[1] = node->location[1];
1105 add_node.flag |= NODE_COLLAPSED;
1106
1107 /* Connect the origin of the node to the first input of the add node and remove the original
1108 * link. */
1110 *node_tree, *value_link->fromnode, *value_link->fromsock, add_node, add_input_a);
1111 bke::node_remove_link(node_tree, *value_link);
1112
1113 /* Set the offset to the second input of the add node. */
1114 static_cast<bNodeSocketValueFloat *>(add_input_b.default_value)->value = offset;
1115
1116 /* Add a multiply node to multiply by the size. */
1117 bNode &multiply_node = version_node_add_empty(*node_tree, "ShaderNodeMath");
1118 multiply_node.parent = frame;
1119 multiply_node.custom1 = NODE_MATH_MULTIPLY;
1120 multiply_node.location[0] = add_node.location[0];
1121 multiply_node.location[1] = add_node.location[1] - 40.0f;
1122 multiply_node.flag |= NODE_COLLAPSED;
1123
1124 bNodeSocket &multiply_input_a = version_node_add_socket(
1125 *node_tree, multiply_node, SOCK_IN, "NodeSocketFloat", "Value");
1126 bNodeSocket &multiply_input_b = version_node_add_socket(
1127 *node_tree, multiply_node, SOCK_IN, "NodeSocketFloat", "Value_001");
1128 version_node_add_socket(*node_tree, multiply_node, SOCK_IN, "NodeSocketFloat", "Value_002");
1129
1130 bNodeSocket &multiply_output = version_node_add_socket(
1131 *node_tree, multiply_node, SOCK_OUT, "NodeSocketFloat", "Value");
1132
1133 /* Connect the output of the add node to the first input of the multiply node. */
1134 version_node_add_link(*node_tree, add_node, add_output, multiply_node, multiply_input_a);
1135
1136 /* Set the size to the second input of the multiply node. */
1137 static_cast<bNodeSocketValueFloat *>(multiply_input_b.default_value)->value = size;
1138
1139 bNode *final_node = &multiply_node;
1140 bNodeSocket *final_output = &multiply_output;
1141
1142 if (use_min) {
1143 /* Add a maximum node to clamp by the minimum. */
1144 bNode &max_node = version_node_add_empty(*node_tree, "ShaderNodeMath");
1145 max_node.parent = frame;
1146 max_node.custom1 = NODE_MATH_MAXIMUM;
1147 max_node.location[0] = final_node->location[0];
1148 max_node.location[1] = final_node->location[1] - 40.0f;
1149 max_node.flag |= NODE_COLLAPSED;
1150
1151 bNodeSocket &max_input_a = version_node_add_socket(
1152 *node_tree, max_node, SOCK_IN, "NodeSocketFloat", "Value");
1153 bNodeSocket &max_input_b = version_node_add_socket(
1154 *node_tree, max_node, SOCK_IN, "NodeSocketFloat", "Value_001");
1155 version_node_add_socket(*node_tree, max_node, SOCK_IN, "NodeSocketFloat", "Value_002");
1157 *node_tree, max_node, SOCK_OUT, "NodeSocketFloat", "Value");
1158
1159 /* Connect the output of the final node to the first input of the maximum node. */
1160 version_node_add_link(*node_tree, *final_node, *final_output, max_node, max_input_a);
1161
1162 /* Set the minimum to the second input of the maximum node. */
1163 static_cast<bNodeSocketValueFloat *>(max_input_b.default_value)->value = min;
1164
1165 final_node = &max_node;
1166 final_output = &max_output;
1167 }
1168
1169 if (use_max) {
1170 /* Add a minimum node to clamp by the maximum. */
1171 bNode &min_node = version_node_add_empty(*node_tree, "ShaderNodeMath");
1172 min_node.parent = frame;
1173 min_node.custom1 = NODE_MATH_MINIMUM;
1174 min_node.location[0] = final_node->location[0];
1175 min_node.location[1] = final_node->location[1] - 40.0f;
1176 min_node.flag |= NODE_COLLAPSED;
1177
1178 bNodeSocket &min_input_a = version_node_add_socket(
1179 *node_tree, min_node, SOCK_IN, "NodeSocketFloat", "Value");
1180 bNodeSocket &min_input_b = version_node_add_socket(
1181 *node_tree, min_node, SOCK_IN, "NodeSocketFloat", "Value_001");
1182 version_node_add_socket(*node_tree, min_node, SOCK_IN, "NodeSocketFloat", "Value_002");
1184 *node_tree, min_node, SOCK_OUT, "NodeSocketFloat", "Value");
1185
1186 /* Connect the output of the final node to the first input of the minimum node. */
1187 version_node_add_link(*node_tree, *final_node, *final_output, min_node, min_input_a);
1188
1189 /* Set the maximum to the second input of the minimum node. */
1190 static_cast<bNodeSocketValueFloat *>(min_input_b.default_value)->value = max;
1191
1192 final_node = &min_node;
1193 final_output = &min_output;
1194 }
1195
1196 /* Relink from the Map Value node to the final node. */
1197 for (bNodeLink &link : node_tree->links.items_reversed_mutable()) {
1198 if (link.fromnode != node) {
1199 continue;
1200 }
1201
1202 version_node_add_link(*node_tree, *final_node, *final_output, *link.tonode, *link.tosock);
1203 bke::node_remove_link(node_tree, link);
1204 }
1205
1206 MEM_delete(&texture_mapping);
1207 node->storage = nullptr;
1208
1209 version_node_remove(*node_tree, *node);
1210
1212}
1213
1214/* The compositor Value, Color Ramp, Mix Color, Map Range, Map Value, Math, Combine XYZ, Separate
1215 * XYZ, and Vector Curves nodes are now deprecated and should be replaced by their generic Shader
1216 * node counterpart. */
1218{
1219 for (bNode &node : node_tree->nodes.items_mutable()) {
1220 switch (node.type_legacy) {
1222 node.type_legacy = SH_NODE_VALUE;
1223 STRNCPY_UTF8(node.idname, "ShaderNodeValue");
1224 break;
1226 node.type_legacy = SH_NODE_MATH;
1227 STRNCPY_UTF8(node.idname, "ShaderNodeMath");
1228 break;
1230 node.type_legacy = SH_NODE_COMBXYZ;
1231 STRNCPY_UTF8(node.idname, "ShaderNodeCombineXYZ");
1232 break;
1234 node.type_legacy = SH_NODE_SEPXYZ;
1235 STRNCPY_UTF8(node.idname, "ShaderNodeSeparateXYZ");
1236 break;
1238 node.type_legacy = SH_NODE_CURVE_VEC;
1239 STRNCPY_UTF8(node.idname, "ShaderNodeVectorCurve");
1240 break;
1242 node.type_legacy = SH_NODE_VALTORGB;
1243 STRNCPY_UTF8(node.idname, "ShaderNodeValToRGB");
1244
1245 /* Compositor node uses "Image" as the output name while the shader node uses "Color" as
1246 * the output name. */
1247 bNodeSocket *image_output = bke::node_find_socket(node, SOCK_OUT, "Image"_ustr);
1248 version_node_socket_identifier_set(*image_output, "Color");
1249 STRNCPY_UTF8(image_output->name, "Color");
1250
1251 break;
1252 }
1254 node.type_legacy = SH_NODE_MAP_RANGE;
1255 STRNCPY_UTF8(node.idname, "ShaderNodeMapRange");
1256
1257 /* Transfer options from node to NodeMapRange storage. */
1258 NodeMapRange *data = MEM_new<NodeMapRange>(__func__);
1259 data->clamp = node.custom1;
1260 data->data_type = CD_PROP_FLOAT;
1261 data->interpolation_type = NODE_MAP_RANGE_LINEAR;
1262 node.storage = data;
1263
1264 /* Compositor node uses "Value" as the output name while the shader node uses "Result" as
1265 * the output name. */
1266 bNodeSocket *value_output = bke::node_find_socket(node, SOCK_OUT, "Value"_ustr);
1267 version_node_socket_identifier_set(*value_output, "Result");
1268 STRNCPY_UTF8(value_output->name, "Result");
1269
1270 break;
1271 }
1273 node.type_legacy = SH_NODE_MIX;
1274 STRNCPY_UTF8(node.idname, "ShaderNodeMix");
1275
1276 /* Transfer options from node to NodeShaderMix storage. */
1277 NodeShaderMix *data = MEM_new<NodeShaderMix>(__func__);
1278 data->data_type = SOCK_RGBA;
1279 data->factor_mode = NODE_MIX_MODE_UNIFORM;
1280 data->clamp_factor = 0;
1281 data->clamp_result = node.custom2 & SHD_MIXRGB_CLAMP ? 1 : 0;
1282 data->blend_type = node.custom1;
1283 node.storage = data;
1284
1285 /* Compositor node uses "Fac", "Image", and ("Image" "Image_001") as socket names and
1286 * identifiers while the shader node uses ("Factor", "Factor_Float"), ("A", "A_Color"),
1287 * ("B", "B_Color"), and ("Result", "Result_Color") as socket names and identifiers. */
1288 bNodeSocket *factor_input = bke::node_find_socket(node, SOCK_IN, "Fac"_ustr);
1289 version_node_socket_identifier_set(*factor_input, "Factor_Float");
1290 STRNCPY_UTF8(factor_input->name, "Factor");
1291 bNodeSocket *first_input = bke::node_find_socket(node, SOCK_IN, "Image"_ustr);
1292 version_node_socket_identifier_set(*first_input, "A_Color");
1293 STRNCPY_UTF8(first_input->name, "A");
1294 bNodeSocket *second_input = bke::node_find_socket(node, SOCK_IN, "Image_001"_ustr);
1295 version_node_socket_identifier_set(*second_input, "B_Color");
1296 STRNCPY_UTF8(second_input->name, "B");
1297 bNodeSocket *image_output = bke::node_find_socket(node, SOCK_OUT, "Image"_ustr);
1298 version_node_socket_identifier_set(*image_output, "Result_Color");
1299 STRNCPY_UTF8(image_output->name, "Result");
1300
1302
1303 break;
1304 }
1306 do_version_map_value_node(node_tree, &node);
1307 break;
1308 }
1309 default:
1310 break;
1311 }
1312 }
1313}
1314
1315/* Equivalent to do_version_convert_to_generic_nodes but performed after linking for handing things
1316 * like animation or node construction. */
1318{
1319 const DriverMap driver_map = BKE_animdata_build_driver_target_map(*bmain);
1320 for (bNode &node : node_tree->nodes.items_mutable()) {
1321 char escaped_node_name[sizeof(node.name) * 2 + 1];
1322 BLI_str_escape(escaped_node_name, node.name, sizeof(escaped_node_name));
1323 const std::string rna_path_prefix = fmt::format("nodes[\"{}\"].inputs", escaped_node_name);
1324
1325 switch (node.type_legacy) {
1326 /* Notice that we use the shader type because the node is already converted in versioning
1327 * before linking. */
1328 case SH_NODE_CURVE_VEC: {
1329 /* The node gained a new Factor input as a first socket, so the vector socket moved to be
1330 * the second socket and we need to transfer its animation as well. */
1331 BKE_animdata_fix_paths(node_tree->id,
1332 rna_path_prefix,
1335 /*verify_paths=*/false,
1336 driver_map);
1337 break;
1338 }
1339 /* Notice that we use the shader type because the node is already converted in versioning
1340 * before linking. */
1341 case SH_NODE_MIX: {
1342 /* The node gained multiple new sockets after the factor socket, so the second and third
1343 * sockets moved to be the 7th and 8th sockets. */
1344 BKE_animdata_fix_paths(node_tree->id,
1345 rna_path_prefix,
1348 /*verify_paths=*/false,
1349 driver_map);
1350 BKE_animdata_fix_paths(node_tree->id,
1351 rna_path_prefix,
1354 /*verify_paths=*/false,
1355 driver_map);
1356 break;
1357 }
1358 default:
1359 break;
1360 }
1361 }
1362}
1363
1365{
1366 bNodeSocket *factor_input = bke::node_find_socket(*node, SOCK_IN, "Factor"_ustr);
1367 float factor = factor_input->default_value_typed<bNodeSocketValueFloat>()->value;
1368
1369 bNodeSocket *rotation_input = bke::node_find_socket(*node, SOCK_IN, "Rotation"_ustr);
1370 if (!rotation_input) {
1371 rotation_input = bke::node_add_static_socket(
1372 *node_tree, *node, SOCK_IN, SOCK_FLOAT, PROP_ANGLE, "Rotation", "Rotation");
1373 }
1374
1375 bNodeSocket *position_input = bke::node_find_socket(*node, SOCK_IN, "Position"_ustr);
1376 if (!position_input) {
1377 position_input = bke::node_add_static_socket(
1378 *node_tree, *node, SOCK_IN, SOCK_VECTOR, PROP_FACTOR, "Position", "Position");
1379 }
1380
1381 constexpr int CMP_NODE_SPLIT_HORIZONTAL = 0;
1382 constexpr int CMP_NODE_SPLIT_VERTICAL = 1;
1383
1384 switch (node->custom2) {
1385 case CMP_NODE_SPLIT_HORIZONTAL: {
1386 rotation_input->default_value_typed<bNodeSocketValueFloat>()->value =
1387 -std::numbers::pi_v<float> / 2.0f;
1388 position_input->default_value_typed<bNodeSocketValueVector>()->value[0] = factor;
1389 /* The y-coordinate doesn't matter in this case, so set the value to 0.5 so that the gizmo
1390 * appears nicely at the center. */
1391 position_input->default_value_typed<bNodeSocketValueVector>()->value[1] = 0.5f;
1392 break;
1393 }
1394 case CMP_NODE_SPLIT_VERTICAL: {
1395 rotation_input->default_value_typed<bNodeSocketValueFloat>()->value = 0.0f;
1396 position_input->default_value_typed<bNodeSocketValueVector>()->value[0] = 0.5f;
1397 position_input->default_value_typed<bNodeSocketValueVector>()->value[1] = factor;
1398 break;
1399 }
1400 }
1401}
1402
1404{
1405 ListBaseT<PTCacheID> pidlist;
1406
1407 BKE_ptcache_ids_from_object(&pidlist, object, nullptr, 0);
1408
1409 for (PTCacheID &pid : pidlist) {
1410 bool found_incompatible_cache = false;
1411 if (ELEM(pid.cache->compression,
1414 {
1415 pid.cache->compression = PTCACHE_COMPRESS_ZSTD_FILTERED;
1416 found_incompatible_cache = true;
1417 }
1418 if (pid.type == PTCACHE_TYPE_DYNAMICPAINT) {
1419 /* Dynamicpaint was hardcoded to use LZO. */
1420 found_incompatible_cache = true;
1421 }
1422
1423 if (!found_incompatible_cache) {
1424 continue;
1425 }
1426
1427 std::string cache_type;
1428 switch (pid.type) {
1430 cache_type = RPT_("Softbody");
1431 break;
1433 cache_type = RPT_("Particle");
1434 break;
1435 case PTCACHE_TYPE_CLOTH:
1436 cache_type = RPT_("Cloth");
1437 break;
1439 cache_type = RPT_("Smoke Domain");
1440 break;
1442 cache_type = RPT_("Smoke");
1443 break;
1445 cache_type = RPT_("Dynamic Paint");
1446 break;
1448 /* Rigidbody caches shouldn't have any disk caches, but keep it here just in case. */
1449 cache_type = RPT_("Rigidbody");
1450 break;
1451 }
1453 fd->reports,
1455 RPT_("%s Cache in object %s can not be read because it uses an "
1456 "outdated compression method. You need to delete the caches and re-bake."),
1457 cache_type.c_str(),
1458 pid.owner_id->name + 2);
1459 }
1460
1461 pidlist.free_no_destruct();
1462}
1463
1465{
1466 /* Because this change is backported into the 4.5 branch, we need to avoid performing versioning
1467 * in case the user updated their custom brush assets between using 4.5 and 5.0 to avoid
1468 * overwriting their changes.
1469 *
1470 * See #142104
1471 */
1472 if ((brush->flag2 & BRUSH_JITTER_COLOR) != 0 || !is_zero_v3(brush->hsv_jitter)) {
1473 return;
1474 }
1475
1476 BrushGpencilSettings *settings = brush->gpencil_settings;
1477 float old_hsv_jitter[3] = {
1478 settings->random_hue, settings->random_saturation, settings->random_value};
1479 if (!is_zero_v3(old_hsv_jitter)) {
1480 brush->flag2 |= BRUSH_JITTER_COLOR;
1481 }
1482 copy_v3_v3(brush->hsv_jitter, old_hsv_jitter);
1483 if (brush->curve_rand_hue) {
1484 BKE_curvemapping_free_data(brush->curve_rand_hue);
1485 BKE_curvemapping_copy_data(brush->curve_rand_hue, settings->curve_rand_hue);
1486 }
1487 else {
1488 brush->curve_rand_hue = BKE_curvemapping_copy(settings->curve_rand_hue);
1489 }
1490 if (brush->curve_rand_saturation) {
1491 BKE_curvemapping_free_data(brush->curve_rand_saturation);
1492 BKE_curvemapping_copy_data(brush->curve_rand_saturation, settings->curve_rand_saturation);
1493 }
1494 else {
1495 brush->curve_rand_saturation = BKE_curvemapping_copy(settings->curve_rand_saturation);
1496 }
1497 if (brush->curve_rand_value) {
1498 BKE_curvemapping_free_data(brush->curve_rand_value);
1499 BKE_curvemapping_copy_data(brush->curve_rand_value, settings->curve_rand_value);
1500 }
1501 else {
1502 brush->curve_rand_value = BKE_curvemapping_copy(settings->curve_rand_value);
1503 }
1504}
1505
1506/* The Sun beams node was removed and the Glare node should be used instead, so we need to
1507 * make the replacement. */
1508static void do_version_sun_beams(bNodeTree &node_tree, bNode &node)
1509{
1510 bke::node_tree_set_type(node_tree);
1511
1512 bNodeSocket *old_image_input = bke::node_find_socket(node, SOCK_IN, "Image"_ustr);
1513 bNodeSocket *old_source_input = bke::node_find_socket(node, SOCK_IN, "Source"_ustr);
1514 bNodeSocket *old_length_input = bke::node_find_socket(node, SOCK_IN, "Length"_ustr);
1515 bNodeSocket *old_image_output = bke::node_find_socket(node, SOCK_OUT, "Image"_ustr);
1516
1517 bNode *glare_node = bke::node_add_node(nullptr, node_tree, "CompositorNodeGlare"_ustr);
1518 glare_node->parent = node.parent;
1519 glare_node->location[0] = node.location[0];
1520 glare_node->location[1] = node.location[1];
1521
1522 bNodeSocket *image_input = bke::node_find_socket(*glare_node, SOCK_IN, "Image"_ustr);
1523 bNodeSocket *type_input = bke::node_find_socket(*glare_node, SOCK_IN, "Type"_ustr);
1524 bNodeSocket *quality_input = bke::node_find_socket(*glare_node, SOCK_IN, "Quality"_ustr);
1525 bNodeSocket *threshold_input = bke::node_find_socket(
1526 *glare_node, SOCK_IN, "Highlights Threshold"_ustr);
1527 bNodeSocket *size_input = bke::node_find_socket(*glare_node, SOCK_IN, "Size"_ustr);
1528 bNodeSocket *source_input = bke::node_find_socket(*glare_node, SOCK_IN, "Sun Position"_ustr);
1529 bNodeSocket *glare_output = bke::node_find_socket(*glare_node, SOCK_OUT, "Glare"_ustr);
1530
1531 type_input->default_value_typed<bNodeSocketValueMenu>()->value = CMP_NODE_GLARE_SUN_BEAMS;
1532 quality_input->default_value_typed<bNodeSocketValueMenu>()->value = CMP_NODE_GLARE_QUALITY_HIGH;
1533 copy_v4_v4(image_input->default_value_typed<bNodeSocketValueRGBA>()->value,
1534 old_image_input->default_value_typed<bNodeSocketValueRGBA>()->value);
1535 threshold_input->default_value_typed<bNodeSocketValueFloat>()->value = 0.0f;
1536 size_input->default_value_typed<bNodeSocketValueFloat>()->value =
1537 old_length_input->default_value_typed<bNodeSocketValueFloat>()->value;
1538 copy_v2_v2(source_input->default_value_typed<bNodeSocketValueVector>()->value,
1539 old_source_input->default_value_typed<bNodeSocketValueVector>()->value);
1540
1541 for (bNodeLink &link : node_tree.links.items_reversed_mutable()) {
1542 if (link.tosock == old_image_input) {
1543 version_node_add_link(node_tree, *link.fromnode, *link.fromsock, *glare_node, *image_input);
1544 bke::node_remove_link(&node_tree, link);
1545 continue;
1546 }
1547
1548 if (link.tosock == old_source_input) {
1549 version_node_add_link(node_tree, *link.fromnode, *link.fromsock, *glare_node, *source_input);
1550 bke::node_remove_link(&node_tree, link);
1551 continue;
1552 }
1553
1554 if (link.tosock == old_length_input) {
1555 version_node_add_link(node_tree, *link.fromnode, *link.fromsock, *glare_node, *size_input);
1556 bke::node_remove_link(&node_tree, link);
1557 continue;
1558 }
1559
1560 if (link.fromsock == old_image_output) {
1561 version_node_add_link(node_tree, *link.tonode, *link.tosock, *glare_node, *glare_output);
1562 bke::node_remove_link(&node_tree, link);
1563 }
1564 }
1565
1566 version_node_remove(node_tree, node);
1567}
1568
1569/* The Composite node was removed and a Group Output node should be used instead, so we need to
1570 * make the replacement. But first note that the Group Output node relies on the node tree
1571 * interface, so we ensure a default interface with a single input and output. This is only for
1572 * root trees used as scene compositing node groups, for other node trees, we remove all composite
1573 * nodes since they are no longer supported inside groups. */
1575{
1576 bke::node_tree_set_type(node_tree);
1577
1578 /* Remove inactive nodes. */
1579 if (!(node.flag & NODE_DO_OUTPUT)) {
1580 version_node_remove(node_tree, node);
1581 return nullptr;
1582 }
1583
1584 bNodeSocket *old_image_input = bke::node_find_socket(node, SOCK_IN, "Image"_ustr);
1585
1586 /* Find the link going into the Image input of the Composite node. */
1587 bNodeLink *image_link = nullptr;
1588 for (bNodeLink &link : node_tree.links) {
1589 if (link.tosock == old_image_input) {
1590 image_link = &link;
1591 }
1592 }
1593
1594 bNode *group_output_node = bke::node_add_node(nullptr, node_tree, "NodeGroupOutput"_ustr);
1595 group_output_node->parent = node.parent;
1596 group_output_node->location[0] = node.location[0];
1597 group_output_node->location[1] = node.location[1];
1598
1599 bNodeSocket *image_input = group_output_node->inputs.first();
1600 BLI_assert(StringRef(image_input->name) == "Image");
1601 copy_v4_v4(image_input->default_value_typed<bNodeSocketValueRGBA>()->value,
1602 old_image_input->default_value_typed<bNodeSocketValueRGBA>()->value);
1603
1604 if (image_link) {
1606 node_tree, *image_link->fromnode, *image_link->fromsock, *group_output_node, *image_input);
1607 bke::node_remove_link(&node_tree, *image_link);
1608 }
1609
1610 version_node_remove(node_tree, node);
1611
1612 return group_output_node;
1613}
1614
1615/* The file output node started using item accessors, so we need to free socket storage and copy
1616 * them to the new items members. Additionally, the base path was split into a directory and a file
1617 * name, so we need to split it. */
1619{
1620 if (node.storage == nullptr) {
1621 return;
1622 }
1623
1625
1626 /* The directory previously stored both the directory and the file name. */
1627 char directory[FILE_MAX] = "";
1628 char file_name[FILE_MAX] = "";
1629 BLI_path_split_dir_file(data->directory, directory, FILE_MAX, file_name, FILE_MAX);
1630 STRNCPY(data->directory, directory);
1631 data->file_name = BLI_strdup_null(file_name);
1632
1633 data->items_count = node.inputs.count();
1634 data->items = MEM_new_array<NodeCompositorFileOutputItem>(data->items_count, __func__);
1635
1636 for (const auto [i, input] : node.inputs.enumerate()) {
1637 NodeImageMultiFileSocket *old_item_data = static_cast<NodeImageMultiFileSocket *>(
1638 input.storage);
1639 NodeCompositorFileOutputItem *item_data = &data->items[i];
1640
1641 item_data->identifier = i;
1642 BKE_image_format_copy(&item_data->format, &old_item_data->format);
1643 item_data->save_as_render = old_item_data->save_as_render;
1644 item_data->override_node_format = !bool(old_item_data->use_node_format);
1645
1646 item_data->socket_type = input.type;
1647 if (item_data->socket_type == SOCK_VECTOR) {
1648 item_data->vector_socket_dimensions =
1649 input.default_value_typed<bNodeSocketValueVector>()->dimensions;
1650 }
1651
1652 if (data->format.imtype == R_IMF_IMTYPE_MULTILAYER) {
1653 item_data->name = BLI_strdup(old_item_data->layer);
1654 }
1655 else {
1656 item_data->name = BLI_strdup(old_item_data->path);
1657 }
1658
1659 const std::string identifier = "Item_" + std::to_string(item_data->identifier);
1660 version_node_socket_identifier_set(input, identifier);
1661
1662 BKE_image_format_free(&old_item_data->format);
1663 MEM_delete(old_item_data);
1664 input.storage = nullptr;
1665 }
1666}
1667
1668/* Updates the media type of the given format to match its imtype. */
1670{
1671 if (BKE_imtype_is_image(format->imtype)) {
1672 format->media_type = MEDIA_TYPE_IMAGE;
1673 }
1674 else if (BKE_imtype_is_multi_layer_image(format->imtype)) {
1675 format->media_type = MEDIA_TYPE_MULTI_LAYER_IMAGE;
1676 }
1677 else if (BKE_imtype_is_movie(format->imtype)) {
1678 format->media_type = MEDIA_TYPE_VIDEO;
1679 }
1680 else {
1682 }
1683}
1684
1686{
1687 if (world->use_nodes) {
1688 return;
1689 }
1690
1691 /* Users defined a world node tree, but deactivated it by disabling "Use Nodes". So we
1692 * simulate the same effect by creating a new World Output node and setting it to active. */
1693 bNodeTree *ntree = world->nodetree;
1694 if (ntree == nullptr) {
1695 /* In case the world was defined through Python API it might have been missing a node tree. */
1697 bmain, &world->id, "World Node Tree Versioning", "ShaderNodeTree");
1698 }
1699
1700 bNode *old_output = nullptr;
1701 for (bNode &node : ntree->nodes) {
1702 if (STREQ(node.idname, "ShaderNodeOutputWorld") && (node.flag & NODE_DO_OUTPUT)) {
1703 old_output = &node;
1704 old_output->flag &= ~NODE_DO_OUTPUT;
1705 }
1706 }
1707
1708 bNode &new_output = version_node_add_empty(*ntree, "ShaderNodeOutputWorld");
1709 bNodeSocket &output_surface_input = version_node_add_socket(
1710 *ntree, new_output, SOCK_IN, "NodeSocketShader", "Surface");
1711 version_node_add_socket(*ntree, new_output, SOCK_IN, "NodeSocketShader", "Volume");
1712 new_output.flag |= NODE_DO_OUTPUT;
1713
1714 bNode &background = version_node_add_empty(*ntree, "ShaderNodeBackground");
1715 bNodeSocket &background_color_output = version_node_add_socket(
1716 *ntree, background, SOCK_OUT, "NodeSocketShader", "Background");
1717 bNodeSocket &background_color_input = version_node_add_socket(
1718 *ntree, background, SOCK_IN, "NodeSocketColor", "Color");
1719 bNodeSocket &background_strength_input = version_node_add_socket(
1720 *ntree, background, SOCK_IN, "NodeSocketFloat", "Strength");
1721 bNodeSocket &background_weight_input = version_node_add_socket(
1722 *ntree, background, SOCK_IN, "NodeSocketFloat", "Weight");
1723 background_weight_input.flag |= SOCK_UNAVAIL;
1724
1726 *ntree, background, background_color_output, new_output, output_surface_input);
1727
1728 bNodeSocketValueRGBA *rgba = background_color_input.default_value_typed<bNodeSocketValueRGBA>();
1729 rgba->value[0] = world->horr;
1730 rgba->value[1] = world->horg;
1731 rgba->value[2] = world->horb;
1732 rgba->value[3] = 1.0f;
1733 background_strength_input.default_value_typed<bNodeSocketValueFloat>()->value = 1.0f;
1734
1735 if (old_output != nullptr) {
1736 /* Position the newly created node after the old output. Assume the old output node is at
1737 * the far right of the node tree. */
1738 background.location[0] = old_output->location[0] + 1.5f * old_output->width;
1739 background.location[1] = old_output->location[1];
1740 }
1741
1742 new_output.location[0] = background.location[0] + 2.0f * background.width;
1743 new_output.location[1] = background.location[1];
1744
1745 bNode *frame = bke::node_add_static_node(nullptr, *ntree, NODE_FRAME);
1746 STRNCPY(frame->label, RPT_("Versioning: Use Nodes was removed"));
1747 background.parent = frame;
1748 new_output.parent = frame;
1749}
1750
1752{
1753 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
1754 return;
1755 }
1757 return;
1758 }
1759 const auto &storage = *static_cast<NodeBlurData *>(node.storage);
1760 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
1761 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.filtertype;
1762}
1763
1765{
1766 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
1767 return;
1768 }
1769 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
1770 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
1771}
1772
1774{
1775 if (bke::node_find_socket(node, SOCK_IN, "Channel"_ustr)) {
1776 return;
1777 }
1778 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Channel");
1779 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
1780}
1781
1783{
1784 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
1785 return;
1786 }
1788 return;
1789 }
1790 bNodeSocket &type_socket = version_node_add_socket(
1791 ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
1792 type_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
1793
1794 const auto &storage = *static_cast<NodeDilateErode *>(node.storage);
1795 bNodeSocket &falloff_socket = version_node_add_socket(
1796 ntree, node, SOCK_IN, "NodeSocketMenu", "Falloff");
1797 falloff_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.falloff;
1798}
1799
1801{
1802 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
1803 return;
1804 }
1806 return;
1807 }
1808
1809 const auto &storage = *static_cast<NodeTonemap *>(node.storage);
1810 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
1811 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.type;
1812}
1813
1815{
1816 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
1817 return;
1818 }
1820 return;
1821 }
1822
1823 const auto &storage = *static_cast<NodeLensDist *>(node.storage);
1824 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
1825 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.distortion_type;
1826}
1827
1829{
1830 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
1831 return;
1832 }
1834 return;
1835 }
1836
1837 const auto &storage = *static_cast<NodeKuwaharaData *>(node.storage);
1838 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
1839 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.variation;
1840}
1841
1843{
1844 if (bke::node_find_socket(node, SOCK_IN, "Prefilter"_ustr)) {
1845 return;
1846 }
1848 return;
1849 }
1850
1851 const auto &storage = *static_cast<NodeDenoise *>(node.storage);
1852 bNodeSocket &prefilter_socket = version_node_add_socket(
1853 ntree, node, SOCK_IN, "NodeSocketMenu", "Prefilter");
1854 prefilter_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.prefilter;
1855 bNodeSocket &quality_socket = version_node_add_socket(
1856 ntree, node, SOCK_IN, "NodeSocketMenu", "Quality");
1857 quality_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.quality;
1858}
1859
1861{
1862 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
1863 return;
1864 }
1866 return;
1867 }
1868
1869 const auto &storage = *static_cast<NodeTranslateData *>(node.storage);
1870 bNodeSocket &interpolation_socket = version_node_add_socket(
1871 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
1872 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.interpolation;
1873 bNodeSocket &extension_x_socket = version_node_add_socket(
1874 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension X");
1875 extension_x_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_x;
1876 bNodeSocket &extension_y_socket = version_node_add_socket(
1877 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension Y");
1878 extension_y_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_y;
1879}
1880
1882{
1883 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
1884 return;
1885 }
1887 return;
1888 }
1889
1890 const auto &storage = *static_cast<NodeTransformData *>(node.storage);
1891 bNodeSocket &interpolation_socket = version_node_add_socket(
1892 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
1893 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.interpolation;
1894 bNodeSocket &extension_x_socket = version_node_add_socket(
1895 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension X");
1896 extension_x_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_x;
1897 bNodeSocket &extension_y_socket = version_node_add_socket(
1898 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension Y");
1899 extension_y_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_y;
1900}
1901
1903{
1904 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
1905 return;
1906 }
1908 return;
1909 }
1910
1911 const auto &storage = *static_cast<NodeCornerPinData *>(node.storage);
1912 bNodeSocket &interpolation_socket = version_node_add_socket(
1913 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
1914 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.interpolation;
1915 bNodeSocket &extension_x_socket = version_node_add_socket(
1916 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension X");
1917 extension_x_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_x;
1918 bNodeSocket &extension_y_socket = version_node_add_socket(
1919 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension Y");
1920 extension_y_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_y;
1921}
1922
1924{
1925 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
1926 return;
1927 }
1929 return;
1930 }
1931
1932 const auto &storage = *static_cast<NodeMapUVData *>(node.storage);
1933 bNodeSocket &interpolation_socket = version_node_add_socket(
1934 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
1935 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.interpolation;
1936 bNodeSocket &extension_x_socket = version_node_add_socket(
1937 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension X");
1938 extension_x_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_x;
1939 bNodeSocket &extension_y_socket = version_node_add_socket(
1940 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension Y");
1941 extension_y_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_y;
1942}
1943
1945{
1946 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
1947 return;
1948 }
1950 return;
1951 }
1952
1953 bNodeSocket &type_socket = version_node_add_socket(
1954 ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
1955 type_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
1956 bNodeSocket &frame_type_socket = version_node_add_socket(
1957 ntree, node, SOCK_IN, "NodeSocketMenu", "Frame Type");
1958 frame_type_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2;
1959
1960 const auto &storage = *static_cast<NodeScaleData *>(node.storage);
1961 bNodeSocket &interpolation_socket = version_node_add_socket(
1962 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
1963 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.interpolation;
1964 bNodeSocket &extension_x_socket = version_node_add_socket(
1965 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension X");
1966 extension_x_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_x;
1967 bNodeSocket &extension_y_socket = version_node_add_socket(
1968 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension Y");
1969 extension_y_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_y;
1970}
1971
1973{
1974 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
1975 return;
1976 }
1978 return;
1979 }
1980
1981 const auto &storage = *static_cast<NodeRotateData *>(node.storage);
1982 bNodeSocket &interpolation_socket = version_node_add_socket(
1983 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
1984 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.interpolation;
1985 bNodeSocket &extension_x_socket = version_node_add_socket(
1986 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension X");
1987 extension_x_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_x;
1988 bNodeSocket &extension_y_socket = version_node_add_socket(
1989 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension Y");
1990 extension_y_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_y;
1991}
1992
1994{
1995 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
1996 return;
1997 }
1999 return;
2000 }
2001
2002 const auto &storage = *static_cast<NodeDisplaceData *>(node.storage);
2003 bNodeSocket &interpolation_socket = version_node_add_socket(
2004 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
2005 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.interpolation;
2006 bNodeSocket &extension_x_socket = version_node_add_socket(
2007 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension X");
2008 extension_x_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_x;
2009 bNodeSocket &extension_y_socket = version_node_add_socket(
2010 ntree, node, SOCK_IN, "NodeSocketMenu", "Extension Y");
2011 extension_y_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.extension_y;
2012}
2013
2015{
2016 if (bke::node_find_socket(node, SOCK_IN, "Interpolation"_ustr)) {
2017 return;
2018 }
2019
2020 bNodeSocket &interpolation_socket = version_node_add_socket(
2021 ntree, node, SOCK_IN, "NodeSocketMenu", "Interpolation");
2022 interpolation_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2023}
2024
2026{
2027 if (bke::node_find_socket(node, SOCK_IN, "Operation"_ustr)) {
2028 return;
2029 }
2030
2031 bNodeSocket &operation_socket = version_node_add_socket(
2032 ntree, node, SOCK_IN, "NodeSocketMenu", "Operation");
2033 operation_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2034}
2035
2037{
2038 if (bke::node_find_socket(node, SOCK_IN, "Operation"_ustr)) {
2039 return;
2040 }
2041
2042 bNodeSocket &operation_socket = version_node_add_socket(
2043 ntree, node, SOCK_IN, "NodeSocketMenu", "Operation");
2044 operation_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2045}
2046
2048{
2049 if (bke::node_find_socket(node, SOCK_IN, "Mode"_ustr)) {
2050 return;
2051 }
2052
2053 bNodeSocket &mode_socket = version_node_add_socket(
2054 ntree, node, SOCK_IN, "NodeSocketMenu", "Mode");
2055 mode_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2056 bNodeSocket &frame_socket = version_node_add_socket(
2057 ntree, node, SOCK_IN, "NodeSocketInt", "Frame");
2058 frame_socket.default_value_typed<bNodeSocketValueInt>()->value = node.custom2;
2059}
2060
2062{
2063 if (bke::node_find_socket(node, SOCK_IN, "Feather Falloff"_ustr)) {
2064 return;
2065 }
2067 return;
2068 }
2069
2070 const auto &storage = *static_cast<NodeKeyingData *>(node.storage);
2071 bNodeSocket &feather_falloff_socket = version_node_add_socket(
2072 ntree, node, SOCK_IN, "NodeSocketMenu", "Feather Falloff");
2073 feather_falloff_socket.default_value_typed<bNodeSocketValueMenu>()->value =
2074 storage.feather_falloff;
2075}
2076
2078{
2079 if (bke::node_find_socket(node, SOCK_IN, "Size Source"_ustr)) {
2080 return;
2081 }
2082
2083 bNodeSocket &size_source_socket = version_node_add_socket(
2084 ntree, node, SOCK_IN, "NodeSocketMenu", "Size Source");
2085 size_source_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2086}
2087
2089{
2090 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
2091 return;
2092 }
2093
2094 bNodeSocket &type_socket = version_node_add_socket(
2095 ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
2096 type_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2097}
2098
2100{
2101 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
2102 return;
2103 }
2105 return;
2106 }
2107
2108 const auto &storage = *static_cast<NodeGlare *>(node.storage);
2109 bNodeSocket &type_socket = version_node_add_socket(
2110 ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
2111 type_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.type;
2112 bNodeSocket &quality_socket = version_node_add_socket(
2113 ntree, node, SOCK_IN, "NodeSocketMenu", "Quality");
2114 quality_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.quality;
2115}
2116
2118{
2119 /* When opening and saving 5.0 files with bundle/closure nodes in 4.5, the storage is lost, since
2120 * Blender 4.5 does not officially support these features yet (they were experimental features
2121 * though). This versioning code just adds back the storage so that it does not crash further
2122 * down the line. */
2123 for (bNode &node : ntree.nodes) {
2124 if (node.storage) {
2125 continue;
2126 }
2127 switch (node.type_legacy) {
2128 case NODE_CLOSURE_INPUT: {
2129 node.storage = MEM_new<NodeClosureInput>(__func__);
2130 break;
2131 }
2132 case NODE_CLOSURE_OUTPUT: {
2133 node.storage = MEM_new<NodeClosureOutput>(__func__);
2134 break;
2135 }
2136 case NODE_EVALUATE_CLOSURE: {
2137 node.storage = MEM_new<NodeEvaluateClosure>(__func__);
2138 break;
2139 }
2140 case NODE_COMBINE_BUNDLE: {
2141 node.storage = MEM_new<NodeCombineBundle>(__func__);
2142 break;
2143 }
2144 case NODE_SEPARATE_BUNDLE: {
2145 node.storage = MEM_new<NodeSeparateBundle>(__func__);
2146 break;
2147 }
2148 }
2149 }
2150}
2151
2153{
2154 if (material->use_nodes) {
2155 return;
2156 }
2157
2158 /* Users defined a material node tree, but deactivated it by disabling "Use Nodes". So we
2159 * simulate the same effect by creating a new Material Output node and setting it to active. */
2160 bNodeTree *ntree = material->nodetree;
2161 if (ntree == nullptr) {
2162 /* In case the material was created in Python API it might have been missing a node tree. */
2164 bmain, &material->id, "Material Node Tree Versioning", "ShaderNodeTree");
2165 }
2166
2167 bNode *old_output = nullptr;
2168 for (bNode &node : ntree->nodes) {
2169 if (STREQ(node.idname, "ShaderNodeOutputMaterial") && (node.flag & NODE_DO_OUTPUT)) {
2170 old_output = &node;
2171 old_output->flag &= ~NODE_DO_OUTPUT;
2172 }
2173 }
2174
2175 bNode *frame = bke::node_add_static_node(nullptr, *ntree, NODE_FRAME);
2176 STRNCPY(frame->label, RPT_("Versioning: Use Nodes was removed"));
2177
2178 {
2179 /* For EEVEE, we use a principled BSDF shader because we need to recreate the metallic,
2180 * specular and roughness properties of the material for use_nodes = false.*/
2181 bNode &new_output_eevee = version_node_add_empty(*ntree, "ShaderNodeOutputMaterial");
2182 bNodeSocket &output_surface_input = version_node_add_socket(
2183 *ntree, new_output_eevee, SOCK_IN, "NodeSocketShader", "Surface");
2184 version_node_add_socket(*ntree, new_output_eevee, SOCK_IN, "NodeSocketShader", "Volume");
2185 version_node_add_socket(*ntree, new_output_eevee, SOCK_IN, "NodeSocketVector", "Displacement");
2186 version_node_add_socket(*ntree, new_output_eevee, SOCK_IN, "NodeSocketFloat", "Thickness");
2187
2188 version_node_add_socket(*ntree, new_output_eevee, SOCK_IN, "NodeSocketShader", "Volume");
2189 new_output_eevee.flag |= NODE_DO_OUTPUT;
2190 new_output_eevee.custom1 = SHD_OUTPUT_EEVEE;
2191
2192 bNode &shader_eevee = *bke::node_add_static_node(nullptr, *ntree, SH_NODE_BSDF_PRINCIPLED);
2193 bNodeSocket &shader_bsdf_output = *bke::node_find_socket(shader_eevee, SOCK_OUT, "BSDF"_ustr);
2194 bNodeSocket &shader_color_input = *bke::node_find_socket(
2195 shader_eevee, SOCK_IN, "Base Color"_ustr);
2196 bNodeSocket &specular_input = *bke::node_find_socket(
2197 shader_eevee, SOCK_IN, "Specular IOR Level"_ustr);
2198 bNodeSocket &metallic_input = *bke::node_find_socket(shader_eevee, SOCK_IN, "Metallic"_ustr);
2199 bNodeSocket &roughness_input = *bke::node_find_socket(shader_eevee, SOCK_IN, "Roughness"_ustr);
2200
2202 *ntree, shader_eevee, shader_bsdf_output, new_output_eevee, output_surface_input);
2203
2204 bNodeSocketValueRGBA *rgba = shader_color_input.default_value_typed<bNodeSocketValueRGBA>();
2205 rgba->value[0] = material->r;
2206 rgba->value[1] = material->g;
2207 rgba->value[2] = material->b;
2208 rgba->value[3] = material->a;
2209 roughness_input.default_value_typed<bNodeSocketValueFloat>()->value = material->roughness;
2210 metallic_input.default_value_typed<bNodeSocketValueFloat>()->value = material->metallic;
2211 specular_input.default_value_typed<bNodeSocketValueFloat>()->value = material->spec;
2212
2213 if (old_output != nullptr) {
2214 /* Position the newly created node after the old output. Assume the old output node is at
2215 * the far right of the node tree. */
2216 shader_eevee.location[0] = old_output->location[0] + 1.5f * old_output->width;
2217 shader_eevee.location[1] = old_output->location[1];
2218 }
2219
2220 new_output_eevee.location[0] = shader_eevee.location[0] + 2.0f * shader_eevee.width;
2221 new_output_eevee.location[1] = shader_eevee.location[1];
2222
2223 shader_eevee.parent = frame;
2224 new_output_eevee.parent = frame;
2225 }
2226
2227 {
2228 /* For Cycles, a simple diffuse BSDF is sufficient. */
2229 bNode &new_output_cycles = version_node_add_empty(*ntree, "ShaderNodeOutputMaterial");
2230 bNodeSocket &output_surface_input = version_node_add_socket(
2231 *ntree, new_output_cycles, SOCK_IN, "NodeSocketShader", "Surface");
2232 version_node_add_socket(*ntree, new_output_cycles, SOCK_IN, "NodeSocketShader", "Volume");
2234 *ntree, new_output_cycles, SOCK_IN, "NodeSocketVector", "Displacement");
2235 version_node_add_socket(*ntree, new_output_cycles, SOCK_IN, "NodeSocketFloat", "Thickness");
2236 /* We don't activate the output explicitly to avoid having two active outputs. We assume
2237 * `node_tree.get_output_node('Cycles')` will return this node. */
2238 new_output_cycles.custom1 = SHD_OUTPUT_CYCLES;
2239
2240 bNode &shader_cycles = *bke::node_add_static_node(nullptr, *ntree, SH_NODE_BSDF_DIFFUSE);
2241 bNodeSocket &shader_bsdf_output = *bke::node_find_socket(shader_cycles, SOCK_OUT, "BSDF"_ustr);
2242 bNodeSocket &shader_color_input = *bke::node_find_socket(shader_cycles, SOCK_IN, "Color"_ustr);
2243
2245 *ntree, shader_cycles, shader_bsdf_output, new_output_cycles, output_surface_input);
2246
2247 bNodeSocketValueRGBA *rgba = shader_color_input.default_value_typed<bNodeSocketValueRGBA>();
2248 rgba->value[0] = material->r;
2249 rgba->value[1] = material->g;
2250 rgba->value[2] = material->b;
2251 rgba->value[3] = material->a;
2252
2253 if (old_output != nullptr) {
2254 shader_cycles.location[0] = old_output->location[0] + 1.5f * old_output->width;
2255 shader_cycles.location[1] = old_output->location[1] + 2.0f * old_output->height;
2256 }
2257
2258 new_output_cycles.location[0] = shader_cycles.location[0] + 3.0f * shader_cycles.width;
2259 new_output_cycles.location[1] = shader_cycles.location[1];
2260
2261 shader_cycles.parent = frame;
2262 new_output_cycles.parent = frame;
2263 }
2264}
2265
2267{
2268 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
2269 return;
2270 }
2272 return;
2273 }
2274
2275 const auto &storage = *static_cast<NodeSetAlpha *>(node.storage);
2276 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
2277 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.mode;
2278}
2279
2281{
2282 if (bke::node_find_socket(node, SOCK_IN, "Color Space"_ustr)) {
2283 return;
2284 }
2286 return;
2287 }
2288
2289 const auto &storage = *static_cast<NodeChroma *>(node.storage);
2290 bNodeSocket &color_space_socket = version_node_add_socket(
2291 ntree, node, SOCK_IN, "NodeSocketMenu", "Color Space");
2292 color_space_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1 - 1;
2293 bNodeSocket &rgb_key_channel_socket = version_node_add_socket(
2294 ntree, node, SOCK_IN, "NodeSocketMenu", "RGB Key Channel");
2295 rgb_key_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2 - 1;
2296 bNodeSocket &hsv_key_channel_socket = version_node_add_socket(
2297 ntree, node, SOCK_IN, "NodeSocketMenu", "HSV Key Channel");
2298 hsv_key_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2 - 1;
2299 bNodeSocket &yuv_key_channel_socket = version_node_add_socket(
2300 ntree, node, SOCK_IN, "NodeSocketMenu", "YUV Key Channel");
2301 yuv_key_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2 - 1;
2302 bNodeSocket &ycc_key_channel_socket = version_node_add_socket(
2303 ntree, node, SOCK_IN, "NodeSocketMenu", "YCbCr Key Channel");
2304 ycc_key_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2 - 1;
2305
2306 bNodeSocket &limit_method_socket = version_node_add_socket(
2307 ntree, node, SOCK_IN, "NodeSocketMenu", "Limit Method");
2308 limit_method_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.algorithm;
2309 bNodeSocket &rgb_limit_channel_socket = version_node_add_socket(
2310 ntree, node, SOCK_IN, "NodeSocketMenu", "RGB Limit Channel");
2311 rgb_limit_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.channel -
2312 1;
2313 bNodeSocket &hsv_limit_channel_socket = version_node_add_socket(
2314 ntree, node, SOCK_IN, "NodeSocketMenu", "HSV Limit Channel");
2315 hsv_limit_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.channel -
2316 1;
2317 bNodeSocket &yuv_limit_channel_socket = version_node_add_socket(
2318 ntree, node, SOCK_IN, "NodeSocketMenu", "YUV Limit Channel");
2319 yuv_limit_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.channel -
2320 1;
2321 bNodeSocket &ycc_limit_channel_socket = version_node_add_socket(
2322 ntree, node, SOCK_IN, "NodeSocketMenu", "YCbCr Limit Channel");
2323 ycc_limit_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.channel -
2324 1;
2325}
2326
2328{
2329 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
2330 return;
2331 }
2332
2333 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
2334 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2335}
2336
2338{
2339 if (bke::node_find_socket(node, SOCK_IN, "Type"_ustr)) {
2340 return;
2341 }
2342
2343 bNodeSocket &socket = version_node_add_socket(ntree, node, SOCK_IN, "NodeSocketMenu", "Type");
2344 socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1;
2345}
2346
2348{
2349 if (bke::node_find_socket(node, SOCK_IN, "Color Space"_ustr)) {
2350 return;
2351 }
2353 return;
2354 }
2355
2356 auto &storage = *static_cast<NodeChroma *>(node.storage);
2358 ntree, node, SOCK_IN, "NodeSocketMenu", "Color Space");
2359 socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.channel - 1;
2360}
2361
2363{
2364 if (bke::node_find_socket(node, SOCK_IN, "Spill Channel"_ustr)) {
2365 return;
2366 }
2368 return;
2369 }
2370
2371 bNodeSocket &spill_channel_socket = version_node_add_socket(
2372 ntree, node, SOCK_IN, "NodeSocketMenu", "Spill Channel");
2373 spill_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom1 - 1;
2374 bNodeSocket &limit_method_socket = version_node_add_socket(
2375 ntree, node, SOCK_IN, "NodeSocketMenu", "Limit Method");
2376 limit_method_socket.default_value_typed<bNodeSocketValueMenu>()->value = node.custom2;
2377
2378 auto &storage = *static_cast<NodeColorspill *>(node.storage);
2379 bNodeSocket &limit_channel_socket = version_node_add_socket(
2380 ntree, node, SOCK_IN, "NodeSocketMenu", "Limit Channel");
2381 limit_channel_socket.default_value_typed<bNodeSocketValueMenu>()->value = storage.limchan;
2382}
2383
2385{
2386 if (bke::node_find_socket(node, SOCK_IN, "Image Edges"_ustr)) {
2387 return;
2388 }
2389
2390 bNodeSocket &image_edges_socket = version_node_add_socket(
2391 ntree, node, SOCK_IN, "NodeSocketBool", "Image Edges");
2392 image_edges_socket.default_value_typed<bNodeSocketValueBoolean>()->value = bool(node.custom2);
2393 bNodeSocket &only_inside_outer_socket = version_node_add_socket(
2394 ntree, node, SOCK_IN, "NodeSocketBool", "Only Inside Outer");
2395 only_inside_outer_socket.default_value_typed<bNodeSocketValueBoolean>()->value = bool(
2396 node.custom1);
2397}
2398
2400{
2401 for (bNode &node : ntree.nodes) {
2402 if (node.type_legacy != GEO_NODE_VIEWER) {
2403 continue;
2404 }
2406 return;
2407 }
2408 NodeGeometryViewer *storage = static_cast<NodeGeometryViewer *>(node.storage);
2409 const int input_sockets_num = node.inputs.count();
2410 if (input_sockets_num == storage->items_num + 1) {
2411 /* Make versioning idempotent. */
2412 continue;
2413 }
2414 storage->items_num = 2;
2415 storage->items = MEM_new_array<NodeGeometryViewerItem>(2, __func__);
2416 NodeGeometryViewerItem &geometry_item = storage->items[0];
2417 geometry_item.name = BLI_strdup("Geometry");
2418 geometry_item.socket_type = SOCK_GEOMETRY;
2419 geometry_item.identifier = 0;
2420 NodeGeometryViewerItem &value_item = storage->items[1];
2421 value_item.name = BLI_strdup("Value");
2423 eCustomDataType(storage->data_type_legacy))
2424 .value_or(SOCK_FLOAT);
2425 value_item.identifier = 1;
2426 storage->next_identifier = 2;
2427 }
2428}
2429
2431{
2432 bke::node_tree_set_type(node_tree);
2433
2434 bNodeSocket *displacement_input = bke::node_find_socket(node, SOCK_IN, "Displacement"_ustr);
2435 bNodeSocket *x_scale_input = bke::node_find_socket(node, SOCK_IN, "X Scale"_ustr);
2436 bNodeSocket *y_scale_input = bke::node_find_socket(node, SOCK_IN, "Y Scale"_ustr);
2437
2438 /* Find the link going into the inputs of the node. */
2439 bNodeLink *displacement_link = nullptr;
2440 bNodeLink *x_scale_link = nullptr;
2441 bNodeLink *y_scale_link = nullptr;
2442 for (bNodeLink &link : node_tree.links) {
2443 if (link.tosock == displacement_input) {
2444 displacement_link = &link;
2445 }
2446 if (link.tosock == x_scale_input) {
2447 x_scale_link = &link;
2448 }
2449 if (link.tosock == y_scale_input) {
2450 y_scale_link = &link;
2451 }
2452 }
2453
2454 bNode *multiply_node = bke::node_add_node(nullptr, node_tree, "ShaderNodeVectorMath"_ustr);
2455 multiply_node->parent = node.parent;
2456 multiply_node->location[0] = node.location[0] - node.width - 20.0f;
2457 multiply_node->location[1] = node.location[1];
2458 multiply_node->custom1 = NODE_VECTOR_MATH_MULTIPLY;
2459
2460 bNodeSocket *multiply_a_input = bke::node_find_socket(*multiply_node, SOCK_IN, "Vector"_ustr);
2461 bNodeSocket *multiply_b_input = bke::node_find_socket(
2462 *multiply_node, SOCK_IN, "Vector_001"_ustr);
2463 bNodeSocket *multiply_output = bke::node_find_socket(*multiply_node, SOCK_OUT, "Vector"_ustr);
2464
2465 copy_v2_v2(multiply_a_input->default_value_typed<bNodeSocketValueVector>()->value,
2466 displacement_input->default_value_typed<bNodeSocketValueVector>()->value);
2467 if (displacement_link) {
2468 version_node_add_link(node_tree,
2469 *displacement_link->fromnode,
2470 *displacement_link->fromsock,
2471 *multiply_node,
2472 *multiply_a_input);
2473 bke::node_remove_link(&node_tree, *displacement_link);
2474 }
2475
2476 version_node_add_link(node_tree, *multiply_node, *multiply_output, node, *displacement_input);
2477
2478 bNode *combine_node = bke::node_add_node(nullptr, node_tree, "ShaderNodeCombineXYZ"_ustr);
2479 combine_node->parent = node.parent;
2480 combine_node->location[0] = multiply_node->location[0] - multiply_node->width - 20.0f;
2481 combine_node->location[1] = multiply_node->location[1];
2482
2483 bNodeSocket *combine_x_input = bke::node_find_socket(*combine_node, SOCK_IN, "X"_ustr);
2484 bNodeSocket *combine_y_input = bke::node_find_socket(*combine_node, SOCK_IN, "Y"_ustr);
2485 bNodeSocket *combine_output = bke::node_find_socket(*combine_node, SOCK_OUT, "Vector"_ustr);
2486
2488 node_tree, *combine_node, *combine_output, *multiply_node, *multiply_b_input);
2489
2490 combine_x_input->default_value_typed<bNodeSocketValueFloat>()->value =
2491 x_scale_input->default_value_typed<bNodeSocketValueFloat>()->value;
2492 if (x_scale_link) {
2493 version_node_add_link(node_tree,
2494 *x_scale_link->fromnode,
2495 *x_scale_link->fromsock,
2496 *combine_node,
2497 *combine_x_input);
2498 bke::node_remove_link(&node_tree, *x_scale_link);
2499 }
2500
2501 combine_y_input->default_value_typed<bNodeSocketValueFloat>()->value =
2502 y_scale_input->default_value_typed<bNodeSocketValueFloat>()->value;
2503 if (y_scale_link) {
2504 version_node_add_link(node_tree,
2505 *y_scale_link->fromnode,
2506 *y_scale_link->fromsock,
2507 *combine_node,
2508 *combine_y_input);
2509 bke::node_remove_link(&node_tree, *y_scale_link);
2510 }
2511}
2512
2513/* The Size input is now in pixels, while previously, it was relative to 0.01 of the greater image
2514 * dimension. */
2516{
2517 bke::node_tree_set_type(node_tree);
2518
2519 bNodeSocket *image_input = bke::node_find_socket(node, SOCK_IN, "Image"_ustr);
2520 bNodeSocket *size_input = bke::node_find_socket(node, SOCK_IN, "Size"_ustr);
2521
2522 /* Find the link going into the inputs of the node. */
2523 bNodeLink *image_link = nullptr;
2524 bNodeLink *size_link = nullptr;
2525 for (bNodeLink &link : node_tree.links) {
2526 if (link.tosock == size_input) {
2527 size_link = &link;
2528 }
2529 if (link.tosock == image_input) {
2530 image_link = &link;
2531 }
2532 }
2533
2534 bNode &multiply_node = version_node_add_empty(node_tree, "ShaderNodeMath");
2535 multiply_node.parent = node.parent;
2536 multiply_node.location[0] = node.location[0] - node.width - 20.0f;
2537 multiply_node.location[1] = node.location[1];
2538 multiply_node.custom1 = NODE_MATH_MULTIPLY;
2539
2540 bNodeSocket &multiply_a_input = version_node_add_socket(
2541 node_tree, multiply_node, SOCK_IN, "NodeSocketFloat", "Value");
2542 bNodeSocket &multiply_b_input = version_node_add_socket(
2543 node_tree, multiply_node, SOCK_IN, "NodeSocketFloat", "Value_001");
2544 bNodeSocket &multiply_output = version_node_add_socket(
2545 node_tree, multiply_node, SOCK_OUT, "NodeSocketFloat", "Value");
2546
2547 multiply_a_input.default_value_typed<bNodeSocketValueFloat>()->value =
2548 size_input->default_value_typed<bNodeSocketValueFloat>()->value;
2549 if (size_link) {
2551 node_tree, *size_link->fromnode, *size_link->fromsock, multiply_node, multiply_a_input);
2552 bke::node_remove_link(&node_tree, *size_link);
2553 }
2554
2555 version_node_add_link(node_tree, multiply_node, multiply_output, node, *size_input);
2556
2557 bNode *relative_to_pixel_node = bke::node_add_node(
2558 nullptr, node_tree, "CompositorNodeRelativeToPixel"_ustr);
2559 relative_to_pixel_node->parent = node.parent;
2560 relative_to_pixel_node->location[0] = multiply_node.location[0] - multiply_node.width - 20.0f;
2561 relative_to_pixel_node->location[1] = multiply_node.location[1];
2562 relative_to_pixel_node->custom1 = CMP_NODE_RELATIVE_TO_PIXEL_DATA_TYPE_FLOAT;
2564
2565 bNodeSocket *relative_to_pixel_image_input = bke::node_find_socket(
2566 *relative_to_pixel_node, SOCK_IN, "Image"_ustr);
2567 bNodeSocket *relative_to_pixel_value_input = bke::node_find_socket(
2568 *relative_to_pixel_node, SOCK_IN, "Float Value"_ustr);
2569 bNodeSocket *relative_to_pixel_value_output = bke::node_find_socket(
2570 *relative_to_pixel_node, SOCK_OUT, "Float Value"_ustr);
2571
2572 version_node_add_link(node_tree,
2573 *relative_to_pixel_node,
2574 *relative_to_pixel_value_output,
2575 multiply_node,
2576 multiply_b_input);
2577
2578 relative_to_pixel_value_input->default_value_typed<bNodeSocketValueFloat>()->value = 0.01f;
2579 if (image_link) {
2580 version_node_add_link(node_tree,
2581 *image_link->fromnode,
2582 *image_link->fromsock,
2583 *relative_to_pixel_node,
2584 *relative_to_pixel_image_input);
2585 }
2586}
2587
2589{
2590 bScreen *screen = WM_window_get_active_screen(win);
2591 if (!screen) {
2592 return false;
2593 }
2594 for (ScrArea &area : screen->areabase) {
2595 for (SpaceLink &sl : area.spacedata) {
2596 if (sl.spacetype == SPACE_SEQ) {
2597 return true;
2598 }
2599 }
2600 }
2601 return false;
2602}
2603
2604/* Merge transform effect properties with strip transform. Because this effect could use modifiers,
2605 * change its type to gaussian blur with 0 radius. */
2606static void sequencer_substitute_transform_effects(Scene *scene, const DriverMap &driver_map)
2607{
2608 seq::foreach_strip(&scene->ed->seqbase, [&](Strip *strip) -> bool {
2609 if (strip->type == STRIP_TYPE_TRANSFORM_LEGACY && strip->effectdata != nullptr) {
2610 TransformVarsLegacy *tv = static_cast<TransformVarsLegacy *>(strip->effectdata);
2611 StripTransform *transform = strip->data->transform;
2612 float2 offset(tv->xIni, tv->yIni);
2613 if (tv->percent == 1) {
2614 float2 scene_resolution(scene->r.xsch, scene->r.ysch);
2615 offset *= scene_resolution / 100;
2616 }
2617 transform->xofs += offset.x;
2618 transform->yofs += offset.y;
2619 transform->scale_x *= tv->ScalexIni;
2620 transform->scale_y *= tv->ScaleyIni;
2621 transform->rotation += DEG2RADF(tv->rotIni);
2622 seq::effect_free(strip);
2623 strip->type = STRIP_TYPE_GAUSSIAN_BLUR;
2624 seq::effect_ensure_initialized(strip);
2625 GaussianBlurVars *gv = static_cast<GaussianBlurVars *>(strip->effectdata);
2626 gv->size_x = gv->size_y = 0.0f;
2627 seq::edit_strip_name_set(scene, strip, "Transform Placeholder (Migrated)");
2628 seq::ensure_unique_name(strip, scene, driver_map);
2629 }
2630 return true;
2631 });
2632}
2633
2634/* The LGG mode of the Color Balance node was being done in sRGB space, while now it is done in
2635 * linear space. So a Gamma node will be added before and after the node to perform the adjustment
2636 * in sRGB space. */
2638{
2639 bNodeSocket *image_input = bke::node_find_socket(node, SOCK_IN, "Image"_ustr);
2640 bNodeSocket *type_input = bke::node_find_socket(node, SOCK_IN, "Type"_ustr);
2641 bNodeSocket *image_output = bke::node_find_socket(node, SOCK_OUT, "Image"_ustr);
2642
2643 /* Find the links going into and out of the node. */
2644 bNodeLink *image_input_link = nullptr;
2645 bNodeLink *type_input_link = nullptr;
2646 for (bNodeLink &link : node_tree.links) {
2647 if (link.tosock == image_input) {
2648 image_input_link = &link;
2649 }
2650 if (link.tosock == type_input) {
2651 type_input_link = &link;
2652 }
2653 }
2654
2655 if (type_input_link || !type_input ||
2656 type_input->default_value_typed<bNodeSocketValueMenu>()->value != CMP_NODE_COLOR_BALANCE_LGG)
2657 {
2658 return;
2659 }
2660
2661 bNode *inverse_gamma_node = bke::node_add_static_node(nullptr, node_tree, SH_NODE_GAMMA);
2662 inverse_gamma_node->parent = node.parent;
2663 inverse_gamma_node->location[0] = node.location[0];
2664 inverse_gamma_node->location[1] = node.location[1];
2665
2666 bNodeSocket *inverse_gamma_color_input = bke::node_find_socket(
2667 *inverse_gamma_node, SOCK_IN, "Color"_ustr);
2668 copy_v4_v4(inverse_gamma_color_input->default_value_typed<bNodeSocketValueRGBA>()->value,
2669 image_input->default_value_typed<bNodeSocketValueRGBA>()->value);
2670 bNodeSocket *inverse_gamma_color_output = bke::node_find_socket(
2671 *inverse_gamma_node, SOCK_OUT, "Color"_ustr);
2672
2673 bNodeSocket *inverse_gamma_input = bke::node_find_socket(
2674 *inverse_gamma_node, SOCK_IN, "Gamma"_ustr);
2675 inverse_gamma_input->default_value_typed<bNodeSocketValueFloat>()->value = 1.0f / 2.2f;
2676
2678 node_tree, *inverse_gamma_node, *inverse_gamma_color_output, node, *image_input);
2679 if (image_input_link) {
2680 version_node_add_link(node_tree,
2681 *image_input_link->fromnode,
2682 *image_input_link->fromsock,
2683 *inverse_gamma_node,
2684 *inverse_gamma_color_input);
2685 bke::node_remove_link(&node_tree, *image_input_link);
2686 }
2687
2688 bNode *gamma_node = bke::node_add_static_node(nullptr, node_tree, SH_NODE_GAMMA);
2689 gamma_node->parent = node.parent;
2690 gamma_node->location[0] = node.location[0];
2691 gamma_node->location[1] = node.location[1];
2692
2693 bNodeSocket *gamma_color_input = bke::node_find_socket(*gamma_node, SOCK_IN, "Color"_ustr);
2694 bNodeSocket *gamma_color_output = bke::node_find_socket(*gamma_node, SOCK_OUT, "Color"_ustr);
2695
2696 bNodeSocket *gamma_input = bke::node_find_socket(*gamma_node, SOCK_IN, "Gamma"_ustr);
2697 gamma_input->default_value_typed<bNodeSocketValueFloat>()->value = 2.2f;
2698
2699 for (bNodeLink &link : node_tree.links.items_reversed_mutable()) {
2700 if (link.fromsock != image_output) {
2701 continue;
2702 }
2703
2704 version_node_add_link(node_tree, *gamma_node, *gamma_color_output, *link.tonode, *link.tosock);
2705 bke::node_remove_link(&node_tree, link);
2706 }
2707
2708 version_node_add_link(node_tree, node, *image_output, *gamma_node, *gamma_color_input);
2709}
2710
2712{
2713 using namespace blender::animrig;
2714 constexpr char const *hide_prop_prefix = "bones[";
2715 constexpr char const *hide_prop_suffix = "\"].hide";
2716
2717 Vector<FCurve *> drivers_to_fix;
2718 for (FCurve &fcurve : arm_adt->drivers) {
2719 const StringRefNull rna_path = fcurve.rna_path();
2720 int quoted_bone_name_start = 0;
2721 int quoted_bone_name_end = 0;
2722 const bool is_prefix_found = BLI_str_quoted_substr_range(
2723 rna_path.c_str(), hide_prop_prefix, &quoted_bone_name_start, &quoted_bone_name_end);
2724 if (is_prefix_found && STREQ(rna_path.c_str() + quoted_bone_name_end, hide_prop_suffix)) {
2725 drivers_to_fix.append(&fcurve);
2726 }
2727 }
2728
2729 if (drivers_to_fix.is_empty()) {
2730 return;
2731 }
2732
2733 for (Object *ob : users) {
2734 AnimData *ob_adt = BKE_animdata_ensure_id(&ob->id);
2735 for (FCurve *original : drivers_to_fix) {
2736 /* Has to be a copy in case there is more than 1 object using the armature. */
2737 FCurve *copy = BKE_fcurve_copy(original);
2738 char *fixed_path = BLI_string_joinN("pose.", copy->rna_path().c_str());
2739 copy->rna_path_set_move(fixed_path);
2740 BLI_addtail(&ob_adt->drivers, copy);
2741 }
2742 }
2743
2744 for (FCurve *original : drivers_to_fix) {
2745 BLI_remlink(&arm_adt->drivers, original);
2746 BKE_fcurve_free(original);
2747 }
2748}
2749
2751{
2752 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 9)) {
2753 for (Scene &scene : bmain->scenes) {
2756 }
2757 }
2758 }
2759
2760 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 27)) {
2761 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2762 if (ntree->type == NTREE_COMPOSIT) {
2764 }
2765 }
2767 }
2768
2769 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 37)) {
2770 for (Object &object : bmain->objects) {
2772 }
2773 }
2774
2775 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 41)) {
2776 for (Scene &scene : bmain->scenes) {
2777 bNodeTree *node_tree = version_get_scene_compositor_node_tree(bmain, &scene);
2778 if (node_tree) {
2779 /* Add a default interface for the node tree. See the versioning function below for more
2780 * details. */
2781 node_tree->tree_interface.clear_items();
2782 node_tree->tree_interface.add_socket(
2783 DATA_("Image"), "", "NodeSocketColor", NODE_INTERFACE_SOCKET_INPUT, nullptr);
2784 node_tree->tree_interface.add_socket(
2785 DATA_("Image"), "", "NodeSocketColor", NODE_INTERFACE_SOCKET_OUTPUT, nullptr);
2786
2787 bNode *active_group_output = nullptr;
2788 for (bNode &node : node_tree->nodes.items_reversed_mutable()) {
2789 if (node.type_legacy == CMP_NODE_COMPOSITE_DEPRECATED) {
2790 active_group_output = do_version_composite_node_in_scene_tree(*node_tree, node);
2791 }
2792 }
2793 if (active_group_output) {
2794 for (bNode &node : node_tree->nodes) {
2795 if (node.type_legacy == NODE_GROUP_OUTPUT) {
2796 node.flag &= ~NODE_DO_OUTPUT;
2797 }
2798 }
2799
2800 active_group_output->flag |= NODE_DO_OUTPUT;
2801 }
2802 }
2803 }
2804 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
2805 bke::node_tree_set_type(*node_tree);
2806 if (node_tree->type == NTREE_COMPOSIT) {
2807 for (bNode &node : node_tree->nodes.items_reversed_mutable()) {
2808 if (node.type_legacy == CMP_NODE_COMPOSITE_DEPRECATED) {
2809 /* See do_version_composite_node_in_scene_tree. */
2810 version_node_remove(*node_tree, node);
2811 }
2812 }
2813 }
2814 }
2816 }
2817
2818 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 54)) {
2819 for (Object &object : bmain->objects) {
2820 if (object.type != OB_ARMATURE || !object.data) {
2821 continue;
2822 }
2823 BKE_pose_rebuild(nullptr, &object, id_cast<bArmature *>(object.data), false);
2824 for (bPoseChannel &pose_bone : object.pose->chanbase) {
2825 if (pose_bone.bone_get(object)->flag & BONE_HIDDEN_P) {
2826 pose_bone.drawflag |= PCHAN_DRAW_HIDDEN;
2827 }
2828 else {
2829 pose_bone.drawflag &= ~PCHAN_DRAW_HIDDEN;
2830 }
2831 }
2832 }
2833 }
2834
2835 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 57)) {
2836 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
2837 if (node_tree->type == NTREE_COMPOSIT) {
2838 for (bNode &node : node_tree->nodes.items_reversed_mutable()) {
2839 if (node.type_legacy == CMP_NODE_SUNBEAMS_DEPRECATED) {
2840 do_version_sun_beams(*node_tree, node);
2841 }
2842 }
2843 }
2844 }
2846 }
2847
2848 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 63)) {
2849 for (wmWindowManager &wm : bmain->wm) {
2850 for (wmWindow &win : wm.windows) {
2852 Scene *scene = WM_window_get_active_scene(&win);
2853 if (scene->ed != nullptr) {
2854 WorkSpace *workspace = WM_window_get_active_workspace(&win);
2855 workspace->sequencer_scene = scene;
2856 }
2857 }
2858 }
2859 }
2860 }
2861
2862 /* Menus were converted into inputs, so the input indices were changed, see the same subversion
2863 * in blo_do_versions_500. */
2864 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 66)) {
2873 }
2874
2875 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 97)) {
2876 const DriverMap driver_map = BKE_animdata_build_driver_target_map(*bmain);
2877 for (Scene &scene : bmain->scenes) {
2878 if (scene.ed != nullptr) {
2879 sequencer_substitute_transform_effects(&scene, driver_map);
2880 }
2881 }
2882 }
2883
2884 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 101)) {
2885 const uint8_t default_flags = ToolSettings().fix_to_cam_flag;
2886 for (Scene &scene : bmain->scenes) {
2887 if (!scene.toolsettings) {
2888 continue;
2889 }
2890 scene.toolsettings->fix_to_cam_flag = default_flags;
2891 }
2892 }
2893
2894 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 110)) {
2895 /* Build map of armature->object to quickly find out afterwards which armature is used by which
2896 * objects. */
2897 Map<bArmature *, Vector<Object *>> armature_usage_map;
2898 for (Object &ob : bmain->objects) {
2899 if (ob.type != OB_ARMATURE || !ob.data) {
2900 continue;
2901 }
2902 bArmature *arm = reinterpret_cast<bArmature *>(ob.data);
2903 Vector<Object *> &users = armature_usage_map.lookup_or_add_default(arm);
2904 users.append(&ob);
2905 }
2906
2907 for (bArmature &armature : bmain->armatures) {
2908 AnimData *arm_adt = BKE_animdata_from_id(&armature.id);
2909
2910 if (!arm_adt || arm_adt->drivers.is_empty()) {
2911 continue;
2912 }
2913
2914 Vector<Object *> *users = armature_usage_map.lookup_ptr(&armature);
2915 if (!users) {
2916 /* If `users` is a nullptr that means there is no user of that armature. That means the
2917 * property won't be fixed for armatures that are not used by an object during versioning.
2918 * However since the driver has to be moved to an object there is no way to fix it in this
2919 * case. */
2920 continue;
2921 }
2922
2923 version_bone_hide_property_driver(arm_adt, *users);
2924 }
2925 }
2926
2933}
2934
2936{
2937 const Span old_sockets(panel.items_array, panel.items_num);
2938
2940 for (bNodeTreeInterfaceItem *item : old_sockets) {
2941 if (item->item_type == NodeTreeInterfaceItemType::Panel) {
2943 continue;
2944 }
2945 bNodeTreeInterfaceSocket *socket = reinterpret_cast<bNodeTreeInterfaceSocket *>(item);
2946 constexpr int in_and_out = NODE_INTERFACE_SOCKET_INPUT | NODE_INTERFACE_SOCKET_OUTPUT;
2947 if ((socket->flag & in_and_out) != in_and_out) {
2948 continue;
2949 }
2950
2951 bNodeTreeInterfaceSocket *new_output = MEM_new<bNodeTreeInterfaceSocket>(__func__);
2953 new_output->name_ = BLI_strdup_null(socket->name_);
2954 new_output->description_ = BLI_strdup_null(socket->description_);
2955 new_output->socket_type = BLI_strdup_null(socket->socket_type);
2956 new_output->flag = socket->flag & ~NODE_INTERFACE_SOCKET_INPUT;
2957 new_output->attribute_domain = socket->attribute_domain;
2958 new_output->default_input = socket->default_input;
2960 new_output->identifier = BLI_strdup(socket->identifier);
2961 if (socket->properties) {
2962 new_output->properties = IDP_CopyProperty_ex(socket->properties,
2964 }
2965 new_output->structure_type = socket->structure_type;
2966 new_sockets.append(reinterpret_cast<bNodeTreeInterfaceItem *>(new_output));
2967
2969 }
2970
2971 if (new_sockets.is_empty()) {
2972 return;
2973 }
2974
2975 new_sockets.extend(old_sockets);
2976 VectorData new_socket_data = new_sockets.release();
2977 MEM_delete(panel.items_array);
2978 panel.items_array = new_socket_data.data;
2979 panel.items_num = new_socket_data.size;
2980}
2981
2990
2992{
2993 Map<bNodeSocket *, bNode *> socket_to_node;
2994 for (bNode &node : node_tree.nodes) {
2995 for (bNodeSocket &socket : node.inputs) {
2996 socket_to_node.add(&socket, &node);
2997 }
2998 for (bNodeSocket &socket : node.outputs) {
2999 socket_to_node.add(&socket, &node);
3000 }
3001 }
3002 for (bNodeLink &link : node_tree.links) {
3003 bool fixed = false;
3004 bNode *to_node = socket_to_node.lookup(link.tosock);
3005 if (to_node != link.tonode) {
3006 link.tonode = to_node;
3007 fixed = true;
3008 }
3009 bNode *from_node = socket_to_node.lookup(link.fromsock);
3010 if (from_node != link.fromnode) {
3011 link.fromnode = from_node;
3012 fixed = true;
3013 }
3014 if (fixed) {
3017 "Repairing invalid state in node link from %s:%s to %s:%s",
3018 link.fromnode->name,
3019 link.fromsock->identifier,
3020 link.tonode->name,
3021 link.tosock->identifier);
3022 }
3023 }
3024}
3025
3027{
3028 Editing *ed = scene.ed;
3029 if (!ed) {
3030 return;
3031 }
3032 const MetaStack *last_meta_stack = seq::meta_stack_active_get(ed);
3033 if (!last_meta_stack) {
3034 return;
3035 }
3036 ed->current_meta_strip = last_meta_stack->parent_strip;
3037 seq::meta_stack_set(&scene, last_meta_stack->parent_strip);
3038}
3039
3041{
3042 /* Move cycles properties natively into subdivision surface modifier. */
3043 bool experimental_features = false;
3044 for (Scene &scene : bmain->scenes) {
3046 if (idprop) {
3047 experimental_features |= version_cycles_property_boolean(idprop, "feature_set", false);
3048 }
3049 }
3050
3051 for (Object &object : bmain->objects) {
3052 bool use_adaptive_subdivision = false;
3053 float dicing_rate = 1.0f;
3054
3056 if (idprop) {
3057 if (experimental_features) {
3058 use_adaptive_subdivision = version_cycles_property_boolean(
3059 idprop, "use_adaptive_subdivision", false);
3060 }
3061 dicing_rate = version_cycles_property_float(idprop, "dicing_rate", 1.0f);
3062 }
3063
3064 for (ModifierData &md : object.modifiers) {
3065 if (md.type == eModifierType_Subsurf) {
3066 SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData *>(&md);
3068 smd->adaptive_pixel_size = dicing_rate;
3069 smd->adaptive_object_edge_length = 0.01f;
3070
3071 if (use_adaptive_subdivision) {
3073 }
3074 }
3075 }
3076 }
3077}
3078
3080{
3081 using namespace blender::bke;
3082
3083 for (bNode &node : node_tree->nodes.items_reversed_mutable()) {
3084 if (node.type_legacy != SH_NODE_TEX_GRADIENT) {
3085 continue;
3086 }
3088 return;
3089 }
3090 auto *data = static_cast<NodeTexGradient *>(node.storage);
3092 /* Nothing to do. No changes for other gradient types. */
3093 continue;
3094 }
3095
3096 bNodeSocket *factor_output = node_find_socket(node, SOCK_OUT, "Fac"_ustr);
3097 bNodeSocket *color_output = node_find_socket(node, SOCK_OUT, "Color"_ustr);
3098 bNodeSocket *vector_input = node_find_socket(node, SOCK_IN, "Vector"_ustr);
3099
3100 bool is_factor_output_linked = false;
3101 bool is_color_output_linked = false;
3102 bNodeLink *vector_input_link = nullptr;
3103
3104 for (bNodeLink &link : node_tree->links) {
3105 if (link.fromsock == factor_output) {
3106 is_factor_output_linked = true;
3107 }
3108 else if (link.fromsock == color_output) {
3109 is_color_output_linked = true;
3110 }
3111 else if (link.tosock == vector_input) {
3112 vector_input_link = &link;
3113 }
3114 }
3115
3116 if (!is_factor_output_linked && !is_color_output_linked) {
3117 /* Node is not linked, nothing to do. */
3118 continue;
3119 }
3120
3121 bNode *gradient_node = nullptr;
3122 bNodeSocket *gradient_socket = nullptr;
3123
3124 bNode &separate = version_node_add_empty(*node_tree, "ShaderNodeSeparateXYZ");
3125 bNodeSocket &separate_input = version_node_add_socket(
3126 *node_tree, separate, SOCK_IN, "NodeSocketVector", "Vector");
3127 bNodeSocket &separate_x_output = version_node_add_socket(
3128 *node_tree, separate, SOCK_OUT, "NodeSocketFloat", "X");
3129 bNodeSocket &separate_y_output = version_node_add_socket(
3130 *node_tree, separate, SOCK_OUT, "NodeSocketFloat", "Y");
3131 version_node_add_socket(*node_tree, separate, SOCK_OUT, "NodeSocketFloat", "Z");
3132
3133 copy_v2_v2(separate.location, node.location);
3134
3135 switch (data->gradient_type) {
3136 case SHD_BLEND_LINEAR: {
3137 /* Gradient = X */
3138 gradient_node = &separate;
3139 gradient_socket = &separate_x_output;
3140 break;
3141 }
3142 case SHD_BLEND_QUADRATIC: {
3143 /* Gradient = (max(X, 0))^2 */
3144 bNode &max = version_node_add_empty(*node_tree, "ShaderNodeMath");
3145 bNodeSocket &max_input_a = version_node_add_socket(
3146 *node_tree, max, SOCK_IN, "NodeSocketFloat", "Value");
3147 bNodeSocket &max_input_b = version_node_add_socket(
3148 *node_tree, max, SOCK_IN, "NodeSocketFloat", "Value_001");
3149 version_node_add_socket(*node_tree, max, SOCK_IN, "NodeSocketFloat", "Value_002");
3150
3152 *node_tree, max, SOCK_OUT, "NodeSocketFloat", "Value");
3153
3154 max.location[0] = separate.location[0] + 20.0f;
3155 max.location[1] = separate.location[1];
3156
3157 max.custom1 = NODE_MATH_MAXIMUM;
3158
3159 version_node_add_link(*node_tree, separate, separate_x_output, max, max_input_a);
3160 max_input_b.default_value_typed<bNodeSocketValueFloat>()->value = 0.0f;
3161
3162 bNode &multiply = version_node_add_empty(*node_tree, "ShaderNodeMath");
3163
3164 bNodeSocket &multiply_input_a = version_node_add_socket(
3165 *node_tree, multiply, SOCK_IN, "NodeSocketFloat", "Value");
3166 bNodeSocket &multiply_input_b = version_node_add_socket(
3167 *node_tree, multiply, SOCK_IN, "NodeSocketFloat", "Value_001");
3168 version_node_add_socket(*node_tree, multiply, SOCK_IN, "NodeSocketFloat", "Value_002");
3169
3170 bNodeSocket &multiply_output = version_node_add_socket(
3171 *node_tree, multiply, SOCK_OUT, "NodeSocketFloat", "Value");
3172
3173 multiply.location[0] = max.location[0] + 20.0f;
3174 multiply.location[1] = max.location[1];
3175 multiply.custom1 = NODE_MATH_MULTIPLY;
3176
3177 version_node_add_link(*node_tree, max, max_output, multiply, multiply_input_a);
3178 version_node_add_link(*node_tree, max, max_output, multiply, multiply_input_b);
3179
3180 gradient_node = &multiply;
3181 gradient_socket = &multiply_output;
3182 break;
3183 }
3184 case SHD_BLEND_DIAGONAL: {
3185 /* Gradient = (X + Y) * 0.5. */
3186 bNode &add = version_node_add_empty(*node_tree, "ShaderNodeMath");
3187 bNodeSocket &add_input_a = version_node_add_socket(
3188 *node_tree, add, SOCK_IN, "NodeSocketFloat", "Value");
3189 bNodeSocket &add_input_b = version_node_add_socket(
3190 *node_tree, add, SOCK_IN, "NodeSocketFloat", "Value_001");
3191 version_node_add_socket(*node_tree, add, SOCK_IN, "NodeSocketFloat", "Value_002");
3192
3194 *node_tree, add, SOCK_OUT, "NodeSocketFloat", "Value");
3195
3196 add.location[0] = separate.location[0] + 20.0f;
3197 add.location[1] = separate.location[1];
3198 add.custom1 = NODE_MATH_ADD;
3199
3200 version_node_add_link(*node_tree, separate, separate_x_output, add, add_input_a);
3201 version_node_add_link(*node_tree, separate, separate_y_output, add, add_input_b);
3202
3203 bNode &multiply = version_node_add_empty(*node_tree, "ShaderNodeMath");
3204 bNodeSocket &multiply_input_a = version_node_add_socket(
3205 *node_tree, multiply, SOCK_IN, "NodeSocketFloat", "Value");
3206 bNodeSocket &multiply_input_b = version_node_add_socket(
3207 *node_tree, multiply, SOCK_IN, "NodeSocketFloat", "Value_001");
3208 version_node_add_socket(*node_tree, multiply, SOCK_IN, "NodeSocketFloat", "Value_002");
3209
3210 bNodeSocket &multiply_output = version_node_add_socket(
3211 *node_tree, multiply, SOCK_OUT, "NodeSocketFloat", "Value");
3212
3213 copy_v2_v2(multiply.location, node.location);
3214 multiply.location[0] = add.location[0] + 20.0f;
3215 multiply.location[1] = add.location[1];
3216
3217 multiply.custom1 = NODE_MATH_MULTIPLY;
3218
3219 version_node_add_link(*node_tree, add, add_output, multiply, multiply_input_a);
3220
3221 static_cast<bNodeSocketValueFloat *>(multiply_input_b.default_value)->value = 0.5f;
3222
3223 gradient_node = &multiply;
3224 gradient_socket = &multiply_output;
3225 break;
3226 }
3227 }
3228
3229 if (is_factor_output_linked) {
3230 /* Output socket can be connected to multiple nodes, so consider all links. */
3231 for (bNodeLink &link : node_tree->links.items_reversed_mutable()) {
3232 if (link.fromsock == factor_output) {
3234 *node_tree, *gradient_node, *gradient_socket, *link.tonode, *link.tosock);
3235 node_remove_link(node_tree, link);
3236 }
3237 }
3238 }
3239
3240 if (is_color_output_linked) {
3241 bNode &combine = version_node_add_empty(*node_tree, "FunctionNodeCombineColor");
3242 bNodeSocket &combine_red = version_node_add_socket(
3243 *node_tree, combine, SOCK_IN, "NodeSocketFloat", "Red");
3244 bNodeSocket &combine_green = version_node_add_socket(
3245 *node_tree, combine, SOCK_IN, "NodeSocketFloat", "Green");
3246 bNodeSocket &combine_blue = version_node_add_socket(
3247 *node_tree, combine, SOCK_IN, "NodeSocketFloat", "Blue");
3248 bNodeSocket &combine_alpha = version_node_add_socket(
3249 *node_tree, combine, SOCK_IN, "NodeSocketFloat", "Alpha");
3250
3251 bNodeSocket &combine_output = version_node_add_socket(
3252 *node_tree, combine, SOCK_OUT, "NodeSocketColor", "Color");
3253
3254 NodeCombSepColor *storage = MEM_new<NodeCombSepColor>(__func__);
3256 combine.storage = storage;
3257
3258 combine.location[0] = gradient_node->location[0] + 20.0f;
3259 combine.location[1] = gradient_node->location[1];
3260
3261 version_node_add_link(*node_tree, *gradient_node, *gradient_socket, combine, combine_red);
3262 version_node_add_link(*node_tree, *gradient_node, *gradient_socket, combine, combine_green);
3263 version_node_add_link(*node_tree, *gradient_node, *gradient_socket, combine, combine_blue);
3264
3265 static_cast<bNodeSocketValueFloat *>(combine_alpha.default_value)->value = 1.0f;
3266
3267 for (bNodeLink &link : node_tree->links.items_reversed_mutable()) {
3268 if (link.fromsock == color_output) {
3269 version_node_add_link(*node_tree, combine, combine_output, *link.tonode, *link.tosock);
3270 node_remove_link(node_tree, link);
3271 }
3272 }
3273
3274 gradient_node = &combine;
3275 gradient_socket = &combine_output;
3276 }
3277
3278 if (vector_input_link) {
3279 version_node_add_link(*node_tree,
3280 *vector_input_link->fromnode,
3281 *vector_input_link->fromsock,
3282 separate,
3283 separate_input);
3284 node_remove_link(node_tree, *vector_input_link);
3285 }
3286 else {
3287 /* Gradient texture's input in geometry nodes defaults to using Input Position if it's not
3288 * connected. */
3289 bNode &position = version_node_add_empty(*node_tree, "GeometryNodeInputPosition");
3290 bNodeSocket &position_output = version_node_add_socket(
3291 *node_tree, position, SOCK_OUT, "NodeSocketVector", "Position");
3292 position.location[0] = separate.location[0] - 20.0f;
3293 position.location[1] = separate.location[1] - 20.0f;
3294
3295 version_node_add_link(*node_tree, position, position_output, separate, separate_input);
3296 }
3297
3298 node_tree_set_type(*node_tree);
3299 version_node_remove(*node_tree, node);
3300 }
3301}
3302
3303void blo_do_versions_500(FileData *fd, Library * /*lib*/, Main *bmain)
3304{
3305 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 1)) {
3306 for (Mesh &mesh : bmain->meshes) {
3310 }
3311
3312 update_brush_sizes(*bmain);
3313 }
3314
3315 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 2)) {
3316 for (PointCloud &pointcloud : bmain->pointclouds) {
3318 }
3319 }
3320
3321 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 3)) {
3322 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3323 if (ntree->type == NTREE_GEOMETRY) {
3325 }
3326 }
3328 }
3329
3330 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 7)) {
3331 const int uv_select_island = 1 << 3;
3332 for (Scene &scene : bmain->scenes) {
3333 ToolSettings *ts = scene.toolsettings;
3334 if (ts->uv_selectmode & uv_select_island) {
3337 }
3338 }
3339 }
3340
3341 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 8)) {
3342 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3343 if (ntree->type != NTREE_COMPOSIT) {
3344 continue;
3345 }
3346 for (bNode &node : ntree->nodes) {
3347 if (node.type_legacy != CMP_NODE_DISPLACE) {
3348 continue;
3349 }
3350 if (node.storage != nullptr) {
3351 continue;
3352 }
3353 NodeDisplaceData *data = MEM_new<NodeDisplaceData>(__func__);
3355 node.storage = data;
3356 }
3357 }
3359 }
3360
3361 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 10)) {
3362 for (Scene &scene : bmain->scenes) {
3363 for (ViewLayer &view_layer : scene.view_layers) {
3365 }
3366 }
3367 }
3368
3369 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 13)) {
3370 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3371 if (ntree->type == NTREE_COMPOSIT) {
3372 version_node_socket_name(ntree, CMP_NODE_VIEW_LEVELS, "Std Dev", "Standard Deviation");
3373 }
3374 }
3376 }
3377
3378 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 14)) {
3379 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3381 }
3383 }
3384
3385 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 15)) {
3386 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3387 if (ntree->type == NTREE_COMPOSIT) {
3388 version_node_socket_name(ntree, CMP_NODE_ROTATE, "Degr", "Angle");
3389 }
3390 }
3392 }
3393
3394 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 17)) {
3395 for (Scene &scene : bmain->scenes) {
3397 }
3398 }
3399
3400 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 20)) {
3401 for (bScreen &screen : bmain->screens) {
3402 for (ScrArea &area : screen.areabase) {
3403 for (SpaceLink &sl : area.spacedata) {
3405 continue;
3406 }
3407 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
3408 &sl.regionbase;
3410 regionbase, RGN_TYPE_FOOTER, "footer for animation editors", RGN_TYPE_HEADER);
3411 if (new_footer == nullptr) {
3412 continue;
3413 }
3414
3415 new_footer->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP :
3417 if (ELEM(sl.spacetype, SPACE_GRAPH, SPACE_NLA)) {
3418 new_footer->flag |= RGN_FLAG_HIDDEN;
3419 }
3420 }
3421 }
3422 }
3423 }
3424
3425 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 21)) {
3426 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3427 if (node_tree->type == NTREE_COMPOSIT) {
3428 for (bNode &node : node_tree->nodes.items_mutable()) {
3429 if (node.type_legacy == CMP_NODE_NORMAL) {
3431 }
3432 }
3433 }
3434 }
3436 }
3437
3438 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 25)) {
3440 }
3441
3442 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 26)) {
3443 for (Scene &scene : bmain->scenes) {
3445 }
3446 }
3447
3448 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 27)) {
3449 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3450 if (ntree->type == NTREE_COMPOSIT) {
3452 }
3453 }
3455 }
3456
3457 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 28)) {
3458 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3459 if (node_tree->type == NTREE_COMPOSIT) {
3460 for (bNode &node : node_tree->nodes) {
3461 if (node.type_legacy == CMP_NODE_SPLIT) {
3463 }
3464 }
3465 }
3466 }
3468 }
3469
3470 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 30)) {
3471 for (bScreen &screen : bmain->screens) {
3472 for (ScrArea &area : screen.areabase) {
3473 for (SpaceLink &sl : area.spacedata) {
3474 if (sl.spacetype != SPACE_FILE) {
3475 continue;
3476 }
3477 SpaceFile *sfile = reinterpret_cast<SpaceFile *>(&sl);
3478 if (sfile->browse_mode != FILE_BROWSE_MODE_ASSETS) {
3479 continue;
3480 }
3482 }
3483 }
3484 }
3485 }
3486
3487 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 32)) {
3488 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3489 if (ntree->type != NTREE_COMPOSIT) {
3490 continue;
3491 }
3492 for (bNode &node : ntree->nodes) {
3493 if (node.type_legacy != CMP_NODE_TRANSLATE) {
3494 continue;
3495 }
3496 if (node.storage == nullptr) {
3497 continue;
3498 }
3499 NodeTranslateData *data = static_cast<NodeTranslateData *>(node.storage);
3500 /* Map old wrap axis to new extension mode. */
3501 switch (data->wrap_axis) {
3503 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3504 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3505 break;
3507 data->extension_x = CMP_NODE_EXTENSION_MODE_REPEAT;
3508 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3509 break;
3511 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3512 data->extension_y = CMP_NODE_EXTENSION_MODE_REPEAT;
3513 break;
3515 data->extension_x = CMP_NODE_EXTENSION_MODE_REPEAT;
3516 data->extension_y = CMP_NODE_EXTENSION_MODE_REPEAT;
3517 break;
3518 }
3519 }
3521 }
3522 }
3523
3524 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 32)) {
3525 for (Mesh &mesh : bmain->meshes) {
3526 mesh.radial_symmetry[0] = 1;
3527 mesh.radial_symmetry[1] = 1;
3528 mesh.radial_symmetry[2] = 1;
3529 }
3530 }
3531
3532 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 33)) {
3533 for (Curves &curves : bmain->hair_curves) {
3535 }
3536 for (GreasePencil &grease_pencil : bmain->grease_pencils) {
3538 for (const int i : IndexRange(grease_pencil.drawing_array_num)) {
3539 GreasePencilDrawingBase *drawing_base = grease_pencil.drawing_array[i];
3540 if (drawing_base->type == GP_DRAWING) {
3541 GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(drawing_base);
3542 bke::curves_convert_customdata_to_storage(drawing->wrap().strokes_for_write());
3543 }
3544 }
3545 }
3546 }
3547
3548 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 34)) {
3549 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3550 if (ntree->type != NTREE_COMPOSIT) {
3551 continue;
3552 }
3553 for (bNode &node : ntree->nodes) {
3554 if (node.type_legacy != CMP_NODE_SCALE) {
3555 continue;
3556 }
3557 if (node.storage == nullptr) {
3558 continue;
3559 }
3560 NodeScaleData *data = static_cast<NodeScaleData *>(node.storage);
3561 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3562 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3563 }
3565 }
3566 }
3567
3568 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 35)) {
3569 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3570 if (ntree->type != NTREE_COMPOSIT) {
3571 continue;
3572 }
3573 for (bNode &node : ntree->nodes) {
3574 if (node.type_legacy != CMP_NODE_TRANSFORM) {
3575 continue;
3576 }
3577 if (node.storage != nullptr) {
3578 continue;
3579 }
3580 NodeTransformData *data = MEM_new<NodeTransformData>(__func__);
3581 data->interpolation = node.custom1;
3582 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3583 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3584 node.storage = data;
3585 }
3587 }
3588 }
3589
3590 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 36)) {
3591 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3592 if (ntree->type == NTREE_COMPOSIT) {
3594 version_node_input_socket_name(ntree, CMP_NODE_ZCOMBINE, "Image_001", "B");
3595
3596 version_node_input_socket_name(ntree, CMP_NODE_ZCOMBINE, "Z", "Depth A");
3597 version_node_input_socket_name(ntree, CMP_NODE_ZCOMBINE, "Z_001", "Depth B");
3598
3599 version_node_output_socket_name(ntree, CMP_NODE_ZCOMBINE, "Image", "Result");
3601 }
3602 }
3604 }
3605
3606 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 38)) {
3607 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3608 if (node_tree->type == NTREE_GEOMETRY) {
3609 for (bNode &node : node_tree->nodes) {
3610 if (node.type_legacy == GEO_NODE_TRANSFORM_GEOMETRY) {
3612 }
3613 else if (node.type_legacy == GEO_NODE_POINTS_TO_VOLUME) {
3615 }
3616 else if (node.type_legacy == GEO_NODE_TRIANGULATE) {
3618 }
3619 else if (node.type_legacy == GEO_NODE_VOLUME_TO_MESH) {
3621 }
3622 else if (STREQ(node.idname, "FunctionNodeMatchString")) {
3624 }
3625 }
3626 }
3627 }
3629 }
3630
3631 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 39)) {
3632 for (Scene &scene : bmain->scenes) {
3633 Editing *ed = seq::editing_get(&scene);
3634
3635 if (ed != nullptr) {
3636 seq::foreach_strip(&ed->seqbase, [](Strip *strip) -> bool {
3637 for (StripModifierData &smd : strip->modifiers) {
3638 seq::modifier_persistent_uid_init(*strip, smd);
3639 }
3640 return true;
3641 });
3642 }
3643 }
3644 }
3645
3646 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 40)) {
3647 for (Brush &brush : bmain->brushes) {
3648 if (brush.gpencil_settings) {
3650 }
3651 }
3652 }
3653
3654 /* ImageFormatData gained a new media type which we need to be set according to the
3655 * existing imtype. */
3656 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 42)) {
3657 for (Scene &scene : bmain->scenes) {
3658 update_format_media_type(&scene.r.im_format);
3659 }
3660
3661 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3662 if (node_tree->type != NTREE_COMPOSIT) {
3663 continue;
3664 }
3665
3666 for (bNode &node : node_tree->nodes) {
3667 if (node.type_legacy != CMP_NODE_OUTPUT_FILE) {
3668 continue;
3669 }
3671 return;
3672 }
3673
3676
3677 for (bNodeSocket &input : node.inputs) {
3678 NodeImageMultiFileSocket *input_storage = static_cast<NodeImageMultiFileSocket *>(
3679 input.storage);
3680 update_format_media_type(&input_storage->format);
3681 }
3682 }
3683 }
3685 }
3686
3687 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 43)) {
3688 for (World &world : bmain->worlds) {
3689 do_version_world_remove_use_nodes(bmain, &world);
3690 }
3691 }
3692
3693 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 45)) {
3694 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3695 if (node_tree->type == NTREE_GEOMETRY) {
3696 for (bNode &node : node_tree->nodes) {
3697 if (node.type_legacy == GEO_NODE_FILL_CURVE) {
3699 }
3700 else if (node.type_legacy == GEO_NODE_FILLET_CURVE) {
3702 }
3703 else if (node.type_legacy == GEO_NODE_RESAMPLE_CURVE) {
3705 }
3706 else if (node.type_legacy == GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME) {
3708 }
3709 else if (node.type_legacy == GEO_NODE_MERGE_BY_DISTANCE) {
3711 }
3712 else if (node.type_legacy == GEO_NODE_MESH_TO_VOLUME) {
3714 }
3715 else if (node.type_legacy == GEO_NODE_RAYCAST) {
3717 }
3718 else if (node.type_legacy == GEO_NODE_REMOVE_ATTRIBUTE) {
3720 }
3721 else if (node.type_legacy == GEO_NODE_SAMPLE_GRID) {
3723 }
3724 else if (node.type_legacy == GEO_NODE_SCALE_ELEMENTS) {
3726 }
3727 else if (node.type_legacy == GEO_NODE_SET_CURVE_NORMAL) {
3729 }
3730 else if (node.type_legacy == GEO_NODE_SUBDIVISION_SURFACE) {
3732 }
3733 else if (node.type_legacy == GEO_NODE_UV_PACK_ISLANDS) {
3735 }
3736 else if (node.type_legacy == GEO_NODE_UV_UNWRAP) {
3738 }
3739 }
3740 }
3741 }
3743 }
3744
3745 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 46)) {
3746 /* Versioning from 0a0dd4ca37 was wrong, it only created asset shelf regions for Node Editors
3747 * that are Compositors. If you change a non-Node Editor (e.g. an Image Editor) to a Compositor
3748 * Editor, all is fine (SpaceLink *node_create gets called, the regions set up correctly), but
3749 * changing an existing Node Editor (e.g. Shader or Geometry Nodes) to a Compositor, no new
3750 * Space gets set up (rightfully so) and we are then missing the regions. Now corrected below
3751 * (version bump in 5.1 since that is also affected). */
3752 }
3753
3754 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 48)) {
3755 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3756 if (ntree->type != NTREE_COMPOSIT) {
3757 continue;
3758 }
3759 for (bNode &node : ntree->nodes) {
3760 if (node.type_legacy != CMP_NODE_ROTATE) {
3761 continue;
3762 }
3763 if (node.storage != nullptr) {
3764 continue;
3765 }
3766 NodeRotateData *data = MEM_new<NodeRotateData>(__func__);
3767 data->interpolation = node.custom1;
3768 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3769 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3770 node.storage = data;
3771 }
3773 }
3774 }
3775
3776 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 49)) {
3777 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3778 if (ntree->type != NTREE_COMPOSIT) {
3779 continue;
3780 }
3781 for (bNode &node : ntree->nodes) {
3782 if (node.type_legacy != CMP_NODE_DISPLACE) {
3783 continue;
3784 }
3785 if (node.storage == nullptr) {
3786 continue;
3787 }
3788 NodeDisplaceData *data = static_cast<NodeDisplaceData *>(node.storage);
3789 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3790 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3791 }
3793 }
3794 }
3795
3796 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 50)) {
3797 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3798 if (ntree->type != NTREE_COMPOSIT) {
3799 continue;
3800 }
3801 for (bNode &node : ntree->nodes) {
3802 if (node.type_legacy != CMP_NODE_MAP_UV) {
3803 continue;
3804 }
3805 if (node.storage != nullptr) {
3806 continue;
3807 }
3808 NodeMapUVData *data = MEM_new<NodeMapUVData>(__func__);
3809 data->interpolation = node.custom2;
3810 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3811 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3812 node.storage = data;
3813 }
3815 }
3816 }
3817 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 51)) {
3818 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3819 if (ntree->type != NTREE_COMPOSIT) {
3820 continue;
3821 }
3822 for (bNode &node : ntree->nodes) {
3823 if (node.type_legacy != CMP_NODE_CORNERPIN) {
3824 continue;
3825 }
3826 if (node.storage != nullptr) {
3827 continue;
3828 }
3829 NodeCornerPinData *data = MEM_new<NodeCornerPinData>(__func__);
3830 data->interpolation = node.custom1;
3831 data->extension_x = CMP_NODE_EXTENSION_MODE_CLIP;
3832 data->extension_y = CMP_NODE_EXTENSION_MODE_CLIP;
3833 node.storage = data;
3834 }
3836 }
3837 }
3838
3839 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 54)) {
3840 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3841 if (node_tree->type != NTREE_COMPOSIT) {
3842 continue;
3843 }
3844 for (bNode &node : node_tree->nodes) {
3845 if (node.type_legacy == CMP_NODE_OUTPUT_FILE) {
3847 }
3848 }
3850 }
3851 }
3852
3853 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 56)) {
3854 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3855 if (node_tree->type != NTREE_SHADER) {
3856 continue;
3857 }
3858
3859 for (bNode &node : node_tree->nodes) {
3860 if (node.type_legacy == SH_NODE_NORMAL_MAP) {
3861 NodeShaderNormalMap *normal_map = static_cast<NodeShaderNormalMap *>(node.storage);
3862 normal_map->base = SHD_NORMAL_MAP_BASE_DISPLACED;
3863 }
3864 }
3865 }
3867 }
3868
3869 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 58)) {
3870 for (Object &object : bmain->objects) {
3871 for (ModifierData &modifier : object.modifiers) {
3873 continue;
3874 }
3876 &modifier);
3877 if (lmd->radius != 0.0f) {
3878 continue;
3879 }
3880 lmd->radius = float(lmd->thickness_legacy) *
3882 }
3883 }
3884 }
3885 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 61)) {
3886 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
3887 if (ntree->type != NTREE_COMPOSIT) {
3888 continue;
3889 }
3892
3893 for (bNode &node : ntree->nodes) {
3894 if (node.type_legacy == CMP_NODE_GAMMA_DEPRECATED) {
3895 node.type_legacy = SH_NODE_GAMMA;
3896 STRNCPY_UTF8(node.idname, "ShaderNodeGamma");
3897 }
3898 }
3899 }
3901 }
3902
3903 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 63)) {
3904 for (Scene &scene : bmain->scenes) {
3905 if (scene.r.bake_flag & R_BAKE_MULTIRES) {
3906 scene.r.bake.type = eBakeType(scene.r.bake_mode);
3907 scene.r.bake.flag |= (scene.r.bake_flag & (R_BAKE_MULTIRES | R_BAKE_LORES_MESH));
3908 scene.r.bake.margin_type = eBakeMarginType(scene.r.bake_margin_type);
3909 scene.r.bake.margin = scene.r.bake_margin;
3910 }
3911 else {
3912 scene.r.bake.type = R_BAKE_NORMALS;
3913 }
3914 }
3915 }
3916
3917 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 62)) {
3918 for (Scene &scene : bmain->scenes) {
3919 scene.r.bake.displacement_space = R_BAKE_SPACE_OBJECT;
3920 }
3921 }
3922
3923 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 64)) {
3924 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3926 }
3928 }
3929
3930 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 65)) {
3931 for (Brush &brush : bmain->brushes) {
3933 srgb_to_linearrgb_v3_v3(brush.secondary_color, brush.secondary_rgb);
3934 }
3935 for (Scene &scene : bmain->scenes) {
3936 UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings;
3939
3940 for_each_mode_paint_settings(scene, [](Scene & /*scene*/, Paint *paint) {
3941 if (paint != nullptr) {
3942 UnifiedPaintSettings &ups = paint->unified_paint_settings;
3945 }
3946 });
3947 }
3948 for (Palette &palette : bmain->palettes) {
3949 for (PaletteColor &color : palette.colors) {
3951 }
3952 }
3953 }
3954
3955 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 66)) {
3956 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
3957 if (node_tree->type != NTREE_COMPOSIT) {
3958 continue;
3959 }
3960 for (bNode &node : node_tree->nodes) {
3961 if (node.type_legacy == CMP_NODE_BLUR) {
3963 }
3964 else if (node.type_legacy == CMP_NODE_FILTER) {
3966 }
3967 else if (node.type_legacy == CMP_NODE_VIEW_LEVELS) {
3969 }
3970 else if (node.type_legacy == CMP_NODE_DILATEERODE) {
3972 }
3973 else if (node.type_legacy == CMP_NODE_TONEMAP) {
3975 }
3976 else if (node.type_legacy == CMP_NODE_LENSDIST) {
3978 }
3979 else if (node.type_legacy == CMP_NODE_KUWAHARA) {
3981 }
3982 else if (node.type_legacy == CMP_NODE_DENOISE) {
3984 }
3985 else if (node.type_legacy == CMP_NODE_TRANSLATE) {
3987 }
3988 else if (node.type_legacy == CMP_NODE_TRANSFORM) {
3990 }
3991 else if (node.type_legacy == CMP_NODE_CORNERPIN) {
3993 }
3994 else if (node.type_legacy == CMP_NODE_MAP_UV) {
3996 }
3997 else if (node.type_legacy == CMP_NODE_SCALE) {
3999 }
4000 else if (node.type_legacy == CMP_NODE_ROTATE) {
4002 }
4003 else if (node.type_legacy == CMP_NODE_DISPLACE) {
4005 }
4006 else if (node.type_legacy == CMP_NODE_STABILIZE2D) {
4008 }
4009 else if (node.type_legacy == CMP_NODE_MASK_BOX) {
4011 }
4012 else if (node.type_legacy == CMP_NODE_MASK_ELLIPSE) {
4014 }
4015 else if (node.type_legacy == CMP_NODE_TRACKPOS) {
4017 }
4018 else if (node.type_legacy == CMP_NODE_KEYING) {
4020 }
4021 else if (node.type_legacy == CMP_NODE_MASK) {
4023 }
4024 else if (node.type_legacy == CMP_NODE_MOVIEDISTORTION) {
4026 }
4027 else if (node.type_legacy == CMP_NODE_GLARE) {
4029 }
4030 }
4031 }
4033 }
4034
4035 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 67)) {
4036 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
4038 }
4040 }
4041
4042 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 68)) {
4043 for (Scene &scene : bmain->scenes) {
4045 }
4046 }
4047
4048 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 71)) {
4049 for (Scene &scene : bmain->scenes) {
4050 scene.toolsettings->uvsculpt.size *= 2;
4051 }
4052 }
4053
4054 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 72)) {
4055 for (Brush &brush : bmain->brushes) {
4056 if (brush.curve_size == nullptr) {
4057 brush.curve_size = BKE_paint_default_curve();
4058 }
4059 if (brush.curve_strength == nullptr) {
4060 brush.curve_strength = BKE_paint_default_curve();
4061 }
4062 if (brush.curve_jitter == nullptr) {
4063 brush.curve_jitter = BKE_paint_default_curve();
4064 }
4065 }
4066 }
4067
4068 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 73)) {
4069 /* Old files created on WIN32 use `\r`. */
4070 for (Curve &cu : bmain->curves) {
4071 if (cu.str) {
4072 BLI_string_replace_char(cu.str, '\r', '\n');
4073 }
4074 }
4075 }
4076
4077 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 74)) {
4078 for (Scene &scene : bmain->scenes) {
4079 if (scene.ed != nullptr) {
4080 /* Set the first strip modifier as the active one and uncollapse the root panel. */
4081 seq::foreach_strip(&scene.ed->seqbase, [&](Strip *strip) -> bool {
4082 seq::modifier_set_active(strip, strip->modifiers.first());
4083 for (StripModifierData &smd : strip->modifiers) {
4084 smd.layout_panel_open_flag |= UI_PANEL_DATA_EXPAND_ROOT;
4085 }
4086 return true;
4087 });
4088 }
4089 }
4090 }
4091
4092 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 75)) {
4093 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
4094 if (ntree->type == NTREE_COMPOSIT) {
4095 version_node_socket_name(ntree, CMP_NODE_RGB, "RGBA", "Color");
4096 }
4097 }
4099 }
4100
4101 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 81)) {
4102 for (Material &material : bmain->materials) {
4103 do_version_material_remove_use_nodes(bmain, &material);
4104 }
4105 }
4106
4107 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 82)) {
4108 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4109 if (node_tree->type != NTREE_COMPOSIT) {
4110 continue;
4111 }
4112 for (bNode &node : node_tree->nodes) {
4113 if (node.type_legacy == CMP_NODE_SETALPHA) {
4115 }
4116 else if (node.type_legacy == CMP_NODE_CHANNEL_MATTE) {
4118 }
4119 else if (node.type_legacy == CMP_NODE_COLORBALANCE) {
4121 }
4122 else if (node.type_legacy == CMP_NODE_PREMULKEY) {
4124 }
4125 else if (node.type_legacy == CMP_NODE_DIST_MATTE) {
4127 }
4128 else if (node.type_legacy == CMP_NODE_COLOR_SPILL) {
4130 }
4131 }
4132 }
4134 }
4135
4136 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 83)) {
4137 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4138 if (node_tree->type != NTREE_COMPOSIT) {
4139 continue;
4140 }
4141 for (bNode &node : node_tree->nodes) {
4142 if (node.type_legacy == CMP_NODE_DOUBLEEDGEMASK) {
4144 }
4145 }
4146 }
4148 }
4149
4150 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 84)) {
4151 /* Add sidebar to the preferences editor. */
4152 for (bScreen &screen : bmain->screens) {
4153 for (ScrArea &area : screen.areabase) {
4154 for (SpaceLink &sl : area.spacedata) {
4155 if (sl.spacetype == SPACE_USERPREF) {
4156 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
4157 &sl.regionbase;
4159 regionbase, RGN_TYPE_UI, "sidebar for preferences", RGN_TYPE_HEADER);
4160 if (new_sidebar != nullptr) {
4161 new_sidebar->alignment = RGN_ALIGN_LEFT;
4162 new_sidebar->flag &= ~RGN_FLAG_HIDDEN;
4163 }
4164 }
4165 }
4166 }
4167 }
4168 }
4169
4170 if (MAIN_VERSION_FILE_ATLEAST(bmain, 500, 23) && !MAIN_VERSION_FILE_ATLEAST(bmain, 500, 85)) {
4171 /* Old sky textures were temporarily removed and restored. */
4172 /* Change default Sky Texture to Nishita (after removal of old sky models) */
4173 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
4174 if (ntree->type == NTREE_SHADER) {
4175 for (bNode &node : ntree->nodes) {
4176 if (node.type_legacy == SH_NODE_TEX_SKY && node.storage) {
4177 NodeTexSky *tex = static_cast<NodeTexSky *>(node.storage);
4178 if (tex->sky_model == 0) {
4180 }
4181 if (tex->sky_model == 1) {
4183 }
4184 }
4185 }
4186 }
4187 }
4189 }
4190
4191 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 86)) {
4192 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
4193 if (ntree->type != NTREE_GEOMETRY) {
4194 continue;
4195 }
4197 }
4199 }
4200
4201 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 87)) {
4202 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4203 if (node_tree->type != NTREE_COMPOSIT) {
4204 continue;
4205 }
4206 version_node_input_socket_name(node_tree, CMP_NODE_ALPHAOVER, "Image_001", "Foreground");
4207 version_node_input_socket_name(node_tree, CMP_NODE_ALPHAOVER, "Image", "Background");
4208 }
4210 }
4211
4212 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 88)) {
4213 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4214 if (node_tree->type != NTREE_COMPOSIT) {
4215 continue;
4216 }
4217 version_node_input_socket_name(node_tree, CMP_NODE_DISPLACE, "Vector", "Displacement");
4218 for (bNode &node : node_tree->nodes) {
4219 if (node.type_legacy == CMP_NODE_DISPLACE) {
4221 }
4222 }
4223 }
4225 }
4226
4227 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 89)) {
4228 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4229 if (node_tree->type != NTREE_COMPOSIT) {
4230 continue;
4231 }
4232 version_node_input_socket_name(node_tree, CMP_NODE_BOKEHBLUR, "Bounding box", "Mask");
4233 for (bNode &node : node_tree->nodes) {
4234 if (node.type_legacy == CMP_NODE_BOKEHBLUR) {
4236 }
4237 }
4238 }
4240 }
4241
4242 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 89)) {
4243 /* Node Editor: toggle overlays on. */
4244 if (!DNA_struct_exists(fd->filesdna, "SpaceClipOverlay")) {
4245 for (bScreen &screen : bmain->screens) {
4246 for (ScrArea &area : screen.areabase) {
4247 for (SpaceLink &space : area.spacedata) {
4248 if (space.spacetype == SPACE_CLIP) {
4249 SpaceClip *sclip = reinterpret_cast<SpaceClip *>(&space);
4250 sclip->overlay.flag |= SC_SHOW_OVERLAYS;
4251 sclip->overlay.flag |= SC_SHOW_CURSOR;
4252 }
4253 }
4254 }
4255 }
4256 }
4257 }
4258
4259 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 92)) {
4261 }
4262
4263 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 95)) {
4264 for (Camera &camera : bmain->cameras) {
4265 float default_col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
4266 copy_v4_v4(camera.composition_guide_color, default_col);
4267 }
4268 }
4269
4270 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 97)) {
4271 /* Enable new "Optional Label" setting for all menu sockets. This was implicit before. */
4272 FOREACH_NODETREE_BEGIN (bmain, tree, id) {
4273 tree->tree_interface.foreach_item([&](bNodeTreeInterfaceItem &item) {
4275 return true;
4276 }
4277 auto &socket = reinterpret_cast<bNodeTreeInterfaceSocket &>(item);
4278 if (!STREQ(socket.socket_type, "NodeSocketMenu")) {
4279 return true;
4280 }
4282 return true;
4283 });
4284 }
4286 }
4287
4288 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 98)) {
4289 /* For a brief period of time, these values were not properly versioned, so it is possible for
4290 * files to be in an odd state. This versioning was formerly run in 4.2 subversion 23. */
4291 for (Scene &scene : bmain->scenes) {
4292 UvSculpt &uvsculpt = scene.toolsettings->uvsculpt;
4293 if (uvsculpt.size == 0 || uvsculpt.curve_distance_falloff == nullptr) {
4294 uvsculpt.size = 100;
4295 uvsculpt.strength = 1.0f;
4297 if (uvsculpt.curve_distance_falloff == nullptr) {
4298 uvsculpt.curve_distance_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
4299 }
4300 }
4301 }
4302 }
4303
4304 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 99)) {
4305 for (wmWindowManager &wm : bmain->wm) {
4306 wm.xr.session_settings.fly_speed = 3.0f;
4307 }
4308 }
4309
4310 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 102)) {
4311 for (Scene &scene : bmain->scenes) {
4312 scene.r.time_jump_delta = 1.0f;
4313 scene.r.time_jump_unit = 1;
4314 }
4315 }
4316
4317 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 405, 103)) {
4318 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4319 if (node_tree->type == NTREE_COMPOSIT) {
4320 for (bNode &node : node_tree->nodes) {
4321 if (node.type_legacy == CMP_NODE_COLORBALANCE) {
4323 }
4324 }
4325 }
4326 }
4328 }
4329
4330 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 104)) {
4331 /* Dope Sheet Editor: toggle overlays on. */
4332 if (!DNA_struct_exists(fd->filesdna, "SpaceActionOverlays")) {
4333 for (bScreen &screen : bmain->screens) {
4334 for (ScrArea &area : screen.areabase) {
4335 for (SpaceLink &space : area.spacedata) {
4336 if (space.spacetype == SPACE_ACTION) {
4337 SpaceAction *space_action = reinterpret_cast<SpaceAction *>(&space);
4338 space_action->overlays.flag |= ADS_OVERLAY_SHOW_OVERLAYS;
4340 }
4341 }
4342 }
4343 }
4344 }
4345 }
4346
4347 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 105)) {
4348 for (Mesh &mesh : bmain->meshes) {
4350 }
4351 }
4352
4353 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 106)) {
4354 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4355 if (node_tree->type != NTREE_COMPOSIT) {
4356 continue;
4357 }
4359 node_tree, CMP_NODE_COLORCORRECTION, "Master Lift", "Master Offset");
4361 node_tree, CMP_NODE_COLORCORRECTION, "Highlights Lift", "Highlights Offset");
4363 node_tree, CMP_NODE_COLORCORRECTION, "Midtones Lift", "Midtones Offset");
4365 node_tree, CMP_NODE_COLORCORRECTION, "Shadows Lift", "Shadows Offset");
4366 }
4368 }
4369
4370 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 107)) {
4371 for (Material &material : bmain->materials) {
4372 /* The flag was actually interpreted as reversed. */
4373 material.blend_flag ^= MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED;
4374 }
4375 }
4376
4377 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 108)) {
4378 for (bScreen &screen : bmain->screens) {
4379 for (ScrArea &area : screen.areabase) {
4380 for (SpaceLink &sl : area.spacedata) {
4381 if (sl.spacetype == SPACE_IMAGE) {
4382 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&sl);
4384 }
4385 }
4386 }
4387 }
4388 }
4389
4390 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 109)) {
4391 for (bNodeTree &ntree : bmain->nodetrees) {
4393 }
4394 }
4395
4396 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 112)) {
4397 /* The ownership of these pointers was moved to #CustomData in #customdata_version_242 and they
4398 * became deprecated in 05952aa94d33ee when we started using implicit-sharing. However, they
4399 * were never cleared and became dangling pointers. */
4400 for (Mesh &mesh : bmain->meshes) {
4401 mesh.mpoly = nullptr;
4402 mesh.mloop = nullptr;
4403 mesh.mvert = nullptr;
4404 mesh.medge = nullptr;
4405 mesh.dvert = nullptr;
4406 mesh.mtface = nullptr;
4407 mesh.tface = nullptr;
4408 mesh.mcol = nullptr;
4409 mesh.mface = nullptr;
4410 }
4411 }
4412
4413 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 501, 2)) {
4414 for (bScreen &screen : bmain->screens) {
4415 for (ScrArea &area : screen.areabase) {
4416 for (SpaceLink &sl : area.spacedata) {
4417 if (sl.spacetype != SPACE_NODE) {
4418 continue;
4419 }
4420
4421 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
4422 &sl.regionbase;
4423
4424 if (ARegion *new_shelf_region = do_versions_add_region_if_not_found(
4425 regionbase,
4427 "Asset shelf for compositing (versioning)",
4429 {
4430 new_shelf_region->alignment = RGN_ALIGN_BOTTOM;
4431 }
4432 if (ARegion *new_shelf_header = do_versions_add_region_if_not_found(
4433 regionbase,
4435 "Asset shelf header for compositing (versioning)",
4437 {
4438 new_shelf_header->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV;
4439 }
4440 }
4441 }
4442 }
4443 }
4444
4445 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 501, 4)) {
4446 /* Clear mute flag on node types that set ntype->no_muting = true. */
4447 static const Set<std::string> no_muting_nodes = {"CompositorNodeViewer",
4448 "NodeClosureInput",
4449 "NodeClosureOutput",
4450 "GeometryNodeForeachGeometryElementInput",
4451 "GeometryNodeForeachGeometryElementOutput",
4452 "GeometryNodeRepeatInput",
4453 "GeometryNodeRepeatOutput",
4454 "GeometryNodeSimulationInput",
4455 "GeometryNodeSimulationOutput",
4456 "GeometryNodeViewer",
4457 "NodeGroupInput",
4458 "NodeGroupOutput",
4459 "ShaderNodeOutputAOV",
4460 "ShaderNodeOutputLight",
4461 "ShaderNodeOutputLineStyle",
4462 "ShaderNodeOutputMaterial",
4463 "ShaderNodeOutputWorld",
4464 "TextureNodeOutput",
4465 "TextureNodeViewer"};
4466 for (bNodeTree &ntree : bmain->nodetrees) {
4467 for (bNode &node : ntree.nodes) {
4468 if (no_muting_nodes.contains(node.idname)) {
4469 node.flag &= ~NODE_MUTED;
4470 }
4471 }
4472 }
4473 }
4474
4475 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 114)) {
4476 for (Scene &scene : bmain->scenes) {
4477 if (!scene.ed) {
4478 continue;
4479 }
4480 seq::foreach_strip(&scene.ed->seqbase, [&](Strip *strip) {
4481 for (StripModifierData &md : strip->modifiers) {
4482 md.ui_expand_flag = md.layout_panel_open_flag & UI_PANEL_DATA_EXPAND_ROOT;
4483 }
4484 return true;
4485 });
4486 }
4487 }
4488
4489 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 115)) {
4490 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4491 if (ELEM(GS(id->name), ID_MA, ID_LA, ID_WO, ID_TE, ID_SCE, ID_LS)) {
4492 /* These node trees should not have interface sockets. However, in some files they were
4493 * added through the Python API. Remove these interface sockets here before they cause
4494 * problems further down the line. */
4496 }
4497 }
4499 }
4500
4501 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 117)) {
4502 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
4503 if (node_tree->type == NTREE_GEOMETRY) {
4504 /* Gradient Texture node did not clamp results for the Compositor CPU and geometry nodes.
4505 * The compositor is not versioned to unify it with GPU backend. */
4507 }
4508 }
4510 }
4511
4518
4519 /* TODO: Can be moved to subversion bump. */
4521}
4522
4523} // namespace blender
Low-level operations for curves.
Low-level operations for grease pencil.
#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 NODE_GROUP_OUTPUT
Definition BKE_node.hh:869
#define FOREACH_NODETREE_END
Definition BKE_node.hh:936
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:926
#define NODE_FRAME
Definition BKE_node.hh:866
#define GEO_NODE_MERGE_BY_DISTANCE
#define GEO_NODE_TRIANGULATE
#define CMP_NODE_PREMULKEY
#define CMP_NODE_DENOISE
#define SH_NODE_COMBINE_COLOR
#define NODE_EVALUATE_CLOSURE
#define CMP_NODE_MASK
#define CMP_NODE_SCALE
#define GEO_NODE_SUBDIVISION_SURFACE
#define SH_NODE_TEX_GRADIENT
#define SH_NODE_COMBRGB_LEGACY
#define CMP_NODE_MATH_DEPRECATED
#define CMP_NODE_SEPHSVA_LEGACY
#define CMP_NODE_VALUE_DEPRECATED
#define CMP_NODE_COLOR_SPILL
#define SH_NODE_COMBXYZ
#define CMP_NODE_CORNERPIN
#define GEO_NODE_MESH_TO_VOLUME
#define CMP_NODE_MASK_ELLIPSE
#define CMP_NODE_DISPLACE
#define CMP_NODE_COMBYCCA_LEGACY
#define SH_NODE_BSDF_PRINCIPLED
#define CMP_NODE_SEPRGBA_LEGACY
#define CMP_NODE_SEPARATE_COLOR
#define CMP_NODE_TRANSLATE
#define GEO_NODE_VIEWER
#define GEO_NODE_UV_PACK_ISLANDS
#define CMP_NODE_MOVIEDISTORTION
#define CMP_NODE_TONEMAP
#define SH_NODE_SEPARATE_COLOR
#define CMP_NODE_MAP_RANGE_DEPRECATED
#define CMP_NODE_COLORBALANCE
#define SH_NODE_MAP_RANGE
#define GEO_NODE_REMOVE_ATTRIBUTE
#define TEX_NODE_DECOMPOSE_LEGACY
#define GEO_NODE_UV_UNWRAP
#define SH_NODE_SEPRGB_LEGACY
#define CMP_NODE_COMBYUVA_LEGACY
#define CMP_NODE_ROTATE
#define CMP_NODE_KUWAHARA
#define CMP_NODE_FILTER
#define SH_NODE_NORMAL_MAP
#define SH_NODE_VALUE
#define SH_NODE_CURVE_VEC
#define CMP_NODE_ALPHAOVER
#define CMP_NODE_MAP_VALUE_DEPRECATED
#define CMP_NODE_SEPYUVA_LEGACY
#define TEX_NODE_COMBINE_COLOR
#define SH_NODE_MATH
#define CMP_NODE_COMBHSVA_LEGACY
#define GEO_NODE_TRANSFORM_GEOMETRY
#define CMP_NODE_COMBINE_XYZ_DEPRECATED
#define FN_NODE_COMBINE_COLOR
#define CMP_NODE_GLARE
#define SH_NODE_SEPXYZ
#define GEO_NODE_RAYCAST
#define TEX_NODE_SEPARATE_COLOR
#define CMP_NODE_TRANSFORM
#define CMP_NODE_DILATEERODE
#define CMP_NODE_SPLIT
#define SH_NODE_BSDF_DIFFUSE
#define SH_NODE_GAMMA
#define CMP_NODE_BOKEHBLUR
#define SH_NODE_SEPHSV_LEGACY
#define TEX_NODE_COMPOSE_LEGACY
#define CMP_NODE_LENSDIST
#define GEO_NODE_SAMPLE_GRID
#define GEO_NODE_FILLET_CURVE
#define CMP_NODE_ZCOMBINE
#define NODE_CLOSURE_OUTPUT
#define CMP_NODE_MAP_UV
#define SH_NODE_TEX_SKY
#define CMP_NODE_TRACKPOS
#define CMP_NODE_SUNBEAMS_DEPRECATED
#define CMP_NODE_MIX_RGB_DEPRECATED
#define CMP_NODE_OUTPUT_FILE
#define CMP_NODE_COLORCORRECTION
#define CMP_NODE_SETALPHA
#define CMP_NODE_DOUBLEEDGEMASK
#define CMP_NODE_GAMMA_DEPRECATED
#define GEO_NODE_RESAMPLE_CURVE
#define CMP_NODE_VALTORGB_DEPRECATED
#define CMP_NODE_STABILIZE2D
#define SH_NODE_MIX
#define CMP_NODE_COMBINE_COLOR
#define SH_NODE_VALTORGB
#define GEO_NODE_SCALE_ELEMENTS
#define NODE_COMBINE_BUNDLE
#define CMP_NODE_COMBRGBA_LEGACY
#define CMP_NODE_COMPOSITE_DEPRECATED
#define CMP_NODE_RGB
#define CMP_NODE_MASK_BOX
#define FN_NODE_SEPARATE_COLOR
#define GEO_NODE_FILL_CURVE
#define CMP_NODE_KEYING
#define GEO_NODE_POINTS_TO_VOLUME
#define CMP_NODE_SEPYCCA_LEGACY
#define GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME
#define CMP_NODE_DIST_MATTE
#define NODE_SEPARATE_BUNDLE
#define NODE_CLOSURE_INPUT
#define CMP_NODE_SEPARATE_XYZ_DEPRECATED
#define CMP_NODE_NORMAL
#define CMP_NODE_VIEW_LEVELS
#define SH_NODE_COMBHSV_LEGACY
#define CMP_NODE_CURVE_VEC_DEPRECATED
#define CMP_NODE_BLUR
#define GEO_NODE_VOLUME_TO_MESH
#define GEO_NODE_SET_CURVE_NORMAL
#define CMP_NODE_CHANNEL_MATTE
#define PTCACHE_TYPE_SMOKE_HIGHRES
#define PTCACHE_TYPE_CLOTH
#define PTCACHE_TYPE_DYNAMICPAINT
#define PTCACHE_TYPE_PARTICLES
#define PTCACHE_TYPE_SOFTBODY
#define PTCACHE_TYPE_SMOKE_DOMAIN
#define PTCACHE_TYPE_RIGIDBODY
#define FILE_MAX
#define STRNCPY_UTF8(dst, src)
#define BLI_string_joinN(...)
#define RPT_(msgid)
#define DATA_(msgid)
ID and Library types, which are fundamental for SDNA.
#define FILTER_ID_SCE
Definition DNA_ID.h:1219
blenloader genfile private function prototypes
Types and defines for representing Rigid Body entities.
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define ELEM(...)
#define STREQ(a, b)
#define CD_MASK_PROP_ALL
btScalar max
Definition scene.h:133
constexpr IndexRange()=default
const Value * lookup_ptr(const Key &key) const
Definition BLI_map.hh:508
Value & lookup_or_add_default(const Key &key)
Definition BLI_map.hh:639
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
constexpr MutableSpan()=default
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr Span()=default
void append(const T &value)
bool is_empty() const
void extend(Span< T > array)
VectorData< T, Allocator > release()
#define storage(slot, qualifiers)
#define position
#define layer
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
ccl_device_inline void copy_v4_v4(ccl_private float *r, const float4 val)
constexpr float LEGACY_RADIUS_CONVERSION_FACTOR
void mesh_sculpt_mask_to_generic(Mesh &mesh)
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, StringRefNull name, StringRefNull idname)
Definition node.cc:5005
void pointcloud_convert_customdata_to_storage(PointCloud &pointcloud)
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
Definition node.cc:4676
void node_tree_set_type(bNodeTree &ntree)
Definition node.cc:2748
bNode * node_add_node(const bContext *C, bNodeTree &ntree, UString idname, std::optional< int > unique_identifier=std::nullopt)
Definition node.cc:4260
std::optional< eNodeSocketDatatype > custom_data_type_to_socket_type(eCustomDataType type)
Definition node.cc:5935
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:4283
void curves_convert_customdata_to_storage(CurvesGeometry &curves)
void grease_pencil_convert_customdata_to_storage(GreasePencil &grease_pencil)
bNodeSocket * node_add_static_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out, int type, int subtype, StringRefNull identifier, StringRefNull name)
Definition node.cc:3980
void mesh_custom_normals_to_generic(Mesh &mesh)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
Definition node.cc:3036
void mesh_uv_select_to_single_attribute(Mesh &mesh)
T min(const T &a, const T &b)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T max(const T &a, const T &b)
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:60
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
void meta_stack_set(const Scene *scene, Strip *dst)
Definition sequencer.cc:493
MetaStack * meta_stack_active_get(const Editing *ed)
Definition sequencer.cc:484
BMesh Iterators.
bool version_node_ensure_storage_or_invalidate(bNode &node)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition colortools.cc:99
@ CMP_NODE_RELATIVE_TO_PIXEL_REFERENCE_DIMENSION_GREATER
UserDef U
Definition blender.cc:58
static void update_format_media_type(ImageFormatData *format)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void do_version_scale_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void copy_unified_paint_settings(Scene &scene, Paint *paint)
@ CMP_NODE_TRANSLATE_REPEAT_AXIS_XY
@ CMP_NODE_TRANSLATE_REPEAT_AXIS_Y
@ CMP_NODE_TRANSLATE_REPEAT_AXIS_X
@ CMP_NODE_TRANSLATE_REPEAT_AXIS_NONE
static void do_version_convert_to_generic_nodes_after_linking(Main *bmain, bNodeTree *node_tree)
CurveMapping * BKE_curvemapping_copy(const CurveMapping *cumap)
char * STRNCPY(char(&dst)[N], const char *src)
static void initialize_closure_input_structure_types(bNodeTree &ntree)
static void do_version_filter_menus_to_inputs(bNodeTree &ntree, bNode &node)
void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
@ SUBSURF_ADAPTIVE_SPACE_PIXEL
@ RPT_WARNING
Definition BKE_report.hh:40
static void do_version_distribute_points_in_volume_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_raycast_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_triangulate_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_box_mask_menus_to_inputs(bNodeTree &ntree, bNode &node)
MINLINE void copy_v3_v3(float r[3], const float a[3])
static void do_version_set_alpha_menus_to_inputs(bNodeTree &ntree, bNode &node)
@ RGN_TYPE_ASSET_SHELF_HEADER
@ CMP_NODE_RELATIVE_TO_PIXEL_DATA_TYPE_FLOAT
static void do_version_resample_curve_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_rotate_menus_to_inputs(bNodeTree &ntree, bNode &node)
@ NODE_MAP_RANGE_LINEAR
@ MEDIA_TYPE_MULTI_LAYER_IMAGE
static void do_version_fill_curve_options_to_inputs(bNodeTree &ntree, bNode &node)
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)
std::string RNA_path_number_to_infix(const int number)
Definition rna_path.cc:1425
void do_versions_after_linking_500(FileData *fd, Main *bmain)
static void do_version_denoise_menus_to_inputs(bNodeTree &ntree, bNode &node)
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
static void do_version_file_output_node(bNode &node)
static void for_each_mode_paint_settings(Scene &scene, FunctionRef< void(Scene &scene, Paint *paint)> func)
void BLI_string_replace_char(char *str, char src, char dst) ATTR_NONNULL(1)
void blo_do_versions_500(FileData *fd, Library *lib, Main *bmain)
static CustomDataLayer * find_old_seam_layer(CustomData &custom_data, const StringRef name)
@ CMP_NODE_COMBSEP_COLOR_YCC
@ CMP_NODE_COMBSEP_COLOR_YUV
@ CMP_NODE_COMBSEP_COLOR_HSV
@ CMP_NODE_COMBSEP_COLOR_RGB
static void do_version_uv_pack_islands_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_mask_menus_to_inputs(bNodeTree &ntree, bNode &node)
@ eModifierType_GreasePencilLineart
void BKE_curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap)
static void do_version_displace_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_color_spill_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_set_curve_normal_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_volume_to_mesh_options_to_inputs(bNodeTree &ntree, bNode &node)
@ FILE_BROWSE_MODE_ASSETS
@ CMP_NODE_GLARE_QUALITY_HIGH
@ MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED
static void do_version_corner_pin_menus_to_inputs(bNodeTree &ntree, bNode &node)
bool BKE_imtype_is_multi_layer_image(char imtype)
@ NODE_COMBSEP_COLOR_HSV
@ NODE_COMBSEP_COLOR_RGB
static void do_version_fillet_curve_options_to_inputs(bNodeTree &ntree, bNode &node)
static void version_dynamic_viewer_node_items(bNodeTree &ntree)
static void do_version_split_node_rotation(bNodeTree *node_tree, bNode *node)
bNode & version_node_add_empty(bNodeTree &ntree, const char *idname)
static void do_version_dilate_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void repair_node_link_node_pointers(FileData &fd, bNodeTree &node_tree)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
static void do_version_blur_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_sample_grid_options_to_inputs(bNodeTree &ntree, bNode &node)
@ SHD_NORMAL_MAP_BASE_DISPLACED
@ ADS_OVERLAY_SHOW_OVERLAYS
@ ADS_SHOW_SCENE_STRIP_FRAME_RANGE
AnimData * BKE_animdata_ensure_id(ID *id)
Definition anim_data.cc:107
@ RGN_ALIGN_HIDE_WITH_PREV
const char * RE_engine_id_BLENDER_EEVEE
Definition scene.cc:1717
void version_socket_update_is_used(bNodeTree *ntree)
void BKE_animdata_fix_paths(ID &id, StringRef prefix, StringRef old_infix, StringRef new_infix, bool verify_paths, const DriverMap &driver_map)
void version_node_output_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
static void do_version_ellipse_mask_menus_to_inputs(bNodeTree &ntree, bNode &node)
bool BKE_imtype_is_image(char imtype)
static void rename_mesh_uv_seam_attribute(Mesh &mesh)
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
size_t void BLI_uniquename_cb(FunctionRef< bool(StringRefNull)> unique_check, const char *defname, char delim, char *name, size_t name_maxncpy) ATTR_NONNULL(2
void version_node_socket_identifier_set(bNodeSocket &socket, const StringRefNull identifier)
@ R_IMF_IMTYPE_MULTILAYER
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
static void remove_in_and_out_node_interface(bNodeTree &node_tree)
static void do_version_channel_matte_menus_to_inputs(bNodeTree &ntree, bNode &node)
@ CMP_NODE_GLARE_SUN_BEAMS
static void do_version_scale_elements_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_transform_menus_to_inputs(bNodeTree &ntree, bNode &node)
@ eSubsurfModifierFlag_UseAdaptiveSubdivision
static void do_version_uv_unwrap_options_to_inputs(bNodeTree &ntree, bNode &node)
Scene * WM_window_get_active_scene(const wmWindow *win)
static void sequencer_remove_listbase_pointers(Scene &scene)
static void do_version_displace_node_remove_xy_scale(bNodeTree &node_tree, bNode &node)
@ SHD_MIXRGB_USE_ALPHA
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
BMesh const char void * data
static bNode * do_version_composite_node_in_scene_tree(bNodeTree &node_tree, bNode &node)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
static void do_version_lift_gamma_gain_srgb_to_linear(bNodeTree &node_tree, bNode &node)
void AS_asset_library_import_method_ensure_valid(Main &bmain)
static void initialize_missing_closure_and_bundle_node_storage(bNodeTree &ntree)
void version_system_idprops_nodes_generate(Main *bmain)
unsigned char uint8_t
Definition BKE_text.h:79
static void do_version_mix_color_use_alpha(bNodeTree *node_tree, bNode *node)
static void version_seq_text_from_legacy(Main *bmain)
FCurve * BKE_fcurve_copy(const FCurve *fcu)
static void remove_in_and_out_node_panel_recursive(bNodeTreeInterfacePanel &panel)
DriverMap BKE_animdata_build_driver_target_map(Main &bmain)
Definition anim_data.cc:980
static void do_version_convert_to_generic_nodes(bNodeTree *node_tree)
static void do_version_texture_gradient_clamp(bNodeTree *node_tree)
static void do_version_stabilize_2d_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_convert_alpha_menus_to_inputs(bNodeTree &ntree, bNode &node)
WorkSpace * WM_window_get_active_workspace(const wmWindow *win)
static void do_version_kuwahara_menus_to_inputs(bNodeTree &ntree, bNode &node)
@ CMP_NODE_EXTENSION_MODE_REPEAT
@ CMP_NODE_EXTENSION_MODE_CLIP
void BKE_ptcache_ids_from_object(ListBaseT< PTCacheID > *lb, struct Object *ob, struct Scene *scene, int duplis)
static void do_version_match_string_options_to_inputs(bNodeTree &ntree, bNode &node)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition readfile.cc:237
@ CMP_NODE_INTERPOLATION_ANISOTROPIC
static void do_version_world_remove_use_nodes(Main *bmain, World *world)
static void idprops_process(IDProperty *idprops, IDProperty **system_idprops)
static void do_version_convert_gp_jitter_values(Brush *brush)
void version_node_tree_clear_interface(bNodeTree &ntree)
static void do_version_remove_attribute_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_points_to_volume_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_double_edge_mask_options_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_subdivision_surface_options_to_inputs(bNodeTree &ntree, bNode &node)
void BKE_image_format_free(ImageFormatData *imf)
bool BKE_imtype_is_movie(char imtype)
static void do_version_track_position_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_mesh_to_volume_options_to_inputs(bNodeTree &ntree, bNode &node)
bool version_cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
static void do_version_adaptive_subdivision(Main *bmain)
void BKE_fcurve_free(FCurve *fcu)
void BKE_curvemapping_free_data(CurveMapping *cumap)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
@ IMA_SHOW_SEQUENCER_SCENE
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
static void do_version_keying_menus_to_inputs(bNodeTree &ntree, bNode &node)
@ NODE_MIX_MODE_UNIFORM
bool BLI_str_quoted_substr_range(const char *__restrict str, const char *__restrict prefix, int *__restrict r_start, int *__restrict r_end) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
@ CMP_NODE_COLOR_BALANCE_LGG
static void do_version_levels_menus_to_inputs(bNodeTree &ntree, bNode &node)
void version_system_idprops_children_bones_generate(Main *bmain)
static void do_version_glare_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_map_uv_menus_to_inputs(bNodeTree &ntree, bNode &node)
void version_node_input_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
static void do_version_translate_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void do_version_scene_remove_use_nodes(Scene *scene)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
IDProperty * version_cycles_properties_from_ID(ID *id)
static void do_version_map_value_node(bNodeTree *node_tree, bNode *node)
@ SHD_SKY_SINGLE_SCATTERING
@ SHD_SKY_MULTIPLE_SCATTERING
static void do_version_material_remove_use_nodes(Main *bmain, Material *material)
static void do_version_color_balance_menus_to_inputs(bNodeTree &ntree, bNode &node)
void BLI_path_split_dir_file(const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
@ SHD_BLEND_QUADRATIC
CurveMapping * BKE_paint_default_curve()
Definition scene.cc:157
@ NODE_VECTOR_MATH_DOT_PRODUCT
@ NODE_VECTOR_MATH_MULTIPLY
Map< ID *, Vector< DriverTarget * > > DriverMap
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
MINLINE void copy_v4_v4(float r[4], const float a[4])
static void do_version_movie_distortion_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void version_bone_hide_property_driver(AnimData *arm_adt, Vector< Object * > &users)
ARegion * do_versions_add_region_if_not_found(ListBaseT< ARegion > *regionbase, int region_type, const char *, int link_after_region_type)
static void do_version_distance_matte_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTree *ntree)
static void do_version_tone_map_menus_to_inputs(bNodeTree &ntree, bNode &node)
static void update_brush_sizes(Main &bmain)
static void do_version_remove_lzo_and_lzma_compression(FileData *fd, Object *object)
const char * RE_engine_id_BLENDER_EEVEE_NEXT
Definition scene.cc:1718
VecBase< float, 3 > float3
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:968
static void do_version_merge_by_distance_options_to_inputs(bNodeTree &ntree, bNode &node)
@ PROP_FACTOR
Definition RNA_types.hh:308
static void do_version_normal_node_dot_product(bNodeTree *node_tree, bNode *node)
void version_node_socket_index_animdata(Main *bmain, const int node_tree_type, const int node_type, const int socket_index_orig, const int socket_index_offset, const int total_number_of_sockets)
bScreen * WM_window_get_active_screen(const wmWindow *win)
static void do_version_transform_geometry_options_to_inputs(bNodeTree &ntree, bNode &node)
void BKE_image_format_copy(ImageFormatData *imf_dst, const ImageFormatData *imf_src)
@ PTCACHE_COMPRESS_LZMA_DEPRECATED
@ PTCACHE_COMPRESS_LZO_DEPRECATED
@ PTCACHE_COMPRESS_ZSTD_FILTERED
static void do_version_lens_distortion_menus_to_inputs(bNodeTree &ntree, bNode &node)
bNodeLink & version_node_add_link(bNodeTree &ntree, bNode &node_a, bNodeSocket &socket_a, bNode &node_b, bNodeSocket &socket_b)
static void sequencer_substitute_transform_effects(Scene *scene, const DriverMap &driver_map)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
bNodeTree * version_get_scene_compositor_node_tree(Main *bmain, Scene *scene)
static bool window_has_sequence_editor_open(const wmWindow *win)
void version_node_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
static void do_version_bokeh_blur_pixel_size(bNodeTree &node_tree, bNode &node)
bNodeSocket & version_node_add_socket(bNodeTree &ntree, bNode &node, const eNodeSocketInOut in_out, const char *idname, const char *identifier)
void version_node_remove(bNodeTree &ntree, bNode &node)
static void do_version_sun_beams(bNodeTree &node_tree, bNode &node)
void version_system_idprops_generate(Main *bmain)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
eRegion_Alignment alignment
ListBaseT< FCurve > drivers
ListBaseT< Bone > childbase
struct CurveMapping * curve_rand_saturation
struct CurveMapping * curve_rand_hue
struct CurveMapping * curve_rand_value
ListBaseT< Strip > seqbase
BlendFileReadReport * reports
Definition readfile.hh:208
IDProperty * system_properties
Definition DNA_ID.h:490
IDProperty * properties
Definition DNA_ID.h:481
eImageUser_Flag flag
ListBaseT< wmWindowManager > wm
Definition BKE_main.hh:415
ListBaseT< bArmature > armatures
Definition BKE_main.hh:407
ListBaseT< Curves > hair_curves
Definition BKE_main.hh:428
ListBaseT< PointCloud > pointclouds
Definition BKE_main.hh:429
ListBaseT< Brush > brushes
Definition BKE_main.hh:410
ListBaseT< Object > objects
Definition BKE_main.hh:388
ListBaseT< Mesh > meshes
Definition BKE_main.hh:389
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
ListBaseT< GreasePencil > grease_pencils
Definition BKE_main.hh:418
ListBaseT< bScreen > screens
Definition BKE_main.hh:400
NodeSocketInterfaceStructureType structure_type
NodeSocketInterfaceStructureType structure_type
DNA_DEPRECATED char path[1024]
DNA_DEPRECATED ImageFormatData format
ListBaseT< PaletteColor > colors
DNA_DEPRECATED float gtao_distance
ListBaseT< ViewLayer > view_layers
struct Editing * ed
DNA_DEPRECATED char use_nodes
DNA_DEPRECATED struct bNodeTree * compositing_node_group
DNA_DEPRECATED struct bNodeTree * nodetree
struct RenderData r
struct SceneEEVEE eevee
struct ToolSettings * toolsettings
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
SpaceActionOverlays_Flag flag
SpaceActionOverlays overlays
struct SpaceClipOverlay overlay
eFileBrowse_Mode browse_mode
FileAssetSelectParams * asset_params
struct ImageUser iuser
eSubsurfAdaptiveSpace adaptive_space
eTexMapping_Flag flag
CurvesSculpt * curves_sculpt
DNA_DEPRECATED struct UnifiedPaintSettings unified_paint_settings
struct ImagePaintSettings imapaint
GpSculptPaint * gp_sculptpaint
eTool_UvSelectMode uv_selectmode
GpVertexPaint * gp_vertexpaint
GpWeightPaint * gp_weightpaint
eUnifiedPaintSettingsFlags flag
DNA_DEPRECATED float rgb[3]
struct CurveMapping * curve_rand_saturation
DNA_DEPRECATED float secondary_rgb[3]
struct CurveMapping * curve_rand_value
struct CurveMapping * curve_rand_hue
struct CurveMapping * curve_distance_falloff
int8_t curve_distance_falloff_preset
struct ViewLayerEEVEE eevee
struct IDProperty * id_properties
struct IDProperty * system_properties
struct Scene * sequencer_scene
ListBaseT< Bone > bonebase
NodeSocketInterfaceStructureType structure_type
ListBaseT< bNodeLink > links
bNodeTreeInterface tree_interface
eNodeTree_Type type
ListBaseT< bNode > nodes
struct bNode * parent
ListBaseT< bNodeSocket > inputs
ListBaseT< struct ScrArea > areabase