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 <bastien@blender.org>2021-03-18 17:26:49 +0300
committerBastien Montagne <bastien@blender.org>2021-03-18 17:59:18 +0300
commit06351c050482bfef562cddf363420560508b79aa (patch)
tree62b6bdfdf89afc60b953e51d9b874148791745db
parent7ee365d8c713459d6217c2728f5b796bc3ed241d (diff)
LibOverride: Outliner: Tweak override creation from instancing empty.
Now behavior is similar to the one from 3DView: once override of the collection is successfuly created, we remove the instancing empty from the scene.
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 052ef9a5dea..00be5142776 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -784,10 +784,10 @@ typedef struct OutlinerLibOverrideData {
} OutlinerLibOverrideData;
static void id_override_library_create_fn(bContext *C,
- ReportList *UNUSED(reports),
- Scene *UNUSED(scene),
+ ReportList *reports,
+ Scene *scene,
TreeElement *te,
- TreeStoreElem *UNUSED(tsep),
+ TreeStoreElem *tsep,
TreeStoreElem *tselem,
void *user_data)
{
@@ -795,6 +795,21 @@ static void id_override_library_create_fn(bContext *C,
ID *id_root = tselem->id;
OutlinerLibOverrideData *data = user_data;
const bool do_hierarchy = data->do_hierarchy;
+ bool success = false;
+
+ ID *id_reference = NULL;
+ bool is_override_instancing_object = false;
+ if (tsep != NULL && tsep->type == TSE_SOME_ID && tsep->id != NULL &&
+ GS(tsep->id->name) == ID_OB) {
+ Object *ob = (Object *)tsep->id;
+ if (ob->type == OB_EMPTY && &ob->instance_collection->id == id_root) {
+ BLI_assert(GS(id_root->name) == ID_GR);
+ /* Empty instantiating the collection we override, we need to pass it to BKE overriding code
+ * for proper handling. */
+ id_reference = tsep->id;
+ is_override_instancing_object = true;
+ }
+ }
if (ID_IS_OVERRIDABLE_LIBRARY(id_root) || (ID_IS_LINKED(id_root) && do_hierarchy)) {
Main *bmain = CTX_data_main(C);
@@ -824,19 +839,28 @@ static void id_override_library_create_fn(bContext *C,
}
te->store_elem->id->tag |= LIB_TAG_DOIT;
}
- BKE_lib_override_library_create(
- bmain, CTX_data_scene(C), CTX_data_view_layer(C), id_root, NULL);
+ success = BKE_lib_override_library_create(
+ bmain, CTX_data_scene(C), CTX_data_view_layer(C), id_root, id_reference);
}
else if (ID_IS_OVERRIDABLE_LIBRARY(id_root)) {
- BKE_lib_override_library_create_from_id(bmain, id_root, true);
+ success = BKE_lib_override_library_create_from_id(bmain, id_root, true) != NULL;
/* Cleanup. */
BKE_main_id_clear_newpoins(bmain);
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
}
+
+ /* Remove the instance empty from this scene, the items now have an overridden collection
+ * instead. */
+ if (success && is_override_instancing_object) {
+ ED_object_base_free_and_unlink(bmain, scene, (Object *)id_reference);
+ }
}
- else {
- CLOG_WARN(&LOG, "Could not create library override for data block '%s'", id_root->name);
+ if (!success) {
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Could not create library override from data-block '%s'",
+ id_root->name);
}
}