Blender V5.3
versioning_502.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
14
15#include "DNA_ID.h"
16#include "DNA_brush_types.h"
17#include "DNA_camera_types.h"
18#include "DNA_curve_types.h"
19#include "DNA_mesh_types.h"
20#include "DNA_modifier_types.h"
22#include "DNA_node_types.h"
23#include "DNA_scene_types.h"
24#include "DNA_screen_types.h"
26#include "DNA_xr_types.h"
27
29#include "BLI_string.hh"
30#include "BLI_string_utf8.hh"
31#include "BLI_string_utils.hh"
32#include "BLI_sys_types.hh"
33
35#include "BKE_animsys.hh"
36#include "BKE_attribute.hh"
37#include "BKE_colortools.hh"
38#include "BKE_curves.hh"
39#include "BKE_idprop.hh"
40#include "BKE_layer.hh"
41#include "BKE_lib_id.hh"
42#include "BKE_lib_override.hh"
43#include "BKE_main.hh"
45#include "BKE_node.hh"
47#include "BKE_node_runtime.hh"
48#include "BKE_report.hh"
49
50#include "SEQ_effects.hh"
51#include "SEQ_iterator.hh"
52#include "SEQ_sequencer.hh"
53
54#include "BLO_read_write.hh"
55#include "readfile.hh"
56
57#include "versioning_common.hh"
58
59// #include "CLG_log.h"
60
61namespace blender {
62
63// static CLG_LogRef LOG = {"blend.doversion"};
64
66 Main &bmain,
67 Object &object,
69{
70 const IDProperty *old_props = nmd.settings_legacy.properties;
71 if (!old_props) {
72 /* Versioning has already been done, this check makes the function idempotent. */
73 return;
74 }
75 if (!nmd.node_group) {
77 nmd.settings_legacy.properties = nullptr;
80 "Modifier '%s' from Object '%s' is missing its Geometry Node Group, its "
81 "settings will be lost (reset to default).",
82 nmd.modifier.name,
83 BKE_id_name(object.id));
84 return;
85 }
86 if (ID_MISSING(&nmd.node_group->id)) {
87 /* Keeping the old idproperties is not an option, and not really useful, since if the
88 * blend-file is saved in this current state, it won't be re-versioned here later anyway.
89 *
90 * Furthermore, the whole remaining part of the code expects this to be nullptr, and keeping it
91 * at runtime actually causes weird issues in depsgraph nodes building phase.
92 *
93 * So all in all, it's simpler and safer to also just lose these values here - if file is not
94 * saved in this state, next loading will do the versioning if the node-group is available
95 * again, otherwise that data is lost.
96 */
98 nmd.settings_legacy.properties = nullptr;
100 fd.reports,
102 "Modifier '%s' from Object '%s' is using a missing linked Geometry Node Group, its "
103 "settings will be lost (reset to default) if the file is saved in this state.",
104 nmd.modifier.name,
105 BKE_id_name(object.id));
106 return;
107 }
108 const bNodeTree &ntree = *nmd.node_group;
109 ntree.ensure_interface_cache();
110
111 IDProperty *system_props = bke::idprop::create_group("NodesModifierProperties").release();
112
113 IDProperty *inputs = bke::idprop::create_group("inputs").release();
114 IDP_AddToGroup(system_props, inputs);
115
116 const std::string inputs_path_prefix = fmt::format("modifiers[\"{}\"]",
118 const DriverMap driver_map = BKE_animdata_build_driver_target_map(bmain);
119 for (const bNodeTreeInterfaceSocket *input : ntree.interface_inputs()) {
120 const StringRefNull identifier = input->identifier;
121 IDProperty *old_value_prop = IDP_GetPropertyFromGroup(old_props, identifier);
122 if (!old_value_prop) {
123 continue;
124 }
125
126 IDProperty *group = bke::idprop::create_group(identifier).release();
127 IDP_AddToGroup(inputs, group);
128
129 if (input->flag & NODE_INTERFACE_SOCKET_LAYER_SELECTION) {
131 group, bke::idprop::create("type", int(nodes::GeometryNodesInputType::Layer)).release());
132 const StringRefNull layer_name = [&]() {
133 const IDProperty *layer_name = IDP_GetPropertyTypeFromGroup(
134 old_props, identifier, IDP_STRING);
135 if (layer_name) {
136 return StringRefNull(IDP_string_get(layer_name));
137 }
138 return StringRefNull();
139 }();
140 IDP_AddToGroup(group, bke::idprop::create("layer_name", layer_name).release());
141 continue;
142 }
143
144 IDProperty *new_value_prop = IDP_CopyProperty(old_value_prop);
145 STRNCPY(new_value_prop->name, "value");
146 IDP_AddToGroup(group, new_value_prop);
147
148 const std::string old_value_path = fmt::format("[\"{}\"]", identifier);
149 const std::string new_value_path = fmt::format(".properties.inputs.{}.value", identifier);
150 BKE_animdata_fix_paths(object.id,
151 inputs_path_prefix,
152 old_value_path,
153 new_value_path,
154 /*verify_paths=*/false,
155 driver_map);
156
157 if (IDOverrideLibrary *override_library = object.id.override_library) {
158 for (IDOverrideLibraryProperty &prop : override_library->properties) {
159 const StringRef path = prop.rna_path;
160 const int64_t i = path.find(inputs_path_prefix);
161 if (i == StringRef::not_found) {
162 continue;
163 }
164 if (path.drop_known_prefix(inputs_path_prefix) != old_value_path) {
165 continue;
166 }
167 MEM_delete(prop.rna_path);
168 prop.rna_path = BLI_sprintfN("%s%s", inputs_path_prefix.c_str(), new_value_path.c_str());
169 }
170 }
171
172 bool use_attribute = false;
173 if (const IDProperty *use_attribute_prop = IDP_GetPropertyFromGroup(
174 old_props, identifier + "_use_attribute"))
175 {
176 /* This property changed to an enum property and animation is not versioned. */
177 if (use_attribute_prop->type == IDP_INT) {
178 use_attribute = bool(IDP_int_get(use_attribute_prop));
179 }
180 else if (use_attribute_prop->type == IDP_BOOLEAN) {
181 use_attribute = bool(IDP_bool_get(use_attribute_prop));
182 }
183 }
184
185 const auto input_type = use_attribute ? nodes::GeometryNodesInputType::Attribute :
187 IDP_AddToGroup(group, bke::idprop::create("type", int(input_type)).release());
188 const StringRefNull attribute_name = [&]() {
189 const IDProperty *attribute_name = IDP_GetPropertyTypeFromGroup(
190 old_props, identifier + "_attribute_name", IDP_STRING);
191 if (attribute_name) {
192 return StringRefNull(IDP_string_get(attribute_name));
193 }
194 return StringRefNull();
195 }();
196 IDP_AddToGroup(group, bke::idprop::create("attribute_name", attribute_name).release());
197 }
198
199 IDProperty *outputs = bke::idprop::create_group("outputs").release();
200 IDP_AddToGroup(system_props, outputs);
201 for (const bNodeTreeInterfaceSocket *output : ntree.interface_outputs()) {
202 const StringRef identifier = output->identifier;
204 old_props, identifier + "_attribute_name", IDP_STRING);
205 if (!old_name_prop) {
206 continue;
207 }
208 IDProperty *group = bke::idprop::create_group(identifier).release();
209 IDP_AddToGroup(outputs, group);
210
211 IDProperty *new_value_prop = IDP_CopyProperty(old_name_prop);
212 STRNCPY(new_value_prop->name, "attribute_name");
213 IDP_AddToGroup(group, new_value_prop);
214 }
215
216 if (nmd.modifier.system_properties) {
218 }
219 nmd.modifier.system_properties = system_props;
221 nmd.settings_legacy.properties = nullptr;
222}
223
225{
226 node_tree.ensure_interface_cache();
227 Set<StringRef> all_identifiers;
228 Map<std::string, StringRefNull> identifier_map;
229 for (bNodeTreeInterfaceItem *item : node_tree.interface_items()) {
230 if (item->item_type == NodeTreeInterfaceItemType::Panel) {
231 continue;
232 }
234 /* Socket identifiers are required to be valid RNA identifiers and unique. */
235 if (!RNA_validate_identifier(socket.identifier, true)) {
236 std::string prev_identifier(socket.identifier);
237 RNA_identifier_sanitize(socket.identifier, true);
238 if (all_identifiers.contains(socket.identifier)) {
239 std::string new_identifier = BLI_uniquename_cb(
240 [&](StringRef name) { return all_identifiers.contains(name); },
241 '_',
242 socket.identifier);
243 MEM_SAFE_DELETE(socket.identifier);
244 socket.identifier = BLI_strdup(new_identifier.c_str());
245 }
246 identifier_map.add(std::move(prev_identifier), socket.identifier);
247 }
248 all_identifiers.add(socket.identifier);
249 }
250
251 /* Rename all the node socket identifiers that got changed in the interface. */
252 if (!identifier_map.is_empty()) {
253 for (bNode &node : node_tree.nodes) {
254 if (!(node.is_group_input() || node.is_group_output())) {
255 continue;
256 }
257 ListBaseT<bNodeSocket> sockets = node.is_group_output() ? node.inputs : node.outputs;
258 for (bNodeSocket &socket : sockets) {
259 if (identifier_map.contains(socket.identifier)) {
260 version_node_socket_identifier_set(socket, identifier_map.lookup(socket.identifier));
261 }
262 }
263 }
264 }
265}
266
267/* Saving file extension is now a property of the File Output node. So inherit this
268 * setting from the active scene to restore the old behavior.
269 * Note: One limitation is that node groups containing file outputs that are not part of any
270 * scene are not affected by versioning. */
272 const Scene &scene)
273{
274 for (bNode &node : node_tree.nodes) {
275 if (node.type_legacy == CMP_NODE_OUTPUT_FILE) {
277 data->use_file_extension = (scene.r.scemode & R_EXTENSION) != 0;
278 }
279 else if (node.type_legacy == NODE_GROUP) {
280 bNodeTree *ngroup = id_cast<bNodeTree *>(node.id);
281 if (ngroup) {
283 }
284 }
285 }
286}
287
289{
290 for (Scene &scene : bmain.scenes) {
291 Editing *ed = seq::editing_get(&scene);
292 if (ed != nullptr) {
293 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
294 constexpr eStripFlag flag_linear_modifiers = eStripFlag(1 << 23);
295 strip->flag &= ~flag_linear_modifiers;
296 return true;
297 });
298 }
299 }
300}
301
303{
304 for (Scene &scene : bmain.scenes) {
305 Editing *ed = seq::editing_get(&scene);
306 if (ed == nullptr) {
307 continue;
308 }
309
310 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
311 if (strip->type == STRIP_TYPE_TEXT && strip->effectdata != nullptr) {
312 TextVars *data = static_cast<TextVars *>(strip->effectdata);
313 data->space_line = 1.0f;
314 }
315 return true;
316 });
317 }
318}
319
321{
322 /* A file with compositor effects that was saved, opened in
323 * previous version and saved there, would have lost the
324 * compositor effect data since earlier versions would not
325 * write it. Ensure the effect data is not null. */
326 for (Scene &scene : bmain.scenes) {
327 if (scene.ed) {
328 seq::foreach_strip(&scene.ed->seqbase, [&](Strip *strip) {
329 if (strip->type == STRIP_TYPE_COMPOSITOR) {
330 seq::effect_ensure_initialized(strip);
331 }
332 return true;
333 });
334 }
335 }
336}
337
339{
340 for (Scene &scene : bmain.scenes) {
341 Editing *ed = seq::editing_get(&scene);
342 if (ed == nullptr) {
343 continue;
344 }
345
346 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
347 if (strip->type == STRIP_TYPE_TEXT && strip->effectdata != nullptr) {
348 TextVars *data = static_cast<TextVars *>(strip->effectdata);
349 data->abs_space_line = 60.0f;
350 data->flag &= ~SEQ_TEXT_USE_ABSOLUTE_LINE_SPACING;
351 }
352 return true;
353 });
354 }
355}
356
358{
359 /* Fix corrupted flagu/flagv values created by older versions of the Curve Pen tool.
360 * The tool could create loose vertices with invalid flag values (e.g. -2), where
361 * CU_NURB_CUSTOM was set alongside other flags and knotsu/knotsv was left null,
362 * causing a crash when opening these files in newer versions. */
363 for (Curve &cu : bmain->curves) {
364 for (Nurb *nu = cu.nurb.first(); nu != nullptr; nu = nu->next) {
365 if (nu->knotsu == nullptr && (nu->flagu & CU_NURB_CUSTOM)) {
367 }
368 if (nu->knotsv == nullptr && (nu->flagv & CU_NURB_CUSTOM)) {
370 }
371 }
372 }
373}
374
376{
377 for (Scene &scene : bmain.scenes) {
378 Editing *ed = seq::editing_get(&scene);
379 if (ed == nullptr) {
380 continue;
381 }
382 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
383 for (StripModifierData &smd : strip->modifiers) {
384 if ((smd.flag & STRIP_MODIFIER_FLAG_MUTE) == 0) {
385 smd.flag |= STRIP_MODIFIER_FLAG_SHOW_PREVIEW;
386 }
387 }
388 return true;
389 });
390 }
391}
392
394{
395 for (const Scene &scene : bmain.scenes) {
396 Editing *ed = seq::editing_get(&scene);
397 if (ed == nullptr) {
398 continue;
399 }
400
401 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
402 if (strip->type != STRIP_TYPE_SCENE || strip->scene == nullptr) {
403 return true;
404 }
405 strip->scene_view_layer_name = BLI_strdup(BKE_view_layer_default_render(strip->scene)->name);
406 return true;
407 });
408 }
409}
410
411/* Compositor node trees with an image input and an image output can likely be used as strip
412 * modifiers. */
414{
415 for (bNodeTree &group : bmain.nodetrees) {
416 if (group.type != NTREE_COMPOSIT) {
417 continue;
418 }
419 bool has_image_input = false;
420 bool has_image_output = false;
421 group.tree_interface.foreach_item([&](const bNodeTreeInterfaceItem &item) {
423 /* Continue. */
424 return true;
425 }
426 const auto &socket = reinterpret_cast<const bNodeTreeInterfaceSocket &>(item);
427 if (socket.flag & NODE_INTERFACE_SOCKET_INPUT) {
428 has_image_input = has_image_input || STREQ(socket.socket_type, "NodeSocketColor");
429 /* Continue. */
430 return true;
431 }
432 if (socket.flag & NODE_INTERFACE_SOCKET_OUTPUT) {
433 has_image_output = has_image_output || STREQ(socket.socket_type, "NodeSocketColor");
434 /* Continue. */
435 return true;
436 }
437 /* Break. */
438 return false;
439 });
440
441 if (has_image_input && has_image_output) {
442 if (!group.compositor_node_asset_traits) {
443 group.compositor_node_asset_traits = MEM_new<CompositorNodeAssetTraits>(__func__);
444 }
447 }
448 }
449}
450
452{
453 version_node_input_socket_name(node_tree, CMP_NODE_SWITCH, "On", "True");
454 version_node_input_socket_name(node_tree, CMP_NODE_SWITCH, "Off", "False");
455 version_node_output_socket_name(node_tree, CMP_NODE_SWITCH, "Image", "Output");
456
457 for (bNode &node : node_tree->nodes) {
458 if (node.type_legacy == CMP_NODE_SWITCH) {
459 node.type_legacy = GEO_NODE_SWITCH;
460 NodeSwitch *storage = MEM_new<NodeSwitch>(__func__);
461 storage->input_type = SOCK_RGBA;
462 STRNCPY_UTF8(node.idname, "GeometryNodeSwitch");
463 node.storage = storage;
464 }
465 }
466}
467
469{
470 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 2)) {
471 for (Scene &scene : bmain->scenes) {
472 bNodeTree *node_tree = version_get_scene_compositor_node_tree(bmain, &scene);
473 if (node_tree == nullptr) {
474 continue;
475 }
477 }
478 }
479
480 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 16)) {
481 for (Object &object : bmain->objects) {
482 for (ModifierData &md : object.modifiers) {
483 if (md.type == eModifierType_Nodes) {
485 *fd, *bmain, object, reinterpret_cast<NodesModifierData &>(md));
486 }
487 }
488 }
489 }
490
491 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 27)) {
493 }
494
495 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 36)) {
496 /* Shift animation data to accommodate the new thin wall input. */
498 }
499
500 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 44)) {
501 /* We have to remove the invalid motion paths. Re-baking into clip space on file load would be
502 * very expensive. */
503 for (Object &object : bmain->objects) {
504 if (object.mpath && (object.avs.path_bakeflag & MOTIONPATH_BAKE_CAMERA_SPACE)) {
505 bke::motionpath::free(object.mpath);
506 object.mpath = nullptr;
507 object.avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
508 }
509 if (object.pose && (object.pose->avs.path_bakeflag & MOTIONPATH_BAKE_CAMERA_SPACE)) {
510 for (bPoseChannel &pose_bone : object.pose->chanbase) {
511 if (pose_bone.mpath) {
512 bke::motionpath::free(pose_bone.mpath);
513 pose_bone.mpath = nullptr;
514 }
515 }
516 object.pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
517 }
518 }
519 }
520
527}
528
530{
531 for (Scene &scene : bmain.scenes) {
532 Editing *ed = seq::editing_get(&scene);
533 if (ed == nullptr) {
534 continue;
535 }
536 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
537 if (strip->type == STRIP_TYPE_COLOR && strip->effectdata != nullptr) {
538 SolidColorVars *data = static_cast<SolidColorVars *>(strip->effectdata);
539 data->width = scene.r.xsch;
540 data->height = scene.r.ysch;
541 }
542 return true;
543 });
544 }
545}
546
547void blo_do_versions_502(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
548{
549 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 1)) {
550 for (Scene &scene : bmain->scenes) {
551 scene.r.mode |= R_SAVE_OUTPUT;
552 }
553 }
554
555 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 4)) {
556 for (Brush &brush : bmain->brushes) {
557 if (brush.gpencil_settings != nullptr) {
558 brush.blend = 0;
559 }
560 }
561 }
562 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 5)) {
563 FOREACH_NODETREE_BEGIN (bmain, node_tree, id_owner) {
564 for (bNode &node : node_tree->nodes) {
565 if (node.type_legacy == FN_NODE_INPUT_VECTOR) {
566 auto &data = *static_cast<NodeInputVector *>(node.storage);
567 data.vector[3] = 0.0f;
568 data.dimensions = 3;
569 }
570 }
571 }
573 }
574
575 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 6)) {
576 for (Scene &scene : bmain->scenes) {
577 SequencerToolSettings *sequencer_tool_settings = seq::tool_settings_ensure(&scene);
578 sequencer_tool_settings->snap_flag |= SEQ_SNAP_TO_ALL_CHANNEL_STRIPS;
579 }
580 }
581
582 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 7)) {
583 for (Scene &scene : bmain->scenes) {
584 scene.r.anisotropic_filter = 2;
585 }
586 }
587
588 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 9)) {
589 for (Mesh &mesh : bmain->meshes) {
591 }
592 }
593
594 /* Convert H.264 codec value for older files (2.79), see #155775. */
595 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 10)) {
596 for (Scene &scene : bmain->scenes) {
597 if (scene.r.ffcodecdata.codec == 28) {
598 scene.r.ffcodecdata.codec = 27;
599 }
600 }
601 }
602
603 /* Disable "unified" flags for Grease Pencil Draw mode. */
604 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 11)) {
605 for (Scene &scene : bmain->scenes) {
606 if (scene.toolsettings->gp_paint) {
607 UnifiedPaintSettings &settings =
611 }
612 }
613 }
614
615 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 12)) {
616 for (bScreen &screen : bmain->screens) {
617 for (ScrArea &area : screen.areabase) {
618 for (SpaceLink &space : area.spacedata) {
619 if (space.spacetype == SPACE_NODE) {
620 SpaceNode *space_node = reinterpret_cast<SpaceNode *>(&space);
622 space_node->overlay.passepartout_alpha = 0.5f;
623 }
624 }
625 }
626 }
627 }
628
629 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 13)) {
631 }
632
633 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 14)) {
635 }
636
637 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 15)) {
638 for (Scene &scene : bmain->scenes) {
640 }
641 }
642
643 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 16)) {
644 for (Brush &brush : bmain->brushes) {
645 if (brush.gpencil_settings != nullptr) {
646 brush.gpencil_settings->curve_type = CURVE_TYPE_POLY;
647 brush.gpencil_settings->conversion_threshold = 0.001f;
648 }
649 }
650 }
651
652 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 17)) {
653 for (Material &materials : bmain->materials) {
654 if (materials.gp_style != nullptr) {
655 materials.gp_style->placement_mode = GP_MATERIAL_PLACEMENT_COUNT;
656 materials.gp_style->placement_count = 1;
657 materials.gp_style->placement_density = 10.0f;
658 materials.gp_style->placement_radius_spacing = 100.0f;
659 }
660 }
661 }
662
663 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 18)) {
664 for (Scene &scene : bmain->scenes) {
665 if (scene.toolsettings->sculpt) {
666 Sculpt &sculpt = *scene.toolsettings->sculpt;
667 MeshAutomaskingSettings *settings = MEM_new<MeshAutomaskingSettings>(__func__);
668 settings->flags = eAutomasking_flag(sculpt.automasking_flags);
672 settings->cavity_factor = sculpt.automasking_cavity_factor;
679
681 }
682 }
683 }
684
685 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 19)) {
686 for (bNodeTree &tree : bmain->nodetrees) {
688 }
689 }
690
691 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 20)) {
692 for (Brush &brush : bmain->brushes) {
693 if (brush.ob_mode != OB_MODE_SCULPT) {
694 continue;
695 }
696
697 brush.mesh_automasking_settings = MEM_new<MeshAutomaskingSettings>(__func__);
698 brush.mesh_automasking_settings->flags = eAutomasking_flag(brush.automasking_flags);
699 brush.mesh_automasking_settings->boundary_edges_propagation_steps =
700 brush.automasking_boundary_edges_propagation_steps;
701 brush.mesh_automasking_settings->cavity_blur_steps = brush.automasking_cavity_blur_steps;
702 brush.mesh_automasking_settings->cavity_factor = brush.automasking_cavity_factor;
703 brush.mesh_automasking_settings->start_normal_falloff =
704 brush.automasking_start_normal_falloff;
705 brush.mesh_automasking_settings->start_normal_limit = brush.automasking_start_normal_limit;
706 brush.mesh_automasking_settings->view_normal_falloff = brush.automasking_view_normal_falloff;
707 brush.mesh_automasking_settings->view_normal_limit = brush.automasking_view_normal_limit;
708 brush.mesh_automasking_settings->cavity_curve = BKE_curvemapping_copy(
709 brush.automasking_cavity_curve);
710 brush.mesh_automasking_settings->cavity_curve_op = nullptr;
711 }
712 }
713
714 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 21)) {
715 for (Material &materials : bmain->materials) {
716 if (materials.gp_style != nullptr) {
717 materials.gp_style->random_size_factor = 0.0f;
718 materials.gp_style->random_strength_factor = 0.0f;
719 materials.gp_style->random_rotation_factor = 0.0f;
720 materials.gp_style->random_hue_factor = 0.0f;
721 materials.gp_style->random_saturation_factor = 0.0f;
722 materials.gp_style->random_value_factor = 0.0f;
723 materials.gp_style->random_noise_scale = 1.0f;
724 }
725 }
726 }
727
728 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 22)) {
730 }
731
732 /* The ID member of the Viewer node is no longer initialized to the Viewer Image, so clear that
733 * member. */
734 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 23)) {
735 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
736 if (node_tree->type == NTREE_COMPOSIT) {
737 for (bNode &node : node_tree->nodes) {
738 if (node.type_legacy == CMP_NODE_VIEWER) {
739 node.id = nullptr;
740 }
741 }
742 }
743 }
745 }
746
747 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 24)) {
748 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
749 if (node_tree->type == NTREE_SHADER) {
750 for (bNode &node : node_tree->nodes) {
751 if (node.type_legacy == SH_NODE_RAYCAST && node.storage == nullptr) {
752 node.storage = MEM_new<NodeShaderRaycast>(__func__);
753 }
754 }
755 }
756 }
758 }
759
760 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 25)) {
761 for (bScreen &screen : bmain->screens) {
762 for (ScrArea &area : screen.areabase) {
763 for (SpaceLink &space : area.spacedata) {
764 if (space.spacetype == SPACE_OUTLINER) {
765 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&space);
766 space_outliner->flag |= SO_SCROLL_TO_ACTIVE;
767 }
768 }
769 }
770 }
771 }
772
773 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 26)) {
774 FOREACH_NODETREE_BEGIN (bmain, tree, id) {
775 if (tree->type != NTREE_GEOMETRY) {
776 continue;
777 }
778 for (bNode &node : tree->nodes) {
779 switch (node.type_legacy) {
780 case FN_NODE_COMPARE:
784 break;
785 }
786 }
787 }
788 }
790 }
791
792 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 28)) {
795 }
796
797 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 29)) {
798 for (bScreen &screen : bmain->screens) {
799 for (ScrArea &area : screen.areabase) {
800 for (SpaceLink &sl : area.spacedata) {
801 if (sl.spacetype != SPACE_SEQ) {
802 continue;
803 }
804 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
805 &sl.regionbase;
807 regionbase, RGN_TYPE_SCRUBBING, "Scrubbing Region", RGN_TYPE_FOOTER);
808 if (scrubbing_region) {
809 scrubbing_region->alignment = RGN_ALIGN_BOTTOM | RGN_STACK_ON_PREV |
811 }
812 }
813 }
814 }
815 }
816
817 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 30)) {
819 }
820
821 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 31)) {
822 for (Mesh &mesh : bmain->meshes) {
823 if (mesh.attributes().contains(".uv_seam")) {
824 mesh.attributes_for_write().rename(".uv_seam", "uv_seam");
825 }
826 }
827 }
828
829 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 34)) {
830 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
831 if (ntree->type == NTREE_COMPOSIT) {
833 }
834 }
836 }
837
838 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 35)) {
839 for (Object &object : bmain->objects) {
840 object.parent_bone_head_tail_factor = 1.0;
841 }
842 }
843
844 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 37)) {
846 }
847
848 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 38)) {
849 for (Brush &brush : bmain->brushes) {
850 if (brush.gpencil_settings != nullptr) {
851 brush.gpencil_settings->fill_gap_factor = 0.4f;
852 brush.gpencil_settings->flag |= GP_BRUSH_FILL_INTERNAL_GAPS;
853 }
854 }
855 }
856
857 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 39)) {
858 for (bScreen &screen : bmain->screens) {
859 for (ScrArea &area : screen.areabase) {
860 for (SpaceLink &sl : area.spacedata) {
861 if (sl.spacetype == SPACE_SEQ) {
862 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
864 float default_col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
866 }
867 }
868 }
869 }
870 }
871
872 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 40)) {
873 for (wmWindowManager &wm : bmain->wm) {
874 wm.xr.session_settings.viewfinder_enabled = false;
875 wm.xr.session_settings.viewfinder_crosshair_enabled = true;
876
877 wm.xr.session_settings.viewfinder_hand = XR_VIEWFINDER_HAND_RIGHT;
878 wm.xr.session_settings.viewfinder_scale = 1.0f;
879
880 wm.xr.session_settings.viewfinder_passepartout_overscan = 0.5f;
881 wm.xr.session_settings.viewfinder_passepartout_opacity = 0.5f;
882 }
883 }
884
885 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 41)) {
887 }
888
889 /* Fix the fact that previously, making a linked data local and/or clearing a liboverride would
890 * not properly flag some sub-data like modifiers or constraints as local. */
891 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 43)) {
892 for (ID &id : MainAllIDsIterator{*bmain}) {
893 if (!ID_IS_LINKED(&id) && !ID_IS_OVERRIDE_LIBRARY(&id)) {
895 }
896 }
897 }
898
905}
906
907} // namespace blender
Low-level operations for curves.
#define IDP_int_get(prop)
#define IDP_string_get(prop)
#define IDP_bool_get(prop)
#define MAIN_VERSION_FILE_ATLEAST(main, ver, subver)
Definition BKE_main.hh:949
#define FOREACH_NODETREE_END
Definition BKE_node.hh:936
#define NODE_GROUP
Definition BKE_node.hh:865
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:926
#define CMP_NODE_VIEWER
#define SH_NODE_BSDF_PRINCIPLED
#define FN_NODE_RANDOM_VALUE
#define FN_NODE_INPUT_VECTOR
#define FN_NODE_COMPARE
#define GEO_NODE_SWITCH
#define CMP_NODE_OUTPUT_FILE
#define CMP_NODE_SWITCH
#define SH_NODE_RAYCAST
#define STRNCPY_UTF8(dst, src)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
#define ID_MISSING(_id)
Definition DNA_ID.h:695
#define STREQ(a, b)
#define output
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
bool is_empty() const
Definition BLI_map.hh:986
bool contains(const Key &key) const
Definition BLI_map.hh:353
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr StringRefNull()
constexpr StringRef drop_known_prefix(StringRef prefix) const
static constexpr int64_t not_found
constexpr int64_t find(char c, int64_t pos=0) const
#define storage(slot, qualifiers)
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRef prop_name, int32_t value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_INT, set its name and value.
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRef prop_name, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_GROUP.
void free(struct bMotionPath *mpath)
T & get_item_as(bNodeTreeInterfaceItem &item)
void mesh_freestyle_marks_to_generic(Mesh &mesh)
void node_update_asset_metadata(bNodeTree &node_tree)
Definition node.cc:2462
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
SequencerToolSettings * tool_settings_ensure(Scene *scene)
Definition sequencer.cc:393
BMesh Iterators.
@ COMPOSIT_NODE_ASSET_STRIP_MODIFIER
static void sanitize_node_tree_interface_socket_identifiers(bNodeTree &node_tree)
__int64 int64_t
Definition BKE_text.h:90
CurveMapping * BKE_curvemapping_copy(const CurveMapping *cumap)
char * STRNCPY(char(&dst)[N], const char *src)
@ RPT_WARNING
Definition BKE_report.hh:40
IDProperty * IDP_GetPropertyTypeFromGroup(const IDProperty *prop, StringRef name, char type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:839
@ GP_MATERIAL_PLACEMENT_COUNT
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
Definition idprop.cc:788
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:986
static void version_geometry_nodes_properties(FileData &fd, Main &bmain, Object &object, NodesModifierData &nmd)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:818
void BKE_lib_override_flag_subdata_local(ID &id)
static void do_version_file_output_use_file_extension_recursive(bNodeTree &node_tree, const Scene &scene)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
static void version_compositor_effect_initialized(Main &bmain)
const char * BKE_id_name(const ID &id)
static void fix_single_point_curves_custom_knots(Main *bmain)
void do_versions_after_linking_502(FileData *fd, Main *bmain)
static void version_scene_strip_view_layer_name(Main &bmain)
void blo_do_versions_502(FileData *fd, Library *lib, Main *bmain)
@ RGN_ALIGN_HIDE_WITH_PREV
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)
@ XR_VIEWFINDER_HAND_RIGHT
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)
bool RNA_validate_identifier(const char *identifier, bool is_property, const char **r_error)
BMesh const char void * data
static void version_solid_color_width_height_defaults(Main &bmain)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
@ SEQ_PREVIEW_SHOW_COMPOSITION_GUIDES
static void enable_compositor_nodes_is_strip_modifier(Main &bmain)
DriverMap BKE_animdata_build_driver_target_map(Main &bmain)
Definition anim_data.cc:980
static void version_clear_strip_linear_modifier_flag(Main &bmain)
void version_socket_identifier_suffixes_for_dynamic_types(const ListBaseT< bNodeSocket > &sockets, const char *separator, const std::optional< int > total)
static void version_text_strip_space_line(Main &bmain)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition readfile.cc:237
@ SEQ_SNAP_TO_ALL_CHANNEL_STRIPS
void RNA_identifier_sanitize(char *identifier, bool is_property)
static void versioning_replace_legacy_compositor_switch_node(bNodeTree *node_tree)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
void IDP_FreeProperty(IDProperty *prop)
Definition idprop.cc:1403
void version_node_input_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
Map< ID *, Vector< DriverTarget * > > DriverMap
MINLINE void copy_v4_v4(float r[4], const float a[4])
ARegion * do_versions_add_region_if_not_found(ListBaseT< ARegion > *regionbase, int region_type, const char *, int link_after_region_type)
@ UNIFIED_PAINT_SIZE_DEPRECATED
@ UNIFIED_PAINT_COLOR_DEPRECATED
@ UNIFIED_PAINT_ALPHA_DEPRECATED
@ GP_BRUSH_FILL_INTERNAL_GAPS
ViewLayer * BKE_view_layer_default_render(const Scene *scene)
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)
@ MOTIONPATH_BAKE_CAMERA_SPACE
@ MOTIONPATH_BAKE_HAS_PATHS
bNodeTree * version_get_scene_compositor_node_tree(Main *bmain, Scene *scene)
static void version_text_strip_abs_space_line(Main &bmain)
@ SN_OVERLAY_SHOW_RENDER_REGION
static void version_strip_modifier_show_preview_flag(Main &bmain)
eRegion_Alignment alignment
ListBaseT< Nurb > nurb
ListBaseT< Strip > seqbase
BlendFileReadReport * reports
Definition readfile.hh:208
ListBaseT< wmWindowManager > wm
Definition BKE_main.hh:415
ListBaseT< bNodeTree > nodetrees
Definition BKE_main.hh:409
ListBaseT< Brush > brushes
Definition BKE_main.hh:410
ListBaseT< Material > materials
Definition BKE_main.hh:392
ListBaseT< Object > objects
Definition BKE_main.hh:388
ListBaseT< Curve > curves
Definition BKE_main.hh:390
ListBaseT< Mesh > meshes
Definition BKE_main.hh:389
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
ListBaseT< bScreen > screens
Definition BKE_main.hh:400
struct CurveMapping * cavity_curve_op
struct IDProperty * system_properties
struct NodesModifierSettings settings_legacy
struct UnifiedPaintSettings unified_paint_settings
struct MeshAutomaskingSettings * mesh_automasking_settings
struct FFMpegCodecData ffcodecdata
struct Editing * ed
struct RenderData r
struct ToolSettings * toolsettings
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
DNA_DEPRECATED float automasking_view_normal_falloff
DNA_DEPRECATED float automasking_start_normal_falloff
DNA_DEPRECATED struct CurveMapping * automasking_cavity_curve_op
DNA_DEPRECATED struct CurveMapping * automasking_cavity_curve
DNA_DEPRECATED float automasking_cavity_factor
DNA_DEPRECATED float automasking_view_normal_limit
DNA_DEPRECATED int automasking_cavity_blur_steps
DNA_DEPRECATED int automasking_boundary_edges_propagation_steps
DNA_DEPRECATED int automasking_flags
DNA_DEPRECATED float automasking_start_normal_limit
eSpaceSeq_SequencerPreviewOverlay_Flag flag
eSpaceNodeOverlay_Flag flag
SpaceNodeOverlay overlay
eSpaceOutliner_Flag flag
struct SequencerPreviewOverlay preview_overlay
eUnifiedPaintSettingsFlags flag
struct CompositorNodeAssetTraits * compositor_node_asset_traits
bNodeTreeInterface tree_interface
eNodeTree_Type type
ListBaseT< bNode > nodes
ListBaseT< struct ScrArea > areabase