From 794c2828af60af02a38381c2a9a81f9046381074 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 17 Sep 2021 16:22:29 +0200 Subject: Initial implementation of local ID re-use when appending. This commit adds to ID struct a new optional 'weak reference' to a linked ID (in the form of a blend file library path and full ID name). This can then be used on next append to try to find a matching local ID instead of re-making the linked data local again. Ref. T90545 NOTE: ID re-use will be disabled for regular append for the time being (3.0 release), and only used for assets. Therefore, this commit should not change anything user-wise. Differential Revision: https://developer.blender.org/D12545 --- source/blender/blenkernel/BKE_main.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/blender/blenkernel/BKE_main.h') diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index ae60a5563b5..93d5b5c5aa6 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -212,6 +212,32 @@ void BKE_main_relations_tag_set(struct Main *bmain, struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset); +/* + * Temporary runtime API to allow re-using local (already appended) IDs instead of appending a new + * copy again. + */ + +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(); +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(); +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(); +void BKE_main_library_weak_reference_update_item(struct GHash *library_weak_reference_mapping, + const char *library_filepath, + const char *library_id_name, + struct ID *old_id, + struct ID *new_id) ATTR_NONNULL(); +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(); + /* *** Generic utils to loop over whole Main database. *** */ #define FOREACH_MAIN_LISTBASE_ID_BEGIN(_lb, _id) \ -- cgit v1.2.3