diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-25 11:55:36 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-25 12:09:03 +0300 |
commit | c1f8b9753acd6e61317dd7076eac5408fc48d7e6 (patch) | |
tree | c7b8b4885db9ab2fd3334f4b6bb2863ad13cf1d8 /source/blender/blenloader/intern | |
parent | 6d8a945f06e3dfd720de4839d9df67989ce32388 (diff) |
Copy/Paste: refactor to be able to paste any kind of IDs, by type.
This commit does not add anything new from user perspective, but make it
possible to paste any kind of IDs, not only objects/collections.
Will be used by new copy/paste in the outliner in next commit.
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6a0ec8cc2cb..3c5a0f136ba 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11019,21 +11019,25 @@ static ID *link_named_part( /** * Simple reader for copy/paste buffers. */ -void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh) +int BLO_library_link_copypaste(Main *mainl, BlendHandle *bh, const unsigned int id_types_mask) { FileData *fd = (FileData *)(bh); BHead *bhead; + int num_directly_linked = 0; for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) { ID *id = NULL; if (bhead->code == ENDB) break; - if (ELEM(bhead->code, ID_OB, ID_GR)) { + + if (BKE_idcode_is_valid(bhead->code) && BKE_idcode_is_linkable(bhead->code) && + (id_types_mask == 0 || (BKE_idcode_to_idfilter((short)bhead->code) & id_types_mask) != 0)) + { read_libblock(fd, mainl, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, &id); + num_directly_linked++; } - if (id) { /* sort by name in list */ ListBase *lb = which_libbase(mainl, GS(id->name)); @@ -11049,6 +11053,8 @@ void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh) } } } + + return num_directly_linked; } static ID *link_named_part_ex( |