Blender V4.5
versioning_common.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/* allow readfile to use deprecated functionality */
9#define DNA_DEPRECATED_ALLOW
10
11#include <cstring>
12
13#include "DNA_node_types.h"
14#include "DNA_screen_types.h"
15
16#include "BLI_listbase.h"
17#include "BLI_map.hh"
18#include "BLI_string.h"
19#include "BLI_string_ref.hh"
20#include "BLI_string_utf8.h"
21
22#include "BKE_animsys.h"
24#include "BKE_idprop.hh"
25#include "BKE_ipo.h"
26#include "BKE_lib_id.hh"
27#include "BKE_lib_override.hh"
28#include "BKE_library.hh"
29#include "BKE_main.hh"
30#include "BKE_main_namemap.hh"
32#include "BKE_node.hh"
34#include "BKE_node_runtime.hh"
36#include "BKE_screen.hh"
37
38#include "ANIM_versioning.hh"
39
40#include "NOD_socket.hh"
41
42#include "BLT_translation.hh"
43
44#include "SEQ_sequencer.hh"
45
46#include "MEM_guardedalloc.h"
47
48#include "BLO_readfile.hh"
49#include "readfile.hh"
50#include "versioning_common.hh"
51
52using blender::Map;
54
55short do_versions_new_to_old_idcode_get(const short id_code_new)
56{
57 switch (id_code_new) {
58 case ID_GP:
59 /* ID_GD_LEGACY (Grease Pencil v2) is now converted to ID_GP (Grease Pencil v3). */
60 return ID_GD_LEGACY;
61 default:
63 }
64}
65
67 int region_type,
68 const char * /*allocname*/,
69 int link_after_region_type)
70{
71 ARegion *link_after_region = nullptr;
72 LISTBASE_FOREACH (ARegion *, region, regionbase) {
73 if (region->regiontype == region_type) {
74 return nullptr;
75 }
76 if (region->regiontype == link_after_region_type) {
77 link_after_region = region;
78 }
79 }
80
81 ARegion *new_region = BKE_area_region_new();
82 new_region->regiontype = region_type;
83 BLI_insertlinkafter(regionbase, link_after_region, new_region);
84 return new_region;
85}
86
88 int region_type,
89 const char * /*allocname*/,
90 int link_after_region_type)
91{
92 ARegion *link_after_region = nullptr;
93 LISTBASE_FOREACH (ARegion *, region, regionbase) {
94 if (region->regiontype == region_type) {
95 return region;
96 }
97 if (region->regiontype == link_after_region_type) {
98 link_after_region = region;
99 }
100 }
101
102 ARegion *new_region = BKE_area_region_new();
103 new_region->regiontype = region_type;
104 BLI_insertlinkafter(regionbase, link_after_region, new_region);
105 return new_region;
106}
107
109 const short id_type,
110 const char *name_src,
111 const char *name_dst)
112{
113 /* We can ignore libraries */
114 ListBase *lb = which_libbase(bmain, id_type);
115 ID *id = nullptr;
116 LISTBASE_FOREACH (ID *, idtest, lb) {
117 if (!ID_IS_LINKED(idtest)) {
118 if (STREQ(idtest->name + 2, name_src)) {
119 id = idtest;
120 }
121 if (STREQ(idtest->name + 2, name_dst)) {
122 return nullptr;
123 }
124 }
125 }
126 if (id != nullptr) {
127 BKE_libblock_rename(*bmain, *id, name_dst);
128 }
129 return id;
130}
131
132static void change_node_socket_name(ListBase *sockets, const char *old_name, const char *new_name)
133{
134 LISTBASE_FOREACH (bNodeSocket *, socket, sockets) {
135 if (STREQ(socket->name, old_name)) {
136 STRNCPY(socket->name, new_name);
137 }
138 if (STREQ(socket->identifier, old_name)) {
139 STRNCPY(socket->identifier, new_name);
140 }
141 }
142}
143
145{
146 BLI_assert(sock != nullptr);
147 return sock->flag & SOCK_IS_LINKED;
148}
149
151{
152 StringRef name = socket->name;
153 StringRef id = socket->identifier;
154
155 if (!id.startswith(name)) {
156 /* We only need to affect the case where the identifier starts with the name. */
157 return;
158 }
159
160 StringRef id_number = id.drop_known_prefix(name);
161 if (id_number.is_empty()) {
162 /* The name was already unique, and didn't need numbers at the end for the id. */
163 return;
164 }
165
166 if (id_number.startswith(".")) {
167 socket->identifier[name.size()] = '_';
168 }
169}
170
172 const int node_type,
173 const char *old_name,
174 const char *new_name)
175{
176 for (bNode *node : ntree->all_nodes()) {
177 if (node->type_legacy == node_type) {
178 change_node_socket_name(&node->inputs, old_name, new_name);
179 change_node_socket_name(&node->outputs, old_name, new_name);
180 }
181 }
182}
183
185 const int node_type,
186 const char *old_name,
187 const char *new_name)
188{
189 for (bNode *node : ntree->all_nodes()) {
190 if (node->type_legacy == node_type) {
191 change_node_socket_name(&node->inputs, old_name, new_name);
192 }
193 }
194}
195
197 const int node_type,
198 const char *old_name,
199 const char *new_name)
200{
201 for (bNode *node : ntree->all_nodes()) {
202 if (node->type_legacy == node_type) {
203 change_node_socket_name(&node->outputs, old_name, new_name);
204 }
205 }
206}
207
209{
210 using string_pair = std::pair<const char *, const char *>;
211 static const string_pair subtypes_map[] = {{"NodeSocketFloatUnsigned", "NodeSocketFloat"},
212 {"NodeSocketFloatPercentage", "NodeSocketFloat"},
213 {"NodeSocketFloatFactor", "NodeSocketFloat"},
214 {"NodeSocketFloatAngle", "NodeSocketFloat"},
215 {"NodeSocketFloatTime", "NodeSocketFloat"},
216 {"NodeSocketFloatTimeAbsolute", "NodeSocketFloat"},
217 {"NodeSocketFloatDistance", "NodeSocketFloat"},
218 {"NodeSocketIntUnsigned", "NodeSocketInt"},
219 {"NodeSocketIntPercentage", "NodeSocketInt"},
220 {"NodeSocketIntFactor", "NodeSocketInt"},
221 {"NodeSocketVectorTranslation", "NodeSocketVector"},
222 {"NodeSocketVectorDirection", "NodeSocketVector"},
223 {"NodeSocketVectorVelocity", "NodeSocketVector"},
224 {"NodeSocketVectorAcceleration", "NodeSocketVector"},
225 {"NodeSocketVectorEuler", "NodeSocketVector"},
226 {"NodeSocketVectorXYZ", "NodeSocketVector"}};
227 for (const string_pair &pair : subtypes_map) {
228 if (pair.first == idname) {
229 return pair.second;
230 }
231 }
232 /* Unchanged socket idname. */
233 return idname;
234}
235
236bNode &version_node_add_empty(bNodeTree &ntree, const char *idname)
237{
239
240 bNode *node = MEM_callocN<bNode>(__func__);
241 node->runtime = MEM_new<blender::bke::bNodeRuntime>(__func__);
242 BLI_addtail(&ntree.nodes, node);
243 blender::bke::node_unique_id(ntree, *node);
244
245 STRNCPY(node->idname, idname);
246 DATA_(ntype->ui_name).copy_utf8_truncated(node->name);
247 blender::bke::node_unique_name(ntree, *node);
248
250 node->width = ntype->width;
251 node->height = ntype->height;
252 node->color[0] = node->color[1] = node->color[2] = 0.608;
253
254 node->type_legacy = ntype->type_legacy;
255
256 BKE_ntree_update_tag_node_new(&ntree, node);
257 return *node;
258}
259
261 bNode &node,
262 const eNodeSocketInOut in_out,
263 const char *idname,
264 const char *identifier)
265{
267
268 bNodeSocket *socket = MEM_callocN<bNodeSocket>(__func__);
269 socket->runtime = MEM_new<blender::bke::bNodeSocketRuntime>(__func__);
270 socket->in_out = in_out;
271 socket->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
272 socket->type = stype->type;
273
274 STRNCPY(socket->idname, idname);
275 STRNCPY(socket->identifier, identifier);
276 STRNCPY(socket->name, identifier);
277
278 if (in_out == SOCK_IN) {
279 BLI_addtail(&node.inputs, socket);
280 }
281 else {
282 BLI_addtail(&node.outputs, socket);
283 }
284
286
287 BKE_ntree_update_tag_socket_new(&ntree, socket);
288 return *socket;
289}
290
292 bNodeTree &ntree, bNode &node_a, bNodeSocket &socket_a, bNode &node_b, bNodeSocket &socket_b)
293{
294 BLI_assert(socket_a.in_out != socket_b.in_out);
295 if (socket_a.in_out == SOCK_IN) {
296 return version_node_add_link(ntree, node_b, socket_b, node_a, socket_a);
297 }
298 bNode &node_from = node_a;
299 bNodeSocket &socket_from = socket_a;
300 bNode &node_to = node_b;
301 bNodeSocket &socket_to = socket_b;
302
303 bNodeLink *link = MEM_callocN<bNodeLink>(__func__);
304 link->fromnode = &node_from;
305 link->fromsock = &socket_from;
306 link->tonode = &node_to;
307 link->tosock = &socket_to;
308
309 BLI_addtail(&ntree.links, link);
310
312 return *link;
313}
314
316 bNode *node,
317 int in_out,
318 int type,
319 int subtype,
320 const char *identifier,
321 const char *name)
322{
323 bNodeSocket *sock = blender::bke::node_find_socket(*node, eNodeSocketInOut(in_out), identifier);
324 if (sock != nullptr) {
325 return sock;
326 }
328 *ntree, *node, eNodeSocketInOut(in_out), type, subtype, identifier, name);
329}
330
331void version_node_id(bNodeTree *ntree, const int node_type, const char *new_name)
332{
333 for (bNode *node : ntree->all_nodes()) {
334 if (node->type_legacy == node_type) {
335 if (!STREQ(node->idname, new_name)) {
336 STRNCPY(node->idname, new_name);
337 }
338 }
339 }
340}
341
343 const int node_tree_type,
344 const int node_type,
345 const int socket_index_orig,
346 const int socket_index_offset,
347 const int total_number_of_sockets)
348{
349
350 /* The for loop for the input ids is at the top level otherwise we lose the animation
351 * keyframe data. Not sure what causes that, so I (Sybren) moved the code here from
352 * versioning_290.cc as-is (structure-wise). */
353 for (int input_index = total_number_of_sockets - 1; input_index >= socket_index_orig;
354 input_index--)
355 {
356 FOREACH_NODETREE_BEGIN (bmain, ntree, owner_id) {
357 if (ntree->type != node_tree_type) {
358 continue;
359 }
360
361 for (bNode *node : ntree->all_nodes()) {
362 if (node->type_legacy != node_type) {
363 continue;
364 }
365
366 const size_t node_name_length = strlen(node->name);
367 const size_t node_name_escaped_max_length = (node_name_length * 2);
368 char *node_name_escaped = MEM_malloc_arrayN<char>(node_name_escaped_max_length + 1,
369 "escaped name");
370 BLI_str_escape(node_name_escaped, node->name, node_name_escaped_max_length);
371 char *rna_path_prefix = BLI_sprintfN("nodes[\"%s\"].inputs", node_name_escaped);
372
373 const int new_index = input_index + socket_index_offset;
375 bmain, owner_id, rna_path_prefix, nullptr, nullptr, input_index, new_index, false);
376 MEM_freeN(rna_path_prefix);
377 MEM_freeN(node_name_escaped);
378 }
379 }
381 }
382}
383
385{
386 for (bNode *node : ntree->all_nodes()) {
387 LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
388 socket->flag &= ~SOCK_IS_LINKED;
389 }
390 LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
391 socket->flag &= ~SOCK_IS_LINKED;
392 }
393 }
394 LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
395 link->fromsock->flag |= SOCK_IS_LINKED;
396 link->tosock->flag |= SOCK_IS_LINKED;
397 }
398}
399
400ARegion *do_versions_add_region(int regiontype, const char * /*name*/)
401{
402 ARegion *region = BKE_area_region_new();
403 region->regiontype = regiontype;
404 return region;
405}
406
408 bNode &old_node,
409 bNode &new_node,
411{
412 LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree.links) {
413 if (link->tonode == &old_node) {
414 bNodeSocket *old_socket = link->tosock;
415 if (old_socket->is_available()) {
416 if (const std::string *new_identifier = map.lookup_ptr_as(old_socket->identifier)) {
418 *&new_node, SOCK_IN, *new_identifier);
419 link->tonode = &new_node;
420 link->tosock = new_socket;
421 old_socket->link = nullptr;
422 }
423 }
424 }
425 if (link->fromnode == &old_node) {
426 bNodeSocket *old_socket = link->fromsock;
427 if (old_socket->is_available()) {
428 if (const std::string *new_identifier = map.lookup_ptr_as(old_socket->identifier)) {
430 *&new_node, SOCK_OUT, *new_identifier);
431 link->fromnode = &new_node;
432 link->fromsock = new_socket;
433 old_socket->link = nullptr;
434 }
435 }
436 }
437 }
438}
439
441{
443 LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
444 if (link->tosock == in_socket) {
445 links.append(link);
446 }
447 }
448 return links;
449}
450
452 bNode *node,
453 bNodeSocket *geometry_socket)
454{
455 BLI_assert(geometry_socket->type == SOCK_GEOMETRY);
456 blender::Vector<bNodeLink *> links = find_connected_links(ntree, geometry_socket);
457 for (bNodeLink *link : links) {
458 /* If the realize instances node is already before this socket, no need to continue. */
459 if (link->fromnode->type_legacy == GEO_NODE_REALIZE_INSTANCES) {
460 return;
461 }
462
464 nullptr, *ntree, GEO_NODE_REALIZE_INSTANCES);
465 realize_node->parent = node->parent;
466 realize_node->locx_legacy = node->locx_legacy - 100;
467 realize_node->locy_legacy = node->locy_legacy;
469 *link->fromnode,
470 *link->fromsock,
471 *realize_node,
472 *static_cast<bNodeSocket *>(realize_node->inputs.first));
473 link->fromnode = realize_node;
474 link->fromsock = static_cast<bNodeSocket *>(realize_node->outputs.first);
475 }
476}
477
479{
480 bNodeSocketValueFloat *socket_data = static_cast<bNodeSocketValueFloat *>(socket->default_value);
481 return &socket_data->value;
482}
483
485{
486 bNodeSocketValueRGBA *socket_data = static_cast<bNodeSocketValueRGBA *>(socket->default_value);
487 return socket_data->value;
488}
489
491{
492 bNodeSocketValueVector *socket_data = static_cast<bNodeSocketValueVector *>(
493 socket->default_value);
494 return socket_data->value;
495}
496
498{
499 IDProperty *idprop = IDP_GetProperties(id);
500 return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : nullptr;
501}
502
504{
505 IDProperty *idprop = view_layer->id_properties;
506 return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : nullptr;
507}
508
510{
511 IDProperty *idprop = render_layer->prop;
512 return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : nullptr;
513}
514
515float version_cycles_property_float(IDProperty *idprop, const char *name, float default_value)
516{
518 return (prop) ? IDP_Float(prop) : default_value;
519}
520
521int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value)
522{
523 IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT);
524 return (prop) ? IDP_Int(prop) : default_value;
525}
526
527void version_cycles_property_int_set(IDProperty *idprop, const char *name, int value)
528{
529 if (IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT)) {
530 IDP_Int(prop) = value;
531 }
532 else {
533 IDP_AddToGroup(idprop, blender::bke::idprop::create(name, value).release());
534 }
535}
536
537bool version_cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
538{
539 return version_cycles_property_int(idprop, name, default_value);
540}
541
542void version_cycles_property_boolean_set(IDProperty *idprop, const char *name, bool value)
543{
544 version_cycles_property_int_set(idprop, name, value);
545}
546
548{
549 IDProperty *idprop = IDP_GetProperties(id);
550 return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles_visibility", IDP_GROUP) : nullptr;
551}
552
554 bNodeTree *ntree,
555 FunctionRef<bool(bNode *)> check_node,
556 const char *socket_identifier,
557 FunctionRef<void(bNode *, bNodeSocket *)> update_input,
558 FunctionRef<void(bNode *, bNodeSocket *, bNode *, bNodeSocket *)> update_input_link)
559{
560 bool need_update = false;
561
562 /* Iterate backwards from end so we don't encounter newly added links. */
564 /* Detect link to replace. */
565 bNode *fromnode = link->fromnode;
566 bNodeSocket *fromsock = link->fromsock;
567 bNode *tonode = link->tonode;
568 bNodeSocket *tosock = link->tosock;
569
570 if (!(tonode != nullptr && check_node(tonode) && STREQ(tosock->identifier, socket_identifier)))
571 {
572 continue;
573 }
574
575 /* Replace links with updated equivalent */
576 blender::bke::node_remove_link(ntree, *link);
577 update_input_link(fromnode, fromsock, tonode, tosock);
578
579 need_update = true;
580 }
581
582 /* Update sockets and/or their default values.
583 * Do this after the link update in case it changes the identifier. */
584 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
585 if (check_node(node)) {
586 bNodeSocket *input = blender::bke::node_find_socket(*node, SOCK_IN, socket_identifier);
587 if (input != nullptr) {
588 update_input(node, input);
589 }
590 }
591 }
592
593 if (need_update) {
595 }
596}
597
599{
600 bNode *output_node = nullptr;
601 /* NOTE: duplicated from `ntreeShaderOutputNode` with small adjustments so it can be called
602 * during versioning. */
603 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
604 if (node->type_legacy != node_type) {
605 continue;
606 }
607 if (node->custom1 == SHD_OUTPUT_ALL) {
608 if (output_node == nullptr) {
609 output_node = node;
610 }
611 else if (output_node->custom1 == SHD_OUTPUT_ALL) {
612 if ((node->flag & NODE_DO_OUTPUT) && !(output_node->flag & NODE_DO_OUTPUT)) {
613 output_node = node;
614 }
615 }
616 }
617 else if (node->custom1 == SHD_OUTPUT_EEVEE) {
618 if (output_node == nullptr) {
619 output_node = node;
620 }
621 else if ((node->flag & NODE_DO_OUTPUT) && !(output_node->flag & NODE_DO_OUTPUT)) {
622 output_node = node;
623 }
624 }
625 }
626
627 return output_node;
628}
629
631{
632 if (!bmain->scenes.first) {
633 return false;
634 }
635
636 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
637 bool match = false;
638 for (const char *engine : engines) {
639 if (STREQ(scene->r.engine, engine)) {
640 match = true;
641 }
642 }
643 if (!match) {
644 return false;
645 }
646 }
647
648 return true;
649}
650
652 const short versionfile,
653 const short subversionfile)
654{
655 if (!MAIN_VERSION_FILE_ATLEAST(bmain, versionfile, subversionfile)) {
656 return false;
657 }
658
659 LISTBASE_FOREACH (Library *, library, &bmain->libraries) {
660 if (!LIBRARY_VERSION_FILE_ATLEAST(library, versionfile, subversionfile)) {
661 return false;
662 }
663 }
664
665 return true;
666}
667
669 BlendfileLinkAppendContext *lapp_context,
671{
672 /* WARNING: The code below may add IDs. These IDs _will_ be (by definition) conforming to current
673 * code's version already, and _must not_ be *versioned* again.
674 *
675 * This means that when adding code here, _extreme_ care must be taken that it will not badly
676 * affect these 'modern' IDs potentially added by already existing processing.
677 *
678 * Adding code here should only be done in exceptional cases.
679 *
680 * Some further points to keep in mind:
681 * - While typically versioning order should be respected in code below (i.e. versioning
682 * affecting older versions should be done first), _this is not a hard rule_. And it should
683 * not be assumed older code must not be checked when adding newer code.
684 * - Do not rely strongly on versioning numbers here. This code may be run on data from
685 * different Blender versions (through the usage of linked data), and all existing data have
686 * already been processed through the whole do_version during blendfile reading itself. So
687 * decision to apply some versioning on some data should mostly rely on the data itself.
688 * - Unlike the regular do_version code, this one should _not_ be assumed as 'valid forever'.
689 * It is closer to the Editing or BKE code in that respect, changes to the logic or data
690 * model of an ID will require a careful update here as well.
691 *
692 * Another critical weakness of this code is that it is currently _not_ performed on data linked
693 * during an editing session, but only on data linked while reading a whole blendfile. This will
694 * have to be fixed at some point.
695 */
696
697 /* NOTE: Version number is checked against Main version (i.e. current blend file version), AND
698 * the versions of all the linked libraries. */
699
702 }
703
705 LISTBASE_FOREACH (Scene *, scene, &new_bmain->scenes) {
706 if (scene->ed) {
708 }
709 }
710 }
711
714 /* Currently liboverride code can generate invalid namemap. This is a known issue, requires
715 * #107847 to be properly fixed. */
717 }
718
720 /* Does not add any new IDs, but needs the full Main data-base. */
722 }
723
725 /* Initial auto smooth versioning started at (401, 2), but a bug caused the legacy flag to not
726 * be cleared, so it is re-run in a later version when the bug is fixed and the versioning has
727 * been made idempotent. */
729 }
730
732 /* Version all the action assignments of just-versioned datablocks. This MUST happen before the
733 * GreasePencil conversion, as that assumes the Action Slots have already been assigned. */
735 }
736
738 /* Convert all the legacy grease pencil objects. This does not touch annotations. */
740 }
741}
Versioning of old animation data. Most animation versioning code lives in the versioning_xxx....
void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain, struct ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
#define IDP_Float(prop)
#define IDP_Int(prop)
IDProperty * IDP_GetPropertyTypeFromGroup(const IDProperty *prop, blender::StringRef name, char type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:779
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
Definition idprop.cc:725
IDProperty * IDP_GetProperties(ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition idprop.cc:887
void do_versions_ipos_to_layered_actions(struct Main *bmain)
Definition ipo.cc:2147
IDNewNameResult BKE_libblock_rename(Main &bmain, ID &id, blender::StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
Definition lib_id.cc:2350
void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain)
void BKE_lib_override_library_main_proxy_convert(Main *bmain, BlendFileReadReport *reports)
ListBase * which_libbase(Main *bmain, short type)
Definition main.cc:882
#define MAIN_VERSION_FILE_ATLEAST(main, ver, subver)
Definition BKE_main.hh:634
#define LIBRARY_VERSION_FILE_ATLEAST(lib, ver, subver)
Definition BKE_main.hh:646
bool BKE_main_namemap_validate_and_fix(Main &bmain)
void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain)
#define FOREACH_NODETREE_END
Definition BKE_node.hh:866
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:856
#define GEO_NODE_REALIZE_INSTANCES
void BKE_ntree_update_tag_node_new(bNodeTree *ntree, bNode *node)
void BKE_ntree_update_tag_socket_new(bNodeTree *ntree, bNodeSocket *socket)
void BKE_ntree_update_tag_link_added(bNodeTree *ntree, bNodeLink *link)
ARegion * BKE_area_region_new()
Definition screen.cc:381
#define BLI_assert(a)
Definition BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:111
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:332
#define LISTBASE_FOREACH_BACKWARD_MUTABLE(type, var, list)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STREQ(a, b)
external readfile function prototypes.
#define DATA_(msgid)
@ ID_GD_LEGACY
@ ID_GP
@ IDP_FLOAT
@ IDP_INT
@ IDP_GROUP
@ NODE_OPTIONS
@ NODE_DO_OUTPUT
@ NODE_INIT
@ NODE_SELECT
@ SHD_OUTPUT_ALL
@ SHD_OUTPUT_EEVEE
eNodeSocketInOut
@ SOCK_OUT
@ SOCK_IN
@ SOCK_IS_LINKED
@ SOCK_GEOMETRY
Read Guarded memory(de)allocation.
ReportList * reports
Definition WM_types.hh:1025
BKE_main_namemap_clear * new_bmain
Definition blendfile.cc:603
const Value * lookup_ptr_as(const ForwardKey &key) const
Definition BLI_map.hh:516
constexpr bool is_empty() const
constexpr bool startswith(StringRef prefix) const
constexpr int64_t size() const
constexpr StringRef drop_known_prefix(StringRef prefix) const
void append(const T &value)
#define input
#define ID_IS_LINKED(_id)
#define ID_LINK_PLACEHOLDER
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
void convert_legacy_action_assignments(Main &bmain, ReportList *reports)
void legacy_main(Main &bmain, BlendfileLinkAppendContext *lapp_context, BlendFileReadReport &reports)
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.
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
Definition node.cc:2864
void node_unique_id(bNodeTree &ntree, bNode &node)
Definition node.cc:3770
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
Definition node.cc:4124
bNodeSocketType * node_socket_type_find(StringRef idname)
Definition node.cc:2794
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:3804
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:4087
bNodeSocket * node_add_static_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out, int type, int subtype, StringRefNull identifier, StringRefNull name)
Definition node.cc:3529
bNodeType * node_type_find(StringRef idname)
Definition node.cc:2711
void node_unique_name(bNodeTree &ntree, bNode &node)
Definition node.cc:3764
void doversion_250_sound_proxy_update(Main *bmain, Editing *ed)
Definition sequencer.cc:970
void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subtype, void **data)
Definition DNA_ID.h:404
void * first
ListBase scenes
Definition BKE_main.hh:245
ListBase libraries
Definition BKE_main.hh:246
struct IDProperty * id_properties
bNodeSocketRuntimeHandle * runtime
struct bNodeLink * link
void * default_value
char identifier[64]
char idname[64]
ListBase nodes
ListBase links
int16_t custom1
float width
ListBase inputs
float height
float locx_legacy
float color[3]
struct bNode * parent
char name[64]
int16_t type_legacy
bNodeRuntimeHandle * runtime
float locy_legacy
char idname[64]
ListBase outputs
Defines a socket type.
Definition BKE_node.hh:152
eNodeSocketDatatype type
Definition BKE_node.hh:187
Defines a node type.
Definition BKE_node.hh:226
void add_realize_instances_before_socket(bNodeTree *ntree, bNode *node, bNodeSocket *geometry_socket)
ID * do_versions_rename_id(Main *bmain, const short id_type, const char *name_src, const char *name_dst)
bNode * version_eevee_output_node_get(bNodeTree *ntree, int16_t node_type)
bool all_scenes_use(Main *bmain, const blender::Span< const char * > engines)
static blender::Vector< bNodeLink * > find_connected_links(bNodeTree *ntree, bNodeSocket *in_socket)
float * version_cycles_node_socket_float_value(bNodeSocket *socket)
void version_cycles_property_int_set(IDProperty *idprop, const char *name, int value)
IDProperty * version_cycles_properties_from_ID(ID *id)
int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value)
IDProperty * version_cycles_properties_from_render_layer(SceneRenderLayer *render_layer)
bool version_node_socket_is_used(bNodeSocket *sock)
bNodeSocket & version_node_add_socket(bNodeTree &ntree, bNode &node, const eNodeSocketInOut in_out, const char *idname, const char *identifier)
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)
void version_node_socket_id_delim(bNodeSocket *socket)
float * version_cycles_node_socket_rgba_value(bNodeSocket *socket)
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)
void version_node_input_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
bNode & version_node_add_empty(bNodeTree &ntree, const char *idname)
void version_node_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
StringRef legacy_socket_idname_to_socket_type(StringRef idname)
float * version_cycles_node_socket_vector_value(bNodeSocket *socket)
bool version_cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
void version_socket_update_is_used(bNodeTree *ntree)
IDProperty * version_cycles_visibility_properties_from_ID(ID *id)
ARegion * do_versions_add_region(int regiontype, const char *)
void node_tree_relink_with_socket_id_map(bNodeTree &ntree, bNode &old_node, bNode &new_node, const Map< std::string, std::string > &map)
void do_versions_after_setup(Main *new_bmain, BlendfileLinkAppendContext *lapp_context, BlendFileReadReport *reports)
bNodeLink & version_node_add_link(bNodeTree &ntree, bNode &node_a, bNodeSocket &socket_a, bNode &node_b, bNodeSocket &socket_b)
ARegion * do_versions_ensure_region(ListBase *regionbase, int region_type, const char *, int link_after_region_type)
IDProperty * version_cycles_properties_from_view_layer(ViewLayer *view_layer)
bNodeSocket * version_node_add_socket_if_not_exist(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype, const char *identifier, const char *name)
float version_cycles_property_float(IDProperty *idprop, const char *name, float default_value)
static bool blendfile_or_libraries_versions_atleast(Main *bmain, const short versionfile, const short subversionfile)
static void change_node_socket_name(ListBase *sockets, const char *old_name, const char *new_name)
void version_cycles_property_boolean_set(IDProperty *idprop, const char *name, bool value)
ARegion * do_versions_add_region_if_not_found(ListBase *regionbase, int region_type, const char *, int link_after_region_type)
void version_node_output_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
short do_versions_new_to_old_idcode_get(const short id_code_new)
void version_node_id(bNodeTree *ntree, const int node_type, const char *new_name)