diff --git a/source/blender/blenkernel/BKE_lib_id.hh b/source/blender/blenkernel/BKE_lib_id.hh index 7d4e14431d8..cfc90303b22 100644 --- a/source/blender/blenkernel/BKE_lib_id.hh +++ b/source/blender/blenkernel/BKE_lib_id.hh @@ -712,9 +712,15 @@ char *BKE_id_to_unique_string_key(const ID *id); * #LIB_TAG_PRE_EXISTING. * \param set_fake: If true, set fake user on all localized data-blocks * (except group and objects ones). + * \param clear_asset_data: If true, clear the asset metadata on all localized data-blocks, making + * them normal non-asset data-blocks. */ -void BKE_library_make_local( - Main *bmain, const Library *lib, GHash *old_to_new_ids, bool untagged_only, bool set_fake); +void BKE_library_make_local(Main *bmain, + const Library *lib, + GHash *old_to_new_ids, + bool untagged_only, + bool set_fake, + bool clear_asset_data); void BKE_id_tag_set_atomic(ID *id, int tag); void BKE_id_tag_clear_atomic(ID *id, int tag); diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index 1b39fa7d0c6..7379249682c 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -166,7 +166,7 @@ static void brush_make_local(Main *bmain, ID *id, const int flags) * does not deal properly with it. */ /* NOTE: assert below ensures that the comment above is valid, and that exception is * acceptable for the time being. */ - BKE_lib_id_make_local(bmain, &brush->clone.image->id, 0); + BKE_lib_id_make_local(bmain, &brush->clone.image->id, LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR); BLI_assert(!ID_IS_LINKED(brush->clone.image) && brush->clone.image->id.newid == nullptr); } diff --git a/source/blender/blenkernel/intern/lib_id.cc b/source/blender/blenkernel/intern/lib_id.cc index 3e74a066e5e..edd2c206737 100644 --- a/source/blender/blenkernel/intern/lib_id.cc +++ b/source/blender/blenkernel/intern/lib_id.cc @@ -1946,7 +1946,8 @@ void BKE_library_make_local(Main *bmain, const Library *lib, GHash *old_to_new_ids, const bool untagged_only, - const bool set_fake) + const bool set_fake, + const bool clear_asset_data) { /* NOTE: Old (2.77) version was simply making (tagging) data-blocks as local, * without actually making any check whether they were also indirectly used or not... @@ -2061,6 +2062,8 @@ void BKE_library_make_local(Main *bmain, TIMEIT_VALUE_PRINT(make_local); #endif + const int make_local_flags = clear_asset_data ? LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR : 0; + /* Step 3: Make IDs local, either directly (quick and simple), or using generic process, * which involves more complex checks and might instead * create a local copy of original linked ID. */ @@ -2073,7 +2076,7 @@ void BKE_library_make_local(Main *bmain, * currently there are some indirect usages. So instead of making a copy that we'll likely * get rid of later, directly make that data block local. * Saves a tremendous amount of time with complex scenes... */ - BKE_lib_id_clear_library_data(bmain, id, 0); + BKE_lib_id_clear_library_data(bmain, id, make_local_flags); BKE_lib_id_expand_local(bmain, id, 0); id->tag &= ~LIB_TAG_DOIT; @@ -2083,7 +2086,7 @@ void BKE_library_make_local(Main *bmain, } else { /* In this specific case, we do want to make ID local even if it has no local usage yet... */ - BKE_lib_id_make_local(bmain, id, LIB_ID_MAKELOCAL_FULL_LIBRARY); + BKE_lib_id_make_local(bmain, id, make_local_flags | LIB_ID_MAKELOCAL_FULL_LIBRARY); if (id->newid) { if (GS(id->newid->name) == ID_OB) { diff --git a/source/blender/editors/interface/templates/interface_templates.cc b/source/blender/editors/interface/templates/interface_templates.cc index 3dbe699731a..33b70afbd6b 100644 --- a/source/blender/editors/interface/templates/interface_templates.cc +++ b/source/blender/editors/interface/templates/interface_templates.cc @@ -1017,7 +1017,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) template_id_liboverride_hierarchy_make(C, bmain, template_ui, &idptr, &undo_push_label); } else { - if (BKE_lib_id_make_local(bmain, id, 0)) { + if (BKE_lib_id_make_local(bmain, id, LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR)) { BKE_id_newptr_and_tag_clear(id); /* Reassign to get proper updates/notifiers. */ diff --git a/source/blender/editors/object/object_relations.cc b/source/blender/editors/object/object_relations.cc index a892dc9118d..ad7c999c15d 100644 --- a/source/blender/editors/object/object_relations.cc +++ b/source/blender/editors/object/object_relations.cc @@ -2262,7 +2262,8 @@ static int make_local_exec(bContext *C, wmOperator *op) CTX_DATA_END; } - BKE_library_make_local(bmain, nullptr, nullptr, true, false); /* nullptr is all libraries. */ + BKE_library_make_local( + bmain, nullptr, nullptr, true, false, true); /* nullptr is all libraries. */ WM_event_add_notifier(C, NC_WINDOW, nullptr); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 2c72a866cea..ab6b5bdc569 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -978,7 +978,7 @@ static void id_local_fn(bContext *C, { if (ID_IS_LINKED(tselem->id) && (tselem->id->tag & LIB_TAG_EXTERN)) { Main *bmain = CTX_data_main(C); - if (BKE_lib_id_make_local(bmain, tselem->id, 0)) { + if (BKE_lib_id_make_local(bmain, tselem->id, LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR)) { BKE_id_newptr_and_tag_clear(tselem->id); } } diff --git a/source/blender/makesrna/intern/rna_ID.cc b/source/blender/makesrna/intern/rna_ID.cc index ace650de269..fbee7596064 100644 --- a/source/blender/makesrna/intern/rna_ID.cc +++ b/source/blender/makesrna/intern/rna_ID.cc @@ -1101,10 +1101,16 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id) } } -static ID *rna_ID_make_local(ID *self, Main *bmain, bool /*clear_proxy*/, bool clear_liboverride) +static ID *rna_ID_make_local( + ID *self, Main *bmain, bool /*clear_proxy*/, bool clear_liboverride, bool clear_asset_data) { if (ID_IS_LINKED(self)) { - BKE_lib_id_make_local(bmain, self, 0); + int flags = 0; + if (clear_asset_data) { + flags |= LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR; + } + + BKE_lib_id_make_local(bmain, self, flags); } else if (ID_IS_OVERRIDE_LIBRARY_REAL(self)) { BKE_lib_override_library_make_local(bmain, self); @@ -2458,6 +2464,13 @@ static void rna_def_ID(BlenderRNA *brna) false, "", "Remove potential library override data from the newly made local data"); + RNA_def_boolean( + func, + "clear_asset_data", + true, + "", + "Remove potential asset metadata so the newly local data-block is not treated as asset " + "data-block and won't show up in asset libraries"); parm = RNA_def_pointer(func, "id", "ID", "", "This ID, or the new ID if it was copied"); RNA_def_function_return(func, parm);