diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-10-06 17:52:13 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-10-07 14:08:50 +0300 |
commit | 1cdc54dc7db8576607a7734b3ec5e7fa76adb76a (patch) | |
tree | 226818773c893bfa5e9364f2cc7762f28fe0197f /source/blender/blenkernel/intern/library.c | |
parent | 0f88a3546cbd020af3f5c47b049ae4ecc6bc54ba (diff) |
Re-establish link to proxies when they are made local after appending.
This allows appending of an entire scene from another blend file into
this one, even when that blend file contains proxified armatures.
Since the proxified object needs to be linked (not local), this will
only work when the "Localize all" checkbox is disabled. The appended
proxy object should also not be referenced from anything in a library
(for example in a constraint). Referencing it from the appended data
should be fine.
Fixes T49495.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 6d94cd28b31..2d444a610e5 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1715,6 +1715,36 @@ void BKE_library_make_local(Main *bmain, const Library *lib, const bool untagged bool is_local = false, is_lib = false; BKE_library_ID_test_usages(bmain, id, &is_local, &is_lib); + + /* Attempt to re-link appended proxy objects. This allows appending of an entire scene + * from another blend file into this one, even when that blend file contains proxified + * armatures. Since the proxified object needs to be linked (not local), this will + * only work when the "Localize all" checkbox is disabled. + * TL;DR: this is a dirty hack on top of an already weak feature (proxies). */ + if (GS(id->name) == ID_OB && ((Object *)id)->proxy != NULL) { + Object *ob = (Object *)id; + Object *ob_new = (Object *)id->newid; + + /* Proxies only work when the proxied object is linked-in from a library. */ + if (ob->proxy->id.lib == NULL) { + printf("Warning, proxy object %s will loose its link to %s, because the " + "proxied object is local.\n", id->newid->name, ob->proxy->id.name); + } + /* We can only switch the proxy'ing to a made-local proxy if it is no longer + * referred to from a library. Not checking for local use; if new local proxy + * was not used locally would be a nasty bug! */ + else if (is_local || is_lib) { + printf("Warning, made-local proxy object %s will loose its link to %s, " + "because the linked-in proxy is referenced (is_local=%i, is_lib=%i).\n", + id->newid->name, ob->proxy->id.name, is_local, is_lib); + } + else { + /* we can switch the proxy'ing from the linked-in to the made-local proxy. */ + BKE_object_make_proxy(ob_new, ob->proxy, ob->proxy_group); + ob->proxy = ob->proxy_from = ob->proxy_group = NULL; + } + } + if (!is_local && !is_lib) { BKE_libblock_free(bmain, id); do_loop = true; |