Blender V5.3
versioning_400.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#define DNA_DEPRECATED_ALLOW
10
11#include "ANIM_armature_iter.hh"
13
14/* Define macros in `DNA_genfile.h`. */
15#define DNA_GENFILE_VERSIONING_MACROS
16
17#include "DNA_camera_types.h"
18#include "DNA_genfile.h"
19#include "DNA_light_types.h"
21#include "DNA_modifier_types.h"
22#include "DNA_node_types.h"
23#include "DNA_particle_types.h"
24#include "DNA_screen_types.h"
25#include "DNA_sequence_types.h"
26#include "DNA_world_types.h"
27
28#undef DNA_GENFILE_VERSIONING_MACROS
29
30#include "RNA_path.hh"
31
32#include "BLI_listbase.hh"
33#include "BLI_math_vector_c.hh"
34#include "BLI_string.hh"
35#include "BLI_string_utf8.hh"
36
37#include "BLT_translation.hh"
38
39#include "BKE_anim_data.hh"
40#include "BKE_animsys.hh"
41#include "BKE_attribute.hh"
42#include "BKE_curve.hh"
43#include "BKE_effect.h"
44#include "BKE_grease_pencil.hh"
45#include "BKE_idprop.hh"
46#include "BKE_main.hh"
48#include "BKE_node.hh"
50#include "BKE_node_runtime.hh"
51#include "BKE_report.hh"
52#include "BKE_scene.hh"
53#include "BKE_texture.h"
54#include "BKE_tracking.hh"
55
56#include "SEQ_iterator.hh"
57#include "SEQ_retiming.hh"
58#include "SEQ_sequencer.hh"
59
60#include "BLO_read_write.hh"
61
62#include "readfile.hh"
63
64#include "versioning_common.hh"
65
66namespace blender {
67
69{
70 for (bNode *node : ntree->all_nodes()) {
71 if (node->id == nullptr && ((node->type_legacy == CMP_NODE_R_LAYERS) ||
72 (node->type_legacy == CMP_NODE_CRYPTOMATTE &&
74 {
75 node->id = &scene->id;
76 }
77 }
78}
79
80/* Move bone-group color to the individual bones. */
82{
83 using PoseObSet = Set<Object *>;
84 Map<bArmature *, PoseObSet> armature_poses;
85
86 /* Gather a mapping from armature to the poses that use it. */
87 for (Object &ob : bmain->objects) {
88 if (ob.type != OB_ARMATURE || !ob.pose) {
89 continue;
90 }
91
92 bArmature *arm = reinterpret_cast<bArmature *>(ob.data);
93 BLI_assert_msg(GS(arm->id.name) == ID_AR,
94 "Expected ARMATURE object to have an Armature as data");
95
96 /* There is no guarantee that the current state of poses is in sync with the Armature data.
97 *
98 * NOTE: No need to handle user reference-counting in readfile code. */
99 BKE_pose_ensure(bmain, &ob, arm, false);
100
101 PoseObSet &pose_set = armature_poses.lookup_or_add_default(arm);
102 pose_set.add(&ob);
103 }
104
105 /* Move colors from the pose's bone-group to either the armature bones or the
106 * pose bones, depending on how many poses use the Armature. */
107 for (const PoseObSet &pose_set : armature_poses.values()) {
108 /* If the Armature is shared, the bone group colors might be different, and thus they have to
109 * be stored on the pose bones. If the Armature is NOT shared, the bone colors can be stored
110 * directly on the Armature bones. */
111 const bool store_on_armature = pose_set.size() == 1;
112
113 for (Object *pose_ob : pose_set) {
114 bPose *pose = pose_ob->pose;
115 for (bPoseChannel &pchan : pose->chanbase) {
116 const bActionGroup *bgrp = static_cast<const bActionGroup *>(
117 BLI_findlink(&pose->agroups, (pchan.agrp_index - 1)));
118 if (!bgrp) {
119 continue;
120 }
121
122 BoneColor &bone_color = store_on_armature ? pchan.bone_get(*pose_ob)->color : pchan.color;
123 bone_color.palette_index = bgrp->customCol;
124 memcpy(&bone_color.custom, &bgrp->cs, sizeof(bone_color.custom));
125 }
126 }
127 }
128}
129
131{
132 char bcoll_name[MAX_NAME];
133 char custom_prop_name[MAX_NAME];
134
135 for (bArmature &arm : bmain->armatures) {
136 IDProperty *arm_idprops = IDP_GetProperties(&arm.id);
137
138 BLI_assert_msg(arm.edbo == nullptr, "did not expect an Armature to be saved in edit mode");
139 const uint layer_used = arm.layer_used;
140
141 /* Construct a bone collection for each layer that contains at least one bone. */
142 Vector<std::pair<uint, BoneCollection *>> layermask_collection;
143 for (uint layer = 0; layer < 32; ++layer) {
144 const uint layer_mask = 1u << layer;
145 if ((layer_used & layer_mask) == 0) {
146 /* Layer is empty, so no need to convert to collection. */
147 continue;
148 }
149
150 /* Construct a suitable name for this bone layer. */
151 bcoll_name[0] = '\0';
152 if (arm_idprops) {
153 /* See if we can use the layer name from the Bone Manager add-on. This is a popular add-on
154 * for managing bone layers and giving them names. */
155 SNPRINTF_UTF8(custom_prop_name, "layer_name_%u", layer);
156 IDProperty *prop = IDP_GetPropertyFromGroup(arm_idprops, custom_prop_name);
157 if (prop != nullptr && prop->type == IDP_STRING && IDP_string_get(prop)[0] != '\0') {
158 SNPRINTF_UTF8(bcoll_name, "Layer %u - %s", layer + 1, IDP_string_get(prop));
159 }
160 }
161 if (bcoll_name[0] == '\0') {
162 /* Either there was no name defined in the custom property, or
163 * it was the empty string. */
164 SNPRINTF_UTF8(bcoll_name, "Layer %u", layer + 1);
165 }
166
167 /* Create a new bone collection for this layer. */
168 BoneCollection *bcoll = ANIM_armature_bonecoll_new(&arm, bcoll_name);
169 layermask_collection.append(std::make_pair(layer_mask, bcoll));
170
171 if ((arm.layer & layer_mask) == 0) {
172 ANIM_bonecoll_hide(&arm, bcoll);
173 }
174 }
175
176 /* Iterate over the bones to assign them to their layers. */
177 animrig::ANIM_armature_foreach_bone(&arm.bonebase, [&](Bone *bone) {
178 for (auto layer_bcoll : layermask_collection) {
179 const uint layer_mask = layer_bcoll.first;
180 if ((bone->layer & layer_mask) == 0) {
181 continue;
182 }
183
184 BoneCollection *bcoll = layer_bcoll.second;
185 ANIM_armature_bonecoll_assign(bcoll, bone);
186 }
187 });
188 }
189}
190
192{
193 for (Object &ob : bmain->objects) {
194 if (ob.type != OB_ARMATURE || !ob.pose) {
195 continue;
196 }
197
198 /* Convert the bone groups on a bone-by-bone basis. */
199 bArmature *arm = reinterpret_cast<bArmature *>(ob.data);
200 bPose *pose = ob.pose;
201
203 /* Convert all bone groups, regardless of whether they contain any bones. */
204 for (bActionGroup &bgrp : pose->agroups) {
206 collections_by_group.add_new(&bgrp, bcoll);
207
208 /* Before now, bone visibility was determined by armature layers, and bone
209 * groups did not have any impact on this. To retain the behavior, that
210 * hiding all layers a bone is on hides the bone, the
211 * bone-group-collections should be created hidden. */
212 ANIM_bonecoll_hide(arm, bcoll);
213 }
214
215 /* Assign the bones to their bone group based collection. */
216 for (bPoseChannel &pchan : pose->chanbase) {
217 /* Find the bone group of this pose channel. */
218 const bActionGroup *bgrp = static_cast<const bActionGroup *>(
219 BLI_findlink(&pose->agroups, (pchan.agrp_index - 1)));
220 if (!bgrp) {
221 continue;
222 }
223
224 /* Assign the bone. */
225 BoneCollection *bcoll = collections_by_group.lookup(bgrp);
226 ANIM_armature_bonecoll_assign(bcoll, pchan.bone_get(ob));
227 }
228
229 /* The list of bone groups (pose->agroups) is intentionally left alone here. This will allow
230 * for older versions of Blender to open the file with bone groups intact. Of course the bone
231 * groups will not be updated any more, but this way the data at least survives an accidental
232 * save with Blender 4.0. */
233 }
234}
235
237{
238 ID *id = &ntree->id;
240
241 for (bNode &node : ntree->nodes) {
242 if (node.type_legacy != SH_NODE_BSDF_PRINCIPLED) {
243 continue;
244 }
245
246 char node_name_escaped[MAX_NAME * 2];
247 BLI_str_escape(node_name_escaped, node.name, sizeof(node_name_escaped));
248 std::string prefix = "nodes[\"" + std::string(node_name_escaped) + "\"].inputs";
249
250 /* Remove animdata for inputs 18 (Transmission Roughness) and 3 (Subsurface Color). */
251 BKE_animdata_fix_paths_remove(id, (prefix + "[18]").c_str());
252 BKE_animdata_fix_paths_remove(id, (prefix + "[3]").c_str());
253
254 /* Order is important here: If we e.g. want to change A->B and B->C, but perform A->B first,
255 * then later we don't know whether a B entry is an original B (and therefore should be
256 * changed to C) or used to be A and was already handled.
257 * In practice, going reverse mostly works, the two notable dependency chains are:
258 * - 8->13, then 2->8, then 9->2 (13 was changed before)
259 * - 1->9, then 6->1 (9 was changed before)
260 * - 4->10, then 21->4 (10 was changed before)
261 *
262 * 0 (Base Color) and 17 (Transmission) are fine as-is. */
263 std::pair<int, int> remap_table[] = {
264 {20, 27}, /* Emission Strength */
265 {19, 26}, /* Emission */
266 {16, 3}, /* IOR */
267 {15, 19}, /* Clearcoat Roughness */
268 {14, 18}, /* Clearcoat */
269 {13, 25}, /* Sheen Tint */
270 {12, 23}, /* Sheen */
271 {11, 15}, /* Anisotropic Rotation */
272 {10, 14}, /* Anisotropic */
273 {8, 13}, /* Specular Tint */
274 {2, 8}, /* Subsurface Radius */
275 {9, 2}, /* Roughness */
276 {7, 12}, /* Specular */
277 {1, 9}, /* Subsurface Scale */
278 {6, 1}, /* Metallic */
279 {5, 11}, /* Subsurface Anisotropy */
280 {4, 10}, /* Subsurface IOR */
281 {21, 4} /* Alpha */
282 };
283 for (const auto &entry : remap_table) {
285 prefix,
286 RNA_path_number_to_infix(entry.first),
287 RNA_path_number_to_infix(entry.second),
288 /*verify_paths=*/false,
289 driver_map);
290 }
291 }
292}
293
294static bool versioning_convert_strip_speed_factor(Strip *strip, void *user_data)
295{
296 const Scene *scene = static_cast<Scene *>(user_data);
297 const float speed_factor = strip->speed_factor;
298
299 if (speed_factor == 1.0f || !seq::retiming_is_allowed(strip) ||
300 seq::retiming_keys_count(strip) > 0)
301 {
302 return true;
303 }
304
306 SeqRetimingKey *last_key = &seq::retiming_keys_get(strip)[1];
307
308 last_key->strip_frame_index = (strip->len) / speed_factor;
309
310 if (strip->type == STRIP_TYPE_SOUND) {
311 const int prev_length = strip->len - strip->startofs - strip->endofs;
312 const float left_handle = strip->left_handle();
313 strip->right_handle_set(scene, left_handle + prev_length);
314 }
315
316 return true;
317}
318
320{
321 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 9)) {
322 /* Fix area light scaling. */
323 for (Light &light : bmain->lights) {
324 light.energy = light.energy_deprecated;
325 if (light.type == LA_AREA) {
326 light.energy *= M_PI_4;
327 }
328 }
329
330 /* XXX This was added several years ago in `lib_link` code of Scene... Should be safe enough
331 * here. */
332 for (Scene &scene : bmain->scenes) {
333 if (scene.nodetree) {
335 }
336 }
337
338 /* XXX This was added many years ago (1c19940198) in `lib_link` code of particles as a bug-fix.
339 * But this is actually versioning. Should be safe enough here. */
340 for (ParticleSettings &part : bmain->particles) {
341 if (!part.effector_weights) {
343 }
344 }
345
346 /* Object proxies have been deprecated sine 3.x era, so their update & sanity check can now
347 * happen in do_versions code. */
348 for (Object &ob : bmain->objects) {
349 if (ob.proxy) {
350 /* Paranoia check, actually a proxy_from pointer should never be written... */
351 if (!ID_IS_LINKED(ob.proxy)) {
352 ob.proxy->proxy_from = nullptr;
353 ob.proxy = nullptr;
354
355 if (ob.id.lib) {
357 RPT_INFO,
358 RPT_("Proxy lost from object %s lib %s\n"),
359 ob.id.name + 2,
360 ob.id.lib->filepath);
361 }
362 else {
364 RPT_INFO,
365 RPT_("Proxy lost from object %s lib <NONE>\n"),
366 ob.id.name + 2);
367 }
368 fd->reports->count.missing_obproxies++;
369 }
370 else {
371 /* This triggers object_update to always use a copy. */
372 ob.proxy->proxy_from = &ob;
373 }
374 }
375 }
376 }
377
378 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 21)) {
379 if (!DNA_struct_member_exists(fd->filesdna, "bPoseChannel", "BoneColor", "color")) {
381 }
382
383 if (!DNA_struct_member_exists(fd->filesdna, "bArmature", "ListBase", "collections")) {
386 }
387 }
388
389 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 24)) {
390 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
391 if (ntree->type == NTREE_SHADER) {
392 /* Convert animdata on the Principled BSDF sockets. */
394 }
395 }
397 }
398
399 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 27)) {
400 for (Scene &scene : bmain->scenes) {
401 Editing *ed = seq::editing_get(&scene);
402 if (ed != nullptr) {
404 }
405 }
406 }
407
408 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 34)) {
410 }
411}
412
431
433{
434 MovieTracking &tracking = movieclip.tracking;
435 MovieTrackingObject *active_tracking_object = BKE_tracking_object_get_active(&tracking);
436 MovieTrackingObject *tracking_camera_object = BKE_tracking_object_get_camera(&tracking);
437
438 BLI_assert(tracking_camera_object != nullptr);
439
440 if (tracking_camera_object->tracks.is_empty()) {
441 tracking_camera_object->tracks = tracking.tracks_legacy;
442 active_tracking_object->active_track = tracking.act_track_legacy;
443 }
444
445 if (tracking_camera_object->plane_tracks.is_empty()) {
446 tracking_camera_object->plane_tracks = tracking.plane_tracks_legacy;
447 active_tracking_object->active_plane_track = tracking.act_plane_track_legacy;
448 }
449
450 if (tracking_camera_object->reconstruction.cameras == nullptr) {
451 tracking_camera_object->reconstruction = tracking.reconstruction_legacy;
452 }
453
454 /* Clear pointers in the legacy storage.
455 * Always do it, in the case something got missed in the logic above, so that the legacy storage
456 * is always ensured to be empty after load. */
457 tracking.tracks_legacy.clear_no_delete();
458 tracking.plane_tracks_legacy.clear_no_delete();
459 tracking.act_track_legacy = nullptr;
460 tracking.act_plane_track_legacy = nullptr;
462}
463
465{
466 for (MovieClip &movieclip : bmain->movieclips) {
468 }
469}
470
472{
473 for (bNode &node : ntree->nodes) {
474 if (node.type_legacy == SH_NODE_BSDF_GLOSSY_LEGACY) {
475 STRNCPY_UTF8(node.idname, "ShaderNodeBsdfAnisotropic");
476 node.type_legacy = SH_NODE_BSDF_GLOSSY;
477 }
478 }
479}
480
482{
483 /* Find all glossy, glass and refraction BSDF nodes that have their distribution
484 * set to SHARP and set them to GGX, disconnect any link to the Roughness input
485 * and set its value to zero. */
486 for (bNode &node : ntree->nodes) {
488 {
489 continue;
490 }
491 if (node.custom1 != SHD_GLOSSY_SHARP_DEPRECATED) {
492 continue;
493 }
494
495 node.custom1 = SHD_GLOSSY_GGX;
496 for (bNodeSocket &socket : node.inputs) {
497 if (!STREQ(socket.identifier, "Roughness")) {
498 continue;
499 }
500
501 if (socket.link != nullptr) {
502 bke::node_remove_link(ntree, *socket.link);
503 }
504 bNodeSocketValueFloat *socket_value = static_cast<bNodeSocketValueFloat *>(
505 socket.default_value);
506 socket_value->value = 0.0f;
507
508 break;
509 }
510 }
511}
512
514{
515 for (Mesh &mesh : bmain.meshes) {
517 }
518
519 for (bNodeTree &ntree : bmain.nodetrees) {
520 if (ntree.type == NTREE_GEOMETRY) {
521 for (bNode &node : ntree.nodes) {
522 if (STR_ELEM(
523 node.idname, "GeometryNodeStoreNamedAttribute", "GeometryNodeInputNamedAttribute"))
524 {
525 bNodeSocket *socket = bke::node_find_socket(node, SOCK_IN, "Name"_ustr);
526 if (STREQ(socket->default_value_typed<bNodeSocketValueString>()->value, "crease")) {
527 STRNCPY_UTF8(socket->default_value_typed<bNodeSocketValueString>()->value,
528 "crease_edge");
529 }
530 }
531 }
532 }
533 }
534
535 for (Object &object : bmain.objects) {
536 for (ModifierData &md : object.modifiers) {
537 if (md.type != eModifierType_Nodes) {
538 continue;
539 }
540 if (IDProperty *settings =
541 reinterpret_cast<NodesModifierData *>(&md)->settings_legacy.properties)
542 {
543 for (IDProperty &prop : settings->data.group) {
544 if (prop.type != IDP_STRING) {
545 continue;
546 }
547 if (StringRef(prop.name).endswith("_attribute_name")) {
548 if (STREQ(IDP_string_get(&prop), "crease")) {
549 IDP_AssignString(&prop, "crease_edge");
550 }
551 }
552 }
553 }
554 }
555 }
556}
557
559{
560 /* The normal of a spot light was set to the incoming light direction, replace with the
561 * `Incoming` socket from the Geometry shader node. */
562 bNode *geometry_node = nullptr;
563 bNode *transform_node = nullptr;
564 bNodeSocket *incoming_socket = nullptr;
565 bNodeSocket *vec_in_socket = nullptr;
566 bNodeSocket *vec_out_socket = nullptr;
567
568 for (bNodeLink &link : ntree->links.items_mutable()) {
569 if (link.fromnode->type_legacy == SH_NODE_TEX_COORD &&
570 STREQ(link.fromsock->identifier, "Normal"))
571 {
572 if (geometry_node == nullptr) {
573 geometry_node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_NEW_GEOMETRY);
574 incoming_socket = bke::node_find_socket(*geometry_node, SOCK_OUT, "Incoming"_ustr);
575
576 transform_node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VECT_TRANSFORM);
577 vec_in_socket = bke::node_find_socket(*transform_node, SOCK_IN, "Vector"_ustr);
578 vec_out_socket = bke::node_find_socket(*transform_node, SOCK_OUT, "Vector"_ustr);
579
580 NodeShaderVectTransform *nodeprop = static_cast<NodeShaderVectTransform *>(
581 transform_node->storage);
583
585 *ntree, *geometry_node, *incoming_socket, *transform_node, *vec_in_socket);
586 }
587 bke::node_add_link(*ntree, *transform_node, *vec_out_socket, *link.tonode, *link.tosock);
588 bke::node_remove_link(ntree, link);
589 }
590 }
591}
592
593/* Version VertexWeightEdit modifier to make existing weights exclusive of the threshold. */
595{
596 for (Object &ob : bmain->objects) {
597 if (ob.type != OB_MESH) {
598 continue;
599 }
600
601 for (ModifierData &md : ob.modifiers) {
603 WeightVGEditModifierData *wmd = reinterpret_cast<WeightVGEditModifierData *>(&md);
604 wmd->add_threshold = nexttoward(wmd->add_threshold, 2.0);
605 wmd->rem_threshold = nexttoward(wmd->rem_threshold, -1.0);
606 }
607 }
608 }
609}
610
612{
613 for (bNode &node : ntree->nodes) {
614 if (node.type_legacy != SH_NODE_BSDF_PRINCIPLED) {
615 continue;
616 }
617 bNodeSocket *sock = bke::node_find_socket(node, SOCK_IN, "Transmission Roughness"_ustr);
618 if (sock != nullptr) {
619 bke::node_remove_socket(*ntree, node, *sock);
620 }
621 }
622}
623
624/* Convert legacy Velvet BSDF nodes into the new Sheen BSDF node. */
626{
627 for (bNode &node : ntree->nodes) {
628 if (node.type_legacy == SH_NODE_BSDF_SHEEN) {
629 STRNCPY_UTF8(node.idname, "ShaderNodeBsdfSheen");
630
631 bNodeSocket *sigmaInput = bke::node_find_socket(node, SOCK_IN, "Sigma"_ustr);
632 if (sigmaInput != nullptr) {
633 node.custom1 = SHD_SHEEN_ASHIKHMIN;
634 version_node_socket_identifier_set(*sigmaInput, "Roughness");
635 STRNCPY_UTF8(sigmaInput->name, "Roughness");
636 }
637 }
638 }
639}
640
641/* Convert sheen inputs on the Principled BSDF. */
643{
644 auto check_node = [](const bNode *node) {
645 return (node->type_legacy == SH_NODE_BSDF_PRINCIPLED) &&
646 (bke::node_find_socket(*node, SOCK_IN, "Sheen Roughness"_ustr) == nullptr);
647 };
648 auto update_input = [ntree](bNode *node, bNodeSocket *input) {
649 /* Change socket type to Color. */
651
652 /* Account for the change in intensity between the old and new model.
653 * If the Sheen input is set to a fixed value, adjust it and set the tint to white.
654 * Otherwise, if it's connected, keep it as-is but set the tint to 0.2 instead. */
656 if (sheen != nullptr && sheen->link == nullptr) {
658
659 static float default_value[] = {1.0f, 1.0f, 1.0f, 1.0f};
661 }
662 else {
663 static float default_value[] = {0.2f, 0.2f, 0.2f, 1.0f};
665 }
666 };
667 auto update_input_link = [](bNode *, bNodeSocket *, bNode *, bNodeSocket *) {
668 /* Don't replace the link here, tint works differently enough now to make conversion
669 * impractical. */
670 };
671
672 version_update_node_input(ntree, check_node, "Sheen Tint", update_input, update_input_link);
673}
674
675/* Replace old Principled Hair BSDF as a variant in the new Principled Hair BSDF. */
677{
678 for (bNode &node : ntree->nodes) {
679 if (node.type_legacy != SH_NODE_BSDF_HAIR_PRINCIPLED) {
680 continue;
681 }
682 NodeShaderHairPrincipled *data = MEM_new<NodeShaderHairPrincipled>(__func__);
684 data->parametrization = node.custom1;
685
686 node.storage = data;
687 }
688}
689
691 const eNodeSocketInOut in_out)
692{
693 bNodeTreeInterfaceSocket *new_socket = MEM_new<bNodeTreeInterfaceSocket>(__func__);
695
696 /* Move reusable data. */
697 new_socket->name_ = BLI_strdup(legacy_socket.name);
698 new_socket->identifier = BLI_strdup(legacy_socket.identifier);
699 new_socket->description_ = BLI_strdup(legacy_socket.description);
700 /* If the socket idname includes a subtype (e.g. "NodeSocketFloatFactor") this will convert it to
701 * the base type name ("NodeSocketFloat"). */
702 new_socket->socket_type = BLI_strdup(
704 new_socket->flag = (in_out == SOCK_IN ? NODE_INTERFACE_SOCKET_INPUT :
707 new_socket->flag, legacy_socket.flag & SOCK_HIDE_VALUE, NODE_INTERFACE_SOCKET_HIDE_VALUE);
708 SET_FLAG_FROM_TEST(new_socket->flag,
709 legacy_socket.flag & SOCK_HIDE_IN_MODIFIER,
711 new_socket->attribute_domain = legacy_socket.attribute_domain;
712
713 /* The following data are stolen from the old data, the ownership of their memory is directly
714 * transferred to the new data. */
715 new_socket->default_attribute_name = legacy_socket.default_attribute_name;
716 legacy_socket.default_attribute_name = nullptr;
717 new_socket->socket_data = legacy_socket.default_value;
718 legacy_socket.default_value = nullptr;
719 new_socket->properties = legacy_socket.prop;
720 legacy_socket.prop = nullptr;
721
722 /* Unused data. */
723 MEM_delete(legacy_socket.runtime);
724 legacy_socket.runtime = nullptr;
725
726 return &new_socket->item;
727}
728
730{
731 bNodeTreeInterface &tree_interface = ntree->tree_interface;
732
733 const int num_inputs = ntree->inputs_legacy.count();
734 const int num_outputs = ntree->outputs_legacy.count();
735 tree_interface.root_panel.items_num = num_inputs + num_outputs;
737 size_t(tree_interface.root_panel.items_num), __func__);
738
739 /* Convert outputs first to retain old outputs/inputs ordering. */
740
741 for (const auto [index, socket] : ntree->outputs_legacy.enumerate()) {
743 SOCK_OUT);
744 }
745 for (const auto [index, socket] : ntree->inputs_legacy.enumerate()) {
746 tree_interface.root_panel.items_array[num_outputs + index] = legacy_socket_move_to_interface(
747 socket, SOCK_IN);
748 }
749}
750
751/* Convert coat inputs on the Principled BSDF. */
753{
754 for (bNode &node : ntree->nodes) {
755 if (node.type_legacy != SH_NODE_BSDF_PRINCIPLED) {
756 continue;
757 }
758 if (bke::node_find_socket(node, SOCK_IN, "Coat IOR"_ustr) != nullptr) {
759 continue;
760 }
762 *ntree, node, SOCK_IN, SOCK_FLOAT, PROP_NONE, "Coat IOR", "Coat IOR");
763
764 /* Adjust for 4x change in intensity. */
765 bNodeSocket *coat_input = bke::node_find_socket(node, SOCK_IN, "Clearcoat"_ustr);
766 *version_cycles_node_socket_float_value(coat_input) *= 0.25f;
767 /* When the coat input is dynamic, instead of inserting a *0.25 math node, set the Coat IOR
768 * to 1.2 instead - this also roughly quarters reflectivity compared to the 1.5 default. */
769 *version_cycles_node_socket_float_value(coat_ior_input) = (coat_input->link) ? 1.2f : 1.5f;
770 }
771
772 /* Rename sockets. */
773 version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Clearcoat", "Coat");
775 ntree, SH_NODE_BSDF_PRINCIPLED, "Clearcoat Roughness", "Coat Roughness");
777 ntree, SH_NODE_BSDF_PRINCIPLED, "Clearcoat Normal", "Coat Normal");
778}
779
780/* Convert subsurface inputs on the Principled BSDF. */
782{
783 /* - Create Subsurface Scale input
784 * - If a node's Subsurface input was connected or nonzero:
785 * - Make the Base Color a mix of old Base Color and Subsurface Color,
786 * using Subsurface as the mix factor
787 * - Move Subsurface link and default value to the new Subsurface Scale input
788 * - Set the Subsurface input to 1.0
789 * - Remove Subsurface Color input
790 */
791 for (bNode &node : ntree->nodes) {
792 if (node.type_legacy != SH_NODE_BSDF_PRINCIPLED) {
793 continue;
794 }
795 if (bke::node_find_socket(node, SOCK_IN, "Subsurface Scale"_ustr)) {
796 /* Node is already updated. */
797 continue;
798 }
799
800 /* Add Scale input */
802 *ntree, node, SOCK_IN, SOCK_FLOAT, PROP_DISTANCE, "Subsurface Scale", "Subsurface Scale");
803
804 bNodeSocket *subsurf = bke::node_find_socket(node, SOCK_IN, "Subsurface"_ustr);
805 float *subsurf_val = version_cycles_node_socket_float_value(subsurf);
806
807 if (!subsurf->link && *subsurf_val == 0.0f) {
809 }
810 else {
811 *version_cycles_node_socket_float_value(scale_in) = *subsurf_val;
812 }
813
814 if (subsurf->link == nullptr && *subsurf_val == 0.0f) {
815 /* Node doesn't use Subsurf, we're done here. */
816 continue;
817 }
818
819 /* Fix up Subsurface Color input */
820 bNodeSocket *base_col = bke::node_find_socket(node, SOCK_IN, "Base Color"_ustr);
821 bNodeSocket *subsurf_col = bke::node_find_socket(node, SOCK_IN, "Subsurface Color"_ustr);
822 float *base_col_val = version_cycles_node_socket_rgba_value(base_col);
823 float *subsurf_col_val = version_cycles_node_socket_rgba_value(subsurf_col);
824 /* If any of the three inputs is dynamic, we need a Mix node. */
825 if (subsurf->link || subsurf_col->link || base_col->link) {
826 bNode *mix = bke::node_add_static_node(nullptr, *ntree, SH_NODE_MIX);
827 static_cast<NodeShaderMix *>(mix->storage)->data_type = SOCK_RGBA;
828 mix->locx_legacy = node.locx_legacy - 170;
829 mix->locy_legacy = node.locy_legacy - 120;
830
831 bNodeSocket *a_in = bke::node_find_socket(*mix, SOCK_IN, "A_Color"_ustr);
832 bNodeSocket *b_in = bke::node_find_socket(*mix, SOCK_IN, "B_Color"_ustr);
833 bNodeSocket *fac_in = bke::node_find_socket(*mix, SOCK_IN, "Factor_Float"_ustr);
834 bNodeSocket *result_out = bke::node_find_socket(*mix, SOCK_OUT, "Result_Color"_ustr);
835
838 *version_cycles_node_socket_float_value(fac_in) = *subsurf_val;
839
840 if (base_col->link) {
842 *ntree, *base_col->link->fromnode, *base_col->link->fromsock, *mix, *a_in);
843 bke::node_remove_link(ntree, *base_col->link);
844 }
845 if (subsurf_col->link) {
847 *ntree, *subsurf_col->link->fromnode, *subsurf_col->link->fromsock, *mix, *b_in);
848 bke::node_remove_link(ntree, *subsurf_col->link);
849 }
850 if (subsurf->link) {
852 *ntree, *subsurf->link->fromnode, *subsurf->link->fromsock, *mix, *fac_in);
854 *ntree, *subsurf->link->fromnode, *subsurf->link->fromsock, node, *scale_in);
855 bke::node_remove_link(ntree, *subsurf->link);
856 }
857 bke::node_add_link(*ntree, *mix, *result_out, node, *base_col);
858 }
859 /* Mix the fixed values. */
860 interp_v4_v4v4(base_col_val, base_col_val, subsurf_col_val, *subsurf_val);
861
862 /* Set node to 100% subsurface, 0% diffuse. */
863 *subsurf_val = 1.0f;
864
865 /* Delete Subsurface Color input */
866 bke::node_remove_socket(*ntree, node, *subsurf_col);
867 }
868}
869
870/* Convert emission inputs on the Principled BSDF. */
872{
873 /* Blender 3.x and before would default to Emission = 0.0, Emission Strength = 1.0.
874 * Now we default the other way around (1.0 and 0.0), but because the Strength input was added
875 * a bit later, a file that only has the Emission socket would now end up as (1.0, 0.0) instead
876 * of (1.0, 1.0).
877 * Therefore, set strength to 1.0 for those files.
878 */
879 for (bNode &node : ntree->nodes) {
880 if (node.type_legacy != SH_NODE_BSDF_PRINCIPLED) {
881 continue;
882 }
883 if (!bke::node_find_socket(node, SOCK_IN, "Emission"_ustr)) {
884 /* Old enough to have neither, new defaults are fine. */
885 continue;
886 }
887 if (bke::node_find_socket(node, SOCK_IN, "Emission Strength"_ustr)) {
888 /* New enough to have both, no need to do anything. */
889 continue;
890 }
892 *ntree, node, SOCK_IN, SOCK_FLOAT, PROP_NONE, "Emission Strength", "Emission Strength");
894 }
895}
896
898 const bNodeTreeInterfaceSocket &src,
899 char *identifier)
900{
901 /* Node socket copy function based on bNodeTreeInterface::item_copy to avoid using blenkernel. */
902 dst.name_ = BLI_strdup_null(src.name_);
906 dst.identifier = identifier;
907 if (src.properties) {
909 }
910 if (src.socket_data != nullptr) {
912 /* No user count increment needed, gets reset after versioning. */
913 }
914}
915
917 const bNodeTreeInterfaceItem &item,
918 const int initial_pos)
919{
920 const bool sockets_above_panels = !(panel.flag &
923
924 int pos = initial_pos;
925
926 if (sockets_above_panels) {
928 /* Find the closest valid position from the end, only panels at or after #position. */
929 for (int test_pos = items.size() - 1; test_pos >= initial_pos; test_pos--) {
930 if (test_pos < 0) {
931 /* Initial position is out of range but valid. */
932 break;
933 }
934 if (items[test_pos]->item_type != NodeTreeInterfaceItemType::Panel) {
935 /* Found valid position, insert after the last socket item. */
936 pos = test_pos + 1;
937 break;
938 }
939 }
940 }
941 else {
942 /* Find the closest valid position from the start, no panels at or after #position. */
943 for (int test_pos = 0; test_pos <= initial_pos; test_pos++) {
944 if (test_pos >= items.size()) {
945 /* Initial position is out of range but valid. */
946 break;
947 }
948 if (items[test_pos]->item_type == NodeTreeInterfaceItemType::Panel) {
949 /* Found valid position, inserting moves the first panel. */
950 pos = test_pos;
951 break;
952 }
953 }
954 }
955 }
956
957 return pos;
958}
959
962 int position)
963{
964 /* Apply any constraints on the item positions. */
966 position = std::min(std::max(position, 0), parent.items_num);
967
969 parent.items_num++;
971 parent.items().take_front(position).copy_from(old_items.take_front(position));
972 parent.items().drop_front(position + 1).copy_from(old_items.drop_front(position));
973 parent.items()[position] = &socket.item;
974
975 if (old_items.data()) {
976 MEM_delete(old_items.data());
977 }
978}
979
980/* Node group interface copy function based on bNodeTreeInterface::insert_item_copy. */
984 int position)
985{
986 if (parent == nullptr) {
987 parent = &tree_interface.root_panel;
988 }
989
990 bNodeTreeInterfaceSocket *csocket = static_cast<bNodeTreeInterfaceSocket *>(
991 MEM_dupalloc(&socket));
992 /* Generate a new unique identifier.
993 * This might break existing links, but the identifiers were duplicate anyway. */
994 char *dst_identifier = BLI_sprintfN("Socket_%d", tree_interface.next_uid++);
995 version_copy_socket(*csocket, socket, dst_identifier);
996
997 version_nodes_insert_item(*parent, *csocket, position);
998
999 /* Original socket becomes output. */
1001 /* Copied socket becomes input. */
1003}
1004
1006{
1007 /* True if item a should be above item b. */
1008 auto item_compare = [](const bNodeTreeInterfaceItem *a,
1009 const bNodeTreeInterfaceItem *b) -> bool {
1010 if (a->item_type != b->item_type) {
1011 /* Keep sockets above panels. */
1013 }
1014 /* Keep outputs above inputs. */
1016 const bNodeTreeInterfaceSocket *sa = reinterpret_cast<const bNodeTreeInterfaceSocket *>(a);
1017 const bNodeTreeInterfaceSocket *sb = reinterpret_cast<const bNodeTreeInterfaceSocket *>(b);
1018 const bool is_output_a = sa->flag & NODE_INTERFACE_SOCKET_OUTPUT;
1019 const bool is_output_b = sb->flag & NODE_INTERFACE_SOCKET_OUTPUT;
1020 if (is_output_a != is_output_b) {
1021 return is_output_a;
1022 }
1023 }
1024
1025 return false;
1026 };
1027
1028 /* Sort panel content. */
1029 std::stable_sort(panel.items().begin(), panel.items().end(), item_compare);
1030
1031 /* Sort any child panels too. */
1032 for (bNodeTreeInterfaceItem *item : panel.items()) {
1033 if (item->item_type == NodeTreeInterfaceItemType::Panel) {
1035 *reinterpret_cast<bNodeTreeInterfacePanel *>(item));
1036 }
1037 }
1038}
1039
1040/* Convert specular tint in Principled BSDF. */
1042{
1043 for (bNode &node : ntree->nodes) {
1044 if (node.type_legacy != SH_NODE_BSDF_PRINCIPLED) {
1045 continue;
1046 }
1047 bNodeSocket *specular_tint_sock = bke::node_find_socket(node, SOCK_IN, "Specular Tint"_ustr);
1048 if (specular_tint_sock->type == SOCK_RGBA) {
1049 /* Node is already updated. */
1050 continue;
1051 }
1052
1053 bNodeSocket *base_color_sock = bke::node_find_socket(node, SOCK_IN, "Base Color"_ustr);
1054 bNodeSocket *metallic_sock = bke::node_find_socket(node, SOCK_IN, "Metallic"_ustr);
1055 float specular_tint_old = *version_cycles_node_socket_float_value(specular_tint_sock);
1056 float *base_color = version_cycles_node_socket_rgba_value(base_color_sock);
1057 float metallic = *version_cycles_node_socket_float_value(metallic_sock);
1058
1059 /* Change socket type to Color. */
1060 bke::node_modify_socket_type_static(ntree, &node, specular_tint_sock, SOCK_RGBA, 0);
1061 float *specular_tint = version_cycles_node_socket_rgba_value(specular_tint_sock);
1062
1063 /* The conversion logic here is that the new Specular Tint should be
1064 * mix(one, mix(base_color, one, metallic), old_specular_tint).
1065 * This needs to be handled both for the fixed values, as well as for any potential connected
1066 * inputs. */
1067
1068 static float one[] = {1.0f, 1.0f, 1.0f, 1.0f};
1069
1070 /* Mix the fixed values. */
1071 float metallic_mix[4];
1072 interp_v4_v4v4(metallic_mix, base_color, one, metallic);
1073 interp_v4_v4v4(specular_tint, one, metallic_mix, specular_tint_old);
1074
1075 if (specular_tint_sock->link == nullptr && specular_tint_old <= 0.0f) {
1076 /* Specular Tint was fixed at zero, we don't need any conversion node setup. */
1077 continue;
1078 }
1079
1080 /* If the Metallic input is dynamic, or fixed > 0 and base color is dynamic,
1081 * we need to insert a node to compute the metallic_mix.
1082 * Otherwise, use whatever is connected to the base color, or the static value
1083 * if it's unconnected. */
1084 bNodeSocket *metallic_mix_out = nullptr;
1085 bNode *metallic_mix_node = nullptr;
1086 if (metallic_sock->link || (base_color_sock->link && metallic > 0.0f)) {
1087 /* Metallic Mix needs to be dynamically mixed. */
1088 bNode *mix = bke::node_add_static_node(nullptr, *ntree, SH_NODE_MIX);
1089 static_cast<NodeShaderMix *>(mix->storage)->data_type = SOCK_RGBA;
1090 mix->locx_legacy = node.locx_legacy - 270;
1091 mix->locy_legacy = node.locy_legacy - 120;
1092
1093 bNodeSocket *a_in = bke::node_find_socket(*mix, SOCK_IN, "A_Color"_ustr);
1094 bNodeSocket *b_in = bke::node_find_socket(*mix, SOCK_IN, "B_Color"_ustr);
1095 bNodeSocket *fac_in = bke::node_find_socket(*mix, SOCK_IN, "Factor_Float"_ustr);
1096 metallic_mix_out = bke::node_find_socket(*mix, SOCK_OUT, "Result_Color"_ustr);
1097 metallic_mix_node = mix;
1098
1100 if (base_color_sock->link) {
1101 bke::node_add_link(*ntree,
1102 *base_color_sock->link->fromnode,
1103 *base_color_sock->link->fromsock,
1104 *mix,
1105 *a_in);
1106 }
1108 *version_cycles_node_socket_float_value(fac_in) = metallic;
1109 if (metallic_sock->link) {
1111 *ntree, *metallic_sock->link->fromnode, *metallic_sock->link->fromsock, *mix, *fac_in);
1112 }
1113 }
1114 else if (base_color_sock->link) {
1115 /* Metallic Mix is a no-op and equivalent to Base Color. */
1116 metallic_mix_out = base_color_sock->link->fromsock;
1117 metallic_mix_node = base_color_sock->link->fromnode;
1118 }
1119
1120 /* Similar to above, if the Specular Tint input is dynamic, or fixed > 0 and metallic mix
1121 * is dynamic, we need to insert a node to compute the new specular tint. */
1122 if (specular_tint_sock->link || (metallic_mix_out && specular_tint_old > 0.0f)) {
1123 bNode *mix = bke::node_add_static_node(nullptr, *ntree, SH_NODE_MIX);
1124 static_cast<NodeShaderMix *>(mix->storage)->data_type = SOCK_RGBA;
1125 mix->locx_legacy = node.locx_legacy - 170;
1126 mix->locy_legacy = node.locy_legacy - 120;
1127
1128 bNodeSocket *a_in = bke::node_find_socket(*mix, SOCK_IN, "A_Color"_ustr);
1129 bNodeSocket *b_in = bke::node_find_socket(*mix, SOCK_IN, "B_Color"_ustr);
1130 bNodeSocket *fac_in = bke::node_find_socket(*mix, SOCK_IN, "Factor_Float"_ustr);
1131 bNodeSocket *result_out = bke::node_find_socket(*mix, SOCK_OUT, "Result_Color"_ustr);
1132
1135 if (metallic_mix_out) {
1136 bke::node_add_link(*ntree, *metallic_mix_node, *metallic_mix_out, *mix, *b_in);
1137 }
1138 *version_cycles_node_socket_float_value(fac_in) = specular_tint_old;
1139 if (specular_tint_sock->link) {
1140 bke::node_add_link(*ntree,
1141 *specular_tint_sock->link->fromnode,
1142 *specular_tint_sock->link->fromsock,
1143 *mix,
1144 *fac_in);
1145 bke::node_remove_link(ntree, *specular_tint_sock->link);
1146 }
1147 bke::node_add_link(*ntree, *mix, *result_out, node, *specular_tint_sock);
1148 }
1149 }
1150}
1151
1152/* Rename various Principled BSDF sockets. */
1154{
1155 version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Emission", "Emission Color");
1156 version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Specular", "Specular IOR Level");
1158 ntree, SH_NODE_BSDF_PRINCIPLED, "Subsurface", "Subsurface Weight");
1160 ntree, SH_NODE_BSDF_PRINCIPLED, "Transmission", "Transmission Weight");
1161 version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Coat", "Coat Weight");
1162 version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Sheen", "Sheen Weight");
1163}
1164
1166{
1167 /* Any node group with a first socket geometry output can potentially be a modifier. Previously
1168 * this wasn't an explicit option, so better to enable too many groups rather than too few. */
1169 for (bNodeTree &group : bmain.nodetrees) {
1170 if (group.type != NTREE_GEOMETRY) {
1171 continue;
1172 }
1173 group.tree_interface.foreach_item([&](const bNodeTreeInterfaceItem &item) {
1175 return true;
1176 }
1177 const auto &socket = reinterpret_cast<const bNodeTreeInterfaceSocket &>(item);
1178 if ((socket.flag & NODE_INTERFACE_SOCKET_OUTPUT) == 0) {
1179 return true;
1180 }
1181 if (!STREQ(socket.socket_type, "NodeSocketGeometry")) {
1182 return true;
1183 }
1184 if (!group.geometry_node_asset_traits) {
1185 group.geometry_node_asset_traits = MEM_new<GeometryNodeAssetTraits>(
1186 "enable_geometry_nodes_is_modifier geometry_node_asset_traits");
1187 }
1189 return false;
1190 });
1191 }
1192}
1193
1194void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
1195{
1196 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 1)) {
1197 for (Mesh &mesh : bmain->meshes) {
1199 }
1201 }
1202
1203 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 2)) {
1204 for (Mesh &mesh : bmain->meshes) {
1206 }
1207 }
1208
1209 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 5)) {
1210 for (Scene &scene : bmain->scenes) {
1211 ToolSettings *ts = scene.toolsettings;
1212 if (ts->snap_mode_tools != SCE_SNAP_TO_NONE) {
1214 }
1215
1216#define SCE_SNAP_PROJECT (1 << 3)
1217 if (ts->snap_flag & SCE_SNAP_PROJECT) {
1218 ts->snap_mode &= ~eSnapMode(1 << 2); /* SCE_SNAP_TO_FACE */
1219 ts->snap_mode |= eSnapMode(1 << 8); /* SCE_SNAP_INDIVIDUAL_PROJECT */
1220 }
1221#undef SCE_SNAP_PROJECT
1222 }
1223 }
1224
1225 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 6)) {
1226 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1229 }
1231 }
1232
1233 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 7)) {
1235 }
1236
1237 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 8)) {
1238 for (bAction &act : bmain->actions) {
1240 act.frame_end = min_ff(act.frame_end, MAXFRAMEF);
1241 }
1242 }
1243
1244 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 9)) {
1245 for (Light &light : bmain->lights) {
1246 if (light.type == LA_SPOT && light.nodetree) {
1248 }
1249 }
1250 }
1251
1252 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 10)) {
1253 for (bScreen &screen : bmain->screens) {
1254 for (ScrArea &area : screen.areabase) {
1255 for (SpaceLink &space : area.spacedata) {
1256 if (space.spacetype == SPACE_NODE) {
1257 SpaceNode *snode = reinterpret_cast<SpaceNode *>(&space);
1259 }
1260 }
1261 }
1262 }
1263 }
1264
1265 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 11)) {
1267 }
1268
1269 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 12)) {
1270 if (!DNA_struct_member_exists(fd->filesdna, "LightProbe", "int", "grid_bake_samples")) {
1271 for (LightProbe &lightprobe : bmain->lightprobes) {
1272 lightprobe.grid_bake_samples = 2048;
1273 lightprobe.grid_normal_bias = 0.3f;
1274 lightprobe.grid_view_bias = 0.0f;
1275 lightprobe.grid_facing_bias = 0.5f;
1276 lightprobe.grid_dilation_threshold = 0.5f;
1277 lightprobe.grid_dilation_radius = 1.0f;
1278 }
1279 }
1280
1281 /* Set default bake resolution. */
1282 if (!DNA_struct_member_exists(fd->filesdna, "World", "int", "probe_resolution")) {
1283 for (World &world : bmain->worlds) {
1284 world.probe_resolution = LIGHT_PROBE_RESOLUTION_1024;
1285 }
1286 }
1287
1288 if (!DNA_struct_member_exists(fd->filesdna, "LightProbe", "float", "grid_surface_bias")) {
1289 for (LightProbe &lightprobe : bmain->lightprobes) {
1290 lightprobe.grid_surface_bias = 0.05f;
1291 lightprobe.grid_escape_bias = 0.1f;
1292 }
1293 }
1294
1295 /* Clear removed "Z Buffer" flag. */
1296 {
1297 const int R_IMF_FLAG_ZBUF_LEGACY = 1 << 0;
1298 for (Scene &scene : bmain->scenes) {
1299 scene.r.im_format.flag &= ~R_IMF_FLAG_ZBUF_LEGACY;
1300 }
1301 }
1302
1303 /* Reset the layer opacity for all layers to 1. */
1304 for (GreasePencil &grease_pencil : bmain->grease_pencils) {
1305 for (bke::greasepencil::Layer *layer : grease_pencil.layers_for_write()) {
1306 layer->opacity = 1.0f;
1307 }
1308 }
1309
1310 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1311 if (ntree->type == NTREE_SHADER) {
1312 /* Remove Transmission Roughness from Principled BSDF. */
1314 /* Convert legacy Velvet BSDF nodes into the new Sheen BSDF node. */
1316 /* Convert sheen inputs on the Principled BSDF. */
1318 }
1319 }
1321
1322 for (bScreen &screen : bmain->screens) {
1323 for (ScrArea &area : screen.areabase) {
1324 for (SpaceLink &sl : area.spacedata) {
1325 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
1326 &sl.regionbase;
1327
1328 /* Layout based regions used to also disallow resizing, now these are separate flags.
1329 * Make sure they are set together for old regions. */
1330 for (ARegion &region : *regionbase) {
1331 if (region.flag & RGN_FLAG_DYNAMIC_SIZE) {
1332 region.flag |= RGN_FLAG_NO_USER_RESIZE;
1333 }
1334 }
1335 }
1336 }
1337 }
1338 }
1339
1340 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 13)) {
1341 /* For the scenes configured to use the "None" display disable the color management
1342 * again. This will handle situation when the "None" display is removed and is replaced with
1343 * a "Raw" view instead.
1344 *
1345 * Note that this versioning will do nothing if the "None" display exists in the OCIO
1346 * configuration. */
1347 for (Scene &scene : bmain->scenes) {
1348 const ColorManagedDisplaySettings &display_settings = scene.display_settings;
1349 if (STREQ(display_settings.display_device, "None")) {
1351 }
1352 }
1353 }
1354
1355 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 14)) {
1356 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "int", "ray_tracing_method")) {
1357 for (Scene &scene : bmain->scenes) {
1359 }
1360 }
1361
1362 if (!DNA_struct_exists(fd->filesdna, "RegionAssetShelf")) {
1363 for (bScreen &screen : bmain->screens) {
1364 for (ScrArea &area : screen.areabase) {
1365 for (SpaceLink &sl : area.spacedata) {
1366 if (sl.spacetype != SPACE_VIEW3D) {
1367 continue;
1368 }
1369
1370 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
1371 &sl.regionbase;
1372
1373 if (ARegion *new_shelf_region = do_versions_add_region_if_not_found(
1374 regionbase,
1376 "asset shelf for view3d (versioning)",
1378 {
1379 new_shelf_region->alignment = RGN_ALIGN_BOTTOM;
1380 }
1381 if (ARegion *new_shelf_header = do_versions_add_region_if_not_found(
1382 regionbase,
1384 "asset shelf header for view3d (versioning)",
1386 {
1387 new_shelf_header->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
1388 }
1389 }
1390 }
1391 }
1392 }
1393 }
1394
1395 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 16)) {
1396 /* Set Normalize property of Noise Texture node to true. */
1397 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1398 if (ntree->type != NTREE_CUSTOM) {
1399 for (bNode &node : ntree->nodes) {
1400 if (node.type_legacy == SH_NODE_TEX_NOISE) {
1401 if (!node.storage) {
1402 NodeTexNoise *tex = MEM_new<NodeTexNoise>(__func__);
1405 tex->dimensions = 3;
1406 tex->type = SHD_NOISE_FBM;
1407 node.storage = tex;
1408 }
1409 (static_cast<NodeTexNoise *>(node.storage))->normalize = true;
1410 }
1411 }
1412 }
1413 }
1415 }
1416
1417 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 17)) {
1418 if (!DNA_struct_exists(fd->filesdna, "NodeShaderHairPrincipled")) {
1419 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1420 if (ntree->type == NTREE_SHADER) {
1422 }
1423 }
1425 }
1426
1427 /* Panorama properties shared with Eevee. */
1428 if (!DNA_struct_member_exists(fd->filesdna, "Camera", "float", "fisheye_fov")) {
1429 Camera default_cam = {};
1430 for (Camera &camera : bmain->cameras) {
1432 if (ccam) {
1433 camera.panorama_type = eCamera_PanoType(
1434 version_cycles_property_int(ccam, "panorama_type", default_cam.panorama_type));
1436 ccam, "fisheye_fov", default_cam.fisheye_fov);
1438 ccam, "fisheye_lens", default_cam.fisheye_lens);
1440 ccam, "latitude_min", default_cam.latitude_min);
1442 ccam, "latitude_max", default_cam.latitude_max);
1443 camera.longitude_min = version_cycles_property_float(
1444 ccam, "longitude_min", default_cam.longitude_min);
1445 camera.longitude_max = version_cycles_property_float(
1446 ccam, "longitude_max", default_cam.longitude_max);
1447 /* Fit to match default projective camera with focal_length 50 and sensor_width 36. */
1448 camera.fisheye_polynomial_k0 = version_cycles_property_float(
1449 ccam, "fisheye_polynomial_k0", default_cam.fisheye_polynomial_k0);
1450 camera.fisheye_polynomial_k1 = version_cycles_property_float(
1451 ccam, "fisheye_polynomial_k1", default_cam.fisheye_polynomial_k1);
1452 camera.fisheye_polynomial_k2 = version_cycles_property_float(
1453 ccam, "fisheye_polynomial_k2", default_cam.fisheye_polynomial_k2);
1454 camera.fisheye_polynomial_k3 = version_cycles_property_float(
1455 ccam, "fisheye_polynomial_k3", default_cam.fisheye_polynomial_k3);
1456 camera.fisheye_polynomial_k4 = version_cycles_property_float(
1457 ccam, "fisheye_polynomial_k4", default_cam.fisheye_polynomial_k4);
1458 }
1459 else {
1460 camera.panorama_type = default_cam.panorama_type;
1461 camera.fisheye_fov = default_cam.fisheye_fov;
1462 camera.fisheye_lens = default_cam.fisheye_lens;
1463 camera.latitude_min = default_cam.latitude_min;
1464 camera.latitude_max = default_cam.latitude_max;
1465 camera.longitude_min = default_cam.longitude_min;
1466 camera.longitude_max = default_cam.longitude_max;
1467 /* Fit to match default projective camera with focal_length 50 and sensor_width 36. */
1468 camera.fisheye_polynomial_k0 = default_cam.fisheye_polynomial_k0;
1469 camera.fisheye_polynomial_k1 = default_cam.fisheye_polynomial_k1;
1470 camera.fisheye_polynomial_k2 = default_cam.fisheye_polynomial_k2;
1471 camera.fisheye_polynomial_k3 = default_cam.fisheye_polynomial_k3;
1472 camera.fisheye_polynomial_k4 = default_cam.fisheye_polynomial_k4;
1473 }
1474 }
1475 }
1476
1477 if (!DNA_struct_member_exists(fd->filesdna, "LightProbe", "float", "grid_flag")) {
1478 for (LightProbe &lightprobe : bmain->lightprobes) {
1479 /* Keep old behavior of baking the whole lighting. */
1482 }
1483 }
1484
1485 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "int", "gi_irradiance_pool_size")) {
1486 for (Scene &scene : bmain->scenes) {
1487 scene.eevee.gi_irradiance_pool_size = 16;
1488 }
1489 }
1490
1491 for (Scene &scene : bmain->scenes) {
1493 scene.toolsettings->snap_anim_mode |= eSnapMode(1 << 10); /* SCE_SNAP_TO_FRAME */
1494 }
1495 }
1496
1497 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 20)) {
1498 /* Convert old socket lists into new interface items. */
1499 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1501 /* Clear legacy sockets after conversion.
1502 * Internal data pointers have been moved or freed already. */
1503 ntree->inputs_legacy.free_no_destruct();
1504 ntree->outputs_legacy.free_no_destruct();
1505 }
1507 }
1508 else {
1509 /* Legacy node tree sockets are created for forward compatibility,
1510 * but have to be freed after loading and versioning. */
1511 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1512 for (bNodeSocket &legacy_socket : ntree->inputs_legacy.items_mutable()) {
1513 MEM_SAFE_DELETE(legacy_socket.default_attribute_name);
1514 MEM_SAFE_DELETE_VOID(legacy_socket.default_value);
1515 if (legacy_socket.prop) {
1516 IDP_FreeProperty(legacy_socket.prop);
1517 }
1518 MEM_delete(legacy_socket.runtime);
1519 MEM_delete(&legacy_socket);
1520 }
1521 for (bNodeSocket &legacy_socket : ntree->outputs_legacy.items_mutable()) {
1522 MEM_SAFE_DELETE(legacy_socket.default_attribute_name);
1523 MEM_SAFE_DELETE_VOID(legacy_socket.default_value);
1524 if (legacy_socket.prop) {
1525 IDP_FreeProperty(legacy_socket.prop);
1526 }
1527 MEM_delete(legacy_socket.runtime);
1528 MEM_delete(&legacy_socket);
1529 }
1530 ntree->inputs_legacy.clear_no_delete();
1531 ntree->outputs_legacy.clear_no_delete();
1532 }
1534 }
1535
1536 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 22)) {
1537 /* Initialize root panel flags in files created before these flags were added. */
1538 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1539 ntree->tree_interface.root_panel.flag |= NODE_INTERFACE_PANEL_ALLOW_CHILD_PANELS_LEGACY;
1540 }
1542 }
1543
1544 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 23)) {
1545 for (bNodeTree &ntree : bmain->nodetrees) {
1546 if (ntree.type == NTREE_GEOMETRY) {
1547 for (bNode &node : ntree.nodes) {
1548 if (node.type_legacy == GEO_NODE_SET_SHADE_SMOOTH) {
1550 }
1551 }
1552 }
1553 }
1554 }
1555
1556 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 24)) {
1557 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1558 if (ntree->type == NTREE_SHADER) {
1559 /* Convert coat inputs on the Principled BSDF. */
1561 /* Convert subsurface inputs on the Principled BSDF. */
1563 /* Convert emission on the Principled BSDF. */
1565 }
1566 }
1568
1569 {
1570 for (bScreen &screen : bmain->screens) {
1571 for (ScrArea &area : screen.areabase) {
1572 for (SpaceLink &sl : area.spacedata) {
1573 const ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ?
1574 &area.regionbase :
1575 &sl.regionbase;
1576 for (ARegion &region : *regionbase) {
1577 if (region.regiontype != RGN_TYPE_ASSET_SHELF) {
1578 continue;
1579 }
1580
1581 RegionAssetShelf *shelf_data = static_cast<RegionAssetShelf *>(region.regiondata);
1582 if (shelf_data && shelf_data->active_shelf &&
1583 (shelf_data->active_shelf->preferred_row_count == 0))
1584 {
1585 shelf_data->active_shelf->preferred_row_count = 1;
1586 }
1587 }
1588 }
1589 }
1590 }
1591 }
1592
1593 /* Convert sockets with both input and output flag into two separate sockets. */
1594 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1595 Vector<bNodeTreeInterfaceSocket *> sockets_to_split;
1596 ntree->tree_interface.foreach_item([&](bNodeTreeInterfaceItem &item) {
1598 bNodeTreeInterfaceSocket &socket = reinterpret_cast<bNodeTreeInterfaceSocket &>(item);
1599 if ((socket.flag & NODE_INTERFACE_SOCKET_INPUT) &&
1601 {
1602 sockets_to_split.append(&socket);
1603 }
1604 }
1605 return true;
1606 });
1607
1608 for (bNodeTreeInterfaceSocket *socket : sockets_to_split) {
1609 const int position = ntree->tree_interface.find_item_position(socket->item);
1610 bNodeTreeInterfacePanel *parent = ntree->tree_interface.find_item_parent(socket->item);
1611 version_node_group_split_socket(ntree->tree_interface, *socket, parent, position + 1);
1612 }
1613 }
1615 }
1616
1617 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 25)) {
1618 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1619 if (ntree->type == NTREE_SHADER) {
1620 /* Convert specular tint on the Principled BSDF. */
1622 /* Rename some sockets. */
1624 }
1625 }
1627 }
1628
1629 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 26)) {
1631
1632 for (Scene &scene : bmain->scenes) {
1633 scene.simulation_frame_start = scene.r.sfra;
1634 scene.simulation_frame_end = scene.r.efra;
1635 }
1636 }
1637
1638 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 27)) {
1639 for (bScreen &screen : bmain->screens) {
1640 for (ScrArea &area : screen.areabase) {
1641 for (SpaceLink &sl : area.spacedata) {
1642 if (sl.spacetype == SPACE_SEQ) {
1643 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
1645 }
1646 }
1647 }
1648 }
1649
1650 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "int", "shadow_step_count")) {
1651 SceneEEVEE default_scene_eevee = {};
1652 for (Scene &scene : bmain->scenes) {
1653 scene.eevee.shadow_ray_count = default_scene_eevee.shadow_ray_count;
1654 scene.eevee.shadow_step_count = default_scene_eevee.shadow_step_count;
1655 }
1656 }
1657 }
1658
1659 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 28)) {
1660 for (bScreen &screen : bmain->screens) {
1661 for (ScrArea &area : screen.areabase) {
1662 for (SpaceLink &sl : area.spacedata) {
1663 const ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ?
1664 &area.regionbase :
1665 &sl.regionbase;
1666 for (ARegion &region : *regionbase) {
1667 if (region.regiontype != RGN_TYPE_ASSET_SHELF) {
1668 continue;
1669 }
1670
1671 RegionAssetShelf *shelf_data = static_cast<RegionAssetShelf *>(region.regiondata);
1672 if (shelf_data && shelf_data->active_shelf) {
1673 AssetShelfSettings &settings = shelf_data->active_shelf->settings;
1676 }
1677
1678 region.flag |= RGN_FLAG_HIDDEN;
1679 }
1680 }
1681 }
1682 }
1683 }
1684
1685 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 29)) {
1686 /* Unhide all Reroute nodes. */
1687 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1688 for (bNode &node : ntree->nodes) {
1689 if (node.is_reroute()) {
1690 node.inputs.first()->flag &= ~SOCK_HIDDEN;
1691 node.outputs.first()->flag &= ~SOCK_HIDDEN;
1692 }
1693 }
1694 }
1696 }
1697
1698 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 30)) {
1699 for (Scene &scene : bmain->scenes) {
1700 ToolSettings *ts = scene.toolsettings;
1701 enum { IS_DEFAULT = 0, IS_UV, IS_NODE, IS_ANIM };
1702 auto versioning_snap_to = [](short snap_to_old, int type) {
1703 eSnapMode snap_to_new = SCE_SNAP_TO_NONE;
1704 if (snap_to_old & (1 << 0)) {
1705 snap_to_new |= type == IS_NODE ? SCE_SNAP_TO_NONE :
1706 type == IS_ANIM ? SCE_SNAP_TO_FRAME :
1708 }
1709 if (snap_to_old & (1 << 1)) {
1710 snap_to_new |= type == IS_NODE ? SCE_SNAP_TO_NONE :
1711 type == IS_ANIM ? SCE_SNAP_TO_SECOND :
1713 }
1714 if (ELEM(type, IS_DEFAULT, IS_ANIM) && snap_to_old & (1 << 2)) {
1715 snap_to_new |= type == IS_DEFAULT ? SCE_SNAP_TO_FACE : SCE_SNAP_TO_MARKERS;
1716 }
1717 if (type == IS_DEFAULT && snap_to_old & (1 << 3)) {
1718 snap_to_new |= SCE_SNAP_TO_VOLUME;
1719 }
1720 if (type == IS_DEFAULT && snap_to_old & (1 << 4)) {
1721 snap_to_new |= SCE_SNAP_TO_EDGE_MIDPOINT;
1722 }
1723 if (type == IS_DEFAULT && snap_to_old & (1 << 5)) {
1724 snap_to_new |= SCE_SNAP_TO_EDGE_PERPENDICULAR;
1725 }
1726 if (ELEM(type, IS_DEFAULT, IS_UV, IS_NODE) && snap_to_old & (1 << 6)) {
1727 snap_to_new |= SCE_SNAP_TO_INCREMENT;
1728 }
1729 if (ELEM(type, IS_DEFAULT, IS_UV, IS_NODE) && snap_to_old & (1 << 7)) {
1730 snap_to_new |= SCE_SNAP_TO_GRID;
1731 }
1732 if (type == IS_DEFAULT && snap_to_old & (1 << 8)) {
1733 snap_to_new |= SCE_SNAP_INDIVIDUAL_NEAREST;
1734 }
1735 if (type == IS_DEFAULT && snap_to_old & (1 << 9)) {
1736 snap_to_new |= SCE_SNAP_INDIVIDUAL_PROJECT;
1737 }
1738 if (snap_to_old & (1 << 10)) {
1739 snap_to_new |= SCE_SNAP_TO_FRAME;
1740 }
1741 if (snap_to_old & (1 << 11)) {
1742 snap_to_new |= SCE_SNAP_TO_SECOND;
1743 }
1744 if (snap_to_old & (1 << 12)) {
1745 snap_to_new |= SCE_SNAP_TO_MARKERS;
1746 }
1747
1748 if (!snap_to_new) {
1749 snap_to_new = eSnapMode(1 << 0);
1750 }
1751
1752 return snap_to_new;
1753 };
1754
1755 ts->snap_mode = versioning_snap_to(ts->snap_mode, IS_DEFAULT);
1756 ts->snap_uv_mode = versioning_snap_to(ts->snap_uv_mode, IS_UV);
1757 ts->snap_node_mode = versioning_snap_to(ts->snap_node_mode, IS_NODE);
1758 ts->snap_anim_mode = versioning_snap_to(ts->snap_anim_mode, IS_ANIM);
1759 }
1760 }
1761
1762 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 31)) {
1763 for (Curve &curve : bmain->curves) {
1764 /* No need to check the curves type, this will be null for non text curves. */
1765 if (CharInfo *info = curve.strinfo) {
1766 for (int i = curve.len_char32 - 1; i >= 0; i--, info++) {
1767 if (info->mat_nr > 0) {
1769 info->mat_nr--;
1770 }
1771 }
1772 }
1773 }
1774 }
1775
1776 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 33)) {
1777 /* Fix node group socket order by sorting outputs and inputs. */
1778 for (bNodeTree &ntree : bmain->nodetrees) {
1780 }
1781 }
1782}
1783
1784} // namespace blender
Iterators for armatures.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
Low-level operations for grease pencil.
#define IDP_string_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 FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:926
#define SH_NODE_TEX_NOISE
#define SH_NODE_BSDF_PRINCIPLED
#define GEO_NODE_SET_SHADE_SMOOTH
#define CMP_NODE_CRYPTOMATTE
#define SH_NODE_BSDF_SHEEN
#define SH_NODE_TEX_COORD
#define SH_NODE_VECT_TRANSFORM
#define SH_NODE_BSDF_HAIR_PRINCIPLED
#define SH_NODE_BSDF_GLOSSY
#define SH_NODE_MIX
#define SH_NODE_BSDF_GLASS
#define CMP_NODE_R_LAYERS
#define SH_NODE_NEW_GEOMETRY
#define SH_NODE_BSDF_GLOSSY_LEGACY
#define SH_NODE_BSDF_REFRACTION
#define M_PI_4
#define STR_ELEM(...)
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define RPT_(msgid)
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define MAX_NAME
Definition DNA_defs.h:63
blenloader genfile private function prototypes
#define SHD_SHEEN_ASHIKHMIN
#define SCE_SNAP_TO_GEOM
#define MAXFRAMEF
#define SCE_SNAP_TO_VERTEX
#define MINAFRAMEF
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
Value & lookup_or_add_default(const Key &key)
Definition BLI_map.hh:639
ValueIterator values() const &
Definition BLI_map.hh:884
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
void add_new(const Key &key, const Value &value)
Definition BLI_map.hh:265
constexpr T * data() const
Definition BLI_span.hh:545
constexpr MutableSpan drop_front(const int64_t n) const
Definition BLI_span.hh:613
constexpr MutableSpan take_front(const int64_t n) const
Definition BLI_span.hh:635
constexpr int64_t size() const
Definition BLI_span.hh:256
void append(const T &value)
constexpr const char * data() const
constexpr bool endswith(StringRef suffix) const
#define position
#define layer
VecBase< float, D > normalize(VecOp< float, D >) RET
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
void node_modify_socket_type_static(bNodeTree *ntree, bNode *node, bNodeSocket *sock, int type, int subtype)
Definition node.cc:3448
void node_remove_socket(bNodeTree &ntree, bNode &node, bNodeSocket &sock)
Definition node.cc:4015
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
Definition node.cc:4676
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:4283
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:4638
bNodeSocket * node_add_static_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out, int type, int subtype, StringRefNull identifier, StringRefNull name)
Definition node.cc:3980
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
Definition node.cc:3036
MutableSpan< SeqRetimingKey > retiming_keys_get(const Strip *strip)
int retiming_keys_count(const Strip *strip)
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 retiming_data_ensure(Strip *strip)
bool retiming_is_allowed(const Strip *strip)
BMesh Iterators.
MINLINE float min_ff(float a, float b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ SHD_PRINCIPLED_HAIR_CHIANG
static void version_bonelayers_to_bonecollections(Main *bmain)
bool ANIM_armature_bonecoll_assign(BoneCollection *bcoll, Bone *bone)
void BKE_mesh_legacy_crease_to_generic(Mesh *mesh)
StringRef legacy_socket_idname_to_socket_type(StringRef idname)
@ SEQ_TIMELINE_SHOW_STRIP_RETIMING
static void version_replace_velvet_sheen_node(bNodeTree *ntree)
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
@ RGN_TYPE_ASSET_SHELF_HEADER
static void version_nodes_insert_item(bNodeTreeInterfacePanel &parent, bNodeTreeInterfaceSocket &socket, int position)
static bNodeTreeInterfaceItem * legacy_socket_move_to_interface(bNodeSocket &legacy_socket, const eNodeSocketInOut in_out)
void BKE_mesh_legacy_edge_crease_to_layers(Mesh *mesh)
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], float t)
void BKE_pose_ensure(Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
void BKE_mesh_legacy_attribute_flags_to_strings(Mesh *mesh)
MovieTrackingObject * BKE_tracking_object_get_active(const MovieTracking *tracking)
Definition tracking.cc:1982
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
static void version_mesh_legacy_to_struct_of_array_format(Mesh &mesh)
void version_update_node_input(bNodeTree *ntree, FunctionRef< bool(bNode *)> check_node, const char *socket_identifier, FunctionRef< void(bNode *, bNodeSocket *)> update_input, FunctionRef< void(bNode *, bNodeSocket *, bNode *, bNodeSocket *)> update_input_link)
BoneCollection * ANIM_armature_bonecoll_new(bArmature *armature, const char *name, int parent_index=-1)
void BKE_mesh_legacy_sharp_edges_from_flags(Mesh *mesh)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:818
static void version_mesh_crease_generic(Main &bmain)
void BKE_scene_disable_color_management(Scene *scene)
Definition scene.cc:3117
@ eModifierType_WeightVGEdit
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
@ SHD_VECT_TRANSFORM_TYPE_NORMAL
static void version_bonegroup_migrate_color(Main *bmain)
@ GEO_NODE_ASSET_MODIFIER
static void version_node_group_split_socket(bNodeTreeInterface &tree_interface, bNodeTreeInterfaceSocket &socket, bNodeTreeInterfacePanel *parent, int position)
float * version_cycles_node_socket_float_value(bNodeSocket *socket)
void BKE_mesh_legacy_convert_verts_to_positions(Mesh *mesh)
static void version_replace_texcoord_normal_socket(bNodeTree *ntree)
bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix)
void BKE_mesh_legacy_bevel_weight_to_generic(Mesh *mesh)
int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value)
void BKE_animdata_fix_paths(ID &id, StringRef prefix, StringRef old_infix, StringRef new_infix, bool verify_paths, const DriverMap &driver_map)
void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
static void version_principled_bsdf_coat(bNodeTree *ntree)
void BKE_mesh_legacy_sharp_faces_from_flags(Mesh *mesh)
void version_node_socket_identifier_set(bNodeSocket &socket, const StringRefNull identifier)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
void BKE_mesh_legacy_convert_loops_to_corners(Mesh *mesh)
float * version_cycles_node_socket_rgba_value(bNodeSocket *socket)
void * MEM_dupalloc_void(const void *vmemh) ATTR_WARN_UNUSED_RESULT
static void versioning_convert_node_tree_socket_lists_to_interface(bNodeTree *ntree)
static void version_movieclips_legacy_camera_object(Main *bmain)
static void version_vertex_weight_edit_preserve_threshold_exclusivity(Main *bmain)
static void versioning_node_group_sort_sockets_recursive(bNodeTreeInterfacePanel &panel)
void do_versions_after_linking_400(FileData *fd, Main *bmain)
BMesh const char void * data
static void versioning_replace_legacy_glossy_node(bNodeTree *ntree)
void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
void BKE_mesh_legacy_face_map_to_generic(Main *bmain)
static bool versioning_convert_strip_speed_factor(Strip *strip, void *user_data)
static void version_bonegroups_to_bonecollections(Main *bmain)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
static void version_copy_socket(bNodeTreeInterfaceSocket &dst, const bNodeTreeInterfaceSocket &src, char *identifier)
MovieTrackingObject * BKE_tracking_object_get_camera(const MovieTracking *tracking)
Definition tracking.cc:1987
IDProperty * IDP_GetProperties(ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition idprop.cc:1000
@ SCE_SNAP_TO_EDGE_MIDPOINT
@ SCE_SNAP_TO_EDGE_PERPENDICULAR
@ SCE_SNAP_INDIVIDUAL_NEAREST
@ SCE_SNAP_INDIVIDUAL_PROJECT
void IDP_AssignString(IDProperty *prop, const char *st) ATTR_NONNULL()
Definition idprop.cc:505
@ LIGHT_PROBE_RESOLUTION_1024
void BKE_mesh_legacy_convert_polys_to_offsets(Mesh *mesh)
static void enable_geometry_nodes_is_modifier(Main &bmain)
DriverMap BKE_animdata_build_driver_target_map(Main &bmain)
Definition anim_data.cc:980
void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
static void version_principled_transmission_roughness(bNodeTree *ntree)
@ RAYTRACE_EEVEE_METHOD_SCREEN
static void version_principled_bsdf_specular_tint(bNodeTree *ntree)
void BKE_mesh_legacy_convert_edges_to_generic(Mesh *mesh)
static int version_nodes_find_valid_insert_position_for_item(const bNodeTreeInterfacePanel &panel, const bNodeTreeInterfaceItem &item, const int initial_pos)
static void versioning_remove_microfacet_sharp_distribution(bNodeTree *ntree)
void ANIM_bonecoll_hide(bArmature *armature, BoneCollection *bcoll)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition readfile.cc:237
static void version_replace_principled_hair_model(bNodeTree *ntree)
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
Definition texture.cc:234
void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh)
static void version_principled_bsdf_rename_sockets(bNodeTree *ntree)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
void IDP_FreeProperty(IDProperty *prop)
Definition idprop.cc:1403
static void version_composite_nodetree_null_id(bNodeTree *ntree, Scene *scene)
static void version_principled_bsdf_sheen(bNodeTree *ntree)
MINLINE float max_ff(float a, float b)
@ LIGHTPROBE_GRID_CAPTURE_INDIRECT
@ LIGHTPROBE_GRID_CAPTURE_EMISSION
@ LIGHTPROBE_GRID_CAPTURE_WORLD
void version_node_input_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
IDProperty * version_cycles_properties_from_ID(ID *id)
@ SOCK_HIDE_IN_MODIFIER
static void version_principled_bsdf_emission(bNodeTree *ntree)
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])
ARegion * do_versions_add_region_if_not_found(ListBaseT< ARegion > *regionbase, int region_type, const char *, int link_after_region_type)
@ RGN_FLAG_NO_USER_RESIZE
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
Definition texture.cc:337
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:968
@ PROP_DISTANCE
Definition RNA_types.hh:313
@ CMP_NODE_CRYPTOMATTE_SOURCE_RENDER
static void version_principled_bsdf_subsurface(bNodeTree *ntree)
@ SHD_GLOSSY_SHARP_DEPRECATED
void BKE_mesh_legacy_uv_seam_from_flags(Mesh *mesh)
static void version_motion_tracking_legacy_camera_object(MovieClip &movieclip)
static void version_principled_bsdf_update_animdata(Main *bmain, bNodeTree *ntree)
struct EffectorWeights * BKE_effector_add_weights(struct Collection *collection)
Definition effect.cc:63
void blo_do_versions_400(FileData *fd, Library *lib, Main *bmain)
signed char int8_t
Definition BKE_text.h:76
@ SN_OVERLAY_SHOW_PREVIEWS
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *mesh)
#define mix
closure color sheen(normal N, float roughness)
Definition stdcycles.h:96
AssetLibraryReference asset_library_reference
AssetShelfSettings settings
struct blender::BlendFileReadReport::@140003175311343306107257242277261221002217304000 count
struct CharInfo * strinfo
BlendFileReadReport * reports
Definition readfile.hh:208
std::unique_ptr< SDNA > filesdna
Definition readfile.hh:111
ListBaseT< struct IDProperty > group
Definition DNA_ID.h:133
eIDPropertyType type
Definition DNA_ID.h:145
IDPropertyData data
Definition DNA_ID.h:157
char name[258]
Definition DNA_ID.h:433
struct Library * lib
Definition DNA_ID.h:421
char filepath[1024]
Definition DNA_ID.h:562
ListBaseT< bArmature > armatures
Definition BKE_main.hh:407
ListBaseT< bNodeTree > nodetrees
Definition BKE_main.hh:409
ListBaseT< Camera > cameras
Definition BKE_main.hh:397
ListBaseT< Light > lights
Definition BKE_main.hh:396
ListBaseT< World > worlds
Definition BKE_main.hh:399
ListBaseT< MovieClip > movieclips
Definition BKE_main.hh:419
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< ParticleSettings > particles
Definition BKE_main.hh:411
ListBaseT< bAction > actions
Definition BKE_main.hh:408
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
ListBaseT< GreasePencil > grease_pencils
Definition BKE_main.hh:418
ListBaseT< LightProbe > lightprobes
Definition BKE_main.hh:404
ListBaseT< bScreen > screens
Definition BKE_main.hh:400
struct MovieTracking tracking
MovieTrackingPlaneTrack * active_plane_track
MovieTrackingReconstruction reconstruction
ListBaseT< MovieTrackingTrack > tracks
ListBaseT< MovieTrackingPlaneTrack > plane_tracks
MovieTrackingTrack * active_track
struct MovieReconstructedCamera * cameras
MovieTrackingPlaneTrack * act_plane_track_legacy
ListBaseT< MovieTrackingPlaneTrack > plane_tracks_legacy
ListBaseT< MovieTrackingTrack > tracks_legacy
MovieTrackingReconstruction reconstruction_legacy
MovieTrackingTrack * act_track_legacy
ListBaseT< ModifierData > modifiers
DNA_DEPRECATED struct Object * proxy
DNA_DEPRECATED struct Object * proxy_from
struct bPose * pose
DNA_DEPRECATED struct Collection * force_group
struct EffectorWeights * effector_weights
ImageFormatData im_format
RaytraceEEVEE_Method ray_tracing_method
ColorManagedDisplaySettings display_settings
DNA_DEPRECATED struct bNodeTree * nodetree
struct RenderData r
struct SceneEEVEE eevee
struct ToolSettings * toolsettings
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
eSpaceSeq_SequencerTimelineOverlay_Flag flag
eSpaceNodeOverlay_Flag flag
SpaceNodeOverlay overlay
struct SequencerTimelineOverlay timeline_overlay
ListBaseT< EditBone > * edbo
DNA_DEPRECATED unsigned int layer
ListBaseT< Bone > bonebase
DNA_DEPRECATED unsigned int layer_used
eNodeSocketDatatype type
struct bNodeLink * link
bke::bNodeSocketRuntime * runtime
ListBaseT< bNodeLink > links
DNA_DEPRECATED ListBaseT< bNodeSocket > outputs_legacy
struct GeometryNodeAssetTraits * geometry_node_asset_traits
bNodeTreeInterface tree_interface
DNA_DEPRECATED ListBaseT< bNodeSocket > inputs_legacy
eNodeTree_Type type
ListBaseT< bNode > nodes
ListBaseT< struct ScrArea > areabase
#define SCE_SNAP_PROJECT