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 <montagne29@wanadoo.fr>2019-03-25 11:55:36 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-25 12:09:03 +0300
commitc1f8b9753acd6e61317dd7076eac5408fc48d7e6 (patch)
treec7b8b4885db9ab2fd3334f4b6bb2863ad13cf1d8 /source/blender/blenloader
parent6d8a945f06e3dfd720de4839d9df67989ce32388 (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')
-rw-r--r--source/blender/blenloader/BLO_readfile.h2
-rw-r--r--source/blender/blenloader/intern/readfile.c12
2 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index c3a1c0e5185..bff35167792 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -138,7 +138,7 @@ void BLO_library_link_end(
struct Main *mainl, BlendHandle **bh, int flag,
struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d);
-void BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh);
+int BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh, const unsigned int id_types_mask);
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
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(