74 const int flag =
data->flag;
79 cb_flag = ((cb_flag |
data->cb_flag) & ~
data->cb_flag_clear);
87 const int callback_return =
data->callback(
90 .id_owner =
data->owner_id,
91 .id_self =
data->self_id,
116 const bool do_replace)
118 const int cb_flag_backup =
data->cb_flag;
120 data->cb_flag = cb_flag;
123 data->cb_flag |= cb_flag;
125 return cb_flag_backup;
151 const int flag =
data->flag;
227 #define CALLBACK_INVOKE_ID(check_id, cb_flag) \
229 CHECK_TYPE_ANY((check_id), ID *, void *); \
230 BKE_lib_query_foreachid_process(&data, (ID **)&(check_id), (cb_flag)); \
231 if (BKE_lib_query_foreachid_iter_stop(&data)) { \
232 library_foreach_ID_data_cleanup(&data); \
238 #define CALLBACK_INVOKE(check_id_super, cb_flag) \
240 CHECK_TYPE(&((check_id_super)->id), ID *); \
241 BKE_lib_query_foreachid_process(&data, (ID **)&(check_id_super), (cb_flag)); \
242 if (BKE_lib_query_foreachid_iter_stop(&data)) { \
243 library_foreach_ID_data_cleanup(&data); \
262 if (inherit_data ==
NULL) {
286 to_id_entry = to_id_entry->next) {
288 &
data, to_id_entry->id_pointer.to, to_id_entry->usage_flag);
346 #undef CALLBACK_INVOKE_ID
347 #undef CALLBACK_INVOKE
373 const short id_type_owner =
GS(id_owner->
name);
397 switch ((
ID_Type)id_type_owner) {
491 const short id_type_owner =
GS(id_owner->
name);
493 if (id_type_used ==
ID_LI) {
494 return id_type_owner ==
ID_LI;
498 if (id_type_used ==
ID_KE) {
503 if (id_type_used ==
ID_SCR) {
509 return (can_be_used & filter_id_type_used) != 0;
526 const int cb_flag = cb_data->
cb_flag;
537 if (*id_p == iter->
id) {
540 "%s uses %s (refcounted: %d, userone: %d, used_one: %d, used_one_active: %d, "
541 "indirect_usage: %d)\n",
544 (cb_flag & IDWALK_USER) ? 1 : 0,
545 (cb_flag & IDWALK_USER_ONE) ? 1 : 0,
548 (cb_flag & IDWALK_INDIRECT_USAGE) ? 1 : 0);
583 bool is_defined =
false;
587 while (i-- && !is_defined) {
588 ID *id_curr = lb_array[i]->
first;
594 for (; id_curr && !is_defined; id_curr = id_curr->
next) {
626 bool is_defined =
false;
630 while (i-- && !is_defined) {
631 ID *id_curr = lb_array[i]->
first;
637 for (; id_curr && !is_defined; id_curr = id_curr->
next) {
660 const bool do_local_ids,
661 const bool do_linked_ids,
685 if ((
id->
tag & tag) != 0) {
723 bool has_valid_from_users =
false;
724 bool is_part_of_dependency_loop =
false;
727 id_from_item = id_from_item->next) {
728 if ((id_from_item->usage_flag & ignored_usages) != 0 ||
729 (id_from_item->usage_flag & required_usages) == 0) {
733 ID *id_from = id_from_item->id_pointer.from;
742 bmain, tag, do_local_ids, do_linked_ids, id_from, r_num_tagged)) {
745 is_part_of_dependency_loop =
true;
748 if ((id_from->
tag & tag) == 0) {
749 has_valid_from_users =
true;
753 if (!has_valid_from_users && !is_part_of_dependency_loop) {
756 if (r_num_tagged !=
NULL) {
771 if (has_valid_from_users || !is_part_of_dependency_loop) {
775 return is_part_of_dependency_loop;
780 const bool do_local_ids,
781 const bool do_linked_ids,
782 const bool do_tag_recursive,
792 else if (
id->
us == 0) {
794 if (r_num_tagged !=
NULL) {
805 if (!do_tag_recursive) {
812 bmain, tag, do_local_ids, do_linked_ids,
id, r_num_tagged)) {
821 if ((
id->
tag & tag) == 0) {
827 if (r_num_tagged !=
NULL) {
853 const int cb_flag = cb_data->
cb_flag;
890 for (
bool do_loop =
true; do_loop;) {
void BKE_animdata_foreach_id(struct AnimData *adt, struct LibraryForeachIDData *data)
struct AnimData * BKE_animdata_from_id(const struct ID *id)
void IDP_foreach_property(struct IDProperty *id_property_root, int type_filter, IDPForeachPropertyCallback callback, void *user_data)
uint64_t BKE_idtype_idcode_to_idfilter(short idcode)
int BKE_idtype_idcode_to_index(short idcode)
const struct IDTypeInfo * BKE_idtype_get_info_from_id(const struct ID *id)
void id_us_min(struct ID *id)
void id_us_ensure_real(struct ID *id)
void id_us_plus(struct ID *id)
int(* LibraryIDLinkCallback)(LibraryIDLinkCallbackData *cb_data)
@ IDWALK_DO_INTERNAL_RUNTIME_POINTERS
@ IDWALK_IGNORE_EMBEDDED_ID
@ IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE
@ IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE
@ IDWALK_CB_INDIRECT_USAGE
@ IDWALK_RET_STOP_RECURSION
#define BKE_LIB_FOREACHID_PROCESS_ID(_data, _id, _cb_flag)
#define FOREACH_MAIN_ID_END
int set_listbasepointers(struct Main *main, struct ListBase *lb[])
@ MAINIDRELATIONS_INCLUDE_UI
@ MAINIDRELATIONS_ENTRY_TAGS_PROCESSED
@ MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS
void BKE_main_relations_create(struct Main *bmain, short flag)
void BKE_main_relations_free(struct Main *bmain)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
struct bNodeTree * ntreeFromID(struct ID *id)
#define BLI_assert_unreachable()
unsigned int BLI_ghashutil_ptrhash(const void *key)
GSet * BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
bool BLI_ghashutil_ptrcmp(const void *a, const void *b)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
bool BLI_gset_add(GSet *gs, void *key)
BLI_LINKSTACK_*** wrapper macros for using a LinkNode to store a stack of pointers,...
#define BLI_LINKSTACK_PUSH(var, ptr)
#define BLI_LINKSTACK_FREE(var)
#define BLI_LINKSTACK_INIT(var)
#define BLI_LINKSTACK_POP(var)
#define LISTBASE_FOREACH(type, var, list)
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
@ IDP_FLAG_OVERRIDABLE_LIBRARY
#define FILTER_ID_CU_LEGACY
#define ID_IS_LINKED(_id)
@ LIB_TAG_NO_USER_REFCOUNT
DEGForeachIDComponentCallback callback
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
void BKE_lib_query_foreachid_process(LibraryForeachIDData *data, ID **id_pp, int cb_flag)
void BKE_library_ID_test_usages(Main *bmain, void *idv, bool *is_used_local, bool *is_used_linked)
static bool library_foreach_ID_link(Main *bmain, ID *id_owner, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag, LibraryForeachIDData *inherit_data)
void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
struct LibraryForeachIDData LibraryForeachIDData
bool BKE_library_ID_is_indirectly_used(Main *bmain, void *idv)
void BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp)
static bool library_ID_is_used(Main *bmain, void *idv, const bool check_linked)
void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
static bool lib_query_unused_ids_tag_recurse(Main *bmain, const int tag, const bool do_local_ids, const bool do_linked_ids, ID *id, int *r_num_tagged)
int BKE_library_ID_use_ID(ID *id_user, ID *id_used)
static void library_foreach_ID_data_cleanup(LibraryForeachIDData *data)
int BKE_lib_query_foreachid_process_flags_get(LibraryForeachIDData *data)
int BKE_lib_query_foreachid_process_callback_flag_override(LibraryForeachIDData *data, const int cb_flag, const bool do_replace)
#define CALLBACK_INVOKE_ID(check_id, cb_flag)
void BKE_lib_query_idpropertiesForeachIDLink_callback(IDProperty *id_prop, void *user_data)
static int foreach_libblock_id_users_callback(LibraryIDLinkCallbackData *cb_data)
uint64_t BKE_library_id_can_use_filter_id(const ID *id_owner)
void BKE_lib_query_unused_ids_tag(Main *bmain, const int tag, const bool do_local_ids, const bool do_linked_ids, const bool do_tag_recursive, int *r_num_tagged)
void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cb_flag)
bool BKE_lib_query_foreachid_iter_stop(LibraryForeachIDData *data)
struct IDUsersIter IDUsersIter
bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
void BKE_library_indirectly_used_data_tag_clear(Main *bmain)
bool BKE_library_ID_is_locally_used(Main *bmain, void *idv)
static int foreach_libblock_used_linked_data_tag_clear_cb(LibraryIDLinkCallbackData *cb_data)
unsigned __int64 uint64_t
struct ID * hierarchy_root
IDTypeEmbeddedOwnerGetFunction owner_get
IDTypeForeachIDFunction foreach_id
ListBase * lb_array[INDEX_ID_MAX]
IDOverrideLibrary * override_library
BLI_LINKSTACK_DECLARE(ids_todo, ID *)
LibraryIDLinkCallback callback
struct MainIDRelationsEntryItem * to_ids
struct MainIDRelationsEntryItem * from_ids
struct GHash * relations_from_pointers
struct MainIDRelations * relations