143 if (reports !=
NULL) {
147 char *libname = lib_context->
path;
149 if (blo_handle ==
NULL) {
193 liblink = liblink->next) {
219 "Please explicitly clear reference to an embedded blender memfile before "
220 "setting a new one");
239 sizeof(*lib_context));
241 size_t len = strlen(libname) + 1;
245 lib_context->
path = libpath;
261 size_t len = strlen(idname) + 1;
282 const int library_index)
285 int id_code_iter = 0;
291 lapp_context, lib_context, reports);
293 if (blo_handle ==
NULL) {
301 (id_types_filter != 0 &&
308 blo_handle, id_code, use_assets_only, &id_names_num);
310 for (
LinkNode *link_next =
NULL; id_names_list !=
NULL; id_names_list = link_next) {
311 link_next = id_names_list->
next;
317 lapp_context, item, library_index);
323 id_num += id_names_num;
332 const int library_index)
379 if (!callback_function(lapp_context, item, userdata)) {
434 if (ob->type ==
OB_EMPTY && ob->instance_collection == collection) {
527 view_layer->
basact = base;
543 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
556 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
579 parent_collection = parent_collection->next) {
580 if ((parent_collection->collection->id.tag &
LIB_TAG_DOIT) != 0) {
600 const bool do_instantiate_as_empty = (lapp_context->
params->
flag &
608 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
633 !collection_is_instantiated;
637 if (!do_add_collection && do_append && !collection_is_instantiated) {
641 do_add_collection =
true;
646 if (do_add_collection) {
653 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
663 if (!do_add_collection) {
668 if (!do_instantiate_as_empty &&
681 if (do_instantiate_as_empty) {
690 const bool set_active = set_selected;
692 bmain, active_collection, ob, view_layer, v3d, lapp_context->
params->
flag, set_active);
727 const bool object_set_active =
false;
734 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
784 const bool object_set_active =
false;
787 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
833 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
945 const bool do_link = (
data->lapp_context->params->flag &
FILE_LINK) != 0;
993 "Proxies have been removed from Blender (%d proxies were automatically converted "
994 "to library overrides, %d proxies could not be converted and were cleared). "
995 "Please consider re-saving any library .blend file with the newest Blender version",
1013 const bool do_reuse_local_id = (lapp_context->
params->
flag &
1030 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
1048 else if (do_reuse_local_id && existing_local_id !=
NULL) {
1049 CLOG_INFO(&
LOG, 3,
"Appended ID '%s' as a matching local one, re-using it...",
id->
name);
1051 item->
userdata = existing_local_id;
1054 CLOG_INFO(&
LOG, 3,
"Appended ID '%s' was already linked, need to copy it...",
id->
name);
1066 .
lapp_context = lapp_context, .item = item, .reports = reports};
1073 if (existing_local_id !=
NULL &&
1083 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
1090 ID *local_appended_new_id =
NULL;
1099 local_appended_new_id =
id->
newid;
1104 local_appended_new_id =
id;
1116 &
LOG,
"Unexpected unset append action for '%s' ID, assuming 'keep link'",
id->
name);
1122 if (local_appended_new_id !=
NULL) {
1127 local_appended_new_id);
1143 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
1169 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
1197 .active_collection =
NULL};
1218 int lib_idx, item_idx;
1220 for (lib_idx = 0, liblink = lapp_context->
libraries.
list; liblink;
1221 lib_idx++, liblink = liblink->
next) {
1223 char *libname = lib_context->
path;
1225 lapp_context, lib_context, reports);
1227 if (blo_handle ==
NULL) {
1244 "Linking or appending from a very old .blend file format (%d.%d), no animation "
1246 "be done! You may want to re-save your lib file with current Blender",
1253 for (item_idx = 0, itemlink = lapp_context->
items.
list; itemlink;
1254 item_idx++, itemlink = itemlink->
next) {
1285 for (itemlink = lapp_context->
items.
list; itemlink; itemlink = itemlink->
next) {
1294 .
lapp_context = lapp_context, .item = item, .reports = reports};
1303 .active_collection =
NULL};
1321 const bool do_reload,
1322 const short remap_flags)
1333 "Before remap of %s, old_id users: %d, new_id users: %d",
1346 "After remap of %s, old_id users: %d, new_id users: %d",
1360 if (old_id->
us > 0 && new_id && old_id->
lib == new_id->
lib) {
1366 size_t len = strlen(old_id->
name);
1368 bool has_num =
false;
1370 for (dot_pos =
len; dot_pos--;) {
1371 char c = old_id->
name[dot_pos];
1375 if (c < '0' || c >
'9') {
1383 old_id->
name[dot_pos] =
'~';
1395 "Lib Reload: Replacing all references to old data-block '%s' by reloaded one failed, "
1396 "old one (%d remaining users) had to be kept and was renamed to '%s'",
1406 const bool do_reload)
1424 ID *
id = lbarray[lba_idx]->
first;
1425 const short idcode =
id ?
GS(
id->
name) : 0;
1433 for (;
id;
id =
id->
next) {
1442 if (old_key !=
NULL) {
1469 for (item_idx = 0, itemlink = lapp_context->
items.
list; itemlink;
1470 item_idx++, itemlink = itemlink->
next) {
1479 if (old_key !=
NULL) {
1491 for (item_idx = 0, itemlink = lapp_context->
items.
list; itemlink;
1492 item_idx++, itemlink = itemlink->
next) {
1498 if (new_id ==
NULL) {
1503 if (old_key_p ==
NULL) {
1506 Key *old_key = *old_key_p;
1508 if (old_key !=
NULL) {
1512 bmain, &old_key->
id, &new_key->
id, reports, do_reload, remap_flags);
1513 *old_key_p = old_key;
1528 bool keep_looping =
true;
1529 while (keep_looping) {
1530 keep_looping =
false;
1533 for (item_idx = 0, itemlink = lapp_context->
items.
list; itemlink;
1534 item_idx++, itemlink = itemlink->
next) {
1538 if (old_id ==
NULL) {
1568 if (old_id->
us == 0) {
1571 keep_looping =
true;
1573 if (old_key !=
NULL) {
1588 for (
id = lbarray[lba_idx]->first;
id;
id = id_next) {
1602 for (
id = lbarray[lba_idx]->first;
id;
id =
id->
next) {
1610 lib_next =
lib->id.next;
1613 if (
lib->id.us == 0) {
bool(* BKE_BlendfileLinkAppendContexteItemFunction)(struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item, void *userdata)
eBlendfileLinkAppendForeachItemFlag
@ BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT
@ BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_INDIRECT
#define BLENDFILE_LINK_APPEND_INVALID
struct Collection * BKE_collection_add(struct Main *bmain, struct Collection *parent, const char *name)
bool BKE_collection_child_add(struct Main *bmain, struct Collection *parent, struct Collection *child)
bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob)
bool BKE_collection_has_object(struct Collection *collection, const struct Object *ob)
bool BKE_collection_has_object_recursive(struct Collection *collection, struct Object *ob)
struct Collection * BKE_collection_parent_editable_find_recursive(const struct ViewLayer *view_layer, struct Collection *collection)
uint64_t BKE_idtype_idcode_to_idfilter(short idcode)
short BKE_idtype_idcode_iter_step(int *index)
bool BKE_idtype_idcode_is_linkable(short idcode)
bool BKE_idtype_idcode_append_is_reusable(short idcode)
struct Key * BKE_key_from_id(struct ID *id)
struct Key ** BKE_key_from_id_p(struct ID *id)
struct LayerCollection * BKE_layer_collection_get_active(struct ViewLayer *view_layer)
void BKE_main_collection_sync(const struct Main *bmain)
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
struct ViewLayer * BKE_view_layer_find(const struct Scene *scene, const char *layer_name)
void BKE_main_id_newptr_and_tag_clear(struct Main *bmain)
void BKE_main_id_tag_idcode(struct Main *mainvar, short type, int tag, bool value)
void BKE_main_id_tag_all(struct Main *mainvar, int tag, bool value)
void id_us_min(struct ID *id)
void id_fake_user_set(struct ID *id)
void BKE_main_id_refcount_recompute(struct Main *bmain, bool do_linked_only)
@ LIB_ID_MAKELOCAL_FORCE_LOCAL
@ LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR
@ LIB_ID_MAKELOCAL_FULL_LIBRARY
@ LIB_ID_MAKELOCAL_FORCE_COPY
void BKE_id_free(struct Main *bmain, void *idv)
void id_us_plus(struct ID *id)
void id_us_clear_real(struct ID *id)
void id_us_plus_no_lib(struct ID *id)
bool BKE_lib_id_make_local(struct Main *bmain, struct ID *id, int flags)
void id_fake_user_clear(struct ID *id)
size_t BKE_id_multi_tagged_delete(struct Main *bmain) ATTR_NONNULL()
void id_sort_by_name(struct ListBase *lb, struct ID *id, struct ID *id_sorting_hint)
void BKE_lib_override_library_main_resync(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, struct BlendFileReadReport *reports)
void BKE_lib_override_library_main_proxy_convert(struct Main *bmain, struct BlendFileReadReport *reports)
bool BKE_lib_override_library_main_operations_create(struct Main *bmain, bool force_auto)
void BKE_lib_override_library_update(struct Main *bmain, struct ID *local)
void BKE_library_foreach_ID_link(struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
@ IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE
@ ID_REMAP_SKIP_NEVER_NULL_USAGE
@ ID_REMAP_SKIP_INDIRECT_USAGE
void BKE_libblock_relink_to_newid(struct Main *bmain, struct ID *id, int remap_flag) ATTR_NONNULL()
void BKE_libblock_remap_locked(struct Main *bmain, void *old_idv, void *new_idv, short remap_flags) ATTR_NONNULL(1
void BKE_main_library_weak_reference_add_item(struct GHash *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name, struct ID *new_id) ATTR_NONNULL()
#define FOREACH_MAIN_ID_END
int set_listbasepointers(struct Main *main, struct ListBase *lb[])
struct ID * BKE_main_library_weak_reference_search_item(struct GHash *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name) ATTR_NONNULL()
struct GHash * BKE_main_library_weak_reference_create(struct Main *bmain) ATTR_NONNULL()
void BKE_main_library_weak_reference_destroy(struct GHash *library_weak_reference_mapping) ATTR_NONNULL()
void BKE_main_unlock(struct Main *bmain)
void BKE_main_library_weak_reference_remove_item(struct GHash *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name, struct ID *old_id) ATTR_NONNULL()
void BKE_main_lock(struct Main *bmain)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
struct ListBase * which_libbase(struct Main *bmain, short type)
General operations, lookup, etc. for materials.
void BKE_object_materials_test(struct Main *bmain, struct Object *ob, struct ID *id)
General operations, lookup, etc. for blender objects.
int BKE_object_obdata_to_type(const struct ID *id) ATTR_NONNULL(1)
struct Object * BKE_object_add_only_object(struct Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
API for Blender-side Rigid Body stuff.
void BKE_rigidbody_ensure_local_object(struct Main *bmain, struct Object *ob)
void BKE_scene_object_base_flag_sync_from_base(struct Base *base)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW_MEMARENA(_mem, _num)
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
unsigned int BLI_ghashutil_ptrhash(const void *key)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP 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_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_linklist_append_arena(LinkNodePair *list_pair, void *ptr, struct MemArena *ma) ATTR_NONNULL(1
LinkNode * BLI_linklist_find(LinkNode *list, int index) ATTR_WARN_UNUSED_RESULT
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
#define BLI_MEMARENA_STD_BUFSIZE
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void * BLI_memarena_calloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
external readfile function prototypes.
@ BLO_LIBLINK_APPEND_RECURSIVE
@ BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR
@ BLO_LIBLINK_OBDATA_INSTANCE
@ BLO_LIBLINK_APPEND_SET_FAKEUSER
@ BLO_LIBLINK_APPEND_LOCAL_ID_REUSE
@ BLO_LIBLINK_COLLECTION_INSTANCE
BlendHandle * BLO_blendhandle_from_file(const char *filepath, struct BlendFileReadReport *reports)
struct LinkNode * BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, bool use_assets_only, int *r_tot_names)
struct BlendHandle BlendHandle
#define BLO_EMBEDDED_STARTUP_BLEND
struct Main * BLO_library_link_begin(BlendHandle **bh, const char *filepath, const struct LibraryLink_Params *params)
void BLO_library_link_end(struct Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params)
struct ID * BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, short idcode, const char *name, const struct LibraryLink_Params *params)
void BLO_blendhandle_close(BlendHandle *bh)
BlendHandle * BLO_blendhandle_from_memory(const void *mem, int memsize, struct BlendFileReadReport *reports)
external writefile.c function prototypes.
#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)
#define ID_IS_LINKED(_id)
#define ID_NEW_SET(_id, _idn)
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
#define OB_DATA_SUPPORT_ID(_id_type)
#define USER_EXPERIMENTAL_TEST(userdef, member)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
struct BlendfileLinkAppendContext BlendfileLinkAppendContext
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
bool BKE_blendfile_link_append_context_is_empty(struct BlendfileLinkAppendContext *lapp_context)
struct LooseDataInstantiateContext LooseDataInstantiateContext
static void new_id_to_item_mapping_create(BlendfileLinkAppendContext *lapp_context)
@ LINK_APPEND_TAG_INDIRECT
void BKE_blendfile_link_append_context_library_add(BlendfileLinkAppendContext *lapp_context, const char *libname, BlendHandle *blo_handle)
static void loose_data_instantiate_ensure_active_collection(LooseDataInstantiateContext *instantiate_context)
static void loose_data_instantiate_obdata_process(LooseDataInstantiateContext *instantiate_context)
void BKE_blendfile_link_append_context_flag_set(BlendfileLinkAppendContext *lapp_context, const int flag, const bool do_set)
static void loose_data_instantiate_object_base_instance_init(Main *bmain, Collection *collection, Object *ob, ViewLayer *view_layer, const View3D *v3d, const int flag, bool set_active)
void BKE_blendfile_link_append_context_item_foreach(struct BlendfileLinkAppendContext *lapp_context, BKE_BlendfileLinkAppendContexteItemFunction callback_function, const eBlendfileLinkAppendForeachItemFlag flag, void *userdata)
int BKE_blendfile_link_append_context_item_idtypes_from_library_add(BlendfileLinkAppendContext *lapp_context, ReportList *reports, const uint64_t id_types_filter, const int library_index)
static void loose_data_instantiate_object_rigidbody_postprocess(LooseDataInstantiateContext *instantiate_context)
void * BKE_blendfile_link_append_context_item_userdata_get(BlendfileLinkAppendContext *UNUSED(lapp_context), BlendfileLinkAppendContextItem *item)
static bool object_in_any_collection(Main *bmain, Object *ob)
static void blendfile_library_relocate_remap(Main *bmain, ID *old_id, ID *new_id, ReportList *reports, const bool do_reload, const short remap_flags)
static ID * loose_data_instantiate_process_check(LooseDataInstantiateContext *instantiate_context, BlendfileLinkAppendContextItem *item)
BlendfileLinkAppendContext * BKE_blendfile_link_append_context_new(LibraryLink_Params *params)
struct BlendfileLinkAppendContextCallBack BlendfileLinkAppendContextCallBack
void BKE_blendfile_link_append_context_embedded_blendfile_clear(BlendfileLinkAppendContext *lapp_context)
static BlendHandle * link_append_context_library_blohandle_ensure(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextLibrary *lib_context, ReportList *reports)
void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
static void link_append_context_library_blohandle_release(BlendfileLinkAppendContext *UNUSED(lapp_context), BlendfileLinkAppendContextLibrary *lib_context)
void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, ReportList *reports, Library *library, const bool do_reload)
static void blendfile_link_append_proxies_convert(Main *bmain, ReportList *reports)
static bool object_in_any_scene(Main *bmain, Object *ob)
@ LINK_APPEND_ACT_MAKE_LOCAL
@ LINK_APPEND_ACT_REUSE_LOCAL
@ LINK_APPEND_ACT_KEEP_LINKED
@ LINK_APPEND_ACT_COPY_LOCAL
struct BlendfileLinkAppendContextLibrary BlendfileLinkAppendContextLibrary
static void loose_data_instantiate_obdata_preprocess(LooseDataInstantiateContext *instantiate_context)
void BKE_blendfile_link_append_context_embedded_blendfile_set(BlendfileLinkAppendContext *lapp_context, const void *blendfile_mem, int blendfile_memsize)
static bool collection_instantiated_by_any_object(Main *bmain, Collection *collection)
static void new_id_to_item_mapping_add(BlendfileLinkAppendContext *lapp_context, ID *id, BlendfileLinkAppendContextItem *item)
short BKE_blendfile_link_append_context_item_idcode_get(struct BlendfileLinkAppendContext *UNUSED(lapp_context), struct BlendfileLinkAppendContextItem *item)
void BKE_blendfile_link_append_context_item_library_index_enable(BlendfileLinkAppendContext *UNUSED(lapp_context), BlendfileLinkAppendContextItem *item, const int library_index)
static void loose_data_instantiate_collection_process(LooseDataInstantiateContext *instantiate_context)
static bool loose_data_instantiate_collection_parents_check_recursive(Collection *collection)
BlendfileLinkAppendContextItem * BKE_blendfile_link_append_context_item_add(BlendfileLinkAppendContext *lapp_context, const char *idname, const short idcode, void *userdata)
static int foreach_libblock_link_append_callback(LibraryIDLinkCallbackData *cb_data)
static void loose_data_instantiate_object_process(LooseDataInstantiateContext *instantiate_context)
ID * BKE_blendfile_link_append_context_item_newid_get(BlendfileLinkAppendContext *UNUSED(lapp_context), BlendfileLinkAppendContextItem *item)
static void loose_data_instantiate(LooseDataInstantiateContext *instantiate_context)
struct BlendfileLinkAppendContextItem BlendfileLinkAppendContextItem
std::string id_name(void *id)
void(* MEM_freeN)(void *vmemh)
unsigned __int64 uint64_t
unsigned short local_view_bits
struct ReportList * reports
int proxies_to_lib_overrides_failures
struct BlendFileReadReport::@134 count
int proxies_to_lib_overrides_success
BlendfileLinkAppendContext * lapp_context
BlendfileLinkAppendContextItem * item
BlendFileReadReport bf_reports
const void * blendfile_mem
LibraryLink_Params * params
GHash * library_weak_reference_mapping
IDOverrideLibrary * override_library
struct Collection * collection
const struct View3D * v3d
struct ViewLayer * view_layer
struct LibraryLink_Params::@135 context
BlendfileLinkAppendContext * lapp_context
Collection * active_collection
struct Collection * instance_collection
struct Collection * master_collection
unsigned short local_view_uuid
static FT_Library library