Blender
V3.3
|
Go to the source code of this file.
Macros | |
#define | BLENDFILE_LINK_APPEND_INVALID -1 |
Typedefs | |
typedef struct BlendfileLinkAppendContext | BlendfileLinkAppendContext |
typedef struct BlendfileLinkAppendContextItem | BlendfileLinkAppendContextItem |
typedef enum eBlendfileLinkAppendForeachItemFlag | eBlendfileLinkAppendForeachItemFlag |
typedef bool(* | BKE_BlendfileLinkAppendContexteItemFunction) (struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item, void *userdata) |
Enumerations | |
enum | eBlendfileLinkAppendForeachItemFlag { BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT = 1 << 0 , BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_INDIRECT = 1 << 1 } |
#define BLENDFILE_LINK_APPEND_INVALID -1 |
Definition at line 90 of file BKE_blendfile_link_append.h.
typedef bool(* BKE_BlendfileLinkAppendContexteItemFunction) (struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item, void *userdata) |
Callback called by BKE_blendfile_link_append_context_item_foreach over each (or a subset of each) of the items in given BlendfileLinkAppendContext.
userdata | An opaque void pointer passed to the callback_function . |
true
if iteration should continue, false
otherwise. Definition at line 149 of file BKE_blendfile_link_append.h.
typedef struct BlendfileLinkAppendContext BlendfileLinkAppendContext |
Definition at line 1 of file BKE_blendfile_link_append.h.
typedef struct BlendfileLinkAppendContextItem BlendfileLinkAppendContextItem |
Definition at line 1 of file BKE_blendfile_link_append.h.
Enumerator | |
---|---|
BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT | Loop over directly linked items (i.e. those explicitly defined by user code). |
BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_INDIRECT | Loop over indirectly linked items (i.e. those defined by internal code, as dependencies of direct ones). IMPORTANT: Those 'indirect' items currently may not cover all indirectly linked data. See comments in foreach_libblock_link_append_callback. |
Definition at line 131 of file BKE_blendfile_link_append.h.
void BKE_blendfile_append | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct ReportList * | reports | ||
) |
Perform append operation, using modern ID usage looper to detect which ID should be kept linked, made local, duplicated as local, re-used from local etc.
The IDs processed by this functions are the one that have been linked by a previous call to BKE_blendfile_link on the same lapp_context
.
Definition at line 1001 of file blendfile_link_append.c.
References BlendfileLinkAppendContextItem::action, BKE_id_multi_tagged_delete(), BKE_idtype_idcode_append_is_reusable(), BKE_lib_id_make_local(), BKE_libblock_relink_to_newid(), BKE_library_foreach_ID_link(), BKE_main_id_newptr_and_tag_clear(), BKE_main_id_tag_all(), BKE_main_library_weak_reference_add_item(), BKE_main_library_weak_reference_create(), BKE_main_library_weak_reference_destroy(), BKE_main_library_weak_reference_remove_item(), BKE_main_library_weak_reference_search_item(), blendfile_link_append_proxies_convert(), BLI_assert, BLI_assert_unreachable, BLI_strncpy(), BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR, BLO_LIBLINK_APPEND_LOCAL_ID_REUSE, BLO_LIBLINK_APPEND_SET_FAKEUSER, LibraryLink_Params::bmain, CLOG_ERROR, CLOG_INFO, ELEM, FILE_LINK, FILE_MAX, Library::filepath, LibraryLink_Params::flag, foreach_libblock_link_append_callback(), GS, id, id_fake_user_set(), ID_GR, ID_IS_LINKED, ID_NEW_SET, ID_OB, IDWALK_NOP, BlendfileLinkAppendContext::items, BlendfileLinkAppendContextCallBack::lapp_context, LooseDataInstantiateContext::lapp_context, ID::lib, LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR, LIB_ID_MAKELOCAL_FORCE_COPY, LIB_ID_MAKELOCAL_FORCE_LOCAL, LIB_ID_MAKELOCAL_FULL_LIBRARY, LIB_TAG_DOIT, LIB_TAG_PRE_EXISTING, BlendfileLinkAppendContext::library_weak_reference_mapping, LinkNode::link, LINK_APPEND_ACT_COPY_LOCAL, LINK_APPEND_ACT_KEEP_LINKED, LINK_APPEND_ACT_MAKE_LOCAL, LINK_APPEND_ACT_REUSE_LOCAL, LINK_APPEND_ACT_UNSET, LinkNodePair::list, LOG, loose_data_instantiate(), MAX_ID_NAME, ID::name, BlendfileLinkAppendContextItem::new_id, new_id_to_item_mapping_create(), ID::newid, LinkNode::next, NULL, BlendfileLinkAppendContext::num_items, BlendfileLinkAppendContext::params, ID::tag, and BlendfileLinkAppendContextItem::userdata.
Referenced by bpy_lib_exit(), copybuffer_append(), wm_file_link_append_datablock_ex(), and wm_link_append_exec().
void BKE_blendfile_library_relocate | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct ReportList * | reports, | ||
struct Library * | library, | ||
bool | do_reload | ||
) |
Try to relocate all linked IDs added to lapp_context
, belonging to the given library
.
This function searches for matching IDs (type and name) in all libraries added to the given lapp_context
.
Typical usages include:
lapp_context
.lapp_context
lapp_context
.lapp_context
.NOTE: content of lapp_context
after execution of that function should not be assumed valid anymore, and should immediately be freed.
Definition at line 1403 of file blendfile_link_append.c.
References BKE_blendfile_link(), BKE_blendfile_link_append_context_item_add(), BKE_id_free(), BKE_id_multi_tagged_delete(), BKE_idtype_idcode_is_linkable(), BKE_key_from_id(), BKE_key_from_id_p(), BKE_lib_override_library_main_operations_create(), BKE_lib_override_library_main_resync(), BKE_lib_override_library_update(), BKE_main_collection_sync(), BKE_main_id_refcount_recompute(), BKE_main_id_tag_all(), BKE_main_id_tag_idcode(), BKE_main_lock(), BKE_main_unlock(), BKE_view_layer_find(), blendfile_library_relocate_remap(), BLI_addtail(), BLI_assert, BLI_bitmap_set_all(), BLI_remlink(), LibraryLink_Params::bmain, CLOG_INFO, LibraryLink_Params::context, ListBase::first, ID::flag, FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, GS, id, Library::id, Key::id, Scene::id, ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY_REAL, ID_KE, ID_LI, ID_REMAP_SKIP_INDIRECT_USAGE, ID_REMAP_SKIP_NEVER_NULL_USAGE, ID_SCE, id_us_clear_real(), id_us_min(), id_us_plus_no_lib(), INDEX_ID_MAX, BlendfileLinkAppendContext::items, lib, ID::lib, LIB_TAG_DOIT, LIB_TAG_MISSING, LIB_TAG_PRE_EXISTING, BlendfileLinkAppendContextItem::libraries, library, LinkNode::link, LinkNodePair::list, LOG, ViewLayer::name, ID::name, BlendfileLinkAppendContextItem::new_id, LinkNode::next, ID::next, NULL, BlendfileLinkAppendContext::num_items, BlendfileLinkAppendContext::num_libraries, ID::override_library, BlendfileLinkAppendContext::params, IDOverrideLibrary::reference, LibraryLink_Params::scene, set_listbasepointers(), ID::tag, ID::us, USER_EXPERIMENTAL_TEST, BlendfileLinkAppendContextItem::userdata, LibraryLink_Params::view_layer, Scene::view_layers, and which_libbase().
Referenced by WM_lib_reload(), and wm_lib_relocate_exec_do().
void BKE_blendfile_link | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct ReportList * | reports | ||
) |
Perform linking operation on all items added to given lapp_context
.
Definition at line 1205 of file blendfile_link_append.c.
References BKE_library_foreach_ID_link(), BKE_reportf(), blendfile_link_append_proxies_convert(), BLI_assert, BLI_bitmap_set_all(), BLI_BITMAP_TEST, BLO_library_link_begin(), BLO_library_link_end(), BLO_library_link_named_part(), LibraryLink_Params::bmain, LibraryLink_Params::context, Main::curlib, FILE_LINK, LibraryLink_Params::flag, foreach_libblock_link_append_callback(), BlendfileLinkAppendContextItem::idcode, IDWALK_NOP, BlendfileLinkAppendContext::items, BlendfileLinkAppendContextCallBack::lapp_context, LooseDataInstantiateContext::lapp_context, lib, ID::lib, LIB_TAG_MISSING, BlendfileLinkAppendContextItem::libraries, BlendfileLinkAppendContext::libraries, LinkNode::link, link_append_context_library_blohandle_ensure(), link_append_context_library_blohandle_release(), LinkNodePair::list, loose_data_instantiate(), BlendfileLinkAppendContextItem::name, BlendfileLinkAppendContextItem::new_id, new_id_to_item_mapping_create(), LinkNode::next, NULL, BlendfileLinkAppendContext::num_items, BlendfileLinkAppendContext::num_libraries, BlendfileLinkAppendContext::params, BlendfileLinkAppendContextLibrary::path, RPT_WARNING, LibraryLink_Params::scene, BlendfileLinkAppendContextItem::source_library, Main::subversionfile, BlendfileLinkAppendContextItem::userdata, and Main::versionfile.
Referenced by BKE_blendfile_library_relocate(), bpy_lib_exit(), copybuffer_append(), wm_file_link_append_datablock_ex(), and wm_link_append_exec().
void BKE_blendfile_link_append_context_embedded_blendfile_clear | ( | struct BlendfileLinkAppendContext * | lapp_context | ) |
Clear reference to Blender's embedded startup file into the context.
Definition at line 225 of file blendfile_link_append.c.
References BlendfileLinkAppendContext::blendfile_mem, BlendfileLinkAppendContext::blendfile_memsize, and NULL.
void BKE_blendfile_link_append_context_embedded_blendfile_set | ( | struct BlendfileLinkAppendContext * | lapp_context, |
const void * | blendfile_mem, | ||
int | blendfile_memsize | ||
) |
Store reference to a Blender's embedded memfile into the context.
ED
module, which cannot be linked in BKE code. Definition at line 215 of file blendfile_link_append.c.
References BlendfileLinkAppendContext::blendfile_mem, BlendfileLinkAppendContext::blendfile_memsize, BLI_assert_msg, and NULL.
Referenced by wm_file_link_append_datablock_ex(), and wm_link_append_exec().
void BKE_blendfile_link_append_context_flag_set | ( | struct BlendfileLinkAppendContext * | lapp_context, |
int | flag, | ||
bool | do_set | ||
) |
Set or clear flags in given lapp_context.
flag | A combination of:
|
do_set | Set the given flag if true, clear it otherwise. |
Definition at line 203 of file blendfile_link_append.c.
References LibraryLink_Params::flag, and BlendfileLinkAppendContext::params.
Referenced by wm_lib_relocate_exec_do().
void BKE_blendfile_link_append_context_free | ( | struct BlendfileLinkAppendContext * | lapp_context | ) |
Free a link/append context.
Definition at line 186 of file blendfile_link_append.c.
References BLI_assert, BLI_ghash_free(), BLI_memarena_free(), BlendfileLinkAppendContext::libraries, BlendfileLinkAppendContext::library_weak_reference_mapping, link_append_context_library_blohandle_release(), LinkNodePair::list, BlendfileLinkAppendContext::memarena, BlendfileLinkAppendContext::new_id_to_item, and NULL.
Referenced by BKE_copybuffer_paste(), BKE_copybuffer_read(), bpy_lib_exit(), wm_file_link_append_datablock_ex(), WM_lib_reload(), wm_lib_relocate_exec_do(), and wm_link_append_exec().
bool BKE_blendfile_link_append_context_is_empty | ( | struct BlendfileLinkAppendContext * | lapp_context | ) |
Check if given link/append context is empty (has no items to process) or not.
Definition at line 337 of file blendfile_link_append.c.
References BlendfileLinkAppendContext::num_items.
Referenced by wm_link_append_exec().
struct BlendfileLinkAppendContextItem* BKE_blendfile_link_append_context_item_add | ( | struct BlendfileLinkAppendContext * | lapp_context, |
const char * | idname, | ||
short | idcode, | ||
void * | userdata | ||
) |
Add a new item (data-block name and idcode
) to be searched and linked/appended from libraries associated to the given context.
userdata | an opaque user-data pointer stored in generated link/append item. |
TODO: Add a more friendly version of this that combines it with the call to BKE_blendfile_link_append_context_item_library_index_enable to enable the added item for all added library sources.
Definition at line 253 of file blendfile_link_append.c.
References BlendfileLinkAppendContextItem::action, BLI_BITMAP_NEW_MEMARENA, BLI_linklist_append_arena(), BLI_memarena_alloc(), BLI_memarena_calloc(), BLI_strncpy(), BlendfileLinkAppendContextItem::idcode, BlendfileLinkAppendContext::items, len, BlendfileLinkAppendContextItem::libraries, LINK_APPEND_ACT_UNSET, BlendfileLinkAppendContext::memarena, BlendfileLinkAppendContextItem::name, BlendfileLinkAppendContextItem::new_id, NULL, BlendfileLinkAppendContext::num_items, BlendfileLinkAppendContext::num_libraries, and BlendfileLinkAppendContextItem::userdata.
Referenced by BKE_blendfile_library_relocate(), BKE_blendfile_link_append_context_item_idtypes_from_library_add(), bpy_lib_exit(), foreach_libblock_link_append_callback(), wm_file_link_append_datablock_ex(), and wm_link_append_exec().
void BKE_blendfile_link_append_context_item_foreach | ( | struct BlendfileLinkAppendContext * | lapp_context, |
BKE_BlendfileLinkAppendContexteItemFunction | callback_function, | ||
eBlendfileLinkAppendForeachItemFlag | flag, | ||
void * | userdata | ||
) |
Iterate over all (or a subset) of the items listed in given BlendfileLinkAppendContext, and call the callback_function
on them.
flag | Control which type of items to process (see eBlendfileLinkAppendForeachItemFlag enum flags). |
userdata | An opaque void pointer passed to the callback_function . |
Definition at line 361 of file blendfile_link_append.c.
References BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT, BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_INDIRECT, BlendfileLinkAppendContext::items, LINK_APPEND_TAG_INDIRECT, LinkNodePair::list, LinkNode::next, and BlendfileLinkAppendContextItem::tag.
Referenced by bpy_lib_exit().
short BKE_blendfile_link_append_context_item_idcode_get | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct BlendfileLinkAppendContextItem * | item | ||
) |
Referenced by bpy_lib_exit_lapp_context_items_cb().
int BKE_blendfile_link_append_context_item_idtypes_from_library_add | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct ReportList * | reports, | ||
uint64_t | id_types_filter, | ||
int | library_index | ||
) |
Search for all ID matching given id_types_filter
in given library_index
, and add them to the list of items to process.
lapp_context
after this function.id_types_filter | A set of FILTER_ID bitflags, the types of IDs to add to the items list. |
library_index | The index of the library to look into, in given lapp_context . |
BLENDFILE_LINK_APPEND_INVALID
if it could not open the .blend file. Definition at line 278 of file blendfile_link_append.c.
References BKE_blendfile_link_append_context_item_add(), BKE_blendfile_link_append_context_item_library_index_enable(), BKE_idtype_idcode_is_linkable(), BKE_idtype_idcode_iter_step(), BKE_idtype_idcode_to_idfilter(), BLENDFILE_LINK_APPEND_INVALID, BLI_linklist_find(), BLO_blendhandle_get_datablock_names(), FILE_ASSETS_ONLY, LibraryLink_Params::flag, id_name(), BlendfileLinkAppendContext::libraries, LinkNode::link, link_append_context_library_blohandle_ensure(), LinkNodePair::list, MEM_freeN, LinkNode::next, NULL, and BlendfileLinkAppendContext::params.
Referenced by BKE_copybuffer_paste(), and BKE_copybuffer_read().
void BKE_blendfile_link_append_context_item_library_index_enable | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct BlendfileLinkAppendContextItem * | item, | ||
int | library_index | ||
) |
Enable search of the given item into the library stored at given index in the link/append context.
Referenced by bpy_lib_exit(), wm_file_link_append_datablock_ex(), and wm_link_append_exec().
struct ID* BKE_blendfile_link_append_context_item_newid_get | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct BlendfileLinkAppendContextItem * | item | ||
) |
Referenced by bpy_lib_exit_lapp_context_items_cb(), and wm_file_link_append_datablock_ex().
void* BKE_blendfile_link_append_context_item_userdata_get | ( | struct BlendfileLinkAppendContext * | lapp_context, |
struct BlendfileLinkAppendContextItem * | item | ||
) |
Referenced by bpy_lib_exit_lapp_context_items_cb().
void BKE_blendfile_link_append_context_library_add | ( | struct BlendfileLinkAppendContext * | lapp_context, |
const char * | libname, | ||
struct BlendHandle * | blo_handle | ||
) |
Add a new source library to search for items to be linked to the given link/append context.
libname | the absolute path to the library blend file. |
blo_handle | the blend file handle of the library, NULL is not available. Note that this is only borrowed for linking purpose, no releasing or other management will be performed by #BKE_blendfile_link_append code on it. |
Definition at line 232 of file blendfile_link_append.c.
References BLI_assert, BLI_linklist_append_arena(), BLI_memarena_alloc(), BLI_memarena_calloc(), BLI_strncpy(), BlendfileLinkAppendContextLibrary::blo_handle, BlendfileLinkAppendContextLibrary::blo_handle_is_owned, BlendfileLinkAppendContext::items, len, BlendfileLinkAppendContext::libraries, LinkNodePair::list, BlendfileLinkAppendContext::memarena, NULL, BlendfileLinkAppendContext::num_libraries, and BlendfileLinkAppendContextLibrary::path.
Referenced by BKE_copybuffer_paste(), BKE_copybuffer_read(), bpy_lib_exit(), wm_file_link_append_datablock_ex(), WM_lib_reload(), wm_lib_relocate_exec_do(), and wm_link_append_exec().
BlendfileLinkAppendContext* BKE_blendfile_link_append_context_new | ( | struct LibraryLink_Params * | params | ) |
Allocate and initialize a new context to link/append data-blocks.
Definition at line 175 of file blendfile_link_append.c.
References BLI_memarena_calloc(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BlendfileLinkAppendContext::memarena, BlendfileLinkAppendContext::params, and params.
Referenced by BKE_copybuffer_paste(), BKE_copybuffer_read(), bpy_lib_exit(), wm_file_link_append_datablock_ex(), WM_lib_reload(), wm_lib_relocate_exec_do(), and wm_link_append_exec().