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>2020-09-23 11:47:27 +0300
committerBastien Montagne <bastien@blender.org>2020-09-23 12:07:03 +0300
commitc3a0618fbffffffcf5abbeed8de3f19d8a401db1 (patch)
treef3e607810277449efa988354c815260b7938e413 /source/blender/editors/object/object_relations.c
parent6fde0050c45af994d7f0de16622037bf28c938c8 (diff)
LibOverride: Add operator to convert a proxy object into an override.
In the end the process is surpringly simple, we only need to manually convert the proxy itself into an override (which is trivial), and then run common code with the default 'make override' operation. Fix T81059: Add operator to convert proxies to library overrides.
Diffstat (limited to 'source/blender/editors/object/object_relations.c')
-rw-r--r--source/blender/editors/object/object_relations.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 4adf1a8d9f2..9750eff677d 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2490,6 +2490,54 @@ void OBJECT_OT_make_override_library(wmOperatorType *ot)
ot->prop = prop;
}
+static bool convert_proxy_to_override_poll(bContext *C)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ return obact != NULL && obact->proxy != NULL;
+}
+
+static int convert_proxy_to_override_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+
+ BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
+
+ Object *ob_proxy = CTX_data_active_object(C);
+ Object *ob_proxy_group = ob_proxy->proxy_group;
+ const bool is_override_instancing_object = ob_proxy_group != NULL;
+
+ const bool success = BKE_lib_override_library_proxy_convert(bmain, scene, view_layer, ob_proxy);
+
+ /* 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, ob_proxy_group);
+ }
+
+ DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_BASE_FLAGS | ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+ return success ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+}
+
+void OBJECT_OT_convert_proxy_to_override(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Convert Proxy To Override";
+ ot->description = "Convert a proxy to a local library override";
+ ot->idname = "OBJECT_OT_convert_proxy_to_override";
+
+ /* api callbacks */
+ ot->exec = convert_proxy_to_override_exec;
+ ot->poll = convert_proxy_to_override_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/** \} */
/* ------------------------------------------------------------------- */