Blender
V3.3
|
#include <stdlib.h>
#include "DNA_anim_types.h"
#include "BLI_ghash.h"
#include "BLI_linklist_stack.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_anim_data.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_node.h"
Go to the source code of this file.
Classes | |
struct | LibraryForeachIDData |
struct | IDUsersIter |
Macros | |
#define | CALLBACK_INVOKE_ID(check_id, cb_flag) |
#define | CALLBACK_INVOKE(check_id_super, cb_flag) |
Typedefs | |
typedef struct LibraryForeachIDData | LibraryForeachIDData |
typedef struct IDUsersIter | IDUsersIter |
Enumerations | |
enum | { IDWALK_STOP = 1 << 0 } |
#define CALLBACK_INVOKE | ( | check_id_super, | |
cb_flag | |||
) |
#define CALLBACK_INVOKE_ID | ( | check_id, | |
cb_flag | |||
) |
typedef struct IDUsersIter IDUsersIter |
typedef struct LibraryForeachIDData LibraryForeachIDData |
anonymous enum |
Enumerator | |
---|---|
IDWALK_STOP |
Definition at line 26 of file lib_query.c.
bool BKE_lib_query_foreachid_iter_stop | ( | struct LibraryForeachIDData * | data | ) |
Check whether current iteration over ID usages should be stopped or not.
Definition at line 63 of file lib_query.c.
References data, and IDWALK_STOP.
Referenced by BKE_lib_query_foreachid_process(), BKE_library_foreach_ID_embedded(), library_foreach_ID_link(), and window_manager_foreach_id().
void BKE_lib_query_foreachid_process | ( | LibraryForeachIDData * | data, |
ID ** | id_pp, | ||
int | cb_flag | ||
) |
Definition at line 68 of file lib_query.c.
References BKE_lib_query_foreachid_iter_stop(), BLI_assert, BLI_gset_add(), BLI_LINKSTACK_PUSH, data, IDWALK_CB_INTERNAL, IDWALK_CB_LOOPBACK, IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE, IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE, IDWALK_READONLY, IDWALK_RECURSE, IDWALK_RET_STOP_ITER, IDWALK_RET_STOP_RECURSION, and IDWALK_STOP.
Referenced by BKE_library_foreach_ID_embedded(), library_foreach_constraintObjectLooper(), library_foreach_gpencil_modifiersForeachIDLink(), library_foreach_ID_link(), library_foreach_modifiersForeachIDLink(), library_foreach_particlesystemsObjectLooper(), library_foreach_shaderfxForeachIDLink(), scene_foreach_rigidbodyworldSceneLooper(), and window_manager_foreach_id().
int BKE_lib_query_foreachid_process_callback_flag_override | ( | LibraryForeachIDData * | data, |
const int | cb_flag, | ||
const bool | do_replace | ||
) |
Definition at line 114 of file lib_query.c.
References data.
int BKE_lib_query_foreachid_process_flags_get | ( | LibraryForeachIDData * | data | ) |
Definition at line 109 of file lib_query.c.
References data.
Referenced by screen_foreach_id(), and window_manager_foreach_id().
void BKE_lib_query_idpropertiesForeachIDLink_callback | ( | IDProperty * | id_prop, |
void * | user_data | ||
) |
Definition at line 136 of file lib_query.c.
References BKE_LIB_FOREACHID_PROCESS_ID, BLI_assert, data, IDProperty::data, IDProperty::flag, IDP_FLAG_OVERRIDABLE_LIBRARY, IDP_ID, IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE, IDWALK_CB_USER, IDPropertyData::pointer, IDProperty::type, and user_data.
Referenced by armature_foreach_id_bone(), armature_foreach_id_editbone(), BKE_fcurve_foreach_id(), library_foreach_ID_link(), library_foreach_node_socket(), node_foreach_id(), object_foreach_id(), scene_foreach_id(), and seq_foreach_member_id_cb().
void BKE_lib_query_unused_ids_tag | ( | struct Main * | bmain, |
int | tag, | ||
bool | do_local_ids, | ||
bool | do_linked_ids, | ||
bool | do_tag_recursive, | ||
int * | r_num_tagged | ||
) |
Tag all unused IDs (a.k.a 'orphaned').
By default only tag IDs with 0
user count. If do_tag_recursive
is set, it will check dependencies to detect all IDs that are not actually used in current file, including 'archipelagos‘ (i.e. set of IDs referencing each other in loops, but without any 'external’ valid usages.
Valid usages here are defined as ref-counting usages, which are not towards embedded or loop-back data.
r_num_tagged | If non-NULL, must be a zero-initialized array of INDEX_ID_MAX integers. Number of tagged-as-unused IDs is then set for each type, and as total in INDEX_ID_NULL item. |
Definition at line 778 of file lib_query.c.
References BKE_idtype_idcode_to_index(), BKE_main_relations_create(), BKE_main_relations_free(), BLI_assert, BLI_ghash_lookup(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, GS, id, ID_IS_LINKED, INDEX_ID_NULL, lib_query_unused_ids_tag_recurse(), MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, ID::name, NULL, Main::relations, MainIDRelations::relations_from_pointers, ID::tag, MainIDRelationsEntry::tags, and ID::us.
Referenced by bpy_orphans_purge(), outliner_orphans_purge_exec(), and outliner_orphans_purge_invoke().
void BKE_library_foreach_ID_embedded | ( | struct LibraryForeachIDData * | data, |
struct ID ** | id_pp | ||
) |
Process embedded ID pointers (root node-trees, master collections, ...).
Those require specific care, since they are technically sub-data of their owner, yet in some cases they still behave as regular IDs.
Definition at line 147 of file lib_query.c.
References BKE_lib_query_foreachid_iter_stop(), BKE_lib_query_foreachid_process(), BLI_assert, BLI_gset_add(), BLI_LINKSTACK_PUSH, data, IDWALK_CB_EMBEDDED, IDWALK_IGNORE_EMBEDDED_ID, IDWALK_RECURSE, IDWALK_STOP, library_foreach_ID_link(), and NULL.
Referenced by light_foreach_id(), linestyle_foreach_id(), material_foreach_id(), scene_foreach_id(), simulation_foreach_id(), texture_foreach_id(), and world_foreach_id().
void BKE_library_foreach_ID_link | ( | struct Main * | bmain, |
struct ID * | id, | ||
LibraryIDLinkCallback | callback, | ||
void * | user_data, | ||
int | flag | ||
) |
Loop over all of the ID's this data-block links to.
Definition at line 350 of file lib_query.c.
References callback, library_foreach_ID_link(), NULL, and user_data.
Referenced by BKE_blendfile_append(), BKE_blendfile_link(), BKE_id_copy_ex(), BKE_lib_id_clear_library_data(), BKE_lib_id_expand_local(), BKE_lib_override_library_is_hierarchy_leaf(), BKE_libblock_management_main_add(), BKE_libblock_management_usercounts_clear(), BKE_libblock_management_usercounts_set(), BKE_library_ID_test_usages(), BKE_library_ID_use_ID(), BKE_library_indirectly_used_data_tag_clear(), BKE_library_unused_linked_data_set_tag(), BKE_main_id_refcount_recompute(), BKE_main_relations_create(), BKE_mesh_new_from_object_to_bmain(), bpy_user_map(), brush_undo_preserve(), blender::deg::deg_validate_copy_on_write_datablock(), foreach_libblock_link_append_callback(), gather_frames_to_render(), lib_link_main_data_restore(), lib_override_libraries_index_define(), libblock_relink_to_newid_prepare_data(), libblock_remap_data(), library_ID_is_used(), memfile_undosys_step_decode(), previews_ensure_exec(), tag_localizable_objects(), and blender::deg::DepsgraphNodeBuilder::update_invalid_cow_pointers().
Definition at line 367 of file lib_query.c.
References BKE_animdata_from_id(), BLI_assert_unreachable, ELEM, FILTER_ID_ALL, FILTER_ID_BR, FILTER_ID_CU_LEGACY, FILTER_ID_GD, FILTER_ID_GR, FILTER_ID_IM, FILTER_ID_KE, FILTER_ID_LI, FILTER_ID_LS, FILTER_ID_LT, FILTER_ID_MA, FILTER_ID_MC, FILTER_ID_ME, FILTER_ID_MSK, FILTER_ID_NT, FILTER_ID_OB, FILTER_ID_PAL, FILTER_ID_PC, FILTER_ID_SCE, FILTER_ID_SO, FILTER_ID_TE, FILTER_ID_TXT, FILTER_ID_VF, FILTER_ID_WO, FILTER_ID_WS, GS, ID_AC, ID_AR, ID_BR, ID_CA, ID_CF, ID_CU_LEGACY, ID_CV, ID_GD, ID_GR, ID_IM, ID_IP, ID_IS_OVERRIDE_LIBRARY_REAL, ID_KE, ID_LA, ID_LI, ID_LP, ID_LS, ID_LT, ID_MA, ID_MB, ID_MC, ID_ME, ID_MSK, ID_NT, ID_OB, ID_PA, ID_PAL, ID_PC, ID_PT, ID_SCE, ID_SCR, ID_SIM, ID_SO, ID_SPK, ID_TE, ID_TXT, ID_VF, ID_VO, ID_WM, ID_WO, ID_WS, ID::name, ntreeFromID(), and ID::properties.
Referenced by BKE_library_id_can_use_idtype().
Say whether given id_owner may use (in any way) a data-block of id_type_used.
This is a 'simplified' abstract version of BKE_library_foreach_ID_link() above, quite useful to reduce useless iterations in some cases.
Definition at line 484 of file lib_query.c.
References BKE_idtype_idcode_to_idfilter(), BKE_library_id_can_use_filter_id(), ELEM, GS, ID_CU_LEGACY, ID_KE, ID_LI, ID_LT, ID_ME, ID_SCR, ID_WS, ID::name, and ID::properties.
Referenced by BKE_library_ID_test_usages(), and library_ID_is_used().
Check whether given ID is used indirectly (i.e. by another linked ID).
Definition at line 615 of file lib_query.c.
References library_ID_is_used().
Referenced by BKE_brush_delete(), ED_object_base_free_and_unlink(), ED_object_base_free_and_unlink_no_indirect_check(), id_delete_tag(), object_delete_exec(), outliner_batch_delete_hierarchy(), and outliner_object_delete_fn().
Check whether given ID is used locally (i.e. by another non-linked ID).
Definition at line 610 of file lib_query.c.
References library_ID_is_used().
void BKE_library_ID_test_usages | ( | struct Main * | bmain, |
void * | idv, | ||
bool * | is_used_local, | ||
bool * | is_used_linked | ||
) |
Combine BKE_library_ID_is_locally_used() and BKE_library_ID_is_indirectly_used() in a single call.
Definition at line 620 of file lib_query.c.
References BKE_library_foreach_ID_link(), BKE_library_id_can_use_idtype(), IDUsersIter::count_direct, IDUsersIter::count_indirect, IDUsersIter::curr_id, ListBase::first, foreach_libblock_id_users_callback(), GS, IDUsersIter::id, id, IDWALK_READONLY, INDEX_ID_MAX, ID::name, ID::next, and set_listbasepointers().
Referenced by BKE_lib_id_make_local_generic_action_define().
Return the number of times given id_user uses/references id_used.
id_user | the ID which is supposed to use (reference) id_used. |
id_used | the ID which is supposed to be used (referenced) by id_user. |
Definition at line 562 of file lib_query.c.
References BKE_library_foreach_ID_link(), IDUsersIter::count_direct, IDUsersIter::count_indirect, IDUsersIter::curr_id, foreach_libblock_id_users_callback(), IDUsersIter::id, IDWALK_READONLY, and NULL.
Untag linked data blocks used by other untagged linked data-blocks. Used to detect data-blocks that we can forcefully make local (instead of copying them to later get rid of original): All data-blocks we want to make local are tagged by caller, after this function has ran caller knows data-blocks still tagged can directly be made local, since they are only used by other data-blocks that will also be made fully local.
Definition at line 903 of file lib_query.c.
References BKE_library_foreach_ID_link(), foreach_libblock_used_linked_data_tag_clear_cb(), id, ID_IS_LINKED, IDWALK_READONLY, INDEX_ID_MAX, LIB_TAG_DOIT, LISTBASE_FOREACH, set_listbasepointers(), and ID::tag.
Detect orphaned linked data blocks (i.e. linked data not used (directly or indirectly) in any way by any local data), including complex cases like 'linked archipelagoes', i.e. linked data-blocks that use each other in loops, which prevents their deletion by 'basic' usage checks.
do_init_tag | if true, all linked data are checked, if false, only linked data-blocks already tagged with LIB_TAG_DOIT are checked. |
Definition at line 874 of file lib_query.c.
References BKE_library_foreach_ID_link(), foreach_libblock_used_linked_data_tag_clear_cb(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, id, IDWALK_READONLY, ID::lib, LIB_TAG_DOIT, LIB_TAG_INDIRECT, and ID::tag.
Re-usable function, use when replacing ID's.
Definition at line 356 of file lib_query.c.
References id_us_ensure_real(), id_us_min(), id_us_plus(), IDWALK_CB_USER, and IDWALK_CB_USER_ONE.
|
static |
Definition at line 523 of file lib_query.c.
References LibraryIDLinkCallbackData::cb_flag, IDUsersIter::count_direct, IDUsersIter::count_indirect, IDUsersIter::curr_id, IDUsersIter::id, LibraryIDLinkCallbackData::id_pointer, IDWALK_CB_INDIRECT_USAGE, IDWALK_CB_LOOPBACK, IDWALK_RET_NOP, LIB_TAG_EXTRAUSER, LIB_TAG_EXTRAUSER_SET, ID::name, ID::tag, and LibraryIDLinkCallbackData::user_data.
Referenced by BKE_library_ID_test_usages(), BKE_library_ID_use_ID(), and library_ID_is_used().
|
static |
Definition at line 849 of file lib_query.c.
References LibraryIDLinkCallbackData::cb_flag, LibraryIDLinkCallbackData::id_pointer, LibraryIDLinkCallbackData::id_self, IDWALK_CB_LOOPBACK, IDWALK_RET_NOP, LIB_TAG_DOIT, ID::tag, and LibraryIDLinkCallbackData::user_data.
Referenced by BKE_library_indirectly_used_data_tag_clear(), and BKE_library_unused_linked_data_set_tag().
|
static |
Definition at line 658 of file lib_query.c.
References BKE_idtype_get_info_from_id(), BKE_idtype_idcode_to_index(), BLI_assert, BLI_ghash_lookup(), ELEM, ID::flag, MainIDRelationsEntry::from_ids, GS, id, ID_IM, ID_IS_LINKED, ID_LI, ID_SCE, ID_SCR, ID_WM, ID_WS, IDWALK_CB_EMBEDDED, IDWALK_CB_LOOPBACK, IDWALK_CB_USER, IDWALK_CB_USER_ONE, IMA_SRC_VIEWER, image(), INDEX_ID_NULL, LIB_EMBEDDED_DATA, LIB_FAKEUSER, MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, ID::name, NULL, IDTypeInfo::owner_get, Main::relations, MainIDRelations::relations_from_pointers, ID::tag, and MainIDRelationsEntry::tags.
Referenced by BKE_lib_query_unused_ids_tag().
|
static |
Definition at line 184 of file lib_query.c.
References BLI_gset_free(), BLI_LINKSTACK_FREE, data, and NULL.
Referenced by library_foreach_ID_link().
|
static |
Definition at line 193 of file lib_query.c.
References BKE_animdata_foreach_id(), BKE_animdata_from_id(), BKE_idtype_get_info_from_id(), BKE_lib_query_foreachid_iter_stop(), BKE_lib_query_foreachid_process(), BKE_lib_query_idpropertiesForeachIDLink_callback(), BLI_assert, BLI_ghash_lookup(), BLI_ghashutil_ptrcmp(), BLI_ghashutil_ptrhash(), BLI_gset_add(), BLI_gset_new(), BLI_LINKSTACK_INIT, BLI_LINKSTACK_POP, LibraryForeachIDData::bmain, callback, CALLBACK_INVOKE_ID, LibraryForeachIDData::cb_flag, LibraryForeachIDData::cb_flag_clear, data, MainIDRelations::flag, IDTypeInfo::foreach_id, IDOverrideLibrary::hierarchy_root, id, ID_IS_LINKED, IDP_foreach_property(), IDP_TYPE_FILTER_ID, IDWALK_CB_INDIRECT_USAGE, IDWALK_CB_INTERNAL, IDWALK_CB_LOOPBACK, IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE, IDWALK_CB_USER, IDWALK_CB_USER_ONE, IDWALK_DO_INTERNAL_RUNTIME_POINTERS, IDWALK_INCLUDE_UI, IDWALK_READONLY, IDWALK_RECURSE, LIB_EMBEDDED_DATA, LIB_TAG_NO_USER_REFCOUNT, library_foreach_ID_data_cleanup(), MAINIDRELATIONS_INCLUDE_UI, ID::newid, NULL, ID::orig_id, ID::override_library, ID::properties, IDOverrideLibrary::reference, Main::relations, MainIDRelations::relations_from_pointers, IDOverrideLibrary::storage, MainIDRelationsEntry::to_ids, and user_data.
Referenced by BKE_library_foreach_ID_embedded(), and BKE_library_foreach_ID_link().
Definition at line 577 of file lib_query.c.
References BKE_library_foreach_ID_link(), BKE_library_id_can_use_idtype(), IDUsersIter::count_direct, IDUsersIter::count_indirect, IDUsersIter::curr_id, ListBase::first, foreach_libblock_id_users_callback(), GS, IDUsersIter::id, id, IDWALK_READONLY, INDEX_ID_MAX, ID::name, ID::next, and set_listbasepointers().
Referenced by BKE_library_ID_is_indirectly_used(), and BKE_library_ID_is_locally_used().