diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-14 18:50:11 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-15 10:51:15 +0300 |
commit | fe1342ab9b4b45357b47250985ce1b72cd0dd80f (patch) | |
tree | ea2f442bd260f2bd326c757bb03604984bb5bddb /source/blender/blenkernel/intern | |
parent | ec54a08d307b1b1d8af164719ea447ec8f7a40f7 (diff) |
Use temp .blend file copybuffer for pose copy-paste
Uses similar way of storing temp data as object copy paste, just
uses different read entrypoint which does not modify current bmain.
This gives ability to easily copy-paste poses from one blender to
another one.
Hopefully doesn't introduce user-measurable differences.
Request from Peer here in the studio.
Reviewers: mont29
Reviewed By: mont29
Subscribers: hjalti, fsiddi
Differential Revision: https://developer.blender.org/D2229
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/blender_copybuffer.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c index ad01fac2144..a4c28121040 100644 --- a/source/blender/blenkernel/intern/blender_copybuffer.c +++ b/source/blender/blenkernel/intern/blender_copybuffer.c @@ -85,6 +85,31 @@ bool BKE_copybuffer_save(Main *bmain_src, const char *filename, ReportList *repo return retval; } +bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *reports) +{ + BlendHandle *bh = BLO_blendhandle_from_file(libname, reports); + if (bh == NULL) { + /* Error reports will have been made by BLO_blendhandle_from_file(). */ + return false; + } + /* Here appending/linking starts. */ + Main *mainl = BLO_library_link_begin(bmain_dst, &bh, libname); + BLO_library_link_copypaste(mainl, bh); + BLO_library_link_end(mainl, &bh, 0, NULL, NULL); + /* Mark all library linked objects to be updated. */ + BKE_main_lib_objects_recalc_all(bmain_dst); + IMB_colormanagement_check_file_config(bmain_dst); + /* Append, rather than linking. */ + Library *lib = BLI_findstring(&bmain_dst->library, libname, offsetof(Library, filepath)); + BKE_library_make_local(bmain_dst, lib, true, false); + /* Important we unset, otherwise these object wont + * link into other scenes from this blend file. + */ + BKE_main_id_tag_all(bmain_dst, LIB_TAG_PRE_EXISTING, false); + BLO_blendhandle_close(bh); + return true; +} + /** * \return Success. */ |