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/blenkernel/intern
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/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/lib_override.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index d7ccef3c0e7..ec53229057c 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -669,6 +669,42 @@ bool BKE_lib_override_library_create(
}
/**
+ * Converts a given proxy object into a library override.
+ *
+ * \note This is actually a thin wrapper around \a BKE_lib_override_library_create, only extra work
+ * is to actually convert the proxy itself into an override first.
+ *
+ * \return true if override was successfully created.
+ */
+bool BKE_lib_override_library_proxy_convert(Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ Object *ob_proxy)
+{
+ /* proxy_group, if defined, is the empty instanciating the collection from which the proxy is
+ * coming. */
+ Object *ob_proxy_group = ob_proxy->proxy_group;
+ const bool is_override_instancing_object = ob_proxy_group != NULL;
+ ID *id_root = is_override_instancing_object ? &ob_proxy_group->instance_collection->id :
+ &ob_proxy->proxy->id;
+ ID *id_reference = is_override_instancing_object ? &ob_proxy_group->id : &ob_proxy->id;
+
+ /* We manually convert the proxy object into a library override, further override handling will
+ * then be handled by BKE_lib_override_library_create() just as for a regular override creation.
+ */
+ ob_proxy->proxy->id.tag |= LIB_TAG_DOIT;
+ ob_proxy->proxy->id.newid = &ob_proxy->id;
+ BKE_lib_override_library_init(&ob_proxy->id, &ob_proxy->proxy->id);
+
+ ob_proxy->proxy->proxy_from = NULL;
+ ob_proxy->proxy = ob_proxy->proxy_group = NULL;
+
+ DEG_id_tag_update(&ob_proxy->id, ID_RECALC_COPY_ON_WRITE);
+
+ return BKE_lib_override_library_create(bmain, scene, view_layer, id_root, id_reference);
+}
+
+/**
* Advanced 'smart' function to resync, re-create fully functional overrides up-to-date with linked
* data, from an existing override hierarchy.
*