Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-09-05 17:41:35 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-09-05 22:31:00 +0300
commit8622849beb964536d39ca2da8a2a0e4db978502f (patch)
treefd9c4a2dd974698006ea64834bc89ea07c060513
parent23d19c2b0dd3f47339ef07be39d47c41848be39b (diff)
LibOverride: give more remapping control to `BKE_override_library_create_from_id()` too.
Similar change to the one done for tagged IDs overriding some days ago. We do not always want to remap all local usages of a linked data-block to its new local overriding copy.
-rw-r--r--source/blender/blenkernel/BKE_library_override.h4
-rw-r--r--source/blender/blenkernel/intern/library_override.c23
-rw-r--r--source/blender/editors/interface/interface_templates.c3
-rw-r--r--source/blender/editors/object/object_relations.c5
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c5
-rw-r--r--source/blender/makesrna/intern/rna_ID.c19
6 files changed, 46 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_library_override.h b/source/blender/blenkernel/BKE_library_override.h
index 93b2355ce55..5cffabd333f 100644
--- a/source/blender/blenkernel/BKE_library_override.h
+++ b/source/blender/blenkernel/BKE_library_override.h
@@ -38,7 +38,9 @@ void BKE_override_library_copy(struct ID *dst_id, const struct ID *src_id);
void BKE_override_library_clear(struct IDOverrideLibrary *override, const bool do_id_user);
void BKE_override_library_free(struct IDOverrideLibrary **override, const bool do_id_user);
-struct ID *BKE_override_library_create_from_id(struct Main *bmain, struct ID *reference_id);
+struct ID *BKE_override_library_create_from_id(struct Main *bmain,
+ struct ID *reference_id,
+ const bool do_tagged_remap);
bool BKE_override_library_create_from_tag(struct Main *bmain);
struct IDOverrideLibraryProperty *BKE_override_library_property_find(
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 6532fce5778..b3c628f6cb8 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -185,19 +185,28 @@ static ID *override_library_create_from(Main *bmain, ID *reference_id)
}
/** Create an overridden local copy of linked reference. */
-ID *BKE_override_library_create_from_id(Main *bmain, ID *reference_id)
+ID *BKE_override_library_create_from_id(Main *bmain, ID *reference_id, const bool do_tagged_remap)
{
BLI_assert(reference_id != NULL);
BLI_assert(reference_id->lib != NULL);
ID *local_id = override_library_create_from(bmain, reference_id);
- /* Remapping, we obviously only want to affect local data
- * (and not our own reference pointer to overridden ID). */
- BKE_libblock_remap(bmain,
- reference_id,
- local_id,
- ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_OVERRIDE_LIBRARY);
+ if (do_tagged_remap) {
+ ID *other_id;
+ FOREACH_MAIN_ID_BEGIN (bmain, other_id) {
+ if ((other_id->tag & LIB_TAG_DOIT) != 0 && other_id->lib == NULL) {
+ /* Note that using ID_REMAP_SKIP_INDIRECT_USAGE below is superfluous, as we only remap
+ * local IDs usages anyway... */
+ BKE_libblock_relink_ex(bmain,
+ other_id,
+ reference_id,
+ local_id,
+ ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_OVERRIDE_LIBRARY);
+ }
+ }
+ FOREACH_MAIN_ID_END;
+ }
return local_id;
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index f53bef877c4..5a333a5fa27 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -516,7 +516,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (id) {
Main *bmain = CTX_data_main(C);
if (BKE_override_library_is_enabled() && CTX_wm_window(C)->eventstate->shift) {
- ID *override_id = BKE_override_library_create_from_id(bmain, id);
+ /* Only remap that specific ID usage to overriding local data-block. */
+ ID *override_id = BKE_override_library_create_from_id(bmain, id, false);
if (override_id != NULL) {
BKE_main_id_clear_newpoins(bmain);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 06c360ed1cd..60a2b9cca0d 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2528,7 +2528,10 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
}
/* TODO: probably more cases where we want to do automated smart things in the future! */
else {
- success = (BKE_override_library_create_from_id(bmain, &obact->id) != NULL);
+ /* For now, remapp all local usages of linked ID to local override one here. */
+ BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, true);
+ success = (BKE_override_library_create_from_id(bmain, &obact->id, true) != NULL);
+ BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
}
WM_event_add_notifier(C, NC_WINDOW, NULL);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index a2d988f1142..91d7f0f9374 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -715,10 +715,13 @@ static void id_override_library_cb(bContext *C,
{
if (ID_IS_LINKED(tselem->id) && (tselem->id->tag & LIB_TAG_EXTERN)) {
Main *bmain = CTX_data_main(C);
- ID *override_id = BKE_override_library_create_from_id(bmain, tselem->id);
+ /* For now, remapp all local usages of linked ID to local override one here. */
+ BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, true);
+ ID *override_id = BKE_override_library_create_from_id(bmain, tselem->id, true);
if (override_id != NULL) {
BKE_main_id_clear_newpoins(bmain);
}
+ BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
}
}
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 5a4b4a3fa3d..294fdb2e0d8 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -491,13 +491,22 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
return NULL;
}
-static ID *rna_ID_override_create(ID *id, Main *bmain)
+static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages)
{
if (!BKE_override_library_is_enabled() || id->lib == NULL) {
return NULL;
}
- return BKE_override_library_create_from_id(bmain, id);
+ if (remap_local_usages) {
+ BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, true);
+ }
+
+ ID *local_id = BKE_override_library_create_from_id(bmain, id, remap_local_usages);
+
+ if (remap_local_usages) {
+ BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
+ }
+ return local_id;
}
static void rna_ID_update_tag(ID *id, Main *bmain, ReportList *reports, int flag)
@@ -1519,6 +1528,12 @@ static void rna_def_ID(BlenderRNA *brna)
RNA_def_function_flag(func, FUNC_USE_MAIN);
parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the ID");
RNA_def_function_return(func, parm);
+ RNA_def_boolean(func,
+ "remap_local_usages",
+ false,
+ "",
+ "Whether local usages of the linked ID should be remapped to the new "
+ "library override of it");
func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
RNA_def_function_ui_description(func,