From cbf241510d7f0873599b3ec892b74460137421a7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 13 Jun 2016 17:39:02 +0200 Subject: First step towards supporting non-blender-data as assets. Idea is to avoid the need for asset engines to generate whole .blend files with relevant datablocks in case they just need/want to provide files (images, videos, sounds...). This commit introduces the concept of 'virtual' library, which in fact only exists to store asset repository data. Datablocks from those virtual libs are then fully written in .blend file. Much to do still, this is only preliminary/experimental work. --- source/blender/blenloader/intern/readfile.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenloader/intern/readfile.c') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6d96b8a1ec7..12869956cfd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8037,6 +8037,12 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short return blo_nextbhead(fd, bhead); } + /* If we have a real ID from a virtual library, tag ID as extern. */ + if (id->lib && (id->lib->flag & LIBRARY_FLAG_VIRTUAL)) { + BLI_assert(ID_VIRTUAL_LIBRARY_VALID(id)); + id->tag |= LIB_TAG_EXTERN; + } + /* need a name for the mallocN, just for debugging and sane prints on leaks */ allocname = dataname(GS(id->name)); -- cgit v1.2.3 From 5aaf18c39cb71142b41c123a7ffc0561c986be40 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 13 Jun 2016 21:40:48 +0200 Subject: WIP experimental support of direct image-as-linkeddata. Works okish, but break on load (or save) of .blend file currently... --- source/blender/blenloader/intern/readfile.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenloader/intern/readfile.c') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 12869956cfd..1c045d9ef71 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7182,6 +7182,8 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) { Main *newmain; + printf("adding lib %s (%s)\n", lib->id.name, lib->name); + /* check if the library was already read */ for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) { if (newmain->curlib) { -- cgit v1.2.3 From c6d3f76e69fbd213e6076071da67dd700e522c4f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 14 Jun 2016 15:47:54 +0200 Subject: Fix save/load issues with new virtual-lib assets. --- source/blender/blenloader/intern/readfile.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenloader/intern/readfile.c') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1c045d9ef71..3950076c73d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2148,6 +2148,9 @@ static void direct_link_id(FileData *fd, ID *id) /* this case means the data was written incorrectly, it should not happen */ IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } + if (id->uuid) { + id->uuid = newdataadr(fd, id->uuid); + } } /* ************ READ CurveMapping *************** */ @@ -8019,6 +8022,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short return blo_nextbhead(fd, bhead); id->tag = tag | LIB_TAG_NEED_LINK; + printf("id: %s (%p, %p), lib: %p\n", id->name, id, id->uuid, main->curlib); id->lib = main->curlib; id->us = ID_FAKE_USERS(id); id->icon_id = 0; @@ -8491,7 +8495,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) bhead->code = ID_SCR; /* deliberate pass on to default */ default: - bhead = read_libblock(fd, bfd->main, bhead, LIB_TAG_LOCAL, NULL); + bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_LOCAL, NULL); } } -- cgit v1.2.3