From 8cc3d2d6f51f9f05c568104be17c6643edfff101 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 6 Sep 2021 17:37:04 +0200 Subject: ID management: add options to force make local or force copy IDs when making them local. This is to be used when calling code already knows whether the 'made local' linked ID should be copied, or can directly be converted to a local one. Currently unused , this is preparation for rewrite of append code. --- source/blender/blenkernel/intern/lib_id.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern/lib_id.c') diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 11e9053df43..cd0c3635dac 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -406,7 +406,15 @@ static void lib_id_copy_ensure_local(Main *bmain, const ID *old_id, ID *new_id) */ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags) { + if (!ID_IS_LINKED(id)) { + return; + } + const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0; + const bool force_local = (flags & LIB_ID_MAKELOCAL_FORCE_LOCAL) != 0; + const bool force_copy = (flags & LIB_ID_MAKELOCAL_FORCE_COPY) != 0; + BLI_assert(force_copy == false || force_copy != force_local); + bool is_local = false, is_lib = false; /* - only lib users: do nothing (unless force_local is set) @@ -416,14 +424,12 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags) * we always want to localize, and we skip remapping (done later). */ - if (!ID_IS_LINKED(id)) { - return; + if (!force_copy && !force_local) { + BKE_library_ID_test_usages(bmain, id, &is_local, &is_lib); } - BKE_library_ID_test_usages(bmain, id, &is_local, &is_lib); - - if (lib_local || is_local) { - if (!is_lib) { + if (lib_local || is_local || force_copy || force_local) { + if (!is_lib || force_local) { BKE_lib_id_clear_library_data(bmain, id); BKE_lib_id_expand_local(bmain, id); } -- cgit v1.2.3