Blender V5.3
rna_access_compare_override.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#include <cstring>
10#include <fmt/format.h>
11#include <optional>
12
13#include <CLG_log.h>
14
15#include "MEM_guardedalloc.h"
16
17#include "DNA_ID.h"
18#include "DNA_anim_types.h"
19#include "DNA_camera_types.h"
21#include "DNA_key_types.h"
22#include "DNA_modifier_types.h"
23#include "DNA_object_types.h"
24
25#include "BLI_listbase.hh"
26#include "BLI_string.hh"
27#include "BLI_utildefines.hh"
28
29// #define DEBUG_OVERRIDE_TIMEIT
30
31#ifdef DEBUG_OVERRIDE_TIMEIT
33# include <stdio.h>
34#endif
35
36#include "BKE_armature.hh"
37#include "BKE_idprop.hh"
38#include "BKE_idtype.hh"
39#include "BKE_lib_override.hh"
40#include "BKE_library.hh"
41#include "BKE_main.hh"
42
43#include "RNA_access.hh"
44#include "RNA_enum_types.hh"
45#include "RNA_path.hh"
46#include "RNA_prototypes.hh"
47
49#include "rna_internal.hh"
50
51namespace blender {
52
53static CLG_LogRef LOG = {"rna.access_compare_override"};
54
64 PointerRNA *ptr,
65 PropertyRNA *prop,
66 std::optional<std::string> *r_rna_path)
67{
68 ID *id = ptr->owner_id;
69 ID *owner_id = id;
70 const char *rna_path_prefix = nullptr;
71
72 if (r_rna_path != nullptr) {
73 *r_rna_path = std::nullopt;
74 }
75
76 if (id == nullptr) {
77 return nullptr;
78 }
79
81 /* XXX this is very bad band-aid code, but for now it will do.
82 * We should at least use a #define for those prop names.
83 * Ideally RNA as a whole should be aware of those PITA of embedded IDs, and have a way to
84 * retrieve their owner IDs and generate paths from those.
85 */
86
87 switch (GS(id->name)) {
88 case ID_KE:
89 owner_id = (id_cast<Key *>(id))->from;
90 rna_path_prefix = "shape_keys";
91 break;
92 case ID_GR:
93 case ID_NT:
94 /* Master collections, Root node trees. */
95 owner_id = RNA_find_real_ID_and_path(id, &rna_path_prefix);
96 break;
97 default:
99 }
100 }
101
102 if (r_rna_path == nullptr) {
103 return owner_id;
104 }
105
106 if (std::optional<std::string> rna_path = RNA_path_from_ID_to_property(ptr, prop)) {
107 if (rna_path_prefix) {
108 r_rna_path->emplace(
109 fmt::format("{}{}{}", rna_path_prefix, (*rna_path)[0] == '[' ? "" : ".", *rna_path));
110 }
111 else {
112 r_rna_path->emplace(std::move(*rna_path));
113 }
114
115 return owner_id;
116 }
117 return nullptr;
118}
119
124
126{
127 if (prop->magic == RNA_MAGIC) {
128 /* Special handling for insertions of constraints or modifiers... */
129 /* TODO: Note We may want to add a more generic system to RNA
130 * (like a special property in struct of items)
131 * if we get more overridable collections,
132 * for now we can live with those special-cases handling I think. */
133 if (RNA_struct_is_a(ptr->type, RNA_Constraint)) {
134 bConstraint *con = static_cast<bConstraint *>(ptr->data);
136 return true;
137 }
138 }
139 else if (!RNA_struct_in_public_namespace(ptr->type)) {
140 if (const std::optional<AncestorPointerRNA> ancestor =
142 {
143 ModifierData *mod = static_cast<ModifierData *>(ancestor->data);
145 return true;
146 }
147 }
148 }
149 else if (RNA_struct_is_a(ptr->type, RNA_Modifier)) {
150 ModifierData *mod = static_cast<ModifierData *>(ptr->data);
152 return true;
153 }
154 }
155 else if (RNA_struct_is_a(ptr->type, RNA_NlaTrack)) {
156 NlaTrack *nla_track = static_cast<NlaTrack *>(ptr->data);
157 if (nla_track->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) {
158 return true;
159 }
160 }
161 else if (RNA_struct_is_a(ptr->type, RNA_CameraBackgroundImage)) {
162 CameraBGImage *bgpic = static_cast<CameraBGImage *>(ptr->data);
164 return true;
165 }
166 }
167 else if (RNA_struct_is_a(ptr->type, RNA_BoneCollection)) {
168 BoneCollection *bcoll = static_cast<BoneCollection *>(ptr->data);
170 return true;
171 }
172 }
173 /* If this is a RNA-defined property (real or 'virtual' IDProp),
174 * we want to use RNA prop flag. */
175 return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) &&
177 }
178 /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */
179 IDProperty *idprop = reinterpret_cast<IDProperty *>(prop);
180 return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0;
181}
182
184 PropertyRNA *prop,
185 const bool is_overridable)
186{
187 /* Only works for pure custom properties IDProps. */
188 if (prop->magic != RNA_MAGIC) {
189 IDProperty *idprop = reinterpret_cast<IDProperty *>(prop);
191 idprop->flag = is_overridable ? (idprop->flag | flags) : (idprop->flag & ~flags);
192 return true;
193 }
194
195 return false;
196}
197
199{
200 const std::optional<std::string> rna_path = RNA_path_from_ID_to_property(ptr, prop);
201 ID *id = ptr->owner_id;
202
203 if (!rna_path || id == nullptr || !ID_IS_OVERRIDE_LIBRARY(id)) {
204 return false;
205 }
206
207 return (BKE_lib_override_library_property_find(id->override_library, rna_path->c_str()) !=
208 nullptr);
209}
210
212{
213 prop = rna_ensure_property(prop);
214
216}
217
218static bool rna_property_override_operation_apply(Main *bmain,
219 RNAPropertyOverrideApplyContext &rnaapply_ctx);
221 RNAPropertyOverrideApplyContext &rnaapply_ctx);
222
224 PointerRNA *ptr,
225 PointerRNA *fromptr,
226 PropertyRNA *prop,
227 int index,
228 IDOverrideLibraryProperty *removed_oprop,
230{
231 /* Ignore editable state if this is removing a liboverride, and the removed operation is a
232 * custom one. Apply callback of the property is expected to know what to do then. */
233 if (!removed_opop || removed_opop->operation != LIBOVERRIDE_OP_CUSTOM) {
234 if (!RNA_property_editable(ptr, prop)) {
235 return false;
236 }
237 }
238
243
245 rnaapply_ctx.ptr_dst = *ptr;
246 rnaapply_ctx.ptr_src = *fromptr;
247 rnaapply_ctx.prop_dst = prop;
248 rnaapply_ctx.prop_src = prop;
249 rnaapply_ctx.liboverride_operation = &opop;
250
251 rnaapply_ctx.liboverride_removed_property = removed_oprop;
252 rnaapply_ctx.liboverride_removed_operation = removed_opop;
253 if (removed_opop) {
254 /* Note that here, when removing a liboverride operation, the reference data is copied into the
255 * override one, which is the opposite from regular liboverride apply process (where
256 * liboverride data is copied into the reference data). hence the inversion of local and
257 * reference subitem identification info below. */
258 opop.subitem_local_id = removed_opop->subitem_reference_id;
259 opop.subitem_reference_id = removed_opop->subitem_local_id;
260 opop.subitem_local_index = removed_opop->subitem_reference_index;
261 opop.subitem_reference_index = removed_opop->subitem_local_index;
262 opop.subitem_local_name = removed_opop->subitem_reference_name;
263 opop.subitem_reference_name = removed_opop->subitem_local_name;
264 }
265
267
268 return rna_property_override_operation_apply(bmain, rnaapply_ctx);
269}
270
271static int rna_property_override_diff(Main *bmain,
272 PropertyRNAOrID *prop_a,
273 PropertyRNAOrID *prop_b,
274 const char *rna_path,
275 const size_t rna_path_len,
276 eRNACompareMode mode,
277 IDOverrideLibrary *liboverride,
278 const eRNAOverrideMatch flags,
279 eRNAOverrideMatchResult *r_report_flags);
280
282 Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, PropertyRNA *prop, eRNACompareMode mode)
283{
285
286 PropertyRNAOrID prop_a, prop_b;
287
288 rna_property_rna_or_id_get(prop, ptr_a, &prop_a);
289 rna_property_rna_or_id_get(prop, ptr_b, &prop_b);
290
292 bmain, &prop_a, &prop_b, nullptr, 0, mode, nullptr, eRNAOverrideMatch{}, nullptr) ==
293 0);
294}
295
297{
299 PropertyRNA *iterprop;
300 bool equals = true;
301
302 if (ptr_a == nullptr && ptr_b == nullptr) {
303 return true;
304 }
305 if (ptr_a == nullptr || ptr_b == nullptr) {
306 return false;
307 }
308 if (ptr_a->type != ptr_b->type) {
309 return false;
310 }
311
312 if (!*ptr_a) {
313 if (!*ptr_b) {
314 return true;
315 }
316 return false;
317 }
318
319 iterprop = RNA_struct_iterator_property(ptr_a->type);
320
321 RNA_property_collection_begin(ptr_a, iterprop, &iter);
322 for (; iter.valid; RNA_property_collection_next(&iter)) {
323 PropertyRNA *prop = static_cast<PropertyRNA *>(iter.ptr.data);
324
325 if (!RNA_property_equals(bmain, ptr_a, ptr_b, prop, mode)) {
326 equals = false;
327 break;
328 }
329 }
331
332 return equals;
333}
334
335/* Low-level functions, also used by non-override RNA API like copy or equality check. */
336
347 PropertyRNAOrID *prop_a,
348 PropertyRNAOrID *prop_b,
349 const char *rna_path,
350 const size_t rna_path_len,
351 eRNACompareMode mode,
353 const eRNAOverrideMatch flags,
354 eRNAOverrideMatchResult *r_report_flags)
355{
356 BLI_assert(!ELEM(nullptr, prop_a, prop_b));
357
360 {
361 return 0;
362 }
363
364 if (mode == RNA_EQ_UNSET_MATCH_ANY) {
365 /* Unset properties are assumed to match anything. */
366 if (!prop_a->is_set || !prop_b->is_set) {
367 return 0;
368 }
369 }
370 else if (mode == RNA_EQ_UNSET_MATCH_NONE) {
371 /* Unset properties never match set properties. */
372 if (prop_a->is_set != prop_b->is_set) {
373 return 1;
374 }
375 }
376
377 if (prop_a->is_idprop && ELEM(nullptr, prop_a->idprop, prop_b->idprop)) {
378 return (prop_a->idprop == prop_b->idprop) ? 0 : 1;
379 }
380
381 /* Check if we are working with arrays. */
382 const bool is_array_a = prop_a->is_array;
383 const bool is_array_b = prop_b->is_array;
384
385 if (is_array_a != is_array_b) {
386 /* Should probably never happen actually... */
388 return is_array_a ? 1 : -1;
389 }
390
391 /* Get the length of the array to work with. */
392 const uint len_a = prop_a->array_len;
393 const uint len_b = prop_b->array_len;
394
395 if (len_a != len_b) {
396 /* Do not handle override in that case,
397 * we do not support insertion/deletion from arrays for now. */
398 return len_a > len_b ? 1 : -1;
399 }
400
401 if (is_array_a && len_a == 0) {
402 /* Empty arrays, will happen in some case with dynamic ones. */
403 return 0;
404 }
405
406 RNAPropOverrideDiff override_diff = nullptr;
407 /* Special case for IDProps, we use default callback then. */
408 if (prop_a->is_idprop) {
410 if (!prop_b->is_idprop && prop_b->rnaprop->override_diff != override_diff) {
411 override_diff = nullptr;
412 }
413 }
414 else if (prop_b->is_idprop) {
416 if (prop_a->rnaprop->override_diff != override_diff) {
417 override_diff = nullptr;
418 }
419 }
420 else if (prop_a->rnaprop->override_diff == prop_b->rnaprop->override_diff) {
421 override_diff = prop_a->rnaprop->override_diff;
422 if (override_diff == nullptr) {
424 }
425 }
426
427 if (override_diff == nullptr) {
429 &LOG,
430 "'%s' gives unmatching or nullptr RNA diff callbacks, should not happen (%d vs. %d)",
431 rna_path ? rna_path : prop_a->identifier.c_str(),
432 !prop_a->is_idprop,
433 !prop_b->is_idprop);
435 return 1;
436 }
437
438 eRNAOverrideMatch diff_flags = flags;
439 if (!RNA_property_overridable_get(prop_a->ptr, prop_a->rawprop) ||
441 !RNA_property_editable_flag(prop_a->ptr, prop_a->rawprop)))
442 {
443 diff_flags &= ~RNA_OVERRIDE_COMPARE_CREATE;
444 }
445
447 rnadiff_ctx.prop_a = prop_a;
448 rnadiff_ctx.prop_b = prop_b;
449 rnadiff_ctx.mode = mode;
450
451 rnadiff_ctx.liboverride = liboverride;
452 rnadiff_ctx.rna_path = rna_path;
453 rnadiff_ctx.rna_path_len = rna_path_len;
454 rnadiff_ctx.liboverride_flags = diff_flags;
455 override_diff(bmain, rnadiff_ctx);
456
457 if (r_report_flags) {
458 *r_report_flags = rnadiff_ctx.report_flag;
459 }
460 return rnadiff_ctx.comparison;
461}
462
463/* Modify local data-block to make it ready for override application
464 * (only needed for diff operations, where we use
465 * the local data-block's data as second operand). */
467 PointerRNA *ptr_local,
468 PointerRNA *ptr_reference,
469 PointerRNA *ptr_storage,
470 PropertyRNA *prop_local,
471 PropertyRNA *prop_reference,
472 PropertyRNA *prop_storage,
474{
475 int len_local, len_reference, len_storage = 0;
476 bool changed = false;
477
478 if (ptr_storage == nullptr || !*ptr_storage || prop_storage == nullptr) {
479 return changed;
480 }
481
482 /* Runtime definitions may have changed since the operation was created. */
483 const PropertyType type = RNA_property_type(prop_local);
484 if (type != RNA_property_type(prop_reference) || type != RNA_property_type(prop_storage)) {
485 return changed;
486 }
487
488 /* get the length of the array to work with */
489 len_local = RNA_property_array_length(ptr_local, prop_local);
490 len_reference = RNA_property_array_length(ptr_reference, prop_reference);
491 if (prop_storage) {
492 len_storage = RNA_property_array_length(ptr_storage, prop_storage);
493 }
494
495 if (len_local != len_reference || len_local != len_storage) {
496 /* Do not handle override in that case,
497 * we do not support insertion/deletion from arrays for now. */
498 return changed;
499 }
500
501 RNAPropOverrideStore override_store = nullptr;
502 /* Special case for IDProps, we use default callback then. */
503 if (prop_local->magic != RNA_MAGIC) {
505 if (prop_reference->magic == RNA_MAGIC && prop_reference->override_store != override_store) {
506 override_store = nullptr;
507 }
508 }
509 else if (prop_reference->magic != RNA_MAGIC) {
511 if (prop_local->override_store != override_store) {
512 override_store = nullptr;
513 }
514 }
515 else if (prop_local->override_store == prop_reference->override_store) {
516 override_store = prop_local->override_store;
517 if (override_store == nullptr) {
519 }
520 }
521
522 if ((prop_storage->magic == RNA_MAGIC) &&
523 !ELEM(prop_storage->override_store, nullptr, override_store))
524 {
525 override_store = nullptr;
526 }
527
528 if (override_store == nullptr) {
530 &LOG,
531 "'%s' gives unmatching or nullptr RNA store callbacks, should not happen (%d vs. %d)",
532 op->rna_path,
533 prop_local->magic == RNA_MAGIC,
534 prop_reference->magic == RNA_MAGIC);
536 return changed;
537 }
538
540 /* Only needed for diff operations. */
541 if (!ELEM(
543 {
544 continue;
545 }
546
547 if (override_store(bmain,
548 ptr_local,
549 ptr_reference,
550 ptr_storage,
551 prop_local,
552 prop_reference,
553 prop_storage,
554 len_local,
555 len_reference,
556 len_storage,
557 &opop))
558 {
559 changed = true;
560 }
561 }
562
563 return changed;
564}
565
568{
569 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
570 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
571 PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
572 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
573 PropertyRNA *prop_src = rnaapply_ctx.prop_src;
574 PropertyRNA *prop_storage = rnaapply_ctx.prop_storage;
576
577 const short override_op = opop->operation;
578
580 opop, ptr_dst, ptr_src, ptr_storage, prop_dst, prop_src, prop_storage))
581 {
582 return false;
583 }
584
585 if (override_op == LIBOVERRIDE_OP_NOOP) {
586 return true;
587 }
588
589 RNAPropOverrideApply override_apply = nullptr;
590 /* Special case for IDProps, we use default callback then. */
591 if (prop_dst->magic != RNA_MAGIC) {
593 if (prop_src->magic == RNA_MAGIC && !ELEM(prop_src->override_apply, nullptr, override_apply)) {
594 override_apply = nullptr;
595 }
596 }
597 else if (prop_src->magic != RNA_MAGIC) {
599 if (!ELEM(prop_dst->override_apply, nullptr, override_apply)) {
600 override_apply = nullptr;
601 }
602 }
603 else if (prop_dst->override_apply == prop_src->override_apply) {
604 override_apply = prop_dst->override_apply;
605 if (override_apply == nullptr) {
607 }
608 }
609
610 if (prop_storage && prop_storage->magic == RNA_MAGIC &&
611 !ELEM(prop_storage->override_apply, nullptr, override_apply))
612 {
613 override_apply = nullptr;
614 }
615
616 if (override_apply == nullptr) {
618 &LOG,
619 "'%s' gives unmatching or nullptr RNA apply callbacks, should not happen (%d vs. %d)",
620 prop_dst->magic != RNA_MAGIC ? ((IDProperty *)prop_dst)->name :
621 prop_dst->identifier.c_str(),
622 prop_dst->magic == RNA_MAGIC,
623 prop_src->magic == RNA_MAGIC);
625 return false;
626 }
627
628 /* get the length of the array to work with */
629 rnaapply_ctx.len_dst = RNA_property_array_length(ptr_dst, prop_dst);
630 rnaapply_ctx.len_src = RNA_property_array_length(ptr_src, prop_src);
631 if (prop_storage) {
632 rnaapply_ctx.len_storage = RNA_property_array_length(ptr_storage, prop_storage);
633 }
634
635 if (rnaapply_ctx.len_dst != rnaapply_ctx.len_src ||
636 (prop_storage && rnaapply_ctx.len_dst != rnaapply_ctx.len_storage))
637 {
638 /* Do not handle override in that case,
639 * we do not support insertion/deletion from arrays for now. */
640 return false;
641 }
642
643 /* get and set the default values as appropriate for the various types */
644 const bool success = override_apply(bmain, rnaapply_ctx);
645 return success;
646}
647
648bool rna_struct_override_type_matches(const StructRNA *type_a, const StructRNA *type_b)
649{
650 if (type_a == type_b) {
651 return true;
652 }
653 if (ELEM(nullptr, type_a, type_b)) {
654 return false;
655 }
656 /* Public types have unique definitions. Private runtime types, e.g. generated node group
657 * interfaces, can be defined independently for the override and its reference. */
658 return (type_a->flag & STRUCT_RUNTIME) && (type_b->flag & STRUCT_RUNTIME) &&
659 !(type_a->flag & (STRUCT_PUBLIC_NAMESPACE | STRUCT_ID)) &&
660 !(type_b->flag & (STRUCT_PUBLIC_NAMESPACE | STRUCT_ID)) &&
661 !type_a->identifier.is_empty() && type_a->identifier == type_b->identifier &&
662 type_a->base == type_b->base;
663}
664
666{
667 /* Interfaces may have changed. Matching identifiers alone do not guarantee compatible
668 * values, storage, ownership, or override callbacks. UI metadata and defaults may differ. */
669 return a.type == b.type && a.subtype == b.subtype && a.flag == b.flag &&
670 a.flag_override == b.flag_override && a.override_diff == b.override_diff &&
671 a.override_store == b.override_store && a.override_apply == b.override_apply &&
672 a.getlength == b.getlength && a.arraydimension == b.arraydimension &&
673 memcmp(a.arraylength, b.arraylength, sizeof(a.arraylength[0]) * a.arraydimension) == 0;
674}
675
677 PointerRNA *ptr_local,
678 PointerRNA *ptr_reference,
679 const char *root_path,
680 const size_t root_path_len,
682 const eRNAOverrideMatch flags,
683 eRNAOverrideMatchResult *r_report_flags)
684{
686 PropertyRNA *iterprop;
687 bool matching = true;
688
689 BLI_assert(rna_struct_override_type_matches(ptr_local->type, ptr_reference->type));
690 BLI_assert(ptr_local->owner_id && ptr_reference->owner_id);
691
692 const bool ignore_non_overridable = (flags & RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE) != 0;
693 const bool ignore_overridden = (flags & RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN) != 0;
694 const bool do_create = (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0;
695 const bool do_restore = (flags & RNA_OVERRIDE_COMPARE_RESTORE) != 0;
696 const bool do_tag_for_restore = (flags & RNA_OVERRIDE_COMPARE_TAG_FOR_RESTORE) != 0;
697
698#ifdef DEBUG_OVERRIDE_TIMEIT
699 static float _sum_time_global = 0.0f;
700 static float _num_time_global = 0.0f;
701 double _timeit_time_global;
702 static float _sum_time_diffing = 0.0f;
703 static float _delta_time_diffing = 0.0f;
704 static int _num_delta_time_diffing = 0.0f;
705 static float _num_time_diffing = 0.0f;
706 double _timeit_time_diffing;
707
708 if (!root_path) {
709 _delta_time_diffing = 0.0f;
710 _num_delta_time_diffing = 0;
711 _timeit_time_global = BLI_time_now_seconds();
712 }
713#endif
714
715 if (ptr_local->owner_id == ptr_local->data && GS(ptr_local->owner_id->name) == ID_OB) {
716 /* Our beloved pose's bone cross-data pointers. Usually, depsgraph evaluation would
717 * ensure this is valid, but in some situations (like hidden collections etc.) this won't
718 * be the case, so we need to take care of this ourselves.
719 *
720 * NOTE: Typically callers of this function (from BKE_lib_override area) will already have
721 * ensured this. However, studio is still reporting sporadic, unreproducible crashes due to
722 * invalid pose data, so think there are still some cases where some armatures are somehow
723 * missing updates (possibly due to dependencies?). Since calling this function on same ID
724 * several time is almost free, and safe even in a threaded context as long as it has been done
725 * at least once first outside of threaded processing, we do it another time here. */
726 Object *ob_local = id_cast<Object *>(ptr_local->owner_id);
727 if (ob_local->type == OB_ARMATURE) {
728 Object *ob_reference = id_cast<Object *>(ptr_local->owner_id->override_library->reference);
729 BLI_assert(ob_local->data != nullptr);
730 BLI_assert(ob_reference->data != nullptr);
731 BKE_pose_ensure(bmain, ob_local, id_cast<bArmature *>(ob_local->data), true);
732 BKE_pose_ensure(bmain, ob_reference, id_cast<bArmature *>(ob_reference->data), true);
733 }
734 }
735
736 iterprop = RNA_struct_iterator_property(ptr_local->type);
737
738 for (RNA_property_collection_begin(ptr_local, iterprop, &iter); iter.valid;
740 {
741 PropertyRNA *rawprop_local = static_cast<PropertyRNA *>(iter.ptr.data);
742 PropertyRNA *rawprop_reference = rawprop_local;
743 if (ptr_local->type != ptr_reference->type) {
744 /* Use each side's own definition, including defaults, access callbacks, and custom
745 * property array element types. */
746 rawprop_reference = rawprop_local->magic == RNA_MAGIC ?
747 RNA_struct_find_property(ptr_reference, rawprop_local->identifier) :
748 reinterpret_cast<PropertyRNA *>(rna_idproperty_find(
749 ptr_reference,
750 reinterpret_cast<IDProperty *>(rawprop_local)->name));
751 if (!rawprop_reference) {
752 continue;
753 }
754 }
755
756 PropertyRNAOrID prop_local;
757 PropertyRNAOrID prop_reference;
758
759 rna_property_rna_or_id_get(rawprop_local, ptr_local, &prop_local);
760 rna_property_rna_or_id_get(rawprop_reference, ptr_reference, &prop_reference);
761
762 BLI_assert(prop_local.rnaprop != nullptr);
763 BLI_assert(prop_local.is_idprop == prop_reference.is_idprop);
764
765 /* Private runtime RNA types, e.g. generated node group interfaces, may be generated
766 * independently for the local override and its reference, so compatible property definitions
767 * can have different addresses. */
768 if (prop_local.rnaprop != prop_reference.rnaprop) {
769 const PropertyRNA &a = *prop_local.rnaprop;
770 const PropertyRNA &b = *prop_reference.rnaprop;
772 prop_local.is_array != prop_reference.is_array ||
773 prop_local.array_len != prop_reference.array_len)
774 {
775 continue;
776 }
779 RNA_property_pointer_type(ptr_local, rawprop_local),
780 RNA_property_pointer_type(ptr_reference, rawprop_reference)))
781 {
782 continue;
783 }
784 }
785
786 if ((prop_local.is_idprop && prop_local.idprop == nullptr) ||
787 (prop_reference.is_idprop && prop_reference.idprop == nullptr))
788 {
789 continue;
790 }
791
792 if (ignore_non_overridable && !RNA_property_overridable_get(prop_local.ptr, rawprop_local)) {
793 continue;
794 }
795
796 if (!prop_local.is_idprop &&
798 {
799 continue;
800 }
801
802#if 0
803 /* This actually makes things slower, since it has to check for animation paths etc! */
804 if (RNA_property_animated(ptr_local, prop_local)) {
805 /* We cannot do anything here really, animation is some kind of dynamic overrides that has
806 * precedence over static one... */
807 continue;
808 }
809#endif
810
811#define RNA_PATH_BUFFSIZE 8192
812
813 std::optional<std::string> rna_path;
814 size_t rna_path_len = 0;
815
816 /* XXX TODO: this will have to be refined to handle collections insertions, and array items. */
817 if (root_path) {
818 BLI_assert(strlen(root_path) == root_path_len);
819
820 const char *prop_name = prop_local.identifier.c_str();
821 const size_t prop_name_len = prop_local.identifier.size();
822
823 char rna_path_buffer[RNA_PATH_BUFFSIZE];
824 char *rna_path_c = rna_path_buffer;
825
826 /* Inlined building (significantly more efficient). */
827 if (!prop_local.is_idprop) {
828 rna_path_len = root_path_len + 1 + prop_name_len;
829 if (rna_path_len >= RNA_PATH_BUFFSIZE) {
830 rna_path_c = MEM_new_array_uninitialized<char>(rna_path_len + 1, __func__);
831 }
832
833 memcpy(rna_path_c, root_path, root_path_len);
834 rna_path_c[root_path_len] = '.';
835 memcpy(rna_path_c + root_path_len + 1, prop_name, prop_name_len);
836 rna_path_c[rna_path_len] = '\0';
837 }
838 else {
839 char prop_name_esc[MAX_IDPROP_NAME * 2];
840 const size_t prop_name_esc_len = BLI_str_escape(
841 prop_name_esc, prop_name, sizeof(prop_name_esc));
842
843 rna_path_len = root_path_len + 2 + prop_name_esc_len + 2;
844 if (rna_path_len >= RNA_PATH_BUFFSIZE) {
845 rna_path_c = MEM_new_array_uninitialized<char>(rna_path_len + 1, __func__);
846 }
847
848 memcpy(rna_path_c, root_path, root_path_len);
849 rna_path_c[root_path_len] = '[';
850 rna_path_c[root_path_len + 1] = '"';
851 memcpy(rna_path_c + root_path_len + 2, prop_name_esc, prop_name_esc_len);
852 rna_path_c[root_path_len + 2 + prop_name_esc_len] = '"';
853 rna_path_c[root_path_len + 2 + prop_name_esc_len + 1] = ']';
854 rna_path_c[rna_path_len] = '\0';
855 }
856
857 rna_path.emplace(rna_path_c);
858 if (rna_path_c != rna_path_buffer) {
859 MEM_delete(rna_path_c);
860 }
861 }
862 else {
863 /* This is rather slow, but is not much called, so not really worth optimizing. */
864 rna_path = RNA_path_from_ID_to_property(ptr_local, rawprop_local);
865 if (rna_path) {
866 rna_path_len = rna_path->size();
867 }
868 }
869 if (!rna_path) {
870 continue;
871 }
872
873 CLOG_DEBUG(&LOG, "Override Checking %s", rna_path->c_str());
874
875 if (ignore_overridden) {
877 rna_path->c_str());
878 if (op != nullptr) {
880 continue;
881 }
882 }
883
884#ifdef DEBUG_OVERRIDE_TIMEIT
885 if (!root_path) {
886 _timeit_time_diffing = BLI_time_now_seconds();
887 }
888#endif
889
891 const int diff = rna_property_override_diff(bmain,
892 &prop_local,
893 &prop_reference,
894 rna_path->c_str(),
895 rna_path_len,
898 flags,
899 &report_flags);
900
901#ifdef DEBUG_OVERRIDE_TIMEIT
902 if (!root_path) {
903 const float _delta_time = float(BLI_time_now_seconds() - _timeit_time_diffing);
904 _delta_time_diffing += _delta_time;
905 _num_delta_time_diffing++;
906 }
907#endif
908
909 matching = matching && diff == 0;
910 if (r_report_flags) {
911 *r_report_flags = (*r_report_flags | report_flags);
912 }
913
914 if (diff != 0) {
915 /* XXX TODO: refine this for per-item overriding of arrays... */
917 rna_path->c_str());
919 op ? op->operations.first_ : nullptr);
920
921 if (op != nullptr) {
922 /* Only set all operations from this property as used (via
923 * #BKE_lib_override_library_operations_tag) if the property itself is still tagged as
924 * unused.
925 *
926 * In case the property itself is already tagged as used, in means lower-level diffing code
927 * took care of this property (e.g. as is needed collections of items, since then some
928 * operations may be valid, while others may need to be purged). */
931 }
932 }
933
934 if ((do_restore || do_tag_for_restore) &&
935 (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) == 0)
936 {
937 /* We are allowed to restore to reference's values. */
938 if (ELEM(nullptr, op, opop) || opop->operation == LIBOVERRIDE_OP_NOOP) {
939 if (RNA_property_editable(ptr_local, rawprop_local)) {
940 /* This property should be restored to its reference value. This should not be done
941 * here, since this code may be called from non-main thread (modifying data through RNA
942 * is not thread safe). */
943 if (do_restore) {
946 opop_tmp.subitem_reference_index = -1;
947 opop_tmp.subitem_local_index = -1;
948
950 rnaapply_ctx.ptr_dst = *ptr_local;
951 rnaapply_ctx.ptr_src = *ptr_reference;
952 rnaapply_ctx.prop_dst = rawprop_local;
953 rnaapply_ctx.prop_src = rawprop_reference;
954 rnaapply_ctx.liboverride_operation = &opop_tmp;
955
956 const bool is_restored = rna_property_override_operation_apply(bmain, rnaapply_ctx);
957
958 if (is_restored) {
960 "Restored forbidden liboverride `%s` for override data '%s'",
961 rna_path->c_str(),
962 ptr_local->owner_id->name);
963 if (r_report_flags) {
964 *r_report_flags |= RNA_OVERRIDE_MATCH_RESULT_RESTORED;
965 }
966 }
967 else {
969 "Failed to restore forbidden liboverride `%s` for override data '%s'",
970 rna_path->c_str(),
971 ptr_local->owner_id->name);
972 }
973 }
974 else {
975 if (op == nullptr) {
976 /* An override property is needed, create a temp one if necessary. */
978 liboverride, rna_path->c_str(), nullptr);
980 }
984 nullptr,
985 nullptr,
986 {},
987 {},
988 -1,
989 -1,
990 false,
991 nullptr,
992 nullptr);
993 /* Do not use `BKE_lib_override_library_operations_tag` here, as the property may be
994 * a valid one that has other operations that needs to remain (e.g. from a template,
995 * a NOOP operation to enforce no change on that property, etc.). */
997 opop_restore->tag |= LIBOVERRIDE_PROP_TAG_NEEDS_RETORE;
1000
1001 CLOG_DEBUG(
1002 &LOG,
1003 "Tagging for restoration forbidden liboverride `%s` for override data '%s'",
1004 rna_path->c_str(),
1005 ptr_local->owner_id->name);
1006 if (r_report_flags) {
1008 }
1009 }
1010 }
1011 else {
1012 /* Too noisy for now, this triggers on runtime props like transform matrices etc. */
1013#if 0
1015 "We have differences between reference and "
1016 "overriding data on non-editable property.");
1017#endif
1018 matching = false;
1019 }
1020 }
1021 }
1022 else if ((report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) == 0 && ELEM(nullptr, op, opop))
1023 {
1024 /* This property is not overridden, and differs from reference, so we have no match. */
1025 matching = false;
1026 if (!(do_create || do_restore || do_tag_for_restore)) {
1027
1028 break;
1029 }
1030 }
1031 }
1032#undef RNA_PATH_BUFFSIZE
1033 }
1035
1036#ifdef DEBUG_OVERRIDE_TIMEIT
1037 if (!root_path) {
1038 const float _delta_time = float(BLI_time_now_seconds() - _timeit_time_global);
1039 _sum_time_global += _delta_time;
1040 _num_time_global++;
1041 _sum_time_diffing += _delta_time_diffing;
1042 _num_time_diffing++;
1043 printf("ID: %s\n", ((ID *)ptr_local->owner_id)->name);
1044 printf("time end (%s): %.6f\n", __func__, _delta_time);
1045 printf("time averaged (%s): %.6f (total: %.6f, in %d runs)\n",
1046 __func__,
1047 (_sum_time_global / _num_time_global),
1048 _sum_time_global,
1049 int(_num_time_global));
1050 printf("diffing time end (%s): %.6f (in %d runs)\n",
1051 __func__,
1052 _delta_time_diffing,
1053 _num_delta_time_diffing);
1054 printf("diffing time averaged (%s): %.6f (total: %.6f, in %d runs)\n",
1055 __func__,
1056 (_sum_time_diffing / _num_time_diffing),
1057 _sum_time_diffing,
1058 int(_num_time_diffing));
1059 }
1060#endif
1061
1062 return matching;
1063}
1064
1066 PointerRNA *ptr_local,
1067 PointerRNA *ptr_reference,
1068 PointerRNA *ptr_storage,
1070{
1071 bool changed = false;
1072
1073#ifdef DEBUG_OVERRIDE_TIMEIT
1075#endif
1076 for (IDOverrideLibraryProperty &op : liboverride->properties) {
1077 /* Simplified for now! */
1078 PointerRNA data_reference, data_local;
1079 PropertyRNA *prop_reference, *prop_local;
1080
1081 if (RNA_path_resolve_property(ptr_local, op.rna_path, &data_local, &prop_local) &&
1082 RNA_path_resolve_property(ptr_reference, op.rna_path, &data_reference, &prop_reference))
1083 {
1084 PointerRNA data_storage;
1085 PropertyRNA *prop_storage = nullptr;
1086
1087 /* It is totally OK if this does not success,
1088 * only a subset of override operations actually need storage. */
1089 if (ptr_storage && (ptr_storage->owner_id != nullptr)) {
1090 RNA_path_resolve_property(ptr_storage, op.rna_path, &data_storage, &prop_storage);
1091 }
1092
1094 &data_local,
1095 &data_reference,
1096 &data_storage,
1097 prop_local,
1098 prop_reference,
1099 prop_storage,
1100 &op))
1101 {
1102 changed = true;
1103 }
1104 }
1105 }
1106#ifdef DEBUG_OVERRIDE_TIMEIT
1108#endif
1109
1110 return changed;
1111}
1112
1114 const char *item_name,
1115 const int item_name_len,
1116 const bool do_id_pointer,
1117 const std::optional<ID *> &item_id,
1118 PointerRNA *ptr_item_name)
1119{
1120 BLI_assert(!do_id_pointer || RNA_struct_is_ID(ptr_item_name->type));
1121
1122 bool is_match = false;
1123
1124 if (do_id_pointer) {
1125 if (*item_id != static_cast<ID *>(ptr_item_name->data)) {
1126 /* If the ID pointer does not match, then there is no match, no need to check the
1127 * name itself. */
1128 return is_match;
1129 }
1130 }
1131
1132 PropertyRNA *nameprop = ptr_item_name->type->nameproperty;
1133 char name_buf[256];
1134 char *name;
1135 int namelen;
1136
1138 ptr_item_name, nameprop, name_buf, sizeof(name_buf), &namelen);
1139
1140 is_match = ((item_name_len == namelen) && STREQ(item_name, name));
1141
1142 if (name != name_buf) [[unlikely]] {
1143 MEM_delete(name);
1144 }
1145
1146 return is_match;
1147}
1148
1150 PointerRNA *ptr,
1151 PropertyRNA *prop,
1152 const char *item_name,
1153 const int item_name_len,
1154 const bool do_id_pointer,
1155 const std::optional<ID *> &item_id,
1156 PointerRNA *r_ptr_item_name)
1157{
1158 /* NOTE: This code is very similar to the one from #RNA_property_collection_lookup_string_index,
1159 * but it adds an extra early check on matching ID pointer.
1160 *
1161 * This custom code is needed because otherwise, it is only possible to check the first
1162 * name-matched item found by #RNA_property_collection_lookup_string, and not potential other
1163 * items having the same name. */
1164 if (do_id_pointer) {
1166
1167 /* We cannot use a potential `CollectionPropertyRNA->lookupstring` here. */
1169
1170 RNA_property_collection_begin(ptr, prop, &iter);
1171 for (; iter.valid; RNA_property_collection_next(&iter)) {
1172 if (iter.ptr && iter.ptr.type->nameproperty) {
1174 item_name, item_name_len, do_id_pointer, item_id, &iter.ptr))
1175 {
1176 *r_ptr_item_name = iter.ptr;
1177 break;
1178 }
1179 }
1180 }
1182
1183 if (!iter.valid) {
1184 *r_ptr_item_name = {};
1185 }
1186
1187 return iter.valid;
1188 }
1189
1190 return RNA_property_collection_lookup_string(ptr, prop, item_name, r_ptr_item_name);
1191}
1192
1194 PointerRNA *ptr,
1195 PropertyRNA *prop,
1196 const char *item_name,
1197 const std::optional<ID *> &item_id,
1198 const int item_index,
1199 /* Never use index-only lookup to validate a match (unless no item name (+ id) was given). */
1200 const bool ignore_index_only_lookup,
1201 PointerRNA *r_ptr_item_name,
1202 PointerRNA *r_ptr_item_index)
1203{
1204 r_ptr_item_name->invalidate();
1205 r_ptr_item_index->invalidate();
1206
1207 const bool do_id_pointer = item_id && RNA_struct_is_ID(RNA_property_pointer_type(ptr, prop));
1208
1209 const int item_name_len = item_name ? int(strlen(item_name)) : 0;
1210
1211 /* First, lookup by index, but only validate if name also matches (or if there is no given name).
1212 *
1213 * Note that this is also beneficial on performances (when looking up in big collections), since
1214 * typically index lookup will be faster than name lookup.
1215 */
1216 if (item_index != -1) {
1217 if (RNA_property_collection_lookup_int(ptr, prop, item_index, r_ptr_item_index)) {
1218 if (item_name && r_ptr_item_index->has_type()) {
1220 item_name, item_name_len, do_id_pointer, item_id, r_ptr_item_index))
1221 {
1222 *r_ptr_item_name = *r_ptr_item_index;
1223 return;
1224 }
1225 }
1226 }
1227 }
1228
1229 if (!item_name) {
1230 return;
1231 }
1232
1233 /* If index + name (+ id) lookup failed, do not keep result of index-only lookup. That means that
1234 * if the name (+ id) only lookup fails, no matching item was found, even if index-only would
1235 * have matched. */
1236 if (ignore_index_only_lookup) {
1237 r_ptr_item_index->invalidate();
1238 }
1239
1240 /* Then, lookup by name (+ id) only. */
1242 ptr, prop, item_name, item_name_len, do_id_pointer, item_id, r_ptr_item_name))
1243 {
1244 r_ptr_item_index->invalidate();
1245 return;
1246 }
1247
1248 /* If name (+ id) lookup failed, `r_ptr_item_name` is invalidated, so if index lookup was
1249 * successful it will be the only valid return value. */
1250}
1251
1253 RNAPropertyOverrideApplyContext &rnaapply_ctx)
1254{
1255 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
1256 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
1257 PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
1258 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
1259 PropertyRNA *prop_src = rnaapply_ctx.prop_src;
1260 PropertyRNA *prop_storage = rnaapply_ctx.prop_storage;
1261 PointerRNA *ptr_item_dst = &rnaapply_ctx.ptr_item_dst;
1262 PointerRNA *ptr_item_src = &rnaapply_ctx.ptr_item_src;
1263 PointerRNA *ptr_item_storage = &rnaapply_ctx.ptr_item_storage;
1266
1267 if ((RNA_property_type(prop_dst) != PROP_COLLECTION ||
1268 RNA_property_type(prop_src) != PROP_COLLECTION ||
1269 (prop_storage != nullptr && RNA_property_type(prop_storage) != PROP_COLLECTION)) ||
1270 (opop->subitem_local_name == nullptr && opop->subitem_reference_name == nullptr &&
1271 opop->subitem_local_index == -1 && opop->subitem_reference_index == -1))
1272 {
1273 return;
1274 }
1275
1276 const bool use_id_pointer = (opop->flag & LIBOVERRIDE_OP_FLAG_IDPOINTER_ITEM_USE_ID) != 0;
1277 std::optional<ID *> subitem_local_id = use_id_pointer ? std::optional(opop->subitem_local_id) :
1278 std::nullopt;
1279 std::optional<ID *> subitem_reference_id = use_id_pointer ?
1280 std::optional(opop->subitem_reference_id) :
1281 std::nullopt;
1282
1283 ptr_item_dst->invalidate();
1284 ptr_item_src->invalidate();
1285 if (prop_storage != nullptr) {
1286 ptr_item_storage->invalidate();
1287 }
1288
1289 /* If there is an item ID, there should _always_ be a valid item name too. */
1290 BLI_assert(opop->subitem_local_name || !subitem_local_id);
1291 BLI_assert(opop->subitem_reference_name || !subitem_reference_id);
1292 /* Do not match by index only, if there are valid item names and ID.
1293 *
1294 * Otherwise, it can end up 'matching by index' e.g. collection children, re-assigning
1295 * completely wrong collections only based on indices. This is especially bad when some
1296 * collections are _removed_ from the reference collection's children. */
1297 const bool ignore_index_only_lookup = (subitem_local_id || subitem_reference_id);
1298
1299 PointerRNA ptr_item_dst_name, ptr_item_dst_index;
1300 PointerRNA ptr_item_src_name, ptr_item_src_index;
1301 PointerRNA ptr_item_storage_name, ptr_item_storage_index;
1303 prop_src,
1304 opop->subitem_local_name,
1305 subitem_local_id,
1306 opop->subitem_local_index,
1307 ignore_index_only_lookup,
1308 &ptr_item_src_name,
1309 &ptr_item_src_index);
1311 prop_dst,
1313 subitem_reference_id,
1315 ignore_index_only_lookup,
1316 &ptr_item_dst_name,
1317 &ptr_item_dst_index);
1318 /* This is rather fragile, but the fact that local override IDs may have a different name
1319 * than their linked reference makes it necessary.
1320 * Basically, here we are considering that if we cannot find the original linked ID in
1321 * the local override we are (re-)applying the operations, then it may be because some of
1322 * those operations have already been applied, and we may already have the local ID
1323 * pointer we want to set.
1324 * This happens e.g. during re-sync of an override, since we have already remapped all ID
1325 * pointers to their expected values.
1326 * In that case we simply try to get the property from the local expected name. */
1327 if (opop->subitem_reference_name != nullptr && opop->subitem_local_name != nullptr &&
1328 !ptr_item_dst_name.has_type())
1329 {
1331 ptr_dst,
1332 prop_dst,
1333 opop->subitem_local_name,
1334 {},
1336 opop->subitem_local_index,
1337 ignore_index_only_lookup,
1338 &ptr_item_dst_name,
1339 &ptr_item_dst_index);
1340 }
1341
1342 /* For historical compatibility reasons, we fallback to reference if no local item info is given,
1343 * and vice-versa. */
1344 if (opop->subitem_reference_name == nullptr && opop->subitem_local_name != nullptr) {
1346 ptr_dst,
1347 prop_dst,
1348 opop->subitem_local_name,
1349 {},
1351 opop->subitem_local_index,
1352 ignore_index_only_lookup,
1353 &ptr_item_dst_name,
1354 &ptr_item_dst_index);
1355 }
1356 else if (opop->subitem_reference_name != nullptr && opop->subitem_local_name == nullptr) {
1358 prop_src,
1360 {},
1361 opop->subitem_local_index != -1 ?
1362 opop->subitem_local_index :
1364 ignore_index_only_lookup,
1365 &ptr_item_src_name,
1366 &ptr_item_src_index);
1367 }
1368 if (opop->subitem_reference_index == -1 && opop->subitem_local_index != -1) {
1370 prop_dst,
1371 nullptr,
1372 {},
1373 opop->subitem_local_index,
1374 ignore_index_only_lookup,
1375 &ptr_item_dst_name,
1376 &ptr_item_dst_index);
1377 }
1378 else if (opop->subitem_reference_index != -1 && opop->subitem_local_index == -1) {
1380 prop_src,
1381 nullptr,
1382 {},
1384 ignore_index_only_lookup,
1385 &ptr_item_src_name,
1386 &ptr_item_src_index);
1387 }
1388
1389 /* For storage, simply lookup by name first, and fallback to indices. */
1390 if (prop_storage != nullptr) {
1392 prop_storage,
1393 opop->subitem_local_name,
1394 subitem_local_id,
1395 opop->subitem_local_index,
1396 ignore_index_only_lookup,
1397 &ptr_item_storage_name,
1398 &ptr_item_storage_index);
1399 if (!ptr_item_storage_name) {
1401 prop_storage,
1403 subitem_reference_id,
1405 ignore_index_only_lookup,
1406 &ptr_item_storage_name,
1407 &ptr_item_storage_index);
1408 }
1409 if (!ptr_item_storage_name && !ptr_item_storage_index) {
1411 prop_storage,
1412 nullptr,
1413 {},
1414 opop->subitem_local_index,
1415 ignore_index_only_lookup,
1416 &ptr_item_storage_name,
1417 &ptr_item_storage_index);
1418 }
1419 }
1420
1421 /* Final selection. Both matches have to be based on names, or indices, but not a mix of both.
1422 * If we are missing either source or destination data based on names, and based on indices, then
1423 * use partial data from names (allows to handle 'need resync' detection cases). */
1424 if ((ptr_item_src_name.has_type() || ptr_item_dst_name.has_type()) &&
1425 !(ptr_item_src_index.has_type() && ptr_item_dst_index.has_type()))
1426 {
1427 *ptr_item_src = ptr_item_src_name;
1428 *ptr_item_dst = ptr_item_dst_name;
1429 if (prop_storage != nullptr) {
1430 *ptr_item_storage = ptr_item_storage_name;
1431 }
1432 }
1433 else if (ptr_item_src_index.has_type() || ptr_item_dst_index.has_type()) {
1434 *ptr_item_src = ptr_item_src_index;
1435 *ptr_item_dst = ptr_item_dst_index;
1436 if (prop_storage != nullptr) {
1437 *ptr_item_storage = ptr_item_storage_index;
1438 }
1439 }
1440
1441 /* Note that there is no reason to report in case no item is expected, i.e. in case subitem name
1442 * and index are invalid. This can often happen when inserting new items (constraint,
1443 * modifier...) in a collection that supports it. */
1444 if (!ptr_item_dst->has_type() &&
1445 ((opop->subitem_reference_name != nullptr && opop->subitem_reference_name[0] != '\0') ||
1446 opop->subitem_reference_index != -1))
1447 {
1448 CLOG_DEBUG(&LOG,
1449 "Failed to find destination sub-item '%s' (%d) of '%s' in new override data '%s'",
1450 opop->subitem_reference_name != nullptr ? opop->subitem_reference_name : "",
1452 op->rna_path,
1453 ptr_dst->owner_id->name);
1454 }
1455 if (!ptr_item_src->has_type() &&
1456 ((opop->subitem_local_name != nullptr && opop->subitem_local_name[0] != '\0') ||
1457 opop->subitem_local_index != -1))
1458 {
1459 CLOG_DEBUG(&LOG,
1460 "Failed to find source sub-item '%s' (%d) of '%s' in old override data '%s'",
1461 opop->subitem_local_name != nullptr ? opop->subitem_local_name : "",
1462 opop->subitem_local_index,
1463 op->rna_path,
1464 ptr_src->owner_id->name);
1465 }
1466}
1467
1469 PointerRNA *ptr_dst,
1470 PointerRNA *ptr_src,
1471 PointerRNA *ptr_item_dst,
1472 PointerRNA *ptr_item_src)
1473{
1475 bmain, ptr_src, nullptr, nullptr);
1477 bmain, ptr_dst, nullptr, nullptr);
1478 ID *id_src = rna_property_override_property_real_id_owner(bmain, ptr_item_src, nullptr, nullptr);
1479 ID *id_dst = rna_property_override_property_real_id_owner(bmain, ptr_item_dst, nullptr, nullptr);
1480
1482
1483 /* If the owner ID is not part of an override hierarchy, there is no possible resync. */
1485 return;
1486 }
1487
1488 /* If `id_src` is not a liboverride, we cannot perform any further 'need resync' checks from
1489 * here. */
1490 if (id_src != nullptr && !ID_IS_OVERRIDE_LIBRARY_REAL(id_src)) {
1491 return;
1492 }
1493
1494 if (/* We might be in a case where id_dst has already been processed and its usages
1495 * remapped to its new local override. In that case overrides and linked data
1496 * are always properly matching. */
1497 id_src != id_dst &&
1498 /* If one of the pointers is nullptr and not the other, we are in a non-matching case. */
1499 (ELEM(nullptr, id_src, id_dst) ||
1500 /* If `id_dst` is not from same lib as id_src, and linked reference ID of `id_src` is not
1501 * `id_dst`, we are in a non-matching case. */
1502 (id_dst->lib != id_src->lib && id_src->override_library->reference != id_dst) ||
1503 /* If `id_dst` is from same lib as id_src, and is not same as `id_owner`, we are in a
1504 * non-matching case.
1505 *
1506 * NOTE: Here we are testing if `id_owner` is referencing itself, in that case the new
1507 * override copy generated by `BKE_lib_override_library_update` will already have its
1508 * self-references updated to itself, instead of still pointing to its linked source. */
1509 (id_dst->lib == id_src->lib && id_dst != id_owner_dst)))
1510 {
1511 id_owner_dst->tag |= ID_TAG_LIBOVERRIDE_NEED_RESYNC;
1512 if (ID_IS_LINKED(id_owner_src)) {
1513 id_owner_src->lib->runtime->tag |= LIBRARY_TAG_RESYNC_REQUIRED;
1514 }
1515 CLOG_DEBUG(&LOG,
1516 "Local override %s detected as needing resync due to mismatch in its used IDs",
1517 id_owner_dst->name);
1518 }
1519 if ((id_owner_src->override_library->reference->tag & ID_TAG_LIBOVERRIDE_NEED_RESYNC) != 0) {
1520 id_owner_dst->tag |= ID_TAG_LIBOVERRIDE_NEED_RESYNC;
1521 if (ID_IS_LINKED(id_owner_src)) {
1522 id_owner_src->lib->runtime->tag |= LIBRARY_TAG_RESYNC_REQUIRED;
1523 }
1524 CLOG_DEBUG(&LOG,
1525 "Local override %s detected as needing resync as its liboverride reference is "
1526 "already tagged for resync",
1527 id_owner_dst->name);
1528 }
1529}
1530
1532 RNAPropertyOverrideApplyContext &rnaapply_ctx)
1533{
1535 const bool do_insert = rnaapply_ctx.do_insert;
1536
1538 if (opop.operation == LIBOVERRIDE_OP_NOOP) {
1539 continue;
1540 }
1541
1542 if (!do_insert !=
1544 {
1545 if (!do_insert) {
1546 CLOG_DEBUG(&LOG, "Skipping insert override operations in first pass (%s)", op->rna_path);
1547 }
1548 continue;
1549 }
1550
1551 rnaapply_ctx.liboverride_operation = &opop;
1552
1554
1555 if (!rna_property_override_operation_apply(bmain, rnaapply_ctx)) {
1556 CLOG_DEBUG(&LOG,
1557 "Failed to apply '%s' override operation on %s\n",
1558 op->rna_path,
1559 rnaapply_ctx.ptr_src.owner_id->name);
1560 }
1561 }
1562
1563 rnaapply_ctx.liboverride_operation = nullptr;
1564}
1565
1571 PointerRNA *id_ptr_dst,
1572 PointerRNA *id_ptr_src,
1573 RNAPropertyOverrideApplyContext &rnaapply_ctx)
1574{
1575 UNUSED_VARS_NDEBUG(bmain, id_ptr_src);
1576
1577 if ((rnaapply_ctx.flag & RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS) == 0) {
1578 return false;
1579 }
1580
1581 if (!RNA_struct_is_ID(RNA_property_pointer_type(&rnaapply_ctx.ptr_dst, rnaapply_ctx.prop_dst))) {
1583 RNA_property_pointer_type(&rnaapply_ctx.ptr_src, rnaapply_ctx.prop_src)));
1584 return false;
1585 }
1586
1588
1589 /* IDProperties case. */
1590 if (rnaapply_ctx.prop_dst->magic != RNA_MAGIC) {
1591 CLOG_DEBUG(&LOG,
1592 "%s: Ignoring local override on ID pointer custom property '%s', as requested by "
1593 "RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS flag",
1594 id_ptr_dst->owner_id->name,
1595 op->rna_path);
1596 return true;
1597 }
1598
1599 switch (op->rna_prop_type) {
1600 case PROP_POINTER: {
1601 if ((op->operations.first()->flag & LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) {
1603 bmain, &rnaapply_ctx.ptr_src, nullptr, nullptr));
1605 bmain, &rnaapply_ctx.ptr_dst, nullptr, nullptr));
1606
1607 CLOG_DEBUG(&LOG,
1608 "%s: Ignoring local override on ID pointer property '%s', as requested by "
1609 "RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS flag",
1610 id_ptr_dst->owner_id->name,
1611 op->rna_path);
1612 return true;
1613 }
1614 break;
1615 }
1616 case PROP_COLLECTION: {
1617 /* For collections of ID pointers just completely skip the override ops here... A tad brutal,
1618 * but this is a backup 'fix the mess' tool, and in practice this should never be an issue.
1619 * Can always be refined later if needed. */
1620 CLOG_DEBUG(&LOG,
1621 "%s: Ignoring all local override on ID pointer collection property '%s', as "
1622 "requested by RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS flag",
1623 id_ptr_dst->owner_id->name,
1624 op->rna_path);
1625 return true;
1626 }
1627 default:
1628 break;
1629 }
1630
1631 return false;
1632}
1633
1635 PointerRNA *id_ptr_dst,
1636 PointerRNA *id_ptr_src,
1637 PointerRNA *id_ptr_storage,
1639 const eRNAOverrideApplyFlag flag)
1640{
1641#ifdef DEBUG_OVERRIDE_TIMEIT
1643#endif
1644 const bool do_restore_only = (flag & RNA_OVERRIDE_APPLY_FLAG_RESTORE_ONLY) != 0;
1645 /* NOTE: Applying insert operations in a separate pass is mandatory.
1646 * We could optimize this later, but for now, as inefficient as it is,
1647 * don't think this is a critical point.
1648 */
1649 bool do_insert = false;
1650 for (int i = 0; i < (do_restore_only ? 1 : 2); i++, do_insert = true) {
1651 for (IDOverrideLibraryProperty &op : liboverride->properties) {
1652 if (do_restore_only && (op.tag % LIBOVERRIDE_PROP_TAG_NEEDS_RETORE) == 0) {
1653 continue;
1654 }
1655 /* That tag should only exist for short lifespan when restoring values from reference linked
1656 * data. */
1657 BLI_assert((op.tag & LIBOVERRIDE_PROP_TAG_NEEDS_RETORE) == 0 || do_restore_only);
1658
1660 rnaapply_ctx.flag = flag;
1661 rnaapply_ctx.do_insert = do_insert;
1662
1663 rnaapply_ctx.liboverride = liboverride;
1664 rnaapply_ctx.liboverride_property = &op;
1665
1667 op.rna_path,
1668 &rnaapply_ctx.ptr_dst,
1669 &rnaapply_ctx.prop_dst,
1670 &rnaapply_ctx.ptr_item_dst) &&
1672 op.rna_path,
1673 &rnaapply_ctx.ptr_src,
1674 &rnaapply_ctx.prop_src,
1675 &rnaapply_ctx.ptr_item_src)))
1676 {
1677 CLOG_DEBUG(&LOG,
1678 "Failed to apply library override operation to '%s.%s' "
1679 "(could not resolve some properties, local: %d, override: %d)",
1680 static_cast<ID *>(id_ptr_src->owner_id)->name,
1681 op.rna_path,
1683 id_ptr_dst, op.rna_path, &rnaapply_ctx.ptr_dst, &rnaapply_ctx.prop_dst),
1685 id_ptr_src, op.rna_path, &rnaapply_ctx.ptr_src, &rnaapply_ctx.prop_src));
1686 continue;
1687 }
1688
1689 /* It is totally OK if this does not success,
1690 * only a subset of override operations actually need storage. */
1691 if (id_ptr_storage && (id_ptr_storage->owner_id != nullptr)) {
1693 op.rna_path,
1694 &rnaapply_ctx.ptr_storage,
1695 &rnaapply_ctx.prop_storage,
1696 &rnaapply_ctx.ptr_item_storage);
1697 }
1698
1699 /* Check if an overridden ID pointer supposed to be in sync with linked data gets out of
1700 * sync. */
1702 (id_ptr_dst->owner_id->tag & ID_TAG_LIBOVERRIDE_NEED_RESYNC) == 0)
1703 {
1704 if (op.rna_prop_type == PROP_POINTER && op.operations.first_ != nullptr &&
1706 {
1708 RNA_property_pointer_type(&rnaapply_ctx.ptr_src, rnaapply_ctx.prop_src)));
1710 bmain, &rnaapply_ctx.ptr_src, nullptr, nullptr));
1712 bmain, &rnaapply_ctx.ptr_dst, nullptr, nullptr));
1713
1714 PointerRNA prop_ptr_src = RNA_property_pointer_get(&rnaapply_ctx.ptr_src,
1715 rnaapply_ctx.prop_src);
1716 PointerRNA prop_ptr_dst = RNA_property_pointer_get(&rnaapply_ctx.ptr_dst,
1717 rnaapply_ctx.prop_dst);
1719 bmain, id_ptr_dst, id_ptr_src, &prop_ptr_dst, &prop_ptr_src);
1720 }
1721 else if (op.rna_prop_type == PROP_COLLECTION) {
1722 if (RNA_struct_is_ID(
1723 RNA_property_pointer_type(&rnaapply_ctx.ptr_src, rnaapply_ctx.prop_src)))
1724 {
1725 BLI_assert(id_ptr_src->owner_id ==
1727 bmain, &rnaapply_ctx.ptr_src, nullptr, nullptr));
1728 BLI_assert(id_ptr_dst->owner_id ==
1730 bmain, &rnaapply_ctx.ptr_dst, nullptr, nullptr));
1731
1734 continue;
1735 }
1736 rnaapply_ctx.liboverride_operation = &opop;
1737
1739
1741 id_ptr_dst,
1742 id_ptr_src,
1743 &rnaapply_ctx.ptr_item_dst,
1744 &rnaapply_ctx.ptr_item_src);
1745 }
1746 rnaapply_ctx.liboverride_operation = nullptr;
1747 }
1748 }
1749 }
1750
1751 if (override_apply_property_check_skip(bmain, id_ptr_dst, id_ptr_src, rnaapply_ctx)) {
1752 continue;
1753 }
1754
1755 rna_property_override_apply_ex(bmain, rnaapply_ctx);
1756 }
1757 }
1758
1759 /* Some cases (like point caches) may require additional post-processing. */
1760 if (RNA_struct_is_a(id_ptr_dst->type, RNA_ID)) {
1761 ID *id_dst = static_cast<ID *>(id_ptr_dst->data);
1762 ID *id_src = static_cast<ID *>(id_ptr_src->data);
1763 const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id_dst);
1764 if (id_type->lib_override_apply_post != nullptr) {
1765 id_type->lib_override_apply_post(id_dst, id_src);
1766 }
1767 }
1768
1769#ifdef DEBUG_OVERRIDE_TIMEIT
1771#endif
1772}
1773
1775 PointerRNA *ptr,
1776 PropertyRNA *prop,
1777 ID **r_owner_id)
1778{
1779 std::optional<std::string> rna_path;
1780
1781 *r_owner_id = rna_property_override_property_real_id_owner(bmain, ptr, prop, &rna_path);
1782 if (rna_path) {
1784 (*r_owner_id)->override_library, rna_path->c_str());
1785 return op;
1786 }
1787 return nullptr;
1788}
1789
1791 PointerRNA *ptr,
1792 PropertyRNA *prop,
1793 bool *r_created)
1794{
1795 std::optional<std::string> rna_path;
1796
1797 if (r_created != nullptr) {
1798 *r_created = false;
1799 }
1800
1802 if (rna_path) {
1804 id->override_library, rna_path->c_str(), r_created);
1805 return op;
1806 }
1807 return nullptr;
1808}
1809
1811 Main *bmain,
1812 PointerRNA *ptr,
1813 PropertyRNA *prop,
1814 const int index,
1815 const bool strict,
1816 bool *r_strict)
1817{
1818 ID *owner_id;
1819 IDOverrideLibraryProperty *op = RNA_property_override_property_find(bmain, ptr, prop, &owner_id);
1820
1821 if (!op) {
1822 return nullptr;
1823 }
1824
1826 op, nullptr, nullptr, {}, {}, index, index, strict, r_strict);
1827}
1828
1830 Main *bmain,
1831 PointerRNA *ptr,
1832 PropertyRNA *prop,
1833 const eID_OverrideLib_Op operation,
1834 const int index,
1835 const bool strict,
1836 bool *r_strict,
1837 bool *r_created)
1838{
1839 if (r_created != nullptr) {
1840 *r_created = false;
1841 }
1842
1843 IDOverrideLibraryProperty *op = RNA_property_override_property_get(bmain, ptr, prop, nullptr);
1844
1845 if (!op) {
1846 return nullptr;
1847 }
1848
1850 op, operation, nullptr, nullptr, {}, {}, index, index, strict, r_strict, r_created);
1851}
1852
1854 PointerRNA *ptr,
1855 PropertyRNA *prop,
1856 const int index)
1857{
1858 eRNAOverrideStatus override_status = eRNAOverrideStatus{};
1859
1860 if (!ptr || !prop || !ptr->owner_id || !ID_IS_OVERRIDE_LIBRARY(ptr->owner_id)) {
1861 return override_status;
1862 }
1863
1864 if (RNA_property_overridable_get(ptr, prop) && RNA_property_editable_flag(ptr, prop)) {
1865 override_status |= eRNAOverrideStatus::LibOverridable;
1866 }
1867
1869 bmain, ptr, prop, index, false, nullptr);
1870 if (opop != nullptr) {
1871 override_status |= eRNAOverrideStatus::LibOverridden;
1872 if (opop->flag & LIBOVERRIDE_OP_FLAG_MANDATORY) {
1874 }
1875 if (opop->flag & LIBOVERRIDE_OP_FLAG_LOCKED) {
1876 override_status |= eRNAOverrideStatus::LibOverrideLocked;
1877 }
1878 }
1879
1880 return override_status;
1881}
1882
1883} // namespace blender
Utility defines for timing/benchmarks.
#define TIMEIT_START_AVERAGED(var)
#define TIMEIT_END_AVERAGED(var)
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:188
#define CLOG_DEBUG(clg_ref,...)
Definition CLG_log.h:191
ID and Library types, which are fundamental for SDNA.
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition DNA_ID.h:729
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define MAX_IDPROP_NAME
Definition DNA_ID.h:174
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
bool is_empty() const
int64_t size() const
const char * c_str() const
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
Definition frames.inl:1166
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
BMesh Iterators.
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
eRNAOverrideMatchResult
@ RNA_OVERRIDE_MATCH_RESULT_RESTORED
@ RNA_OVERRIDE_MATCH_RESULT_CREATED
@ RNA_OVERRIDE_MATCH_RESULT_RESTORE_TAGGED
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_lib_override_library_tag_set(IDOverrideLibrary &liboverride, IDOverrideLibraryTag tag, bool value)
bool RNA_property_overridable_library_set(PointerRNA *, PropertyRNA *prop, const bool is_overridable)
static bool rna_property_override_collection_subitem_name_id_lookup(PointerRNA *ptr, PropertyRNA *prop, const char *item_name, const int item_name_len, const bool do_id_pointer, const std::optional< ID * > &item_id, PointerRNA *r_ptr_item_name)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
@ NLATRACK_OVERRIDELIBRARY_LOCAL
static void rna_property_override_apply_ex(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx)
@ LIBRARY_TAG_RESYNC_REQUIRED
bool(*)(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage, int len_local, int len_reference, int len_storage, IDOverrideLibraryPropertyOperation *opop) RNAPropOverrideStore
IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_find(IDOverrideLibraryProperty *liboverride_property, const char *subitem_refname, const char *subitem_locname, const std::optional< const ID * > &subitem_refid, const std::optional< const ID * > &subitem_locid, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
@ STRUCT_PUBLIC_NAMESPACE
@ STRUCT_RUNTIME
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
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
bool BKE_lib_override_library_property_operation_operands_validate(IDOverrideLibraryPropertyOperation *liboverride_property_operation, PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage)
bool RNA_property_editable_flag(const PointerRNA *ptr, PropertyRNA *prop)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
Definition rna_path.cc:1237
void BKE_pose_ensure(Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
bool rna_struct_override_type_matches(const StructRNA *type_a, const StructRNA *type_b)
eRNAOverrideApplyFlag
@ RNA_OVERRIDE_APPLY_FLAG_SKIP_RESYNC_CHECK
@ RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS
@ RNA_OVERRIDE_APPLY_FLAG_RESTORE_ONLY
static bool rna_property_override_operation_store(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage, IDOverrideLibraryProperty *op)
IDOverrideLibraryPropertyOperation * RNA_property_override_property_operation_get(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const eID_OverrideLib_Op operation, const int index, const bool strict, bool *r_strict, bool *r_created)
bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACompareMode mode)
@ LIBOVERRIDE_PROP_TAG_NEEDS_RETORE
Definition DNA_ID.h:242
@ LIBOVERRIDE_PROP_OP_TAG_UNUSED
Definition DNA_ID.h:239
std::optional< AncestorPointerRNA > RNA_struct_search_closest_ancestor_by_type(const PointerRNA *ptr, const StructRNA *srna)
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter)
bool RNA_property_overridable_get(const PointerRNA *ptr, PropertyRNA *prop)
static void rna_property_override_check_resync(Main *bmain, PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src)
int RNA_property_override_flag(PropertyRNA *prop)
ID * RNA_find_real_ID_and_path(ID *id, const char **r_path)
Definition rna_path.cc:1018
@ RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE
@ RNA_OVERRIDE_COMPARE_RESTORE
@ RNA_OVERRIDE_COMPARE_TAG_FOR_RESTORE
@ RNA_OVERRIDE_COMPARE_CREATE
@ RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
static bool rna_property_override_definition_matches(const PropertyRNA &a, const PropertyRNA &b)
bool RNA_property_comparable(PointerRNA *, PropertyRNA *prop)
eID_OverrideLib_Op
Definition DNA_ID.h:182
@ LIBOVERRIDE_OP_ADD
Definition DNA_ID.h:192
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:200
@ LIBOVERRIDE_OP_SUBTRACT
Definition DNA_ID.h:194
@ LIBOVERRIDE_OP_MULTIPLY
Definition DNA_ID.h:196
@ LIBOVERRIDE_OP_NOOP
Definition DNA_ID.h:185
@ LIBOVERRIDE_OP_CUSTOM
Definition DNA_ID.h:212
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:188
@ LIBOVERRIDE_OP_INSERT_BEFORE
Definition DNA_ID.h:202
@ LIBOVERRIDE_FLAG_NO_HIERARCHY
Definition DNA_ID.h:303
void RNA_struct_override_apply(Main *bmain, PointerRNA *id_ptr_dst, PointerRNA *id_ptr_src, PointerRNA *id_ptr_storage, IDOverrideLibrary *liboverride, const eRNAOverrideApplyFlag flag)
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:588
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:609
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:596
@ RNA_EQ_UNSET_MATCH_NONE
@ RNA_EQ_UNSET_MATCH_ANY
void rna_property_override_diff_default(Main *bmain, RNAPropertyOverrideDiffContext &rnadiff_ctx)
PropertyType RNA_property_type(PropertyRNA *prop)
static bool override_apply_property_check_skip(Main *bmain, PointerRNA *id_ptr_dst, PointerRNA *id_ptr_src, RNAPropertyOverrideApplyContext &rnaapply_ctx)
const IDTypeInfo * BKE_idtype_get_info_from_id(const ID *id)
Definition idtype.cc:232
bool RNA_path_resolve_property_and_item_pointer(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, PointerRNA *r_item_ptr)
Definition rna_path.cc:626
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_COLLECTION
Definition RNA_types.hh:216
@ IDP_FLAG_OVERRIDABLE_LIBRARY
@ IDP_FLAG_STATIC_TYPE
@ CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL
void RNA_property_collection_end(CollectionPropertyIterator *iter)
static bool rna_property_override_collection_subitem_name_id_match(const char *item_name, const int item_name_len, const bool do_id_pointer, const std::optional< ID * > &item_id, PointerRNA *ptr_item_name)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
void BKE_lib_override_library_operations_tag(IDOverrideLibraryProperty *liboverride_property, eID_OverrideLib_PropTag tag, bool do_set)
bool RNA_struct_override_matches(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, const char *root_path, const size_t root_path_len, IDOverrideLibrary *liboverride, const eRNAOverrideMatch flags, eRNAOverrideMatchResult *r_report_flags)
bool RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
IDOverrideLibraryProperty * RNA_property_override_property_find(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, ID **r_owner_id)
IDOverrideLibraryProperty * BKE_lib_override_library_property_find(IDOverrideLibrary *liboverride, const char *rna_path)
eRNAOverrideStatus RNA_property_override_library_status(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const int index)
bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop)
static void rna_property_override_collection_subitem_lookup(RNAPropertyOverrideApplyContext &rnaapply_ctx)
bool RNA_struct_is_ID(const StructRNA *type)
void RNA_property_collection_next(CollectionPropertyIterator *iter)
static bool rna_property_override_operation_apply(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx)
static int rna_property_override_diff(Main *bmain, PropertyRNAOrID *prop_a, PropertyRNAOrID *prop_b, const char *rna_path, const size_t rna_path_len, eRNACompareMode mode, IDOverrideLibrary *liboverride, const eRNAOverrideMatch flags, eRNAOverrideMatchResult *r_report_flags)
IDOverrideLibraryProperty * RNA_property_override_property_get(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, bool *r_created)
IDOverrideLibraryProperty * BKE_lib_override_library_property_get(IDOverrideLibrary *liboverride, const char *rna_path, bool *r_created)
static ID * rna_property_override_property_real_id_owner(Main *, PointerRNA *ptr, PropertyRNA *prop, std::optional< std::string > *r_rna_path)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
void(*)(Main *bmain, RNAPropertyOverrideDiffContext &rnadiff_ctx) RNAPropOverrideDiff
@ ID_TAG_LIBOVERRIDE_NEED_RESYNC
Definition DNA_ID.h:909
@ eModifierFlag_OverrideLibrary_Local
bool RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
IDOverrideLibraryPropertyOperation * RNA_property_override_property_operation_find(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const int index, const bool strict, bool *r_strict)
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
static CLG_LogRef LOG
Definition logging.cpp:12
double BLI_time_now_seconds()
Definition time.cc:30
PropertyRNA * rna_ensure_property(PropertyRNA *prop)
@ ID_FLAG_EMBEDDED_DATA
Definition DNA_ID.h:775
@ ID_FLAG_EMBEDDED_DATA_LIB_OVERRIDE
Definition DNA_ID.h:786
@ BONE_COLLECTION_OVERRIDE_LIBRARY_LOCAL
bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop)
bool(*)(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx) RNAPropOverrideApply
IDProperty * rna_idproperty_find(PointerRNA *ptr, const char *name)
bool rna_property_override_store_default(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage, int len_local, int len_reference, int len_storage, IDOverrideLibraryPropertyOperation *opop)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:578
bool RNA_struct_in_public_namespace(const StructRNA *type)
IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(IDOverrideLibraryProperty *liboverride_property, eID_OverrideLib_Op operation, const char *subitem_refname, const char *subitem_locname, const std::optional< ID * > &subitem_refid, const std::optional< ID * > &subitem_locid, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict, bool *r_created)
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_ITEM_USE_ID
Definition DNA_ID.h:232
@ LIBOVERRIDE_OP_FLAG_MANDATORY
Definition DNA_ID.h:218
@ LIBOVERRIDE_OP_FLAG_LOCKED
Definition DNA_ID.h:220
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE
Definition DNA_ID.h:226
bool RNA_struct_override_store(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, IDOverrideLibrary *liboverride)
void rna_property_rna_or_id_get(PropertyRNA *prop, PointerRNA *ptr, PropertyRNAOrID *r_prop_rna_or_id)
bool rna_property_override_apply_default(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx)
@ CONSTRAINT_OVERRIDE_LIBRARY_LOCAL
static void rna_property_override_collection_subitem_name_index_lookup(PointerRNA *ptr, PropertyRNA *prop, const char *item_name, const std::optional< ID * > &item_id, const int item_index, const bool ignore_index_only_lookup, PointerRNA *r_ptr_item_name, PointerRNA *r_ptr_item_index)
bool RNA_property_copy(Main *bmain, PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index, IDOverrideLibraryProperty *removed_oprop, IDOverrideLibraryPropertyOperation *removed_opop)
bool RNA_property_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, PropertyRNA *prop, eRNACompareMode mode)
#define RNA_PATH_BUFFSIZE
#define RNA_MAGIC
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBoneCollection_Flag flags
eCamera_BGImage_Flag flag
ListBaseT< IDOverrideLibraryPropertyOperation > operations
Definition DNA_ID.h:326
eID_OverrideLib_PropTag tag
Definition DNA_ID.h:331
eID_OverrideLib_Flag flag
Definition DNA_ID.h:356
IDTypeLibOverrideApplyPost lib_override_apply_post
char name[258]
Definition DNA_ID.h:433
struct Library * lib
Definition DNA_ID.h:421
IDOverrideLibrary * override_library
Definition DNA_ID.h:495
bke::library::LibraryRuntime * runtime
Definition DNA_ID.h:591
eNlaTrack_Flag flag
bool has_type() const
Definition RNA_types.hh:180
StructRNA * type
Definition RNA_types.hh:63
RNAPropOverrideDiff override_diff
RNAPropOverrideApply override_apply
PropArrayLengthGetFunc getlength
unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION]
PropertyOverrideFlag flag_override
RNAPropOverrideStore override_store
IDOverrideLibraryPropertyOperation * liboverride_removed_operation
IDOverrideLibraryPropertyOperation * liboverride_operation
IDOverrideLibraryProperty * liboverride_property
IDOverrideLibraryProperty * liboverride_removed_property