41 #ifdef DEBUG_OVERRIDE_TIMEIT
75 const char *rna_path_prefix =
NULL;
77 if (r_rna_path !=
NULL) {
94 owner_id = ((
Key *)
id)->from;
95 rna_path_prefix =
"shape_keys.";
107 if (r_rna_path ==
NULL) {
113 *r_rna_path = rna_path;
114 if (rna_path_prefix !=
NULL) {
115 *r_rna_path =
BLI_sprintfN(
"%s%s", rna_path_prefix, rna_path);
176 const bool is_overridable)
249 if (
ELEM(
NULL, prop_dst, prop_src)) {
255 .subitem_reference_index = index,
256 .subitem_local_index = index,
259 bmain,
ptr, fromptr,
NULL, prop_dst, prop_src,
NULL,
NULL,
NULL,
NULL, &opop);
265 const char *rna_path,
266 const size_t rna_path_len,
291 if (ptr_a ==
NULL && ptr_b ==
NULL) {
294 if (ptr_a ==
NULL || ptr_b ==
NULL) {
336 const char *rna_path,
337 const size_t rna_path_len,
368 const bool is_array_a = prop_a->
is_array;
369 const bool is_array_b = prop_b->
is_array;
371 if (is_array_a != is_array_b) {
374 return is_array_a ? 1 : -1;
381 if (len_a != len_b) {
384 return len_a > len_b ? 1 : -1;
387 if (is_array_a && len_a == 0) {
397 override_diff =
NULL;
403 override_diff =
NULL;
408 if (override_diff ==
NULL) {
413 if (override_diff ==
NULL) {
415 "'%s' gives unmatching or NULL RNA diff callbacks, should not happen (%d vs. %d)",
423 bool override_changed =
false;
428 const int diff = override_diff(bmain,
437 if (override_changed && r_report_flags) {
456 int len_local, len_reference, len_storage = 0;
457 bool changed =
false;
459 if (ptr_storage ==
NULL) {
470 if (len_local != len_reference || len_local != len_storage) {
481 override_store =
NULL;
487 override_store =
NULL;
492 if (override_store ==
NULL) {
499 override_store =
NULL;
502 if (override_store ==
NULL) {
504 "'%s' gives unmatching or NULL RNA store callbacks, should not happen (%d vs. %d)",
514 if (!
ELEM(opop->operation,
521 if (override_store(bmain,
551 int len_dst, len_src, len_storage = 0;
553 const short override_op = opop->
operation;
556 opop, ptr_dst, ptr_src, ptr_storage, prop_dst, prop_src, prop_storage)) {
569 override_apply =
NULL;
575 override_apply =
NULL;
580 if (override_apply ==
NULL) {
587 override_apply =
NULL;
590 if (override_apply ==
NULL) {
592 "'%s' gives unmatching or NULL RNA apply callbacks, should not happen (%d vs. %d)",
594 prop_dst->identifier,
608 if (len_dst != len_src || (ptr_storage && len_dst != len_storage)) {
615 return override_apply(bmain,
644 const char *root_path,
645 const size_t root_path_len,
652 bool matching =
true;
662 #ifdef DEBUG_OVERRIDE_TIMEIT
663 static float _sum_time_global = 0.0f;
664 static float _num_time_global = 0.0f;
665 double _timeit_time_global;
666 static float _sum_time_diffing = 0.0f;
667 static float _delta_time_diffing = 0.0f;
668 static int _num_delta_time_diffing = 0.0f;
669 static float _num_time_diffing = 0.0f;
670 double _timeit_time_diffing;
673 _delta_time_diffing = 0.0f;
674 _num_delta_time_diffing = 0;
738 #define RNA_PATH_BUFFSIZE 8192
741 char *rna_path = rna_path_buffer;
742 size_t rna_path_len = 0;
746 BLI_assert(strlen(root_path) == root_path_len);
748 const char *prop_name = prop_local.
identifier;
749 const size_t prop_name_len = strlen(prop_name);
753 rna_path_len = root_path_len + 1 + prop_name_len;
755 rna_path =
MEM_mallocN(rna_path_len + 1, __func__);
758 memcpy(rna_path, root_path, root_path_len);
759 rna_path[root_path_len] =
'.';
760 memcpy(rna_path + root_path_len + 1, prop_name, prop_name_len);
761 rna_path[rna_path_len] =
'\0';
764 rna_path_len = root_path_len + 2 + prop_name_len + 2;
766 rna_path =
MEM_mallocN(rna_path_len + 1, __func__);
769 memcpy(rna_path, root_path, root_path_len);
770 rna_path[root_path_len] =
'[';
771 rna_path[root_path_len + 1] =
'"';
772 memcpy(rna_path + root_path_len + 2, prop_name, prop_name_len);
773 rna_path[root_path_len + 2 + prop_name_len] =
'"';
774 rna_path[root_path_len + 2 + prop_name_len + 1] =
']';
775 rna_path[rna_path_len] =
'\0';
781 if (rna_path !=
NULL) {
782 rna_path_len = strlen(rna_path);
785 if (rna_path ==
NULL) {
792 if (ignore_overridden && op !=
NULL) {
795 if (rna_path != rna_path_buffer) {
801 #ifdef DEBUG_OVERRIDE_TIMEIT
818 #ifdef DEBUG_OVERRIDE_TIMEIT
821 _delta_time_diffing += _delta_time;
822 _num_delta_time_diffing++;
826 matching = matching &&
diff == 0;
827 if (r_report_flags) {
828 *r_report_flags |= report_flags;
847 .subitem_reference_index = -1,
848 .subitem_local_index = -1,
861 if (r_report_flags) {
868 BLI_assert(!
"We have differences between reference and "
869 "overriding data on non-editable property.");
878 if (!(do_create || do_restore)) {
880 if (rna_path != rna_path_buffer) {
888 if (rna_path != rna_path_buffer) {
891 #undef RNA_PATH_BUFFSIZE
895 #ifdef DEBUG_OVERRIDE_TIMEIT
898 _sum_time_global += _delta_time;
900 _sum_time_diffing += _delta_time_diffing;
902 printf(
"ID: %s\n", ((
ID *)ptr_local->
owner_id)->name);
903 printf(
"time end (%s): %.6f\n", __func__, _delta_time);
904 printf(
"time averaged (%s): %.6f (total: %.6f, in %d runs)\n",
906 (_sum_time_global / _num_time_global),
908 (
int)_num_time_global);
909 printf(
"diffing time end (%s): %.6f (in %d runs)\n",
912 _num_delta_time_diffing);
913 printf(
"diffing time averaged (%s): %.6f (total: %.6f, in %d runs)\n",
915 (_sum_time_diffing / _num_time_diffing),
917 (
int)_num_time_diffing);
934 bool changed =
false;
936 #ifdef DEBUG_OVERRIDE_TIMEIT
967 #ifdef DEBUG_OVERRIDE_TIMEIT
1000 if (prop_storage !=
NULL) {
1048 if (prop_storage !=
NULL) {
1066 *r_ptr_item_dst = private_ptr_item_dst;
1067 *r_ptr_item_src = private_ptr_item_src;
1068 if (prop_storage !=
NULL) {
1069 *r_ptr_item_storage = private_ptr_item_storage;
1072 if ((*r_ptr_item_dst)->type ==
NULL) {
1075 "Failed to find destination sub-item '%s' (%d) of '%s' in new override data '%s'",
1081 if ((*r_ptr_item_src)->type ==
NULL) {
1084 "Failed to find source sub-item '%s' (%d) of '%s' in old override data '%s'",
1129 const bool do_insert)
1132 if (!do_insert != !
ELEM(opop->operation,
1145 PointerRNA private_ptr_item_dst, private_ptr_item_src, private_ptr_item_storage;
1155 &private_ptr_item_dst,
1156 &private_ptr_item_src,
1157 &private_ptr_item_storage,
1174 "Failed to apply '%s' override operation on %s\n",
1192 #ifdef DEBUG_OVERRIDE_TIMEIT
1199 bool do_insert =
false;
1200 for (
int i = 0; i < 2; i++, do_insert =
true) {
1208 ptr_dst, op->rna_path, &data_dst, &prop_dst, &data_item_dst) &&
1210 ptr_src, op->rna_path, &data_src, &prop_src, &data_item_src)) {
1218 ptr_storage, op->rna_path, &data_storage, &prop_storage, &data_item_storage);
1250 PointerRNA private_ptr_item_dst, private_ptr_item_src;
1260 &private_ptr_item_dst,
1261 &private_ptr_item_src,
1293 if (id_dst !=
NULL) {
1296 "%s: Ignoring local override on ID pointer property '%s', as requested by "
1297 "RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS flag",
1308 prop_storage ? &data_storage :
NULL,
1314 prop_storage ? &data_item_storage :
NULL,
1321 "Failed to apply library override operation to '%s.%s' "
1322 "(could not resolve some properties, local: %d, override: %d)",
1333 ID *id_dst = ptr_dst->
data;
1334 ID *id_src = ptr_src->
data;
1341 #ifdef DEBUG_OVERRIDE_TIMEIT
1354 if (rna_path !=
NULL) {
1356 (*r_owner_id)->override_library, rna_path);
1370 if (r_created !=
NULL) {
1375 if (rna_path !=
NULL) {
1400 op,
NULL,
NULL, index, index, strict, r_strict);
1407 const short operation,
1413 if (r_created !=
NULL) {
1424 op, operation,
NULL,
NULL, index, index, strict, r_strict, r_created);
1432 uint override_status = 0;
1435 return override_status;
1443 bmain,
ptr, prop, index,
false,
NULL);
1454 return override_status;
typedef float(TangentPoint)[2]
void BKE_pose_ensure(struct Main *bmain, struct Object *ob, struct bArmature *arm, const bool do_id_user)
bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL()
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
const struct IDTypeInfo * BKE_idtype_get_info_from_id(const struct ID *id)
struct IDOverrideLibraryProperty * BKE_lib_override_library_property_get(struct IDOverrideLibrary *override, const char *rna_path, bool *r_created)
struct IDOverrideLibraryProperty * BKE_lib_override_library_property_find(struct IDOverrideLibrary *override, const char *rna_path)
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(struct IDOverrideLibraryProperty *override_property, const short operation, const char *subitem_refname, const char *subitem_locname, const int subitem_refindex, const int subitem_locindex, const bool strict, bool *r_strict, bool *r_created)
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_find(struct IDOverrideLibraryProperty *override_property, const char *subitem_refname, const char *subitem_locname, const int subitem_refindex, const int subitem_locindex, const bool strict, bool *r_strict)
void BKE_lib_override_library_operations_tag(struct IDOverrideLibraryProperty *override_property, const short tag, const bool do_set)
bool BKE_lib_override_library_property_operation_operands_validate(struct IDOverrideLibraryPropertyOperation *override_property_operation, struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage)
#define LISTBASE_FOREACH(type, var, list)
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
#define CLOG_ERROR(clg_ref,...)
#define CLOG_INFO(clg_ref, level,...)
ID and Library types, which are fundamental for sdna.
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
@ LIB_TAG_LIB_OVERRIDE_NEED_RESYNC
@ LIB_EMBEDDED_DATA_LIB_OVERRIDE
@ IDOVERRIDE_LIBRARY_FLAG_LOCKED
@ IDOVERRIDE_LIBRARY_FLAG_MANDATORY
@ IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE
@ IDOVERRIDE_LIBRARY_TAG_UNUSED
#define ID_IS_OVERRIDE_LIBRARY(_id)
@ IDP_FLAG_OVERRIDABLE_LIBRARY
@ IDOVERRIDE_LIBRARY_OP_MULTIPLY
@ IDOVERRIDE_LIBRARY_OP_INSERT_AFTER
@ IDOVERRIDE_LIBRARY_OP_NOOP
@ IDOVERRIDE_LIBRARY_OP_SUBTRACT
@ IDOVERRIDE_LIBRARY_OP_ADD
@ IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE
@ IDOVERRIDE_LIBRARY_OP_REPLACE
@ NLATRACK_OVERRIDELIBRARY_LOCAL
@ CONSTRAINT_OVERRIDE_LIBRARY_LOCAL
@ eGpencilModifierFlag_OverrideLibrary_Local
@ eModifierFlag_OverrideLibrary_Local
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
Utility defines for timing/benchmarks.
#define TIMEIT_START_AVERAGED(var)
#define TIMEIT_END_AVERAGED(var)
#define RNA_POINTER_INVALIDATE(ptr)
@ RNA_OVERRIDE_STATUS_OVERRIDABLE
@ RNA_OVERRIDE_STATUS_MANDATORY
@ RNA_OVERRIDE_STATUS_OVERRIDDEN
@ RNA_OVERRIDE_STATUS_LOCKED
@ RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS
@ RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN
@ RNA_OVERRIDE_COMPARE_CREATE
@ RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE
@ RNA_OVERRIDE_COMPARE_RESTORE
@ RNA_EQ_UNSET_MATCH_NONE
@ RNA_OVERRIDE_MATCH_RESULT_RESTORED
@ RNA_OVERRIDE_MATCH_RESULT_CREATED
StructRNA RNA_GpencilModifier
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
@ PROPOVERRIDE_NO_COMPARISON
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt=1)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
void rna_property_rna_or_id_get(PropertyRNA *prop, PointerRNA *ptr, PropertyRNAOrID *r_prop_rna_or_id)
PropertyRNA * rna_ensure_property(PropertyRNA *prop)
bool RNA_struct_is_ID(const StructRNA *type)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter)
PropertyType RNA_property_type(PropertyRNA *prop)
PropertyRNA * rna_ensure_property_realdata(PropertyRNA **prop, PointerRNA *ptr)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
void rna_idproperty_touch(IDProperty *idprop)
char * RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
IDProperty * RNA_struct_idprops(PointerRNA *ptr, bool create)
ID * RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
void RNA_property_collection_next(CollectionPropertyIterator *iter)
bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, PointerRNA *r_item_ptr)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
void RNA_property_collection_end(CollectionPropertyIterator *iter)
bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop_orig)
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop)
static void rna_property_override_check_resync(Main *bmain, PointerRNA *ptr_dst, PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src)
static void rna_porperty_override_collection_subitem_lookup(PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage, PointerRNA **r_ptr_item_dst, PointerRNA **r_ptr_item_src, PointerRNA **r_ptr_item_storage, PointerRNA *private_ptr_item_dst, PointerRNA *private_ptr_item_src, PointerRNA *private_ptr_item_storage, IDOverrideLibraryProperty *op, IDOverrideLibraryPropertyOperation *opop)
bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACompareMode mode)
static ID * rna_property_override_property_real_id_owner(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, char **r_rna_path)
IDOverrideLibraryPropertyOperation * RNA_property_override_property_operation_get(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const short operation, const int index, const bool strict, bool *r_strict, bool *r_created)
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)
int RNA_property_override_flag(PropertyRNA *prop)
static bool rna_property_override_operation_apply(Main *bmain, PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage, PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *ptr_item_storage, IDOverrideLibraryPropertyOperation *opop)
IDOverrideLibraryProperty * RNA_property_override_property_find(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, ID **r_owner_id)
#define RNA_PATH_BUFFSIZE
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_overridable_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_overridable_library_set(PointerRNA *UNUSED(ptr), PropertyRNA *prop, const bool is_overridable)
bool RNA_struct_override_store(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, IDOverrideLibrary *override)
void RNA_struct_override_apply(Main *bmain, PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, IDOverrideLibrary *override, const eRNAOverrideApplyFlag flag)
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 *override, const eRNAOverrideMatch flags, eRNAOverrideMatchResult *r_report_flags)
bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_comparable(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
IDOverrideLibraryProperty * RNA_property_override_property_get(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, bool *r_created)
eRNAOverrideStatus RNA_property_override_library_status(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const int index)
bool RNA_property_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, PropertyRNA *prop, eRNACompareMode mode)
bool RNA_struct_override_matches(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, const char *root_path, const size_t root_path_len, IDOverrideLibrary *override, const eRNAOverrideMatch flags, eRNAOverrideMatchResult *r_report_flags)
static void rna_property_override_apply_ex(Main *bmain, PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage, PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *ptr_item_storage, IDOverrideLibraryProperty *op, const bool do_insert)
bool RNA_property_copy(Main *bmain, PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index)
int rna_property_override_diff_default(struct Main *bmain, struct PropertyRNAOrID *prop_a, struct PropertyRNAOrID *prop_b, const int mode, struct IDOverrideLibrary *override, const char *rna_path, const size_t rna_path_len, const int flags, bool *r_override_changed)
bool rna_property_override_apply_default(struct Main *bmain, struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, const int len_dst, const int len_src, const int len_storage, struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, struct IDOverrideLibraryPropertyOperation *opop)
bool rna_property_override_store_default(struct Main *bmain, struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, const int len_local, const int len_reference, const int len_storage, struct IDOverrideLibraryPropertyOperation *opop)
bool(* RNAPropOverrideStore)(struct Main *bmain, struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, const int len_local, const int len_reference, const int len_storage, struct IDOverrideLibraryPropertyOperation *opop)
bool(* RNAPropOverrideApply)(struct Main *bmain, struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, const int len_dst, const int len_src, const int len_storage, struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, struct IDOverrideLibraryPropertyOperation *opop)
int(* RNAPropOverrideDiff)(struct Main *bmain, struct PropertyRNAOrID *prop_a, struct PropertyRNAOrID *prop_b, const int mode, struct IDOverrideLibrary *override, const char *rna_path, const size_t rna_path_len, const int flags, bool *r_override_changed)
int subitem_reference_index
char * subitem_local_name
char * subitem_reference_name
IDTypeLibOverrideApplyPost lib_override_apply_post
IDOverrideLibrary * override_library
RNAPropOverrideApply override_apply
RNAPropOverrideStore override_store
RNAPropOverrideDiff override_diff
double PIL_check_seconds_timer(void)
ccl_device_inline int mod(int x, int m)