diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 18:10:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 18:10:19 +0300 |
commit | 06a1a66a9b6f120867d3bbebe3928744ec8e3495 (patch) | |
tree | 42e827a3cf58eb76474e479206b02a8d97dd3bf7 /source/blender/blenloader | |
parent | 61d27db35967710421ab92748e09624db068258d (diff) | |
parent | a24b4e6090057479796e914bc603119b12f6ca06 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 2 | ||||
-rw-r--r-- | source/blender/blenloader/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 48 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 1616 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.h | 14 | ||||
-rw-r--r-- | source/blender/blenloader/intern/runtime.c | 10 | ||||
-rw-r--r-- | source/blender/blenloader/intern/undofile.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 42 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_260.c | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 74 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 20 |
11 files changed, 919 insertions, 919 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 8b5c64f4ecd..327812f78d5 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -164,7 +164,7 @@ struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath); struct Main *BLO_main_from_memfile(struct MemFile *memfile, struct Main *bmain, struct Scene **r_scene); #ifdef __cplusplus -} +} #endif #endif /* __BLO_READFILE_H__ */ diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index c59232e7887..2c6f6f3edfb 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -23,7 +23,7 @@ # # ***** END GPL LICENSE BLOCK ***** -set(INC +set(INC . ../blenfont ../blenkernel diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 8d90a11f5d9..4ccdbd9e8e1 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -68,10 +68,10 @@ #endif /* local prototypes --------------------- */ -void BLO_blendhandle_print_sizes(BlendHandle *, void *); +void BLO_blendhandle_print_sizes(BlendHandle *, void *); /* Access routines used by filesel. */ - + /** * Open a blendhandle from a file path. * @@ -104,7 +104,7 @@ BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize) return bh; } -void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) +void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) { FileData *fd = (FileData *) bh; BHead *bhead; @@ -117,7 +117,7 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) const short *sp = fd->filesdna->structs[bhead->SDNAnr]; const char *name = fd->filesdna->types[sp[0]]; char buf[4]; - + buf[0] = (bhead->code >> 24) & 0xFF; buf[1] = (bhead->code >> 16) & 0xFF; buf[2] = (bhead->code >> 8) & 0xFF; @@ -127,7 +127,7 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) buf[1] = buf[1] ? buf[1] : ' '; buf[2] = buf[2] ? buf[2] : ' '; buf[3] = buf[3] ? buf[3] : ' '; - + fprintf(fp, "['%.4s', '%s', %d, %ld ],\n", buf, name, bhead->nr, (long int)(bhead->len + sizeof(BHead))); } } @@ -225,7 +225,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to new_prv->rect[0] = NULL; new_prv->w[0] = new_prv->h[0] = 0; } - + if (prv->rect[1] && prv->w[1] && prv->h[1]) { unsigned int *rect = NULL; size_t len = new_prv->w[1] * new_prv->h[1] * sizeof(unsigned int); @@ -255,7 +255,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to new_prv = NULL; prv = NULL; } - + } *tot_prev = tot; @@ -274,7 +274,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) GSet *gathered = BLI_gset_ptr_new("linkable_groups gh"); LinkNode *names = NULL; BHead *bhead; - + for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) { if (bhead->code == ENDB) { break; @@ -289,11 +289,11 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) } } } - + BLI_gset_free(gathered, NULL); - + return names; -} +} /** * Close and free a blendhandle. The handle becomes invalid after this call. @@ -303,7 +303,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) void BLO_blendhandle_close(BlendHandle *bh) { FileData *fd = (FileData *) bh; - + blo_freefiledata(fd); } @@ -323,7 +323,7 @@ BlendFileData *BLO_read_from_file( { BlendFileData *bfd = NULL; FileData *fd; - + fd = blo_openblenderfile(filepath, reports); if (fd) { fd->reports = reports; @@ -350,7 +350,7 @@ BlendFileData *BLO_read_from_memory( { BlendFileData *bfd = NULL; FileData *fd; - + fd = blo_openblendermemory(mem, memsize, reports); if (fd) { fd->reports = reports; @@ -375,13 +375,13 @@ BlendFileData *BLO_read_from_memfile( BlendFileData *bfd = NULL; FileData *fd; ListBase old_mainlist; - + fd = blo_openblendermemfile(memfile, reports); if (fd) { fd->reports = reports; fd->skip_flags = skip_flags; BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase)); - + /* clear ob->proxy_from pointers in old main */ blo_clear_proxy_pointers_from_lib(oldmain); @@ -389,26 +389,26 @@ BlendFileData *BLO_read_from_memfile( blo_split_main(&old_mainlist, oldmain); /* add the library pointers in oldmap lookup */ blo_add_library_pointer_map(&old_mainlist, fd); - + /* makes lookup of existing images in old main */ blo_make_image_pointer_map(fd, oldmain); - + /* makes lookup of existing video clips in old main */ blo_make_movieclip_pointer_map(fd, oldmain); /* make lookups of existing sound data in old main */ blo_make_sound_pointer_map(fd, oldmain); - + /* removed packed data from this trick - it's internal data that needs saves */ - + bfd = blo_read_file_internal(fd, filename); - + /* ensures relinked images are not freed */ blo_end_image_pointer_map(fd, oldmain); - + /* ensures relinked movie clips are not freed */ blo_end_movieclip_pointer_map(fd, oldmain); - + /* ensures relinked sounds are not freed */ blo_end_sound_pointer_map(fd, oldmain); @@ -467,7 +467,7 @@ void BLO_blendfiledata_free(BlendFileData *bfd) if (bfd->main) { BKE_main_free(bfd->main); } - + if (bfd->user) { MEM_freeN(bfd->user); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ebdca0cb8f7..eb9b3f61c08 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -274,17 +274,17 @@ static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection void blo_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...) { char fixed_buf[1024]; /* should be long enough */ - + va_list args; - + va_start(args, format); vsnprintf(fixed_buf, sizeof(fixed_buf), format, args); va_end(args); - + fixed_buf[sizeof(fixed_buf) - 1] = '\0'; - + BKE_report(reports, type, fixed_buf); - + if (G.background == 0) { printf("%s: %s\n", BKE_report_type_str(type), fixed_buf); } @@ -296,27 +296,27 @@ static const char *library_parent_filepath(Library *lib) return lib->parent ? lib->parent->filepath : "<direct>"; } -static OldNewMap *oldnewmap_new(void) +static OldNewMap *oldnewmap_new(void) { OldNewMap *onm= MEM_callocN(sizeof(*onm), "OldNewMap"); - + onm->entriessize = 1024; onm->entries = MEM_malloc_arrayN(onm->entriessize, sizeof(*onm->entries), "OldNewMap.entries"); - + return onm; } static int verg_oldnewmap(const void *v1, const void *v2) { const struct OldNew *x1=v1, *x2=v2; - + if (x1->old > x2->old) return 1; else if (x1->old < x2->old) return -1; return 0; } -static void oldnewmap_sort(FileData *fd) +static void oldnewmap_sort(FileData *fd) { BLI_assert(fd->libmap->sorted == false); qsort(fd->libmap->entries, fd->libmap->nentries, sizeof(OldNew), verg_oldnewmap); @@ -327,9 +327,9 @@ static void oldnewmap_sort(FileData *fd) static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr) { OldNew *entry; - + if (oldaddr==NULL || newaddr==NULL) return; - + if (UNLIKELY(onm->nentries == onm->entriessize)) { onm->entriessize *= 2; onm->entries = MEM_reallocN(onm->entries, sizeof(*onm->entries) * onm->entriessize); @@ -399,19 +399,19 @@ static int oldnewmap_lookup_entry_full(const OldNewMap *onm, const void *addr, i static void *oldnewmap_lookup_and_inc(OldNewMap *onm, const void *addr, bool increase_users) { int i; - + if (addr == NULL) return NULL; - + if (onm->lasthit < onm->nentries-1) { OldNew *entry = &onm->entries[++onm->lasthit]; - + if (entry->old == addr) { if (increase_users) entry->nr++; return entry->newp; } } - + i = oldnewmap_lookup_entry_full(onm, addr, onm->lasthit); if (i != -1) { OldNew *entry = &onm->entries[i]; @@ -421,7 +421,7 @@ static void *oldnewmap_lookup_and_inc(OldNewMap *onm, const void *addr, bool inc entry->nr++; return entry->newp; } - + return NULL; } @@ -460,7 +460,7 @@ static void *oldnewmap_liblookup(OldNewMap *onm, const void *addr, const void *l return NULL; } -static void oldnewmap_free_unused(OldNewMap *onm) +static void oldnewmap_free_unused(OldNewMap *onm) { int i; @@ -473,13 +473,13 @@ static void oldnewmap_free_unused(OldNewMap *onm) } } -static void oldnewmap_clear(OldNewMap *onm) +static void oldnewmap_clear(OldNewMap *onm) { onm->nentries = 0; onm->lasthit = 0; } -static void oldnewmap_free(OldNewMap *onm) +static void oldnewmap_free(OldNewMap *onm) { MEM_freeN(onm->entries); MEM_freeN(onm); @@ -495,7 +495,7 @@ static void add_main_to_main(Main *mainvar, Main *from) { ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY]; int a; - + set_listbasepointers(mainvar, lbarray); a = set_listbasepointers(from, fromarray); while (a--) { @@ -506,7 +506,7 @@ static void add_main_to_main(Main *mainvar, Main *from) void blo_join_main(ListBase *mainlist) { Main *tojoin, *mainl; - + mainl = mainlist->first; while ((tojoin = mainl->next)) { add_main_to_main(mainl, tojoin); @@ -542,10 +542,10 @@ void blo_split_main(ListBase *mainlist, Main *main) { mainlist->first = mainlist->last = main; main->next = NULL; - + if (BLI_listbase_is_empty(&main->library)) return; - + /* (Library.temp_index -> Main), lookup table */ const unsigned int lib_main_array_len = BLI_listbase_count(&main->library); Main **lib_main_array = MEM_malloc_arrayN(lib_main_array_len, sizeof(*lib_main_array), __func__); @@ -560,7 +560,7 @@ void blo_split_main(ListBase *mainlist, Main *main) lib->temp_index = i; lib_main_array[i] = libmain; } - + ListBase *lbarray[MAX_LIBARRAY]; i = set_listbasepointers(main, lbarray); while (i--) { @@ -577,7 +577,7 @@ void blo_split_main(ListBase *mainlist, Main *main) static void read_file_version(FileData *fd, Main *main) { BHead *bhead; - + for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) { if (bhead->code == GLOB) { FileGlobal *fg= read_struct(fd, bhead, "Global"); @@ -642,37 +642,37 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab Main *m; Library *lib; char name1[FILE_MAX]; - + BLI_strncpy(name1, filepath, sizeof(name1)); BLI_cleanup_path(relabase, name1); - + // printf("blo_find_main: relabase %s\n", relabase); // printf("blo_find_main: original in %s\n", filepath); // printf("blo_find_main: converted to %s\n", name1); - + for (m = mainlist->first; m; m = m->next) { const char *libname = (m->curlib) ? m->curlib->filepath : m->name; - + if (BLI_path_cmp(name1, libname) == 0) { if (G.debug & G_DEBUG) printf("blo_find_main: found library %s\n", libname); return m; } } - + m = BKE_main_new(); BLI_addtail(mainlist, m); - + /* Add library datablock itself to 'main' Main, since libraries are **never** linked data. * Fixes bug where you could end with all ID_LI datablocks having the same name... */ lib = BKE_libblock_alloc(mainlist->first, ID_LI, "Lib", 0); lib->id.us = ID_FAKE_USERS(lib); /* Important, consistency with main ID reading code from read_libblock(). */ BLI_strncpy(lib->name, filepath, sizeof(lib->name)); BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath)); - + m->curlib = lib; - + read_file_version(fd, m); - + if (G.debug & G_DEBUG) printf("blo_find_main: added new lib %s\n", filepath); return m; } @@ -684,7 +684,7 @@ static void switch_endian_bh4(BHead4 *bhead) { /* the ID_.. codes */ if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16; - + if (bhead->code != ENDB) { BLI_endian_switch_int32(&bhead->len); BLI_endian_switch_int32(&bhead->SDNAnr); @@ -696,7 +696,7 @@ static void switch_endian_bh8(BHead8 *bhead) { /* the ID_.. codes */ if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16; - + if (bhead->code != ENDB) { BLI_endian_switch_int32(&bhead->len); BLI_endian_switch_int32(&bhead->SDNAnr); @@ -719,12 +719,12 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap) if (do_endian_swap) { BLI_endian_switch_int64(&bhead8->old); } - + /* this patch is to avoid a long long being read from not-eight aligned positions * is necessary on any modern 64bit architecture) */ memcpy(&old, &bhead8->old, 8); bhead4->old = (int) (old >> 3); - + bhead4->SDNAnr = bhead8->SDNAnr; bhead4->nr = bhead8->nr; } @@ -733,10 +733,10 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap) static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4) { BHead8 *bhead8 = (BHead8 *) bhead; - + bhead8->code = bhead4->code; bhead8->len = bhead4->len; - + if (bhead8->code != ENDB) { bhead8->old = bhead4->old; bhead8->SDNAnr = bhead4->SDNAnr; @@ -748,7 +748,7 @@ static BHeadN *get_bhead(FileData *fd) { BHeadN *new_bhead = NULL; int readsize; - + if (fd) { if (!fd->eof) { /* initializing to zero isn't strictly needed but shuts valgrind up @@ -756,7 +756,7 @@ static BHeadN *get_bhead(FileData *fd) BHead8 bhead8 = {0}; BHead4 bhead4 = {0}; BHead bhead = {0}; - + /* First read the bhead structure. * Depending on the platform the file was written on this can * be a big or little endian BHead4 or BHead8 structure. @@ -767,12 +767,12 @@ static BHeadN *get_bhead(FileData *fd) if (fd->flags & FD_FLAGS_FILE_POINTSIZE_IS_4) { bhead4.code = DATA; readsize = fd->read(fd, &bhead4, sizeof(bhead4)); - + if (readsize == sizeof(bhead4) || bhead4.code == ENDB) { if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { switch_endian_bh4(&bhead4); } - + if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) { bh8_from_bh4(&bhead, &bhead4); } @@ -790,12 +790,12 @@ static BHeadN *get_bhead(FileData *fd) else { bhead8.code = DATA; readsize = fd->read(fd, &bhead8, sizeof(bhead8)); - + if (readsize == sizeof(bhead8) || bhead8.code == ENDB) { if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { switch_endian_bh8(&bhead8); } - + if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) { bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN)); } @@ -810,10 +810,10 @@ static BHeadN *get_bhead(FileData *fd) bhead.len= 0; } } - + /* make sure people are not trying to pass bad blend files */ if (bhead.len < 0) fd->eof = 1; - + /* bhead now contains the (converted) bhead structure. Now read * the associated data and put everything in a BHeadN (creative naming !) */ @@ -822,9 +822,9 @@ static BHeadN *get_bhead(FileData *fd) if (new_bhead) { new_bhead->next = new_bhead->prev = NULL; new_bhead->bhead = bhead; - + readsize = fd->read(fd, new_bhead + 1, bhead.len); - + if (readsize != bhead.len) { fd->eof = 1; MEM_freeN(new_bhead); @@ -844,7 +844,7 @@ static BHeadN *get_bhead(FileData *fd) if (new_bhead) { BLI_addtail(&fd->listbase, new_bhead); } - + return(new_bhead); } @@ -852,7 +852,7 @@ BHead *blo_firstbhead(FileData *fd) { BHeadN *new_bhead; BHead *bhead = NULL; - + /* Rewind the file * Read in a new block if necessary */ @@ -860,11 +860,11 @@ BHead *blo_firstbhead(FileData *fd) if (new_bhead == NULL) { new_bhead = get_bhead(fd); } - + if (new_bhead) { bhead = &new_bhead->bhead; } - + return(bhead); } @@ -872,7 +872,7 @@ BHead *blo_prevbhead(FileData *UNUSED(fd), BHead *thisblock) { BHeadN *bheadn = (BHeadN *)POINTER_OFFSET(thisblock, -offsetof(BHeadN, bhead)); BHeadN *prev = bheadn->prev; - + return (prev) ? &prev->bhead : NULL; } @@ -880,25 +880,25 @@ BHead *blo_nextbhead(FileData *fd, BHead *thisblock) { BHeadN *new_bhead = NULL; BHead *bhead = NULL; - + if (thisblock) { /* bhead is actually a sub part of BHeadN * We calculate the BHeadN pointer from the BHead pointer below */ new_bhead = (BHeadN *)POINTER_OFFSET(thisblock, -offsetof(BHeadN, bhead)); - + /* get the next BHeadN. If it doesn't exist we read in the next one */ new_bhead = new_bhead->next; if (new_bhead == NULL) { new_bhead = get_bhead(fd); } } - + if (new_bhead) { /* here we do the reverse: * go from the BHeadN pointer to the BHead pointer */ bhead = &new_bhead->bhead; } - + return(bhead); } @@ -957,11 +957,11 @@ static void decode_blender_header(FileData *fd) static bool read_file_dna(FileData *fd, const char **r_error_message) { BHead *bhead; - + for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) { if (bhead->code == DNA1) { const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0; - + fd->filesdna = DNA_sdna_from_data(&bhead[1], bhead->len, do_endian_swap, true, r_error_message); if (fd->filesdna) { fd->compflags = DNA_struct_get_compareflags(fd->filesdna, fd->memsdna); @@ -973,12 +973,12 @@ static bool read_file_dna(FileData *fd, const char **r_error_message) else { return false; } - + } else if (bhead->code == ENDB) break; } - + *r_error_message = "Missing DNA block"; return false; } @@ -1027,28 +1027,28 @@ static int *read_file_thumbnail(FileData *fd) static int fd_read_from_file(FileData *filedata, void *buffer, unsigned int size) { int readsize = read(filedata->filedes, buffer, size); - + if (readsize < 0) { readsize = EOF; } else { filedata->seek += readsize; } - + return readsize; } static int fd_read_gzip_from_file(FileData *filedata, void *buffer, unsigned int size) { int readsize = gzread(filedata->gzfiledes, buffer, size); - + if (readsize < 0) { readsize = EOF; } else { filedata->seek += readsize; } - + return (readsize); } @@ -1056,10 +1056,10 @@ static int fd_read_from_memory(FileData *filedata, void *buffer, unsigned int si { /* don't read more bytes then there are available in the buffer */ int readsize = (int)MIN2(size, (unsigned int)(filedata->buffersize - filedata->seek)); - + memcpy(buffer, filedata->buffer + filedata->seek, readsize); filedata->seek += readsize; - + return (readsize); } @@ -1069,13 +1069,13 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int s static unsigned int offset = 0; /* size of previous chunks */ static MemFileChunk *chunk = NULL; unsigned int chunkoffset, readsize, totread; - + if (size == 0) return 0; - + if (seek != (unsigned int)filedata->seek) { chunk = filedata->memfile->chunks.first; seek = 0; - + while (chunk) { if (seek + chunk->size > (unsigned) filedata->seek) break; seek += chunk->size; @@ -1084,48 +1084,48 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int s offset = seek; seek = filedata->seek; } - + if (chunk) { totread = 0; - + do { /* first check if it's on the end if current chunk */ if (seek-offset == chunk->size) { offset += chunk->size; chunk = chunk->next; } - + /* debug, should never happen */ if (chunk == NULL) { printf("illegal read, chunk zero\n"); return 0; } - + chunkoffset = seek-offset; readsize = size-totread; - + /* data can be spread over multiple chunks, so clamp size * to within this chunk, and then it will read further in * the next chunk */ if (chunkoffset+readsize > chunk->size) readsize= chunk->size-chunkoffset; - + memcpy(POINTER_OFFSET(buffer, totread), chunk->buf + chunkoffset, readsize); totread += readsize; filedata->seek += readsize; seek += readsize; } while (totread < size); - + return totread; } - + return 0; } static FileData *filedata_new(void) { FileData *fd = MEM_callocN(sizeof(FileData), "FileData"); - + fd->filedes = -1; fd->gzfiledes = NULL; @@ -1134,14 +1134,14 @@ static FileData *filedata_new(void) fd->datamap = oldnewmap_new(); fd->globmap = oldnewmap_new(); fd->libmap = oldnewmap_new(); - + return fd; } static FileData *blo_decode_and_check(FileData *fd, ReportList *reports) { decode_blender_header(fd); - + if (fd->flags & FD_FLAGS_FILE_OK) { const char *error_message = NULL; if (read_file_dna(fd, &error_message) == false) { @@ -1157,7 +1157,7 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports) blo_freefiledata(fd); fd = NULL; } - + return fd; } @@ -1168,7 +1168,7 @@ FileData *blo_openblenderfile(const char *filepath, ReportList *reports) gzFile gzfile; errno = 0; gzfile = BLI_gzopen(filepath, "rb"); - + if (gzfile == (gzFile)Z_NULL) { BKE_reportf(reports, RPT_WARNING, "Unable to open '%s': %s", filepath, errno ? strerror(errno) : TIP_("unknown error reading file")); @@ -1178,10 +1178,10 @@ FileData *blo_openblenderfile(const char *filepath, ReportList *reports) FileData *fd = filedata_new(); fd->gzfiledes = gzfile; fd->read = fd_read_gzip_from_file; - + /* needed for library_append and read_libraries */ BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase)); - + return blo_decode_and_check(fd, reports); } } @@ -1244,12 +1244,12 @@ static int fd_read_gzip_from_memory_init(FileData *fd) fd->strm.total_out = 0; fd->strm.zalloc = Z_NULL; fd->strm.zfree = Z_NULL; - + if (inflateInit2(&fd->strm, (16+MAX_WBITS)) != Z_OK) return 0; fd->read = fd_read_gzip_from_memory; - + return 1; } @@ -1262,10 +1262,10 @@ FileData *blo_openblendermemory(const void *mem, int memsize, ReportList *report else { FileData *fd = filedata_new(); const char *cp = mem; - + fd->buffer = mem; fd->buffersize = memsize; - + /* test if gzip */ if (cp[0] == 0x1f && cp[1] == 0x8b) { if (0 == fd_read_gzip_from_memory_init(fd)) { @@ -1275,7 +1275,7 @@ FileData *blo_openblendermemory(const void *mem, int memsize, ReportList *report } else fd->read = fd_read_from_memory; - + fd->flags |= FD_FLAGS_NOT_MY_BUFFER; return blo_decode_and_check(fd, reports); @@ -1291,10 +1291,10 @@ FileData *blo_openblendermemfile(MemFile *memfile, ReportList *reports) else { FileData *fd = filedata_new(); fd->memfile = memfile; - + fd->read = fd_read_from_memfile; fd->flags |= FD_FLAGS_NOT_MY_BUFFER; - + return blo_decode_and_check(fd, reports); } } @@ -1306,22 +1306,22 @@ void blo_freefiledata(FileData *fd) if (fd->filedes != -1) { close(fd->filedes); } - + if (fd->gzfiledes != NULL) { gzclose(fd->gzfiledes); } - + if (fd->strm.next_in) { if (inflateEnd(&fd->strm) != Z_OK) { printf("close gzip stream error\n"); } } - + if (fd->buffer && !(fd->flags & FD_FLAGS_NOT_MY_BUFFER)) { MEM_freeN((void *)fd->buffer); fd->buffer = NULL; } - + // Free all BHeadN data blocks BLI_freelistN(&fd->listbase); @@ -1329,7 +1329,7 @@ void blo_freefiledata(FileData *fd) DNA_sdna_free(fd->filesdna); if (fd->compflags) MEM_freeN((void *)fd->compflags); - + if (fd->datamap) oldnewmap_free(fd->datamap); if (fd->globmap) @@ -1346,7 +1346,7 @@ void blo_freefiledata(FileData *fd) oldnewmap_free(fd->libmap); if (fd->bheadmap) MEM_freeN(fd->bheadmap); - + #ifdef USE_GHASH_BHEAD if (fd->bhead_idname_hash) { BLI_ghash_free(fd->bhead_idname_hash, NULL, NULL); @@ -1543,7 +1543,7 @@ static void *newpackedadr(FileData *fd, const void *adr) /* used to restore { if (fd->packedmap && adr) return oldnewmap_lookup_and_inc(fd->packedmap, adr, true); - + return oldnewmap_lookup_and_inc(fd->datamap, adr, true); } @@ -1561,9 +1561,9 @@ void *blo_do_versions_newlibadr(FileData *fd, const void *lib, const void *adr) static void *newlibadr_us(FileData *fd, const void *lib, const void *adr) /* increases user number */ { ID *id = newlibadr(fd, lib, adr); - + id_us_plus_no_lib(id); - + return id; } @@ -1584,13 +1584,13 @@ static void *newlibadr_real_us(FileData *fd, const void *lib, const void *adr) / static void change_idid_adr_fd(FileData *fd, const void *old, void *new) { int i; - + /* use a binary search if we have a sorted libmap, for now it's not needed. */ BLI_assert(fd->libmap->sorted == false); for (i = 0; i < fd->libmap->nentries; i++) { OldNew *entry = &fd->libmap->entries[i]; - + if (old==entry->newp && entry->nr==ID_ID) { entry->newp = new; if (new) entry->nr = GS( ((ID *)new)->name ); @@ -1601,15 +1601,15 @@ static void change_idid_adr_fd(FileData *fd, const void *old, void *new) static void change_idid_adr(ListBase *mainlist, FileData *basefd, void *old, void *new) { Main *mainptr; - + for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) { FileData *fd; - + if (mainptr->curlib) fd = mainptr->curlib->filedata; else fd = basefd; - + if (fd) { change_idid_adr_fd(fd, old, new); } @@ -1623,7 +1623,7 @@ static void change_idid_adr(ListBase *mainlist, FileData *basefd, void *old, voi void blo_clear_proxy_pointers_from_lib(Main *oldmain) { Object *ob = oldmain->object.first; - + for (; ob; ob= ob->id.next) { if (ob->id.lib) ob->proxy_from = NULL; @@ -1635,9 +1635,9 @@ void blo_make_image_pointer_map(FileData *fd, Main *oldmain) Image *ima = oldmain->image.first; Scene *sce = oldmain->scene.first; int a; - + fd->imamap = oldnewmap_new(); - + for (; ima; ima = ima->id.next) { if (ima->cache) oldnewmap_insert(fd->imamap, ima->cache, ima->cache, 0); @@ -1669,13 +1669,13 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain) Image *ima = oldmain->image.first; Scene *sce = oldmain->scene.first; int i; - + /* used entries were restored, so we put them to zero */ for (i = 0; i < fd->imamap->nentries; i++, entry++) { if (entry->nr > 0) entry->newp = NULL; } - + for (; ima; ima = ima->id.next) { ima->cache = newimaadr(fd, ima->cache); if (ima->cache == NULL) { @@ -1687,7 +1687,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain) } LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots) slot->render = newimaadr(fd, slot->render); - + for (i = 0; i < TEXTARGET_COUNT; i++) ima->gputexture[i] = newimaadr(fd, ima->gputexture[i]); ima->rr = newimaadr(fd, ima->rr); @@ -1696,7 +1696,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain) if (sce->nodetree && sce->nodetree->previews) { bNodeInstanceHash *new_previews = BKE_node_instance_hash_new("node previews"); bNodeInstanceHashIterator iter; - + /* reconstruct the preview hash, only using remaining pointers */ NODE_INSTANCE_HASH_ITER(iter, sce->nodetree->previews) { bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter); @@ -1718,17 +1718,17 @@ void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain) { MovieClip *clip = oldmain->movieclip.first; Scene *sce = oldmain->scene.first; - + fd->movieclipmap = oldnewmap_new(); - + for (; clip; clip = clip->id.next) { if (clip->cache) oldnewmap_insert(fd->movieclipmap, clip->cache, clip->cache, 0); - + if (clip->tracking.camera.intrinsics) oldnewmap_insert(fd->movieclipmap, clip->tracking.camera.intrinsics, clip->tracking.camera.intrinsics, 0); } - + for (; sce; sce = sce->id.next) { if (sce->nodetree) { bNode *node; @@ -1747,18 +1747,18 @@ void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain) MovieClip *clip = oldmain->movieclip.first; Scene *sce = oldmain->scene.first; int i; - + /* used entries were restored, so we put them to zero */ for (i=0; i < fd->movieclipmap->nentries; i++, entry++) { if (entry->nr > 0) entry->newp = NULL; } - + for (; clip; clip = clip->id.next) { clip->cache = newmclipadr(fd, clip->cache); clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics); } - + for (; sce; sce = sce->id.next) { if (sce->nodetree) { bNode *node; @@ -1772,12 +1772,12 @@ void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain) void blo_make_sound_pointer_map(FileData *fd, Main *oldmain) { bSound *sound = oldmain->sound.first; - + fd->soundmap = oldnewmap_new(); - + for (; sound; sound = sound->id.next) { if (sound->waveform) - oldnewmap_insert(fd->soundmap, sound->waveform, sound->waveform, 0); + oldnewmap_insert(fd->soundmap, sound->waveform, sound->waveform, 0); } } @@ -1788,13 +1788,13 @@ void blo_end_sound_pointer_map(FileData *fd, Main *oldmain) OldNew *entry = fd->soundmap->entries; bSound *sound = oldmain->sound.first; int i; - + /* used entries were restored, so we put them to zero */ for (i = 0; i < fd->soundmap->nentries; i++, entry++) { if (entry->nr > 0) entry->newp = NULL; } - + for (; sound; sound = sound->id.next) { sound->waveform = newsoundadr(fd, sound->waveform); } @@ -1814,9 +1814,9 @@ void blo_make_packed_pointer_map(FileData *fd, Main *oldmain) VFont *vfont; bSound *sound; Library *lib; - + fd->packedmap = oldnewmap_new(); - + for (ima = oldmain->image.first; ima; ima = ima->id.next) { ImagePackedFile *imapf; @@ -1827,15 +1827,15 @@ void blo_make_packed_pointer_map(FileData *fd, Main *oldmain) if (imapf->packedfile) insert_packedmap(fd, imapf->packedfile); } - + for (vfont = oldmain->vfont.first; vfont; vfont = vfont->id.next) if (vfont->packedfile) insert_packedmap(fd, vfont->packedfile); - + for (sound = oldmain->sound.first; sound; sound = sound->id.next) if (sound->packedfile) insert_packedmap(fd, sound->packedfile); - + for (lib = oldmain->library.first; lib; lib = lib->id.next) if (lib->packedfile) insert_packedmap(fd, lib->packedfile); @@ -1852,13 +1852,13 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain) Library *lib; OldNew *entry = fd->packedmap->entries; int i; - + /* used entries were restored, so we put them to zero */ for (i=0; i < fd->packedmap->nentries; i++, entry++) { if (entry->nr > 0) entry->newp = NULL; } - + for (ima = oldmain->image.first; ima; ima = ima->id.next) { ImagePackedFile *imapf; @@ -1867,13 +1867,13 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain) for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) imapf->packedfile = newpackedadr(fd, imapf->packedfile); } - + for (vfont = oldmain->vfont.first; vfont; vfont = vfont->id.next) vfont->packedfile = newpackedadr(fd, vfont->packedfile); for (sound = oldmain->sound.first; sound; sound = sound->id.next) sound->packedfile = newpackedadr(fd, sound->packedfile); - + for (lib = oldmain->library.first; lib; lib = lib->id.next) lib->packedfile = newpackedadr(fd, lib->packedfile); } @@ -1884,7 +1884,7 @@ void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd) { Main *ptr = old_mainlist->first; ListBase *lbarray[MAX_LIBARRAY]; - + for (ptr = ptr->next; ptr; ptr = ptr->next) { int i = set_listbasepointers(ptr, lbarray); while (i--) { @@ -1905,14 +1905,14 @@ static void switch_endian_structs(const struct SDNA *filesdna, BHead *bhead) { int blocksize, nblocks; char *data; - + data = (char *)(bhead+1); blocksize = filesdna->typelens[ filesdna->structs[bhead->SDNAnr][0] ]; - + nblocks = bhead->nr; while (nblocks--) { DNA_struct_switch_endian(filesdna, bhead->SDNAnr, data); - + data += blocksize; } } @@ -1920,12 +1920,12 @@ static void switch_endian_structs(const struct SDNA *filesdna, BHead *bhead) static void *read_struct(FileData *fd, BHead *bh, const char *blockname) { void *temp = NULL; - + if (bh->len) { /* switch is based on file dna */ if (bh->SDNAnr && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) switch_endian_structs(fd->filesdna, bh); - + if (fd->compflags[bh->SDNAnr] != SDNA_CMP_REMOVED) { if (fd->compflags[bh->SDNAnr] == SDNA_CMP_NOT_EQUAL) { temp = DNA_struct_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh+1)); @@ -1946,9 +1946,9 @@ typedef void (*link_list_cb)(FileData *fd, void *data); static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /* only direct data */ { Link *ln, *prev; - + if (BLI_listbase_is_empty(lb)) return; - + lb->first = newdataadr(fd, lb->first); if (callback != NULL) { callback(fd, lb->first); @@ -1983,7 +1983,7 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */ oldnewmap_insert(fd->globmap, lb->first, poin, 0); } lb->first = poin; - + ln = lb->first; prev = NULL; while (ln) { @@ -2011,11 +2011,11 @@ static void test_pointer_array(FileData *fd, void **mat) */ if (*mat) { len = MEM_allocN_len(*mat)/fd->filesdna->pointerlen; - + if (fd->filesdna->pointerlen==8 && fd->memsdna->pointerlen==4) { ipoin=imat= MEM_malloc_arrayN(len, 4, "newmatar"); lpoin= *mat; - + while (len-- > 0) { if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN)) BLI_endian_switch_int64(lpoin); @@ -2026,11 +2026,11 @@ static void test_pointer_array(FileData *fd, void **mat) MEM_freeN(*mat); *mat = imat; } - + if (fd->filesdna->pointerlen==4 && fd->memsdna->pointerlen==8) { lpoin = lmat = MEM_malloc_arrayN(len, 8, "newmatar"); ipoin = *mat; - + while (len-- > 0) { *lpoin = *ipoin; ipoin++; @@ -2051,21 +2051,21 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData { IDProperty *array; int i; - + /* since we didn't save the extra buffer, set totallen to len */ prop->totallen = prop->len; prop->data.pointer = newdataadr(fd, prop->data.pointer); array = (IDProperty *)prop->data.pointer; - + /* note!, idp-arrays didn't exist in 2.4x, so the pointer will be cleared * theres not really anything we can do to correct this, at least don't crash */ if (array == NULL) { prop->len = 0; prop->totallen = 0; } - - + + for (i = 0; i < prop->len; i++) IDP_DirectLinkProperty(&array[i], switch_endian, fd); } @@ -2074,15 +2074,15 @@ static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *f { IDProperty **array; int i; - + /* since we didn't save the extra buffer, set totallen to len */ prop->totallen = prop->len; prop->data.pointer = newdataadr(fd, prop->data.pointer); - + if (prop->subtype == IDP_GROUP) { test_pointer_array(fd, prop->data.pointer); array = prop->data.pointer; - + for (i = 0; i < prop->len; i++) IDP_DirectLinkProperty(array[i], switch_endian, fd); } @@ -2110,9 +2110,9 @@ static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, FileData *f { ListBase *lb = &prop->data.group; IDProperty *loop; - + link_list(fd, lb); - + /*Link child id properties now*/ for (loop=prop->data.group.first; loop; loop=loop->next) { IDP_DirectLinkProperty(loop, switch_endian, fd); @@ -2144,7 +2144,7 @@ static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData * if switch_endian is true, so we have to first unswap * them then reswap them as a single 64-bit entity. */ - + if (switch_endian) { BLI_endian_switch_int32(&prop->data.val); BLI_endian_switch_int32(&prop->data.val2); @@ -2227,7 +2227,7 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd) static PreviewImage *direct_link_preview_image(FileData *fd, PreviewImage *old_prv) { PreviewImage *prv = newdataadr(fd, old_prv); - + if (prv) { int i; for (i = 0; i < NUM_ICON_SIZES; ++i) { @@ -2239,7 +2239,7 @@ static PreviewImage *direct_link_preview_image(FileData *fd, PreviewImage *old_p prv->icon_id = 0; prv->tag = 0; } - + return prv; } @@ -2308,10 +2308,10 @@ static void direct_link_id(FileData *fd, ID *id) static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap) { int a; - + /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */ cumap->flag &= ~CUMA_PREMULLED; - + for (a = 0; a < CM_TOT; a++) { cumap->cm[a].curve = newdataadr(fd, cumap->cm[a].curve); cumap->cm[a].table = NULL; @@ -2402,7 +2402,7 @@ static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf) if (pf) { pf->data = newpackedadr(fd, pf->data); } - + return pf; } @@ -2414,7 +2414,7 @@ static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf) static void lib_link_ipo(FileData *fd, Main *main) { Ipo *ipo; - + for (ipo = main->ipo.first; ipo; ipo = ipo->id.next) { if (ipo->id.tag & LIB_TAG_NEED_LINK) { IpoCurve *icu; @@ -2433,7 +2433,7 @@ static void direct_link_ipo(FileData *fd, Ipo *ipo) IpoCurve *icu; link_list(fd, &(ipo->curve)); - + for (icu = ipo->curve.first; icu; icu = icu->next) { icu->bezt = newdataadr(fd, icu->bezt); icu->bp = newdataadr(fd, icu->bp); @@ -2446,7 +2446,7 @@ static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist) { bActionStrip *strip; bActionModifier *amod; - + for (strip=striplist->first; strip; strip=strip->next) { strip->object = newlibadr(fd, id->lib, strip->object); strip->act = newlibadr_us(fd, id->lib, strip->act); @@ -2460,9 +2460,9 @@ static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist) static void direct_link_nlastrips(FileData *fd, ListBase *strips) { bActionStrip *strip; - + link_list(fd, strips); - + for (strip = strips->first; strip; strip = strip->next) link_list(fd, &strip->modifiers); } @@ -2482,7 +2482,7 @@ static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbas static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list) { FModifier *fcm; - + for (fcm = list->first; fcm; fcm = fcm->next) { /* data for specific modifiers */ switch (fcm->type) { @@ -2497,33 +2497,33 @@ static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list) } } -static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) +static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) { FCurve *fcu; - + if (list == NULL) return; - + /* relink ID-block references... */ for (fcu = list->first; fcu; fcu = fcu->next) { /* driver data */ if (fcu->driver) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + for (dvar= driver->variables.first; dvar; dvar= dvar->next) { DRIVER_TARGETS_LOOPER(dvar) { /* only relink if still used */ if (tarIndex < dvar->num_targets) - dtar->id = newlibadr(fd, id->lib, dtar->id); + dtar->id = newlibadr(fd, id->lib, dtar->id); else dtar->id = NULL; } DRIVER_TARGETS_LOOPER_END } } - + /* modifiers */ lib_link_fmodifiers(fd, id, &fcu->modifiers); } @@ -2534,20 +2534,20 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) static void direct_link_fmodifiers(FileData *fd, ListBase *list, FCurve *curve) { FModifier *fcm; - + for (fcm = list->first; fcm; fcm = fcm->next) { /* relink general data */ fcm->data = newdataadr(fd, fcm->data); fcm->curve = curve; - + /* do relinking of data for specific types */ switch (fcm->type) { case FMODIFIER_TYPE_GENERATOR: { FMod_Generator *data = (FMod_Generator *)fcm->data; - + data->coefficients = newdataadr(fd, data->coefficients); - + if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { BLI_endian_switch_float_array(data->coefficients, data->arraysize); } @@ -2557,7 +2557,7 @@ static void direct_link_fmodifiers(FileData *fd, ListBase *list, FCurve *curve) case FMODIFIER_TYPE_ENVELOPE: { FMod_Envelope *data= (FMod_Envelope *)fcm->data; - + data->data= newdataadr(fd, data->data); break; @@ -2565,7 +2565,7 @@ static void direct_link_fmodifiers(FileData *fd, ListBase *list, FCurve *curve) case FMODIFIER_TYPE_PYTHON: { FMod_Python *data = (FMod_Python *)fcm->data; - + data->prop = newdataadr(fd, data->prop); IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); @@ -2579,38 +2579,38 @@ static void direct_link_fmodifiers(FileData *fd, ListBase *list, FCurve *curve) static void direct_link_fcurves(FileData *fd, ListBase *list) { FCurve *fcu; - + /* link F-Curve data to F-Curve again (non ID-libs) */ for (fcu = list->first; fcu; fcu = fcu->next) { /* curve data */ fcu->bezt = newdataadr(fd, fcu->bezt); fcu->fpt = newdataadr(fd, fcu->fpt); - + /* rna path */ fcu->rna_path = newdataadr(fd, fcu->rna_path); - + /* group */ fcu->grp = newdataadr_ex(fd, fcu->grp, false); - + /* clear disabled flag - allows disabled drivers to be tried again ([#32155]), * but also means that another method for "reviving disabled F-Curves" exists */ fcu->flag &= ~FCURVE_DISABLED; - + /* driver */ fcu->driver= newdataadr(fd, fcu->driver); if (fcu->driver) { ChannelDriver *driver= fcu->driver; DriverVar *dvar; - + /* compiled expression data will need to be regenerated (old pointer may still be set here) */ driver->expr_comp = NULL; - - /* give the driver a fresh chance - the operating environment may be different now + + /* give the driver a fresh chance - the operating environment may be different now * (addons, etc. may be different) so the driver namespace may be sane now [#32155] */ driver->flag &= ~DRIVER_FLAG_INVALID; - + /* relink variables, targets and their paths */ link_list(fd, &driver->variables); for (dvar= driver->variables.first; dvar; dvar= dvar->next) { @@ -2625,7 +2625,7 @@ static void direct_link_fcurves(FileData *fd, ListBase *list) DRIVER_TARGETS_LOOPER_END } } - + /* modifiers */ link_list(fd, &fcu->modifiers); direct_link_fmodifiers(fd, &fcu->modifiers, fcu); @@ -2638,14 +2638,14 @@ static void lib_link_action(FileData *fd, Main *main) for (bAction *act = main->action.first; act; act = act->id.next) { if (act->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(act->id.properties, fd); - + // XXX deprecated - old animation system <<< for (bActionChannel *chan = act->chanbase.first; chan; chan = chan->next) { chan->ipo = newlibadr_us(fd, act->id.lib, chan->ipo); lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels); } // >>> XXX deprecated - old animation system - + lib_link_fcurves(fd, &act->id, &act->curves); for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { @@ -2672,13 +2672,13 @@ static void direct_link_action(FileData *fd, bAction *act) // XXX deprecated - old animation system <<< for (achan = act->chanbase.first; achan; achan=achan->next) { achan->grp = newdataadr(fd, achan->grp); - + link_list(fd, &achan->constraintChannels); } // >>> XXX deprecated - old animation system direct_link_fcurves(fd, &act->curves); - + for (agrp = act->groups.first; agrp; agrp= agrp->next) { agrp->channels.first= newdataadr(fd, agrp->channels.first); agrp->channels.last= newdataadr(fd, agrp->channels.last); @@ -2688,17 +2688,17 @@ static void direct_link_action(FileData *fd, bAction *act) static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list) { NlaStrip *strip; - + for (strip = list->first; strip; strip = strip->next) { /* check strip's children */ lib_link_nladata_strips(fd, id, &strip->strips); - + /* check strip's F-Curves */ lib_link_fcurves(fd, id, &strip->fcurves); - + /* reassign the counted-reference to action */ strip->act = newlibadr_us(fd, id->lib, strip->act); - + /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */ if ((strip->act) && (strip->act->idroot == 0)) strip->act->idroot = GS(id->name); @@ -2708,29 +2708,29 @@ static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list) static void lib_link_nladata(FileData *fd, ID *id, ListBase *list) { NlaTrack *nlt; - + /* we only care about the NLA strips inside the tracks */ for (nlt = list->first; nlt; nlt = nlt->next) { lib_link_nladata_strips(fd, id, &nlt->strips); } } -/* This handles Animato NLA-Strips linking +/* This handles Animato NLA-Strips linking * NOTE: this assumes that link_list has already been called on the list */ static void direct_link_nladata_strips(FileData *fd, ListBase *list) { NlaStrip *strip; - + for (strip = list->first; strip; strip = strip->next) { /* strip's child strips */ link_list(fd, &strip->strips); direct_link_nladata_strips(fd, &strip->strips); - + /* strip's F-Curves */ link_list(fd, &strip->fcurves); direct_link_fcurves(fd, &strip->fcurves); - + /* strip's F-Modifiers */ link_list(fd, &strip->modifiers); direct_link_fmodifiers(fd, &strip->modifiers, NULL); @@ -2741,11 +2741,11 @@ static void direct_link_nladata_strips(FileData *fd, ListBase *list) static void direct_link_nladata(FileData *fd, ListBase *list) { NlaTrack *nlt; - + for (nlt = list->first; nlt; nlt = nlt->next) { /* relink list of strips */ link_list(fd, &nlt->strips); - + /* relink strip data */ direct_link_nladata_strips(fd, &nlt->strips); } @@ -2757,11 +2757,11 @@ static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list) { KeyingSet *ks; KS_Path *ksp; - + /* here, we're only interested in the ID pointer stored in some of the paths */ for (ks = list->first; ks; ks = ks->next) { for (ksp = ks->paths.first; ksp; ksp = ksp->next) { - ksp->id= newlibadr(fd, id->lib, ksp->id); + ksp->id= newlibadr(fd, id->lib, ksp->id); } } } @@ -2771,12 +2771,12 @@ static void direct_link_keyingsets(FileData *fd, ListBase *list) { KeyingSet *ks; KS_Path *ksp; - + /* link KeyingSet data to KeyingSet again (non ID-libs) */ for (ks = list->first; ks; ks = ks->next) { /* paths */ link_list(fd, &ks->paths); - + for (ksp = ks->paths.first; ksp; ksp = ksp->next) { /* rna path */ ksp->rna_path= newdataadr(fd, ksp->rna_path); @@ -2790,22 +2790,22 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) { if (adt == NULL) return; - + /* link action data */ adt->action= newlibadr_us(fd, id->lib, adt->action); adt->tmpact= newlibadr_us(fd, id->lib, adt->tmpact); - + /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */ if ((adt->action) && (adt->action->idroot == 0)) adt->action->idroot = GS(id->name); if ((adt->tmpact) && (adt->tmpact->idroot == 0)) adt->tmpact->idroot = GS(id->name); - + /* link drivers */ lib_link_fcurves(fd, id, &adt->drivers); - + /* overrides don't have lib-link for now, so no need to do anything */ - + /* link NLA-data */ lib_link_nladata(fd, id, &adt->nla_tracks); } @@ -2815,19 +2815,19 @@ static void direct_link_animdata(FileData *fd, AnimData *adt) /* NOTE: must have called newdataadr already before doing this... */ if (adt == NULL) return; - + /* link drivers */ link_list(fd, &adt->drivers); direct_link_fcurves(fd, &adt->drivers); adt->driver_array = NULL; - + /* link overrides */ // TODO... - + /* link NLA-data */ link_list(fd, &adt->nla_tracks); direct_link_nladata(fd, &adt->nla_tracks); - + /* relink active track/strip - even though strictly speaking this should only be used * if we're in 'tweaking mode', we need to be able to have this loaded back for * undo, but also since users may not exit tweakmode before saving (#24535) @@ -2836,7 +2836,7 @@ static void direct_link_animdata(FileData *fd, AnimData *adt) // state, but it's going to be too hard to enforce this single case... adt->act_track = newdataadr(fd, adt->act_track); adt->actstrip = newdataadr(fd, adt->actstrip); -} +} /* ************ READ CACHEFILES *************** */ @@ -2962,7 +2962,7 @@ static void direct_link_motionpath(FileData *fd, bMotionPath *mpath) /* sanity check */ if (mpath == NULL) return; - + /* relink points cache */ mpath->points = newdataadr(fd, mpath->points); @@ -2978,17 +2978,17 @@ static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree) { bNode *node; bNodeSocket *sock; - + IDP_LibLinkProperty(ntree->id.properties, fd); lib_link_animdata(fd, &ntree->id, ntree->adt); - + ntree->gpd = newlibadr_us(fd, id->lib, ntree->gpd); - + for (node = ntree->nodes.first; node; node = node->next) { /* Link ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ IDP_LibLinkProperty(node->prop, fd); - + node->id = newlibadr_us(fd, id->lib, node->id); for (sock = node->inputs.first; sock; sock = sock->next) { @@ -2998,7 +2998,7 @@ static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree) IDP_LibLinkProperty(sock->prop, fd); } } - + for (sock = ntree->inputs.first; sock; sock = sock->next) { IDP_LibLinkProperty(sock->prop, fd); } @@ -3028,10 +3028,10 @@ static void lib_node_do_versions_group_indices(bNode *gnode) bNodeTree *ngroup = (bNodeTree*)gnode->id; bNodeSocket *sock; bNodeLink *link; - + for (sock=gnode->outputs.first; sock; sock = sock->next) { int old_index = sock->to_index; - + for (link = ngroup->links.first; link; link = link->next) { if (link->tonode == NULL && link->fromsock->own_index == old_index) { strcpy(sock->identifier, link->fromsock->identifier); @@ -3044,7 +3044,7 @@ static void lib_node_do_versions_group_indices(bNode *gnode) } for (sock=gnode->inputs.first; sock; sock = sock->next) { int old_index = sock->to_index; - + for (link = ngroup->links.first; link; link = link->next) { if (link->fromnode == NULL && link->tosock->own_index == old_index) { strcpy(sock->identifier, link->tosock->identifier); @@ -3068,19 +3068,19 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) reinit_nodesystem(); } #endif - + /* set node->typeinfo pointers */ FOREACH_NODETREE(main, ntree, id) { ntreeSetTypes(NULL, ntree); } FOREACH_NODETREE_END - + /* verify static socket templates */ FOREACH_NODETREE(main, ntree, id) { bNode *node; for (node=ntree->nodes.first; node; node=node->next) node_verify_socket_templates(ntree, node); } FOREACH_NODETREE_END - + { bool has_old_groups = false; /* XXX this should actually be part of do_versions, but since we need @@ -3093,7 +3093,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) has_old_groups = 1; } } - + if (has_old_groups) { FOREACH_NODETREE(main, ntree, id) { /* updates external links for all group nodes in a tree */ @@ -3107,12 +3107,12 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) } } FOREACH_NODETREE_END } - + for (bNodeTree *ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { ntree->flag &= ~NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2; } } - + { /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes. * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already @@ -3125,7 +3125,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) * but due to a temporary bug such links could have been added in all trees, * so have to clean up all of them ... */ - + FOREACH_NODETREE(main, ntree, id) { if (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP) { bNode *input_node = NULL, *output_node = NULL; @@ -3136,21 +3136,21 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) * in that case just remove the invalid links. */ const bool create_io_nodes = (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE) != 0; - + float input_locx = 1000000.0f, input_locy = 0.0f; float output_locx = -1000000.0f, output_locy = 0.0f; /* rough guess, not nice but we don't have access to UI constants here ... */ static const float offsetx = 42 + 3*20 + 20; /*static const float offsety = 0.0f;*/ - + if (create_io_nodes) { if (ntree->inputs.first) input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT); - + if (ntree->outputs.first) output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT); } - + /* Redirect links from/to the node tree interface to input/output node. * If the fromnode/tonode pointers are NULL, this means a link from/to * the ntree interface sockets, which need to be redirected to new interface nodes. @@ -3158,13 +3158,13 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) for (link = ntree->links.first; link; link = next_link) { bool free_link = false; next_link = link->next; - + if (link->fromnode == NULL) { if (input_node) { link->fromnode = input_node; link->fromsock = node_group_input_find_socket(input_node, link->fromsock->identifier); ++num_inputs; - + if (link->tonode) { if (input_locx > link->tonode->locx - offsetx) input_locx = link->tonode->locx - offsetx; @@ -3175,13 +3175,13 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) free_link = true; } } - + if (link->tonode == NULL) { if (output_node) { link->tonode = output_node; link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier); ++num_outputs; - + if (link->fromnode) { if (output_locx < link->fromnode->locx + offsetx) output_locx = link->fromnode->locx + offsetx; @@ -3192,11 +3192,11 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) free_link = true; } } - + if (free_link) nodeRemLink(ntree, link); } - + if (num_inputs > 0) { input_locy /= num_inputs; input_node->locx = input_locx; @@ -3207,19 +3207,19 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) output_node->locx = output_locx; output_node->locy = output_locy; } - + /* clear do_versions flags */ ntree->flag &= ~(NTREE_DO_VERSIONS_CUSTOMNODES_GROUP | NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE); } } FOREACH_NODETREE_END } - + /* verify all group user nodes */ for (bNodeTree *ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { ntreeVerifyNodes(main, &ntree->id); } - + /* make update calls where necessary */ { FOREACH_NODETREE(main, ntree, id) { @@ -3233,7 +3233,7 @@ static void direct_link_node_socket(FileData *fd, bNodeSocket *sock) { sock->prop = newdataadr(fd, sock->prop); IDP_DirectLinkGroup_OrFree(&sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - + sock->link = newdataadr(fd, sock->link); sock->typeinfo = NULL; sock->storage = newdataadr(fd, sock->storage); @@ -3248,31 +3248,31 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) bNode *node; bNodeSocket *sock; bNodeLink *link; - + ntree->init = 0; /* to set callbacks and force setting types */ ntree->is_updating = false; ntree->typeinfo= NULL; ntree->interface_type = NULL; - + ntree->progress = NULL; ntree->execdata = NULL; ntree->duplilock = NULL; ntree->adt = newdataadr(fd, ntree->adt); direct_link_animdata(fd, ntree->adt); - + ntree->id.recalc &= ~ID_RECALC_ALL; link_list(fd, &ntree->nodes); for (node = ntree->nodes.first; node; node = node->next) { node->typeinfo = NULL; - + link_list(fd, &node->inputs); link_list(fd, &node->outputs); - + node->prop = newdataadr(fd, node->prop); IDP_DirectLinkGroup_OrFree(&node->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - + link_list(fd, &node->internal_links); for (link = node->internal_links.first; link; link = link->next) { link->fromnode = newdataadr(fd, link->fromnode); @@ -3280,14 +3280,14 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) link->tonode = newdataadr(fd, link->tonode); link->tosock = newdataadr(fd, link->tosock); } - + if (node->type == CMP_NODE_MOVIEDISTORTION) { node->storage = newmclipadr(fd, node->storage); } else { node->storage = newdataadr(fd, node->storage); } - + if (node->storage) { /* could be handlerized at some point */ if (ntree->type==NTREE_SHADER) { @@ -3318,18 +3318,18 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) } } link_list(fd, &ntree->links); - + /* and we connect the rest */ for (node = ntree->nodes.first; node; node = node->next) { node->parent = newdataadr(fd, node->parent); node->lasty = 0; - + for (sock = node->inputs.first; sock; sock = sock->next) direct_link_node_socket(fd, sock); for (sock = node->outputs.first; sock; sock = sock->next) direct_link_node_socket(fd, sock); } - + /* interface socket lists */ link_list(fd, &ntree->inputs); link_list(fd, &ntree->outputs); @@ -3337,19 +3337,19 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) direct_link_node_socket(fd, sock); for (sock = ntree->outputs.first; sock; sock = sock->next) direct_link_node_socket(fd, sock); - + for (link = ntree->links.first; link; link= link->next) { link->fromnode = newdataadr(fd, link->fromnode); link->tonode = newdataadr(fd, link->tonode); link->fromsock = newdataadr(fd, link->fromsock); link->tosock = newdataadr(fd, link->tosock); } - + #if 0 if (ntree->previews) { bNodeInstanceHash *new_previews = BKE_node_instance_hash_new("node previews"); bNodeInstanceHashIterator iter; - + NODE_INSTANCE_HASH_ITER(iter, ntree->previews) { bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter); if (preview) { @@ -3367,7 +3367,7 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) /* XXX TODO */ ntree->previews = NULL; #endif - + /* type verification is in lib-link */ } @@ -3382,7 +3382,7 @@ typedef struct tConstraintLinkData { static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *userdata) { tConstraintLinkData *cld= (tConstraintLinkData *)userdata; - + /* for reference types, we need to increment the usercounts on load... */ if (is_reference) { /* reference type - with usercount */ @@ -3398,7 +3398,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) { tConstraintLinkData cld; bConstraint *con; - + /* legacy fixes */ for (con = conlist->first; con; con=con->next) { /* patch for error introduced by changing constraints (dunno how) */ @@ -3414,29 +3414,29 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) con->flag &= ~CONSTRAINT_STATICOVERRIDE_LOCAL; } } - + /* relink all ID-blocks used by the constraints */ cld.fd = fd; cld.id = id; - + BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld); } static void direct_link_constraints(FileData *fd, ListBase *lb) { bConstraint *con; - + link_list(fd, lb); for (con=lb->first; con; con=con->next) { con->data = newdataadr(fd, con->data); - + switch (con->type) { case CONSTRAINT_TYPE_PYTHON: { bPythonConstraint *data= con->data; - + link_list(fd, &data->targets); - + data->prop = newdataadr(fd, data->prop); IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); break; @@ -3478,10 +3478,10 @@ static void direct_link_constraints(FileData *fd, ListBase *lb) static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) { bArmature *arm = ob->data; - + if (!pose || !arm) return; - + /* always rebuild to match proxy or lib changes, but on Undo */ bool rebuild = false; @@ -3498,7 +3498,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) /* sync proxy layer */ if (pose->proxy_layer) arm->layer = pose->proxy_layer; - + /* sync proxy active bone */ if (pose->proxy_act_bone[0]) { Bone *bone = BLI_ghash_lookup(bone_hash, pose->proxy_act_bone); @@ -3512,7 +3512,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) lib_link_constraints(fd, (ID *)ob, &pchan->constraints); pchan->bone = BLI_ghash_lookup(bone_hash, pchan->name); - + IDP_LibLinkProperty(pchan->prop, fd); pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom); @@ -3527,7 +3527,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) } BLI_ghash_free(bone_hash, NULL, NULL); - + if (rebuild) { DEG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); @@ -3563,15 +3563,15 @@ static void lib_link_armature(FileData *fd, Main *main) static void direct_link_bones(FileData *fd, Bone *bone) { Bone *child; - + bone->parent = newdataadr(fd, bone->parent); bone->prop = newdataadr(fd, bone->prop); IDP_DirectLinkGroup_OrFree(&bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - + bone->flag &= ~BONE_DRAW_ACTIVE; - + link_list(fd, &bone->childbase); - + for (child=bone->childbase.first; child; child=child->next) direct_link_bones(fd, child); } @@ -3579,17 +3579,17 @@ static void direct_link_bones(FileData *fd, Bone *bone) static void direct_link_armature(FileData *fd, bArmature *arm) { Bone *bone; - + link_list(fd, &arm->bonebase); arm->edbo = NULL; - + arm->adt = newdataadr(fd, arm->adt); direct_link_animdata(fd, arm->adt); - + for (bone = arm->bonebase.first; bone; bone = bone->next) { direct_link_bones(fd, bone); } - + arm->act_bone = newdataadr(fd, arm->act_bone); arm->act_edbone = NULL; } @@ -3602,11 +3602,11 @@ static void lib_link_camera(FileData *fd, Main *main) if (ca->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(ca->id.properties, fd); lib_link_animdata(fd, &ca->id, ca->adt); - + ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); // XXX deprecated - old animation system ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); - + for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { bgpic->ima = newlibadr_us(fd, ca->id.lib, bgpic->ima); bgpic->clip = newlibadr_us(fd, ca->id.lib, bgpic->clip); @@ -3638,14 +3638,14 @@ static void lib_link_lamp(FileData *fd, Main *main) if (la->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(la->id.properties, fd); lib_link_animdata(fd, &la->id, la->adt); - + la->ipo = newlibadr_us(fd, la->id.lib, la->ipo); // XXX deprecated - old animation system - + if (la->nodetree) { lib_link_ntree(fd, &la->id, la->nodetree); la->nodetree->id.lib = la->id.lib; } - + la->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -3655,7 +3655,7 @@ static void direct_link_lamp(FileData *fd, Lamp *la) { la->adt = newdataadr(fd, la->adt); direct_link_animdata(fd, la->adt); - + la->curfalloff = newdataadr(fd, la->curfalloff); if (la->curfalloff) direct_link_curvemapping(fd, la->curfalloff); @@ -3665,7 +3665,7 @@ static void direct_link_lamp(FileData *fd, Lamp *la) direct_link_id(fd, &la->nodetree->id); direct_link_nodetree(fd, la->nodetree); } - + la->preview = direct_link_preview_image(fd, la->preview); } @@ -3689,10 +3689,10 @@ static void lib_link_key(FileData *fd, Main *main) if (key->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(key->id.properties, fd); lib_link_animdata(fd, &key->id, key->adt); - + key->ipo = newlibadr_us(fd, key->id.lib, key->ipo); // XXX deprecated - old animation system key->from = newlibadr(fd, key->id.lib, key->from); - + key->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -3702,14 +3702,14 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb) { int elemsize, a, b; char *data; - + elemsize = key->elemsize; data = kb->data; - + for (a = 0; a < kb->totelem; a++) { const char *cp = key->elemstr; char *poin = data; - + while (cp[0]) { /* cp[0] == amount */ switch (cp[1]) { /* cp[1] = type */ case IPO_FLOAT: @@ -3720,7 +3720,7 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb) poin += sizeof(float) * b; break; } - + cp += 2; } data += elemsize; @@ -3730,17 +3730,17 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb) static void direct_link_key(FileData *fd, Key *key) { KeyBlock *kb; - + link_list(fd, &(key->block)); - + key->adt = newdataadr(fd, key->adt); direct_link_animdata(fd, key->adt); - + key->refkey= newdataadr(fd, key->refkey); - + for (kb = key->block.first; kb; kb = kb->next) { kb->data = newdataadr(fd, kb->data); - + if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) switch_endian_keyblock(key, kb); } @@ -3754,13 +3754,13 @@ static void lib_link_mball(FileData *fd, Main *main) if (mb->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(mb->id.properties, fd); lib_link_animdata(fd, &mb->id, mb->adt); - + for (int a = 0; a < mb->totcol; a++) { mb->mat[a] = newlibadr_us(fd, mb->id.lib, mb->mat[a]); } - + mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system - + mb->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -3770,12 +3770,12 @@ static void direct_link_mball(FileData *fd, MetaBall *mb) { mb->adt = newdataadr(fd, mb->adt); direct_link_animdata(fd, mb->adt); - + mb->mat = newdataadr(fd, mb->mat); test_pointer_array(fd, (void **)&mb->mat); - + link_list(fd, &(mb->elems)); - + BLI_listbase_clear(&mb->disp); mb->editelems = NULL; /* mb->edit_elems.first= mb->edit_elems.last= NULL;*/ @@ -3791,14 +3791,14 @@ static void lib_link_world(FileData *fd, Main *main) if (wrld->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(wrld->id.properties, fd); lib_link_animdata(fd, &wrld->id, wrld->adt); - + wrld->ipo = newlibadr_us(fd, wrld->id.lib, wrld->ipo); // XXX deprecated - old animation system - + if (wrld->nodetree) { lib_link_ntree(fd, &wrld->id, wrld->nodetree); wrld->nodetree->id.lib = wrld->id.lib; } - + wrld->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -3808,13 +3808,13 @@ static void direct_link_world(FileData *fd, World *wrld) { wrld->adt = newdataadr(fd, wrld->adt); direct_link_animdata(fd, wrld->adt); - + wrld->nodetree = newdataadr(fd, wrld->nodetree); if (wrld->nodetree) { direct_link_id(fd, &wrld->nodetree->id); direct_link_nodetree(fd, wrld->nodetree); } - + wrld->preview = direct_link_preview_image(fd, wrld->preview); BLI_listbase_clear(&wrld->gpumaterial); } @@ -3867,24 +3867,24 @@ static void direct_link_text(FileData *fd, Text *text) } /* else { */ #endif - + link_list(fd, &text->lines); - + text->curl = newdataadr(fd, text->curl); text->sell = newdataadr(fd, text->sell); - + for (ln = text->lines.first; ln; ln = ln->next) { ln->line = newdataadr(fd, ln->line); ln->format = NULL; - + if (ln->len != (int) strlen(ln->line)) { printf("Error loading text, line lengths differ\n"); ln->len = strlen(ln->line); } } - + text->flags = (text->flags) & ~TXT_ISEXT; - + id_us_ensure_real(&text->id); } @@ -3895,7 +3895,7 @@ static void lib_link_image(FileData *fd, Main *main) for (Image *ima = main->image.first; ima; ima = ima->id.next) { if (ima->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(ima->id.properties, fd); - + ima->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -3919,7 +3919,7 @@ static void direct_link_image(FileData *fd, Image *ima) } ima->rr = NULL; } - + /* undo system, try to restore render buffers */ link_list(fd, &(ima->renderslots)); if (fd->imamap) { @@ -3961,11 +3961,11 @@ static void lib_link_curve(FileData *fd, Main *main) if (cu->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(cu->id.properties, fd); lib_link_animdata(fd, &cu->id, cu->adt); - + for (int a = 0; a < cu->totcol; a++) { cu->mat[a] = newlibadr_us(fd, cu->id.lib, cu->mat[a]); } - + cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj); cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj); cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve); @@ -3973,10 +3973,10 @@ static void lib_link_curve(FileData *fd, Main *main) cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb); cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti); cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi); - + cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system cu->key = newlibadr_us(fd, cu->id.lib, cu->key); - + cu->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -3997,10 +3997,10 @@ static void direct_link_curve(FileData *fd, Curve *cu) { Nurb *nu; TextBox *tb; - + cu->adt= newdataadr(fd, cu->adt); direct_link_animdata(fd, cu->adt); - + /* Protect against integer overflow vulnerability. */ CLAMP(cu->len_wchar, 0, INT_MAX - 4); @@ -4015,7 +4015,7 @@ static void direct_link_curve(FileData *fd, Curve *cu) } else { cu->nurb.first=cu->nurb.last= NULL; - + tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBoxread"); if (cu->tb) { memcpy(tb, cu->tb, cu->totbox*sizeof(TextBox)); @@ -4034,14 +4034,14 @@ static void direct_link_curve(FileData *fd, Curve *cu) cu->editnurb = NULL; cu->editfont = NULL; cu->batch_cache = NULL; - + for (nu = cu->nurb.first; nu; nu = nu->next) { nu->bezt = newdataadr(fd, nu->bezt); nu->bp = newdataadr(fd, nu->bp); nu->knotsu = newdataadr(fd, nu->knotsu); nu->knotsv = newdataadr(fd, nu->knotsv); if (cu->vfont == NULL) nu->charidx = 0; - + if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { switch_endian_knots(nu); } @@ -4057,15 +4057,15 @@ static void lib_link_texture(FileData *fd, Main *main) if (tex->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(tex->id.properties, fd); lib_link_animdata(fd, &tex->id, tex->adt); - + tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima); tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system - + if (tex->nodetree) { lib_link_ntree(fd, &tex->id, tex->nodetree); tex->nodetree->id.lib = tex->id.lib; } - + tex->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -4083,9 +4083,9 @@ static void direct_link_texture(FileData *fd, Tex *tex) direct_link_id(fd, &tex->nodetree->id); direct_link_nodetree(fd, tex->nodetree); } - + tex->preview = direct_link_preview_image(fd, tex->preview); - + tex->iuser.ok = 1; } @@ -4099,14 +4099,14 @@ static void lib_link_material(FileData *fd, Main *main) if (ma->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(ma->id.properties, fd); lib_link_animdata(fd, &ma->id, ma->adt); - + ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system - + if (ma->nodetree) { lib_link_ntree(fd, &ma->id, ma->nodetree); ma->nodetree->id.lib = ma->id.lib; } - + ma->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -4116,15 +4116,15 @@ static void direct_link_material(FileData *fd, Material *ma) { ma->adt = newdataadr(fd, ma->adt); direct_link_animdata(fd, ma->adt); - + ma->texpaintslot = NULL; - + ma->nodetree = newdataadr(fd, ma->nodetree); if (ma->nodetree) { direct_link_id(fd, &ma->nodetree->id); direct_link_nodetree(fd, ma->nodetree); } - + ma->preview = direct_link_preview_image(fd, ma->preview); BLI_listbase_clear(&ma->gpumaterial); } @@ -4172,7 +4172,7 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) } else BLI_listbase_clear(&cache->mem_cache); - + cache->flag &= ~PTCACHE_SIMULATION_VALID; cache->simframe = 0; cache->edit = NULL; @@ -4192,7 +4192,7 @@ static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointC cache->step = 1; } } - + *ocache = newdataadr(fd, *ocache); } else if (*ocache) { @@ -4203,7 +4203,7 @@ static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointC (*ocache)->flag |= PTCACHE_DISK_CACHE; (*ocache)->step = 1; } - + ptcaches->first = ptcaches->last = *ocache; } } @@ -4224,16 +4224,16 @@ static void lib_link_particlesettings(FileData *fd, Main *main) lib_link_animdata(fd, &part->id, part->adt); part->ipo = newlibadr_us(fd, part->id.lib, part->ipo); // XXX deprecated - old animation system - + part->dup_ob = newlibadr(fd, part->id.lib, part->dup_ob); part->dup_group = newlibadr(fd, part->id.lib, part->dup_group); part->eff_group = newlibadr(fd, part->id.lib, part->eff_group); part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob); part->collision_group = newlibadr(fd, part->id.lib, part->collision_group); - + lib_link_partdeflect(fd, &part->id, part->pd); lib_link_partdeflect(fd, &part->id, part->pd2); - + if (part->effector_weights) { part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group); } @@ -4281,7 +4281,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main) else { BLI_listbase_clear(&part->dupliweights); } - + if (part->boids) { BoidState *state = part->boids->states.first; BoidRule *rule; @@ -4314,7 +4314,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main) mtex->object = newlibadr(fd, part->id.lib, mtex->object); } } - + part->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -4328,7 +4328,7 @@ static void direct_link_partdeflect(PartDeflect *pd) static void direct_link_particlesettings(FileData *fd, ParticleSettings *part) { int a; - + part->adt = newdataadr(fd, part->adt); part->pd = newdataadr(fd, part->pd); part->pd2 = newdataadr(fd, part->pd2); @@ -4359,7 +4359,7 @@ static void direct_link_particlesettings(FileData *fd, ParticleSettings *part) if (part->boids) { BoidState *state; link_list(fd, &part->boids->states); - + for (state=part->boids->states.first; state; state=state->next) { link_list(fd, &state->rules); link_list(fd, &state->conditions); @@ -4380,17 +4380,17 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase for (psys=particles->first; psys; psys=psysnext) { psysnext = psys->next; - + psys->part = newlibadr_us(fd, id->lib, psys->part); if (psys->part) { ParticleTarget *pt = psys->targets.first; - + for (; pt; pt=pt->next) pt->ob=newlibadr(fd, id->lib, pt->ob); - + psys->parent = newlibadr(fd, id->lib, psys->parent); psys->target_ob = newlibadr(fd, id->lib, psys->target_ob); - + if (psys->clmd) { /* XXX - from reading existing code this seems correct but intended usage of * pointcache /w cloth should be added in 'ParticleSystem' - campbell */ @@ -4405,7 +4405,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); BLI_remlink(&ob->modifiers, psmd); modifier_free((ModifierData *)psmd); - + BLI_remlink(particles, psys); MEM_freeN(psys); } @@ -4416,21 +4416,21 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) ParticleSystem *psys; ParticleData *pa; int a; - + for (psys=particles->first; psys; psys=psys->next) { psys->particles=newdataadr(fd, psys->particles); - + if (psys->particles && psys->particles->hair) { for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++) pa->hair=newdataadr(fd, pa->hair); } - + if (psys->particles && psys->particles->keys) { for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++) { pa->keys= NULL; pa->totkey= 0; } - + psys->flag &= ~PSYS_KEYED; } @@ -4447,14 +4447,14 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++) pa->boid = NULL; } - + psys->fluid_springs = newdataadr(fd, psys->fluid_springs); - + psys->child = newdataadr(fd, psys->child); psys->effectors = NULL; - + link_list(fd, &psys->targets); - + psys->edit = NULL; psys->free_edit = NULL; psys->pathcache = NULL; @@ -4462,21 +4462,21 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) BLI_listbase_clear(&psys->pathcachebufs); BLI_listbase_clear(&psys->childcachebufs); psys->pdd = NULL; - + if (psys->clmd) { psys->clmd = newdataadr(fd, psys->clmd); psys->clmd->clothObject = NULL; psys->clmd->hairdata = NULL; - + psys->clmd->sim_parms= newdataadr(fd, psys->clmd->sim_parms); psys->clmd->coll_parms= newdataadr(fd, psys->clmd->coll_parms); - + if (psys->clmd->sim_parms) { psys->clmd->sim_parms->effector_weights = NULL; if (psys->clmd->sim_parms->presets > 10) psys->clmd->sim_parms->presets = 0; } - + psys->hair_in_mesh = psys->hair_out_mesh = NULL; psys->clmd->solver_result = NULL; } @@ -4500,16 +4500,16 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) static void lib_link_mesh(FileData *fd, Main *main) { Mesh *me; - + for (me = main->mesh.first; me; me = me->id.next) { if (me->id.tag & LIB_TAG_NEED_LINK) { int i; - + /* Link ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ IDP_LibLinkProperty(me->id.properties, fd); lib_link_animdata(fd, &me->id, me->adt); - + /* this check added for python created meshes */ if (me->mat) { for (i = 0; i < me->totcol; i++) { @@ -4534,9 +4534,9 @@ static void lib_link_mesh(FileData *fd, Main *main) * external CustomData works */ Main *gmain = G_MAIN; G_MAIN = main; - + BKE_mesh_do_versions_convert_mfaces_to_mpolys(me); - + G_MAIN = gmain; } @@ -4564,11 +4564,11 @@ static void lib_link_mesh(FileData *fd, Main *main) static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts) { int i; - + if (mdverts == NULL) { return; } - + for (i = count; i > 0; i--, mdverts++) { /*convert to vgroup allocation system*/ MDeformWeight *dw; @@ -4590,11 +4590,11 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte { if (mdisps) { int i; - + for (i = 0; i < count; ++i) { mdisps[i].disps = newdataadr(fd, mdisps[i].disps); mdisps[i].hidden = newdataadr(fd, mdisps[i].hidden); - + if (mdisps[i].totdisp && !mdisps[i].level) { /* this calculation is only correct for loop mdisps; * if loading pre-BMesh face mdisps this will be @@ -4603,7 +4603,7 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte float gridsize = sqrtf(mdisps[i].totdisp); mdisps[i].level = (int)(logf(gridsize - 1.0f) / (float)M_LN2) + 1; } - + if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps)) { /* DNA_struct_switch_endian doesn't do endian swap for (*disps)[] */ /* this does swap for data written at write_mdisps() - readfile.c */ @@ -4619,7 +4619,7 @@ static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask * { if (grid_paint_mask) { int i; - + for (i = 0; i < count; ++i) { GridPaintMask *gpm = &grid_paint_mask[i]; if (gpm->data) @@ -4632,26 +4632,26 @@ static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask * static void direct_link_customdata(FileData *fd, CustomData *data, int count) { int i = 0; - + data->layers = newdataadr(fd, data->layers); - + /* annoying workaround for bug [#31079] loading legacy files with * no polygons _but_ have stale customdata */ if (UNLIKELY(count == 0 && data->layers == NULL && data->totlayer != 0)) { CustomData_reset(data); return; } - + data->external = newdataadr(fd, data->external); - + while (i < data->totlayer) { CustomDataLayer *layer = &data->layers[i]; - + if (layer->flag & CD_FLAG_EXTERNAL) layer->flag &= ~CD_FLAG_IN_MEMORY; layer->flag &= ~CD_FLAG_NOFREE; - + if (CustomData_verify_versions(data, i)) { layer->data = newdataadr(fd, layer->data); if (layer->type == CD_MDISPS) @@ -4661,7 +4661,7 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count) i++; } } - + CustomData_update_typemap(data); } @@ -4669,7 +4669,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) { mesh->mat= newdataadr(fd, mesh->mat); test_pointer_array(fd, (void **)&mesh->mat); - + mesh->mvert = newdataadr(fd, mesh->mvert); mesh->medge = newdataadr(fd, mesh->medge); mesh->mface = newdataadr(fd, mesh->mface); @@ -4682,15 +4682,15 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) mesh->mloopcol = newdataadr(fd, mesh->mloopcol); mesh->mloopuv = newdataadr(fd, mesh->mloopuv); mesh->mselect = newdataadr(fd, mesh->mselect); - + /* animdata */ mesh->adt = newdataadr(fd, mesh->adt); direct_link_animdata(fd, mesh->adt); - + /* normally direct_link_dverts should be called in direct_link_customdata, * but for backwards compat in do_versions to work we do it here */ direct_link_dverts(fd, mesh->totvert, mesh->dvert); - + direct_link_customdata(fd, &mesh->vdata, mesh->totvert); direct_link_customdata(fd, &mesh->edata, mesh->totedge); direct_link_customdata(fd, &mesh->fdata, mesh->totface); @@ -4710,19 +4710,19 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) mesh->mr= newdataadr(fd, mesh->mr); if (mesh->mr) { MultiresLevel *lvl; - + link_list(fd, &mesh->mr->levels); lvl = mesh->mr->levels.first; - + direct_link_customdata(fd, &mesh->mr->vdata, lvl->totvert); direct_link_dverts(fd, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT)); direct_link_customdata(fd, &mesh->mr->fdata, lvl->totface); - + mesh->mr->edge_flags = newdataadr(fd, mesh->mr->edge_flags); mesh->mr->edge_creases = newdataadr(fd, mesh->mr->edge_creases); - + mesh->mr->verts = newdataadr(fd, mesh->mr->verts); - + /* If mesh has the same number of vertices as the * highest multires level, load the current mesh verts * into multires and discard the old data. Needed @@ -4734,7 +4734,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) MEM_freeN(mesh->mr->verts); mesh->mr->verts = MEM_dupallocN(mesh->mvert); } - + for (; lvl; lvl = lvl->next) { lvl->verts = newdataadr(fd, lvl->verts); lvl->faces = newdataadr(fd, lvl->faces); @@ -4749,11 +4749,11 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) multires_free(mesh->mr); mesh->mr = NULL; } - + if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) { TFace *tf = mesh->tface; int i; - + for (i = 0; i < mesh->totface; i++, tf++) { BLI_endian_switch_uint32_array(tf->col, 4); } @@ -4768,10 +4768,10 @@ static void lib_link_latt(FileData *fd, Main *main) if (lt->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(lt->id.properties, fd); lib_link_animdata(fd, <->id, lt->adt); - + lt->ipo = newlibadr_us(fd, lt->id.lib, lt->ipo); // XXX deprecated - old animation system lt->key = newlibadr_us(fd, lt->id.lib, lt->key); - + lt->id.tag &= ~LIB_TAG_NEED_LINK; } } @@ -4780,13 +4780,13 @@ static void lib_link_latt(FileData *fd, Main *main) static void direct_link_latt(FileData *fd, Lattice *lt) { lt->def = newdataadr(fd, lt->def); - + lt->dvert = newdataadr(fd, lt->dvert); direct_link_dverts(fd, lt->pntsu*lt->pntsv*lt->pntsw, lt->dvert); - + lt->editlatt = NULL; lt->batch_cache = NULL; - + lt->adt = newdataadr(fd, lt->adt); direct_link_animdata(fd, lt->adt); } @@ -4827,7 +4827,7 @@ static void lib_link_object(FileData *fd, Main *main) IDP_LibLinkProperty(ob->id.properties, fd); lib_link_animdata(fd, &ob->id, ob->adt); - + // XXX deprecated - old animation system <<< ob->ipo = newlibadr_us(fd, ob->id.lib, ob->ipo); ob->action = newlibadr_us(fd, ob->id.lib, ob->action); @@ -4845,14 +4845,14 @@ static void lib_link_object(FileData *fd, Main *main) ob->dup_group = NULL; ob->transflag &= ~OB_DUPLICOLLECTION; } - + ob->proxy = newlibadr_us(fd, ob->id.lib, ob->proxy); if (ob->proxy) { /* paranoia check, actually a proxy_from pointer should never be written... */ if (ob->proxy->id.lib == NULL) { ob->proxy->proxy_from = NULL; ob->proxy = NULL; - + if (ob->id.lib) printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name); else @@ -4864,19 +4864,19 @@ static void lib_link_object(FileData *fd, Main *main) } } ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group); - + void *poin = ob->data; ob->data = newlibadr_us(fd, ob->id.lib, ob->data); - + if (ob->data == NULL && poin != NULL) { if (ob->id.lib) printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name); else printf("Object %s lost data.\n", ob->id.name + 2); - + ob->type = OB_EMPTY; warn = true; - + if (ob->pose) { /* we can't call #BKE_pose_free() here because of library linking * freeing will recurse down into every pose constraints ID pointers @@ -4892,9 +4892,9 @@ static void lib_link_object(FileData *fd, Main *main) ob->mode &= ~OB_MODE_POSE; } } - for (a=0; a < ob->totcol; a++) + for (a=0; a < ob->totcol; a++) ob->mat[a] = newlibadr_us(fd, ob->id.lib, ob->mat[a]); - + /* When the object is local and the data is library its possible * the material list size gets out of sync. [#22663] */ if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) { @@ -4905,21 +4905,21 @@ static void lib_link_object(FileData *fd, Main *main) BKE_material_resize_object(main, ob, *totcol_data, false); } } - + ob->gpd = newlibadr_us(fd, ob->id.lib, ob->gpd); - + ob->id.tag &= ~LIB_TAG_NEED_LINK; /* if id.us==0 a new base will be created later on */ - + /* WARNING! Also check expand_object(), should reflect the stuff below. */ lib_link_pose(fd, main, ob, ob->pose); lib_link_constraints(fd, &ob->id, &ob->constraints); - + // XXX deprecated - old animation system <<< lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels); lib_link_nlastrips(fd, &ob->id, &ob->nlastrips); // >>> XXX deprecated - old animation system - + for (PartEff *paf = ob->effect.first; paf; paf = paf->next) { if (paf->type == EFF_PARTICLE) { paf->group = newlibadr_us(fd, ob->id.lib, paf->group); @@ -4928,29 +4928,29 @@ static void lib_link_object(FileData *fd, Main *main) { FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - + if (fluidmd && fluidmd->fss) fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system } - + { SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke); - + if (smd && (smd->type == MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { smd->domain->flags |= MOD_SMOKE_FILE_LOAD; /* flag for refreshing the simulation after loading */ } } - + /* texture field */ if (ob->pd) lib_link_partdeflect(fd, &ob->id, ob->pd); - + if (ob->soft) { ob->soft->collision_group = newlibadr(fd, ob->id.lib, ob->soft->collision_group); ob->soft->effector_weights->group = newlibadr(fd, ob->id.lib, ob->soft->effector_weights->group); } - + lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem); lib_link_modifiers(fd, ob); @@ -4970,7 +4970,7 @@ static void lib_link_object(FileData *fd, Main *main) } } } - + if (warn) { BKE_report(fd->reports, RPT_WARNING, "Warning in console"); } @@ -4995,22 +4995,22 @@ static void direct_link_pose(FileData *fd, bPose *pose) pchan->parent = newdataadr(fd, pchan->parent); pchan->child = newdataadr(fd, pchan->child); pchan->custom_tx = newdataadr(fd, pchan->custom_tx); - + pchan->bbone_prev = newdataadr(fd, pchan->bbone_prev); pchan->bbone_next = newdataadr(fd, pchan->bbone_next); - + direct_link_constraints(fd, &pchan->constraints); - + pchan->prop = newdataadr(fd, pchan->prop); IDP_DirectLinkGroup_OrFree(&pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - + pchan->mpath = newdataadr(fd, pchan->mpath); if (pchan->mpath) direct_link_motionpath(fd, pchan->mpath); - + BLI_listbase_clear(&pchan->iktree); BLI_listbase_clear(&pchan->siktree); - + /* in case this value changes in future, clamp else we get undefined behavior */ CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX); @@ -5025,56 +5025,56 @@ static void direct_link_pose(FileData *fd, bPose *pose) static void direct_link_modifiers(FileData *fd, ListBase *lb) { ModifierData *md; - + link_list(fd, lb); - + for (md=lb->first; md; md=md->next) { md->error = NULL; md->scene = NULL; - + /* if modifiers disappear, or for upward compatibility */ if (NULL == modifierType_getInfo(md->type)) md->type = eModifierType_None; - + if (md->type == eModifierType_Subsurf) { SubsurfModifierData *smd = (SubsurfModifierData *)md; - + smd->emCache = smd->mCache = NULL; } else if (md->type == eModifierType_Armature) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - + amd->prevCos = NULL; } else if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; - + clmd->clothObject = NULL; clmd->hairdata = NULL; - + clmd->sim_parms= newdataadr(fd, clmd->sim_parms); clmd->coll_parms= newdataadr(fd, clmd->coll_parms); - + direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0); - + if (clmd->sim_parms) { if (clmd->sim_parms->presets > 10) clmd->sim_parms->presets = 0; - + clmd->sim_parms->reset = 0; - + clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights); - + if (!clmd->sim_parms->effector_weights) { clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL); } } - + clmd->solver_result = NULL; } else if (md->type == eModifierType_Fluidsim) { FluidsimModifierData *fluidmd = (FluidsimModifierData *)md; - + fluidmd->fss = newdataadr(fd, fluidmd->fss); if (fluidmd->fss) { fluidmd->fss->fmd = fluidmd; @@ -5083,13 +5083,13 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; - + if (smd->type == MOD_SMOKE_TYPE_DOMAIN) { smd->flow = NULL; smd->coll = NULL; smd->domain = newdataadr(fd, smd->domain); smd->domain->smd = smd; - + smd->domain->fluid = NULL; smd->domain->fluid_mutex = BLI_rw_mutex_alloc(); smd->domain->wt = NULL; @@ -5099,13 +5099,13 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) smd->domain->tex_flame = NULL; smd->domain->tex_wt = NULL; smd->domain->coba = newdataadr(fd, smd->domain->coba); - + smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights); if (!smd->domain->effector_weights) smd->domain->effector_weights = BKE_add_effector_weights(NULL); - + direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1); - + /* Smoke uses only one cache from now on, so store pointer convert */ if (smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) { if (smd->domain->point_cache[1]) { @@ -5152,22 +5152,22 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_DynamicPaint) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - + if (pmd->canvas) { pmd->canvas = newdataadr(fd, pmd->canvas); pmd->canvas->pmd = pmd; pmd->canvas->dm = NULL; pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */ - + if (pmd->canvas->surfaces.first) { DynamicPaintSurface *surface; link_list(fd, &pmd->canvas->surfaces); - + for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) { surface->canvas = pmd->canvas; surface->data = NULL; direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1); - + if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights))) surface->effector_weights = BKE_add_effector_weights(NULL); } @@ -5185,17 +5185,17 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) else if (md->type == eModifierType_Collision) { CollisionModifierData *collmd = (CollisionModifierData *)md; #if 0 - // TODO: CollisionModifier should use pointcache + // TODO: CollisionModifier should use pointcache // + have proper reset events before enabling this collmd->x = newdataadr(fd, collmd->x); collmd->xnew = newdataadr(fd, collmd->xnew); collmd->mfaces = newdataadr(fd, collmd->mfaces); - + collmd->current_x = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_x"); collmd->current_xnew = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_xnew"); collmd->current_v = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_v"); #endif - + collmd->x = NULL; collmd->xnew = NULL; collmd->current_x = NULL; @@ -5207,11 +5207,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) collmd->is_static = false; collmd->bvhtree = NULL; collmd->tri = NULL; - + } else if (md->type == eModifierType_Surface) { SurfaceModifierData *surmd = (SurfaceModifierData *)md; - + surmd->mesh = NULL; surmd->bvhtree = NULL; surmd->x = NULL; @@ -5220,7 +5220,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_Hook) { HookModifierData *hmd = (HookModifierData *)md; - + hmd->indexar = newdataadr(fd, hmd->indexar); if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { BLI_endian_switch_int32_array(hmd->indexar, hmd->totindex); @@ -5233,7 +5233,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_ParticleSystem) { ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; - + psmd->mesh_final = NULL; psmd->mesh_original = NULL; psmd->psys= newdataadr(fd, psmd->psys); @@ -5242,22 +5242,22 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_Explode) { ExplodeModifierData *psmd = (ExplodeModifierData *)md; - + psmd->facepa = NULL; } else if (md->type == eModifierType_MeshDeform) { MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; - + mmd->bindinfluences = newdataadr(fd, mmd->bindinfluences); mmd->bindoffsets = newdataadr(fd, mmd->bindoffsets); mmd->bindcagecos = newdataadr(fd, mmd->bindcagecos); mmd->dyngrid = newdataadr(fd, mmd->dyngrid); mmd->dyninfluences = newdataadr(fd, mmd->dyninfluences); mmd->dynverts = newdataadr(fd, mmd->dynverts); - + mmd->bindweights = newdataadr(fd, mmd->bindweights); mmd->bindcos = newdataadr(fd, mmd->bindcos); - + if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { if (mmd->bindoffsets) BLI_endian_switch_int32_array(mmd->bindoffsets, mmd->totvert + 1); if (mmd->bindcagecos) BLI_endian_switch_float_array(mmd->bindcagecos, mmd->totcagevert * 3); @@ -5274,14 +5274,14 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_Warp) { WarpModifierData *tmd = (WarpModifierData *)md; - + tmd->curfalloff= newdataadr(fd, tmd->curfalloff); if (tmd->curfalloff) direct_link_curvemapping(fd, tmd->curfalloff); } else if (md->type == eModifierType_WeightVGEdit) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; - + wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve); if (wmd->cmap_curve) direct_link_curvemapping(fd, wmd->cmap_curve); @@ -5350,7 +5350,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) static void direct_link_object(FileData *fd, Object *ob) { PartEff *paf; - + /* XXX This should not be needed - but seems like it can happen in some cases, so for now play safe... */ ob->proxy_from = NULL; @@ -5366,31 +5366,31 @@ static void direct_link_object(FileData *fd, Object *ob) ob->mode &= ~OB_MODE_POSE; } } - + ob->adt = newdataadr(fd, ob->adt); direct_link_animdata(fd, ob->adt); - + ob->pose = newdataadr(fd, ob->pose); direct_link_pose(fd, ob->pose); - + ob->mpath = newdataadr(fd, ob->mpath); if (ob->mpath) direct_link_motionpath(fd, ob->mpath); - + link_list(fd, &ob->defbase); link_list(fd, &ob->fmaps); // XXX deprecated - old animation system <<< direct_link_nlastrips(fd, &ob->nlastrips); link_list(fd, &ob->constraintChannels); // >>> XXX deprecated - old animation system - + ob->mat= newdataadr(fd, ob->mat); test_pointer_array(fd, (void **)&ob->mat); ob->matbits= newdataadr(fd, ob->matbits); - + /* do it here, below old data gets converted */ direct_link_modifiers(fd, &ob->modifiers); - + link_list(fd, &ob->effect); paf= ob->effect.first; while (paf) { @@ -5401,7 +5401,7 @@ static void direct_link_object(FileData *fd, Object *ob) WaveEff *wav = (WaveEff*) paf; PartEff *next = paf->next; WaveModifierData *wmd = (WaveModifierData*) modifier_new(eModifierType_Wave); - + wmd->damp = wav->damp; wmd->flag = wav->flag; wmd->height = wav->height; @@ -5412,12 +5412,12 @@ static void direct_link_object(FileData *fd, Object *ob) wmd->starty = wav->startx; wmd->timeoffs = wav->timeoffs; wmd->width = wav->width; - + BLI_addtail(&ob->modifiers, wmd); - + BLI_remlink(&ob->effect, paf); MEM_freeN(paf); - + paf = next; continue; } @@ -5425,29 +5425,29 @@ static void direct_link_object(FileData *fd, Object *ob) BuildEff *baf = (BuildEff*) paf; PartEff *next = paf->next; BuildModifierData *bmd = (BuildModifierData*) modifier_new(eModifierType_Build); - + bmd->start = baf->sfra; bmd->length = baf->len; bmd->randomize = 0; bmd->seed = 1; - + BLI_addtail(&ob->modifiers, bmd); - + BLI_remlink(&ob->effect, paf); MEM_freeN(paf); - + paf = next; continue; } paf = paf->next; } - + ob->pd= newdataadr(fd, ob->pd); direct_link_partdeflect(ob->pd); ob->soft= newdataadr(fd, ob->soft); if (ob->soft) { SoftBody *sb = ob->soft; - + sb->bpoint = NULL; // init pointers so it gets rebuilt nicely sb->bspring = NULL; sb->scratch = NULL; @@ -5461,21 +5461,21 @@ static void direct_link_object(FileData *fd, Object *ob) sb->keys[a] = newdataadr(fd, sb->keys[a]); } } - + sb->effector_weights = newdataadr(fd, sb->effector_weights); if (!sb->effector_weights) sb->effector_weights = BKE_add_effector_weights(NULL); - + direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, 0); } ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */ - + ob->rigidbody_object = newdataadr(fd, ob->rigidbody_object); if (ob->rigidbody_object) { RigidBodyOb *rbo = ob->rigidbody_object; - - /* must nullify the references to physics sim objects, since they no-longer exist - * (and will need to be recalculated) + + /* must nullify the references to physics sim objects, since they no-longer exist + * (and will need to be recalculated) */ rbo->physics_object = NULL; rbo->physics_shape = NULL; @@ -5493,12 +5493,12 @@ static void direct_link_object(FileData *fd, Object *ob) while (ob->hooks.first) { ObHook *hook = ob->hooks.first; HookModifierData *hmd = (HookModifierData *)modifier_new(eModifierType_Hook); - + hook->indexar= newdataadr(fd, hook->indexar); if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { BLI_endian_switch_int32_array(hook->indexar, hook->totindex); } - + /* Do conversion here because if we have loaded * a hook we need to make sure it gets converted * and freed, regardless of version. @@ -5510,15 +5510,15 @@ static void direct_link_object(FileData *fd, Object *ob) hmd->object = hook->parent; memcpy(hmd->parentinv, hook->parentinv, sizeof(hmd->parentinv)); hmd->totindex = hook->totindex; - + BLI_addhead(&ob->modifiers, hmd); BLI_remlink(&ob->hooks, hook); - + modifier_unique_name(&ob->modifiers, (ModifierData*)hmd); - + MEM_freeN(hook); } - + ob->iuser = newdataadr(fd, ob->iuser); if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE && !ob->iuser) { BKE_object_empty_draw_type_set(ob, ob->empty_drawtype); @@ -5755,7 +5755,7 @@ static void lib_link_collection(FileData *fd, Main *main) static void composite_patch(bNodeTree *ntree, Scene *scene) { bNode *node; - + for (node = ntree->nodes.first; node; node = node->next) { if (node->id==NULL && node->type == CMP_NODE_R_LAYERS) node->id = &scene->id; @@ -5817,21 +5817,21 @@ static void lib_link_scene(FileData *fd, Main *main) bool need_check_set = false; int totscene = 0; #endif - + for (Scene *sce = main->scene.first; sce; sce = sce->id.next) { if (sce->id.tag & LIB_TAG_NEED_LINK) { /* Link ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ IDP_LibLinkProperty(sce->id.properties, fd); lib_link_animdata(fd, &sce->id, sce->adt); - + lib_link_keyingsets(fd, &sce->id, &sce->keyingsets); - + sce->camera = newlibadr(fd, sce->id.lib, sce->camera); sce->world = newlibadr_us(fd, sce->id.lib, sce->world); sce->set = newlibadr(fd, sce->id.lib, sce->set); sce->gpd = newlibadr_us(fd, sce->id.lib, sce->gpd); - + link_paint(fd, sce, &sce->toolsettings->sculpt->paint); link_paint(fd, sce, &sce->toolsettings->vpaint->paint); link_paint(fd, sce, &sce->toolsettings->wpaint->paint); @@ -5853,14 +5853,14 @@ static void lib_link_scene(FileData *fd, Main *main) if (sce->toolsettings->imapaint.canvas) sce->toolsettings->imapaint.canvas = newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.canvas); - + sce->toolsettings->particle.shape_object = newlibadr(fd, sce->id.lib, sce->toolsettings->particle.shape_object); - + for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) { base_legacy_next = base_legacy->next; - + base_legacy->object = newlibadr_us(fd, sce->id.lib, base_legacy->object); - + if (base_legacy->object == NULL) { blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"), sce->id.name + 2); @@ -5869,7 +5869,7 @@ static void lib_link_scene(FileData *fd, Main *main) MEM_freeN(base_legacy); } } - + Sequence *seq; SEQ_BEGIN (sce->ed, seq) { @@ -5916,11 +5916,11 @@ static void lib_link_scene(FileData *fd, Main *main) marker->camera = newlibadr(fd, sce->id.lib, marker->camera); } } - + BKE_sequencer_update_muting(sce->ed); BKE_sequencer_update_sound_bounds_all(sce); - - + + /* rigidbody world relies on it's linked collections */ if (sce->rigidbody_world) { RigidBodyWorld *rbw = sce->rigidbody_world; @@ -5931,13 +5931,13 @@ static void lib_link_scene(FileData *fd, Main *main) if (rbw->effector_weights) rbw->effector_weights->group = newlibadr(fd, sce->id.lib, rbw->effector_weights->group); } - + if (sce->nodetree) { lib_link_ntree(fd, &sce->id, sce->nodetree); sce->nodetree->id.lib = sce->id.lib; composite_patch(sce->nodetree, sce); } - + for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) { srl->mat_override = newlibadr_us(fd, sce->id.lib, srl->mat_override); for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) { @@ -6006,9 +6006,9 @@ static void lib_link_scene(FileData *fd, Main *main) static void link_recurs_seq(FileData *fd, ListBase *lb) { Sequence *seq; - + link_list(fd, lb); - + for (seq = lb->first; seq; seq = seq->next) { if (seq->seqbase.first) link_recurs_seq(fd, &seq->seqbase); @@ -6068,34 +6068,34 @@ static void direct_link_scene(FileData *fd, Scene *sce) RigidBodyWorld *rbw; ViewLayer *view_layer; SceneRenderLayer *srl; - + sce->depsgraph_hash = NULL; sce->fps_info = NULL; sce->customdata_mask_modal = 0; sce->lay_updated = 0; - + BKE_sound_create_scene(sce); - + /* set users to one by default, not in lib-link, this will increase it for compo nodes */ id_us_ensure_real(&sce->id); - + link_list(fd, &(sce->base)); - + sce->adt = newdataadr(fd, sce->adt); direct_link_animdata(fd, sce->adt); - + link_list(fd, &sce->keyingsets); direct_link_keyingsets(fd, &sce->keyingsets); - + sce->basact = newdataadr(fd, sce->basact); - + sce->toolsettings= newdataadr(fd, sce->toolsettings); if (sce->toolsettings) { direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->sculpt); direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->vpaint); direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->wpaint); direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->uvsculpt); - + direct_link_paint(fd, &sce->toolsettings->imapaint.paint); sce->toolsettings->imapaint.paintcursor = NULL; @@ -6103,7 +6103,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->toolsettings->particle.scene = NULL; sce->toolsettings->particle.object = NULL; sce->toolsettings->gp_sculpt.paintcursor = NULL; - + /* relink grease pencil drawing brushes */ link_list(fd, &sce->toolsettings->gp_brushes); for (bGPDbrush *brush = sce->toolsettings->gp_brushes.first; brush; brush = brush->next) { @@ -6120,7 +6120,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) direct_link_curvemapping(fd, brush->cur_jitter); } } - + /* relink grease pencil interpolation curves */ sce->toolsettings->gp_interpolate.custom_ipo = newdataadr(fd, sce->toolsettings->gp_interpolate.custom_ipo); if (sce->toolsettings->gp_interpolate.custom_ipo) { @@ -6130,29 +6130,29 @@ static void direct_link_scene(FileData *fd, Scene *sce) if (sce->ed) { ListBase *old_seqbasep = &sce->ed->seqbase; - + ed = sce->ed = newdataadr(fd, sce->ed); - + ed->act_seq = newdataadr(fd, ed->act_seq); - + /* recursive link sequences, lb will be correctly initialized */ link_recurs_seq(fd, &ed->seqbase); - + SEQ_BEGIN (ed, seq) { seq->seq1= newdataadr(fd, seq->seq1); seq->seq2= newdataadr(fd, seq->seq2); seq->seq3= newdataadr(fd, seq->seq3); - + /* a patch: after introduction of effects with 3 input strips */ if (seq->seq3 == NULL) seq->seq3 = seq->seq2; - + seq->effectdata = newdataadr(fd, seq->effectdata); seq->stereo3d_format = newdataadr(fd, seq->stereo3d_format); - + if (seq->type & SEQ_TYPE_EFFECT) seq->flag |= SEQ_EFFECT_NOT_LOADED; - + if (seq->type == SEQ_TYPE_SPEED) { SpeedControlVars *s = seq->effectdata; s->frameMap = NULL; @@ -6164,7 +6164,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) seq->strip = newdataadr(fd, seq->strip); if (seq->strip && seq->strip->done==0) { seq->strip->done = true; - + if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) { seq->strip->stripdata = newdataadr(fd, seq->strip->stripdata); } @@ -6205,22 +6205,22 @@ static void direct_link_scene(FileData *fd, Scene *sce) direct_link_sequence_modifiers(fd, &seq->modifiers); } SEQ_END - + /* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */ { Sequence temp; void *poin; intptr_t offset; - + offset = ((intptr_t)&(temp.seqbase)) - ((intptr_t)&temp); - + /* root pointer */ if (ed->seqbasep == old_seqbasep) { ed->seqbasep = &ed->seqbase; } else { poin = POINTER_OFFSET(ed->seqbasep, -offset); - + poin = newdataadr(fd, poin); if (poin) ed->seqbasep = (ListBase *)POINTER_OFFSET(poin, offset); @@ -6229,24 +6229,24 @@ static void direct_link_scene(FileData *fd, Scene *sce) } /* stack */ link_list(fd, &(ed->metastack)); - + for (ms = ed->metastack.first; ms; ms= ms->next) { ms->parseq = newdataadr(fd, ms->parseq); - + if (ms->oldbasep == old_seqbasep) ms->oldbasep= &ed->seqbase; else { poin = POINTER_OFFSET(ms->oldbasep, -offset); poin = newdataadr(fd, poin); - if (poin) + if (poin) ms->oldbasep = (ListBase *)POINTER_OFFSET(poin, offset); - else + else ms->oldbasep = &ed->seqbase; } } } } - + sce->r.avicodecdata = newdataadr(fd, sce->r.avicodecdata); if (sce->r.avicodecdata) { sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat); @@ -6256,7 +6256,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties); IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } - + link_list(fd, &(sce->markers)); link_list(fd, &(sce->transform_spaces)); link_list(fd, &(sce->r.layers)); @@ -6269,7 +6269,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) link_list(fd, &(srl->freestyleConfig.modules)); link_list(fd, &(srl->freestyleConfig.linesets)); } - + sce->nodetree = newdataadr(fd, sce->nodetree); if (sce->nodetree) { direct_link_id(fd, &sce->nodetree->id); @@ -6277,12 +6277,12 @@ static void direct_link_scene(FileData *fd, Scene *sce) } direct_link_view_settings(fd, &sce->view_settings); - + sce->rigidbody_world = newdataadr(fd, sce->rigidbody_world); rbw = sce->rigidbody_world; if (rbw) { - /* must nullify the reference to physics sim object, since it no-longer exist - * (and will need to be recalculated) + /* must nullify the reference to physics sim object, since it no-longer exist + * (and will need to be recalculated) */ rbw->physics_world = NULL; rbw->objects = NULL; @@ -6354,7 +6354,7 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd) /* we must firstly have some grease-pencil data to link! */ if (gpd == NULL) return; - + /* relink animdata */ gpd->adt = newdataadr(fd, gpd->adt); direct_link_animdata(fd, gpd->adt); @@ -6367,21 +6367,21 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd) /* relink layers */ link_list(fd, &gpd->layers); - + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* parent */ gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent); /* relink frames */ link_list(fd, &gpl->frames); gpl->actframe = newdataadr(fd, gpl->actframe); - + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* relink strokes (and their points) */ link_list(fd, &gpf->strokes); - + for (gps = gpf->strokes.first; gps; gps = gps->next) { gps->points = newdataadr(fd, gps->points); - + /* the triangulation is not saved, so need to be recalculated */ gps->triangles = NULL; gps->tot_triangles = 0; @@ -6453,7 +6453,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) } } } - + ar->v2d.tab_offset = NULL; ar->v2d.tab_num = 0; ar->v2d.tab_cur = 0; @@ -6595,7 +6595,7 @@ static void direct_link_area(FileData *fd, ScrArea *area) sima->scopes.vecscope = NULL; sima->scopes.ok = 0; - /* WARNING: gpencil data is no longer stored directly in sima after 2.5 + /* WARNING: gpencil data is no longer stored directly in sima after 2.5 * so sacrifice a few old files for now to avoid crashes with new files! * committed: r28002 */ #if 0 @@ -6606,12 +6606,12 @@ static void direct_link_area(FileData *fd, ScrArea *area) } else if (sl->spacetype == SPACE_NODE) { SpaceNode *snode = (SpaceNode *)sl; - + if (snode->gpd) { snode->gpd = newdataadr(fd, snode->gpd); direct_link_gpencil(fd, snode->gpd); } - + link_list(fd, &snode->treepath); snode->edittree = NULL; snode->iofsd = NULL; @@ -6619,14 +6619,14 @@ static void direct_link_area(FileData *fd, ScrArea *area) } else if (sl->spacetype == SPACE_TEXT) { SpaceText *st= (SpaceText *)sl; - + st->drawcache = NULL; st->scroll_accum[0] = 0.0f; st->scroll_accum[1] = 0.0f; } else if (sl->spacetype == SPACE_SEQ) { SpaceSeq *sseq = (SpaceSeq *)sl; - + /* grease pencil data is not a direct data and can't be linked from direct_link* * functions, it should be linked from lib_link* functions instead * @@ -6930,10 +6930,10 @@ static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map) static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) { wmWindow *win; - + id_us_ensure_real(&wm->id); link_list(fd, &wm->windows); - + for (win = wm->windows.first; win; win = win->next) { WorkSpaceInstanceHook *hook = win->workspace_hook; @@ -6950,12 +6950,12 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) #ifdef WIN32 win->ime_data = NULL; #endif - + BLI_listbase_clear(&win->queue); BLI_listbase_clear(&win->handlers); BLI_listbase_clear(&win->modalhandlers); BLI_listbase_clear(&win->gesture); - + win->active = 0; win->cursor = 0; @@ -6971,13 +6971,13 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) win->stereo3d_format->display_mode = S3D_DISPLAY_ANAGLYPH; } } - + BLI_listbase_clear(&wm->timers); BLI_listbase_clear(&wm->operators); BLI_listbase_clear(&wm->paintcursors); BLI_listbase_clear(&wm->queue); BKE_reports_init(&wm->reports, RPT_STORE); - + BLI_listbase_clear(&wm->keyconfigs); wm->defaultconf = NULL; wm->addonconf = NULL; @@ -6988,7 +6988,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) BLI_listbase_clear(&wm->jobs); BLI_listbase_clear(&wm->drags); - + wm->windrawable = NULL; wm->winactive = NULL; wm->initialized = 0; @@ -7000,7 +7000,7 @@ static void lib_link_windowmanager(FileData *fd, Main *main) { wmWindowManager *wm; wmWindow *win; - + for (wm = main->wm.first; wm; wm = wm->id.next) { if (wm->id.tag & LIB_TAG_NEED_LINK) { /* Note: WM IDProperties are never written to file, hence no need to read/link them here. */ @@ -7011,7 +7011,7 @@ static void lib_link_windowmanager(FileData *fd, Main *main) win->scene = newlibadr(fd, wm->id.lib, win->scene); /* deprecated, but needed for versioning (will be NULL'ed then) */ win->screen = newlibadr(fd, NULL, win->screen); - + for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { lib_link_area(fd, &wm->id, area); } @@ -7024,7 +7024,7 @@ static void lib_link_windowmanager(FileData *fd, Main *main) /* ****************** READ SCREEN ***************** */ -/* note: file read without screens option G_FILE_NO_UI; +/* note: file read without screens option G_FILE_NO_UI; * check lib pointers in call below */ static void lib_link_screen(FileData *fd, Main *main) { @@ -7039,7 +7039,7 @@ static void lib_link_screen(FileData *fd, Main *main) sc->animtimer = NULL; /* saved in rare cases */ sc->tool_tip = NULL; sc->scrubbing = false; - + for (ScrArea *area = sc->areabase.first; area; area = area->next) { lib_link_area(fd, &sc->id, area); } @@ -7209,7 +7209,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; ARegion *ar; - + v3d->camera = restore_pointer_by_name(id_map, (ID *)v3d->camera, USER_REAL); v3d->ob_centre = restore_pointer_by_name(id_map, (ID *)v3d->ob_centre, USER_REAL); @@ -7230,14 +7230,14 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main else if (sl->spacetype == SPACE_IPO) { SpaceIpo *sipo = (SpaceIpo *)sl; bDopeSheet *ads = sipo->ads; - + if (ads) { ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL); - + if (ads->filter_grp) ads->filter_grp = restore_pointer_by_name(id_map, (ID *)ads->filter_grp, USER_IGNORE); } - + /* force recalc of list of channels (i.e. includes calculating F-Curve colors) * thus preventing the "black curves" problem post-undo */ @@ -7261,28 +7261,28 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main } else if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; - + saction->action = restore_pointer_by_name(id_map, (ID *)saction->action, USER_REAL); saction->ads.source = restore_pointer_by_name(id_map, (ID *)saction->ads.source, USER_REAL); - + if (saction->ads.filter_grp) saction->ads.filter_grp = restore_pointer_by_name(id_map, (ID *)saction->ads.filter_grp, USER_IGNORE); - - - /* force recalc of list of channels, potentially updating the active action - * while we're at it (as it can only be updated that way) [#28962] + + + /* force recalc of list of channels, potentially updating the active action + * while we're at it (as it can only be updated that way) [#28962] */ saction->flag |= SACTION_TEMP_NEEDCHANSYNC; } else if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; - + sima->image = restore_pointer_by_name(id_map, (ID *)sima->image, USER_REAL); - + /* this will be freed, not worth attempting to find same scene, * since it gets initialized later */ sima->iuser.scene = NULL; - + #if 0 /* Those are allocated and freed by space code, no need to handle them here. */ MEM_SAFE_FREE(sima->scopes.waveform_1); @@ -7291,7 +7291,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main MEM_SAFE_FREE(sima->scopes.vecscope); #endif sima->scopes.ok = 0; - + /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so assume that here we're doing for undo only... */ @@ -7300,7 +7300,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main } else if (sl->spacetype == SPACE_SEQ) { SpaceSeq *sseq = (SpaceSeq *)sl; - + /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so assume that here we're doing for undo only... */ @@ -7309,25 +7309,25 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main else if (sl->spacetype == SPACE_NLA) { SpaceNla *snla = (SpaceNla *)sl; bDopeSheet *ads = snla->ads; - + if (ads) { ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL); - + if (ads->filter_grp) ads->filter_grp = restore_pointer_by_name(id_map, (ID *)ads->filter_grp, USER_IGNORE); } } else if (sl->spacetype == SPACE_TEXT) { SpaceText *st = (SpaceText *)sl; - + st->text = restore_pointer_by_name(id_map, (ID *)st->text, USER_REAL); if (st->text == NULL) st->text = newmain->text.first; } else if (sl->spacetype == SPACE_SCRIPT) { SpaceScript *scpt = (SpaceScript *)sl; - + scpt->script = restore_pointer_by_name(id_map, (ID *)scpt->script, USER_REAL); - + /*sc->script = NULL; - 2.45 set to null, better re-run the script */ if (scpt->script) { SCRIPT_SET_NULL(scpt->script); @@ -7335,9 +7335,9 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main } else if (sl->spacetype == SPACE_OUTLINER) { SpaceOops *so= (SpaceOops *)sl; - + so->search_tse.id = restore_pointer_by_name(id_map, so->search_tse.id, USER_IGNORE); - + if (so->treestore) { TreeStoreElem *tselem; BLI_mempool_iter iter; @@ -7362,14 +7362,14 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main SpaceNode *snode= (SpaceNode *)sl; bNodeTreePath *path, *path_next; bNodeTree *ntree; - + /* node tree can be stored locally in id too, link this first */ snode->id = restore_pointer_by_name(id_map, snode->id, USER_REAL); snode->from = restore_pointer_by_name(id_map, snode->from, USER_IGNORE); - + ntree = snode->id ? ntreeFromID(snode->id) : NULL; snode->nodetree = ntree ? ntree : restore_pointer_by_name(id_map, (ID *)snode->nodetree, USER_REAL); - + for (path = snode->treepath.first; path; path = path->next) { if (path == snode->treepath.first) { /* first nodetree in path is same as snode->nodetree */ @@ -7377,19 +7377,19 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main } else path->nodetree= restore_pointer_by_name(id_map, (ID*)path->nodetree, USER_REAL); - + if (!path->nodetree) break; } - + /* remaining path entries are invalid, remove */ for (; path; path = path_next) { path_next = path->next; - + BLI_remlink(&snode->treepath, path); MEM_freeN(path); } - + /* edittree is just the last in the path, * set this directly since the path may have been shortened above */ if (snode->treepath.last) { @@ -7401,10 +7401,10 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main } else if (sl->spacetype == SPACE_CLIP) { SpaceClip *sclip = (SpaceClip *)sl; - + sclip->clip = restore_pointer_by_name(id_map, (ID *)sclip->clip, USER_REAL); sclip->mask_info.mask = restore_pointer_by_name(id_map, (ID *)sclip->mask_info.mask, USER_REAL); - + sclip->scopes.ok = 0; } } @@ -7463,11 +7463,11 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) { ARegion *ar; - + for (ar = regions->first; ar; ar = ar->next) { if (ar->regiontype==RGN_TYPE_WINDOW && ar->regiondata==NULL) { RegionView3D *rv3d; - + rv3d = ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch"); rv3d->persp = (char)v3d->persp; rv3d->view = (char)v3d->view; @@ -7476,7 +7476,7 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) copy_qt_qt(rv3d->viewquat, v3d->viewquat); } } - + /* this was not initialized correct always */ if (v3d->gridsubdiv == 0) v3d->gridsubdiv = 10; @@ -7485,7 +7485,7 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) static bool direct_link_screen(FileData *fd, bScreen *sc) { bool wrong_id = false; - + sc->regionbase.first = sc->regionbase.last= NULL; sc->context = NULL; sc->active_region = NULL; @@ -7506,7 +7506,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc) static void direct_link_library(FileData *fd, Library *lib, Main *main) { Main *newmain; - + /* check if the library was already read */ for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) { if (newmain->curlib) { @@ -7514,10 +7514,10 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("Library '%s', '%s' had multiple instances, save and reload!"), lib->name, lib->filepath); - + change_idid_adr(fd->mainlist, fd, lib, newmain->curlib); /* change_idid_adr_fd(fd, lib, newmain->curlib); */ - + BLI_remlink(&main->library, lib); MEM_freeN(lib); @@ -7537,17 +7537,17 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) /* make sure we have full path in lib->filepath */ BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name)); BLI_cleanup_path(fd->relabase, lib->filepath); - + // printf("direct_link_library: name %s\n", lib->name); // printf("direct_link_library: filepath %s\n", lib->filepath); - + lib->packedfile = direct_link_packedfile(fd, lib->packedfile); - + /* new main */ newmain = BKE_main_new(); BLI_addtail(fd->mainlist, newmain); newmain->curlib = lib; - + lib->parent = NULL; } @@ -7618,7 +7618,7 @@ static void lib_link_speaker(FileData *fd, Main *main) if (spk->id.tag & LIB_TAG_NEED_LINK) { IDP_LibLinkProperty(spk->id.properties, fd); lib_link_animdata(fd, &spk->id, spk->adt); - + spk->sound = newlibadr_us(fd, spk->id.lib, spk->sound); spk->id.tag &= ~LIB_TAG_NEED_LINK; @@ -7652,11 +7652,11 @@ static void direct_link_sound(FileData *fd, bSound *sound) if (fd->soundmap) { sound->waveform = newsoundadr(fd, sound->waveform); - } + } else { sound->waveform = NULL; } - + if (sound->spinlock) { sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock"); BLI_spin_init(sound->spinlock); @@ -7675,7 +7675,7 @@ static void lib_link_sound(FileData *fd, Main *main) IDP_LibLinkProperty(sound->id.properties, fd); sound->ipo = newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX deprecated - old animation system - + BKE_sound_load(main, sound); sound->id.tag &= ~LIB_TAG_NEED_LINK; @@ -7693,9 +7693,9 @@ static void direct_link_movieReconstruction(FileData *fd, MovieTrackingReconstru static void direct_link_movieTracks(FileData *fd, ListBase *tracksbase) { MovieTrackingTrack *track; - + link_list(fd, tracksbase); - + for (track = tracksbase->first; track; track = track->next) { track->markers = newdataadr(fd, track->markers); } @@ -7755,7 +7755,7 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip) BLI_listbase_clear(&clip->tracking.dopesheet.coverage_segments); link_list(fd, &tracking->objects); - + for (object = tracking->objects.first; object; object = object->next) { direct_link_movieTracks(fd, &object->tracks); direct_link_moviePlaneTracks(fd, &object->plane_tracks); @@ -7789,9 +7789,9 @@ static void lib_link_movieclip(FileData *fd, Main *main) IDP_LibLinkProperty(clip->id.properties, fd); lib_link_animdata(fd, &clip->id, clip->adt); - + clip->gpd = newlibadr_us(fd, clip->id.lib, clip->gpd); - + lib_link_movieTracks(fd, clip, &tracking->tracks); lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks); @@ -8207,13 +8207,13 @@ static const char *dataname(short id_code) case ID_WS: return "Data from WS"; } return "Data from Lib Block"; - + } static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, const char *allocname) { bhead = blo_nextbhead(fd, bhead); - + while (bhead && bhead->code==DATA) { void *data; #if 0 @@ -8226,14 +8226,14 @@ static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, const char *a #else data = read_struct(fd, bhead, allocname); #endif - + if (data) { oldnewmap_insert(fd->datamap, bhead->old, data, 0); } - + bhead = blo_nextbhead(fd, bhead); } - + return bhead; } @@ -8322,14 +8322,14 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short *r_id = id; if (!id) return blo_nextbhead(fd, bhead); - + id->lib = main->curlib; id->us = ID_FAKE_USERS(id); id->icon_id = 0; id->newid = NULL; /* Needed because .blend may have been saved with crap value here... */ id->orig_id = NULL; id->recalc = 0; - + /* this case cannot be direct_linked: it's just the ID part */ if (bhead->code == ID_ID) { /* That way, we know which datablock needs do_versions (required currently for linking). */ @@ -8340,10 +8340,10 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short /* need a name for the mallocN, just for debugging and sane prints on leaks */ allocname = dataname(GS(id->name)); - + /* read all data into fd->datamap */ bhead = read_data_into_oldnewmap(fd, bhead, allocname); - + /* init pointers direct data */ direct_link_id(fd, id); @@ -8461,14 +8461,14 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short direct_link_workspace(fd, (WorkSpace *)id, main); break; } - + oldnewmap_free_unused(fd->datamap); oldnewmap_clear(fd->datamap); - + if (wrong_id) { BKE_libblock_free(main, id); } - + return (bhead); } @@ -8477,41 +8477,41 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) { FileGlobal *fg = read_struct(fd, bhead, "Global"); - + /* copy to bfd handle */ bfd->main->subversionfile = fg->subversion; bfd->main->minversionfile = fg->minversion; bfd->main->minsubversionfile = fg->minsubversion; bfd->main->build_commit_timestamp = fg->build_commit_timestamp; BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash)); - + bfd->fileflags = fg->fileflags; bfd->globalf = fg->globalf; BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename)); - + /* error in 2.65 and older: main->name was not set if you save from startup (not after loading file) */ if (bfd->filename[0] == 0) { if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1)) if ((G.fileflags & G_FILE_RECOVER)==0) BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename)); - + /* early 2.50 version patch - filename not in FileGlobal struct at all */ if (fd->fileversion <= 250) BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename)); } - + if (G.fileflags & G_FILE_RECOVER) BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase)); - + bfd->curscreen = fg->curscreen; bfd->curscene = fg->curscene; bfd->cur_view_layer = fg->cur_view_layer; MEM_freeN(fg); - + fd->globalf = bfd->globalf; fd->fileflags = bfd->fileflags; - + return blo_nextbhead(fd, bhead); } @@ -8533,12 +8533,12 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd) { Main *bmain = bfd->main; UserDef *user = bfd->user; - + if (user == NULL) return; - + if (MAIN_VERSION_OLDER(bmain, 266, 4)) { bTheme *btheme; - + /* themes for Node and Sequence editor were not using grid color, but back. we copy this over then */ for (btheme = user->themes.first; btheme; btheme = btheme->next) { copy_v4_v4_char(btheme->tnode.grid, btheme->tnode.back); @@ -8559,7 +8559,7 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd) static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ - + if (G.debug & G_DEBUG) { char build_commit_datetime[32]; time_t temp_time = main->build_commit_timestamp; @@ -8575,7 +8575,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) fd->relabase, main->versionfile, main->subversionfile, build_commit_datetime, main->build_hash); } - + blo_do_versions_pre250(fd, lib, main); blo_do_versions_250(fd, lib, main); blo_do_versions_260(fd, lib, main); @@ -8600,7 +8600,7 @@ static void do_versions_after_linking(Main *main) static void lib_link_all(FileData *fd, Main *main) { oldnewmap_sort(fd); - + lib_link_id(fd, main); /* No load UI for undo memfiles */ @@ -8661,22 +8661,22 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) wmKeyMapItem *kmi; wmKeyMapDiffItem *kmdi; bAddon *addon; - + bfd->user = user= read_struct(fd, bhead, "user def"); - + /* User struct has separate do-version handling */ user->versionfile = bfd->main->versionfile; user->subversionfile = bfd->main->subversionfile; - + /* read all data into fd->datamap */ bhead = read_data_into_oldnewmap(fd, bhead, "user def"); - + if (user->keymaps.first) { /* backwards compatibility */ user->user_keymaps= user->keymaps; user->keymaps.first= user->keymaps.last= NULL; } - + link_list(fd, &user->themes); link_list(fd, &user->user_keymaps); link_list(fd, &user->addons); @@ -8686,20 +8686,20 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) keymap->modal_items= NULL; keymap->poll = NULL; keymap->flag &= ~KEYMAP_UPDATE; - + link_list(fd, &keymap->diff_items); link_list(fd, &keymap->items); - + for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) { kmdi->remove_item= newdataadr(fd, kmdi->remove_item); kmdi->add_item= newdataadr(fd, kmdi->add_item); - + if (kmdi->remove_item) direct_link_keymapitem(fd, kmdi->remove_item); if (kmdi->add_item) direct_link_keymapitem(fd, kmdi->add_item); } - + for (kmi=keymap->items.first; kmi; kmi=kmi->next) direct_link_keymapitem(fd, kmi); } @@ -8711,13 +8711,13 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) // XXX user->uifonts.first = user->uifonts.last= NULL; - + link_list(fd, &user->uistyles); - + /* free fd->datamap again */ oldnewmap_free_unused(fd->datamap); oldnewmap_clear(fd->datamap); - + return bhead; } @@ -8726,14 +8726,14 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) BHead *bhead = blo_firstbhead(fd); BlendFileData *bfd; ListBase mainlist = {NULL, NULL}; - + bfd = MEM_callocN(sizeof(BlendFileData), "blendfiledata"); bfd->main = BKE_main_new(); BLI_addtail(&mainlist, bfd->main); fd->mainlist = &mainlist; - + bfd->main->versionfile = fd->fileversion; - + bfd->type = BLENFILETYPE_BLEND; BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name)); @@ -8783,7 +8783,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) case ENDB: bhead = NULL; break; - + case ID_ID: /* Always adds to the most recently loaded ID_LI block, see direct_link_library. * This is part of the file format definition. */ @@ -8808,17 +8808,17 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) } } } - + /* do before read_libraries, but skip undo case */ if (fd->memfile == NULL) { do_versions(fd, NULL, bfd->main); do_versions_userdef(fd, bfd); } - + read_libraries(fd, &mainlist); - + blo_join_main(&mainlist); - + lib_link_all(fd, bfd->main); /* Skip in undo case. */ @@ -8844,9 +8844,9 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) lib_verify_nodetree(bfd->main, true); fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */ - + link_global(fd, bfd); /* as last */ - + fd->mainlist = NULL; /* Safety, this is local variable, shall not be used afterward. */ return bfd; @@ -8862,7 +8862,7 @@ struct BHeadSort { static int verg_bheadsort(const void *v1, const void *v2) { const struct BHeadSort *x1=v1, *x2=v2; - + if (x1->old > x2->old) return 1; else if (x1->old < x2->old) return -1; return 0; @@ -8873,20 +8873,20 @@ static void sort_bhead_old_map(FileData *fd) BHead *bhead; struct BHeadSort *bhs; int tot = 0; - + for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) tot++; - + fd->tot_bheadmap = tot; if (tot == 0) return; - + bhs = fd->bheadmap = MEM_malloc_arrayN(tot, sizeof(struct BHeadSort), "BHeadSort"); - + for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead), bhs++) { bhs->bhead = bhead; bhs->old = bhead->old; } - + qsort(fd->bheadmap, tot, sizeof(struct BHeadSort), verg_bheadsort); } @@ -8910,19 +8910,19 @@ static BHead *find_bhead(FileData *fd, void *old) BHead *bhead; #endif struct BHeadSort *bhs, bhs_s; - + if (!old) return NULL; if (fd->bheadmap == NULL) sort_bhead_old_map(fd); - + bhs_s.old = old; bhs = bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(struct BHeadSort), verg_bheadsort); if (bhs) return bhs->bhead; - + #if 0 for (bhead = blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) { if (bhead->old == old) @@ -8984,32 +8984,32 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) BHead *bhead; FileData *fd = fdhandle; ID *id; - + bhead = find_bhead(fd, old); if (bhead) { /* from another library? */ if (bhead->code == ID_ID) { BHead *bheadlib= find_previous_lib(fd, bhead); - + if (bheadlib) { Library *lib = read_struct(fd, bheadlib, "Library"); Main *ptr = blo_find_main(fd, lib->name, fd->relabase); - + if (ptr->curlib == NULL) { const char *idname= bhead_id_name(fd, bhead); - + blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: Data refers to main .blend file: '%s' from %s"), idname, mainvar->curlib->filepath); return; } else id = is_yet_read(fd, ptr, bhead); - + if (id == NULL) { read_libblock(fd, ptr, bhead, LIB_TAG_READ | LIB_TAG_INDIRECT, NULL); // commented because this can print way too much // if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name); - + /* for outliner dependency only */ ptr->curlib->parent = mainvar->curlib; } @@ -9020,10 +9020,10 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) * lib_indirect.blend but lib.blend does too, linking in a Scene or Group from lib.blend can result in an * empty without the dupli group referenced. Once you save and reload the group would appear. - Campbell */ /* This crashes files, must look further into it */ - + /* Update: the issue is that in file reading, the oldnewmap is OK, but for existing data, it has to be * inserted in the map to be found! */ - + /* Update: previously it was checking for id->tag & LIB_TAG_PRE_EXISTING, however that * does not affect file reading. For file reading we may need to insert it into the libmap as well, * because you might have two files indirectly linking the same datablock, and in that case @@ -9033,11 +9033,11 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) * change_idid_adr not detect the mapping was for an ID_ID datablock. */ oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); change_idid_adr_fd(fd, bhead->old, id); - + // commented because this can print way too much // if (G.debug & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name); } - + MEM_freeN(lib); } } @@ -9119,14 +9119,14 @@ static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop) static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list) { FModifier *fcm; - + for (fcm = list->first; fcm; fcm = fcm->next) { /* library data for specific F-Modifier types */ switch (fcm->type) { case FMODIFIER_TYPE_PYTHON: { FMod_Python *data = (FMod_Python *)fcm->data; - + expand_doit(fd, mainvar, data->script); break; @@ -9138,15 +9138,15 @@ static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list) static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list) { FCurve *fcu; - + for (fcu = list->first; fcu; fcu = fcu->next) { /* Driver targets if there is a driver */ if (fcu->driver) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { - DRIVER_TARGETS_LOOPER(dvar) + DRIVER_TARGETS_LOOPER(dvar) { // TODO: only expand those that are going to get used? expand_doit(fd, mainvar, dtar->id); @@ -9154,7 +9154,7 @@ static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list) DRIVER_TARGETS_LOOPER_END } } - + /* F-Curve Modifiers */ expand_fmodifiers(fd, mainvar, &fcu->modifiers); } @@ -9163,14 +9163,14 @@ static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list) static void expand_action(FileData *fd, Main *mainvar, bAction *act) { bActionChannel *chan; - + // XXX deprecated - old animation system -------------- for (chan=act->chanbase.first; chan; chan=chan->next) { expand_doit(fd, mainvar, chan->ipo); expand_constraint_channels(fd, mainvar, &chan->constraintChannels); } // --------------------------------------------------- - + /* F-Curves in Action */ expand_fcurves(fd, mainvar, &act->curves); @@ -9185,7 +9185,7 @@ static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list) { KeyingSet *ks; KS_Path *ksp; - + /* expand the ID-pointers in KeyingSets's paths */ for (ks = list->first; ks; ks = ks->next) { for (ksp = ks->paths.first; ksp; ksp = ksp->next) { @@ -9197,17 +9197,17 @@ static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list) static void expand_animdata_nlastrips(FileData *fd, Main *mainvar, ListBase *list) { NlaStrip *strip; - + for (strip= list->first; strip; strip= strip->next) { /* check child strips */ expand_animdata_nlastrips(fd, mainvar, &strip->strips); - + /* check F-Curves */ expand_fcurves(fd, mainvar, &strip->fcurves); - + /* check F-Modifiers */ expand_fmodifiers(fd, mainvar, &strip->modifiers); - + /* relink referenced action */ expand_doit(fd, mainvar, strip->act); } @@ -9216,32 +9216,32 @@ static void expand_animdata_nlastrips(FileData *fd, Main *mainvar, ListBase *lis static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt) { NlaTrack *nlt; - + /* own action */ expand_doit(fd, mainvar, adt->action); expand_doit(fd, mainvar, adt->tmpact); - + /* drivers - assume that these F-Curves have driver data to be in this list... */ expand_fcurves(fd, mainvar, &adt->drivers); - + /* nla-data - referenced actions */ - for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) expand_animdata_nlastrips(fd, mainvar, &nlt->strips); -} +} static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part) { int a; - + expand_doit(fd, mainvar, part->dup_ob); expand_doit(fd, mainvar, part->dup_group); expand_doit(fd, mainvar, part->eff_group); expand_doit(fd, mainvar, part->bb_ob); expand_doit(fd, mainvar, part->collision_group); - + if (part->adt) expand_animdata(fd, mainvar, part->adt); - + for (a = 0; a < MAX_MTEX; a++) { if (part->mtex[a]) { expand_doit(fd, mainvar, part->mtex[a]->tex); @@ -9301,7 +9301,7 @@ static void expand_collection(FileData *fd, Main *mainvar, Collection *collectio static void expand_key(FileData *fd, Main *mainvar, Key *key) { expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system - + if (key->adt) expand_animdata(fd, mainvar, key->adt); } @@ -9310,13 +9310,13 @@ static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree) { bNode *node; bNodeSocket *sock; - + if (ntree->adt) expand_animdata(fd, mainvar, ntree->adt); - + if (ntree->gpd) expand_doit(fd, mainvar, ntree->gpd); - + for (node = ntree->nodes.first; node; node = node->next) { if (node->id && node->type != CMP_NODE_R_LAYERS) { expand_doit(fd, mainvar, node->id); @@ -9340,10 +9340,10 @@ static void expand_texture(FileData *fd, Main *mainvar, Tex *tex) { expand_doit(fd, mainvar, tex->ima); expand_doit(fd, mainvar, tex->ipo); // XXX deprecated - old animation system - + if (tex->adt) expand_animdata(fd, mainvar, tex->adt); - + if (tex->nodetree) expand_nodetree(fd, mainvar, tex->nodetree); } @@ -9359,10 +9359,10 @@ static void expand_brush(FileData *fd, Main *mainvar, Brush *brush) static void expand_material(FileData *fd, Main *mainvar, Material *ma) { expand_doit(fd, mainvar, ma->ipo); // XXX deprecated - old animation system - + if (ma->adt) expand_animdata(fd, mainvar, ma->adt); - + if (ma->nodetree) expand_nodetree(fd, mainvar, ma->nodetree); } @@ -9370,10 +9370,10 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma) static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la) { expand_doit(fd, mainvar, la->ipo); // XXX deprecated - old animation system - + if (la->adt) expand_animdata(fd, mainvar, la->adt); - + if (la->nodetree) expand_nodetree(fd, mainvar, la->nodetree); } @@ -9382,7 +9382,7 @@ static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt) { expand_doit(fd, mainvar, lt->ipo); // XXX deprecated - old animation system expand_doit(fd, mainvar, lt->key); - + if (lt->adt) expand_animdata(fd, mainvar, lt->adt); } @@ -9391,10 +9391,10 @@ static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt) static void expand_world(FileData *fd, Main *mainvar, World *wrld) { expand_doit(fd, mainvar, wrld->ipo); // XXX deprecated - old animation system - + if (wrld->adt) expand_animdata(fd, mainvar, wrld->adt); - + if (wrld->nodetree) expand_nodetree(fd, mainvar, wrld->nodetree); } @@ -9403,11 +9403,11 @@ static void expand_world(FileData *fd, Main *mainvar, World *wrld) static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb) { int a; - + for (a = 0; a < mb->totcol; a++) { expand_doit(fd, mainvar, mb->mat[a]); } - + if (mb->adt) expand_animdata(fd, mainvar, mb->adt); } @@ -9415,11 +9415,11 @@ static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb) static void expand_curve(FileData *fd, Main *mainvar, Curve *cu) { int a; - + for (a = 0; a < cu->totcol; a++) { expand_doit(fd, mainvar, cu->mat[a]); } - + expand_doit(fd, mainvar, cu->vfont); expand_doit(fd, mainvar, cu->vfontb); expand_doit(fd, mainvar, cu->vfonti); @@ -9429,7 +9429,7 @@ static void expand_curve(FileData *fd, Main *mainvar, Curve *cu) expand_doit(fd, mainvar, cu->bevobj); expand_doit(fd, mainvar, cu->taperobj); expand_doit(fd, mainvar, cu->textoncurve); - + if (cu->adt) expand_animdata(fd, mainvar, cu->adt); } @@ -9437,14 +9437,14 @@ static void expand_curve(FileData *fd, Main *mainvar, Curve *cu) static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me) { int a; - + if (me->adt) expand_animdata(fd, mainvar, me->adt); - + for (a = 0; a < me->totcol; a++) { expand_doit(fd, mainvar, me->mat[a]); } - + expand_doit(fd, mainvar, me->key); expand_doit(fd, mainvar, me->texcomesh); } @@ -9465,13 +9465,13 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb) { tConstraintExpandData ced; bConstraint *curcon; - + /* relink all ID-blocks used by the constraints */ ced.fd = fd; ced.mainvar = mainvar; - + BKE_constraints_id_loop(lb, expand_constraint_cb, &ced); - + /* deprecated manual expansion stuff */ for (curcon = lb->first; curcon; curcon = curcon->next) { if (curcon->ipo) @@ -9482,10 +9482,10 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb) static void expand_pose(FileData *fd, Main *mainvar, bPose *pose) { bPoseChannel *chan; - + if (!pose) return; - + for (chan = pose->chanbase.first; chan; chan = chan->next) { expand_constraints(fd, mainvar, &chan->constraints); expand_idprops(fd, mainvar, chan->prop); @@ -9516,10 +9516,10 @@ static void expand_object_expandModifiers( void *userData, Object *UNUSED(ob), ID **idpoin, int UNUSED(cb_flag)) { struct { FileData *fd; Main *mainvar; } *data= userData; - + FileData *fd = data->fd; Main *mainvar = data->mainvar; - + expand_doit(fd, mainvar, *idpoin); } @@ -9529,56 +9529,56 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) bActionStrip *strip; PartEff *paf; int a; - + expand_doit(fd, mainvar, ob->data); - + /* expand_object_expandModifier() */ if (ob->modifiers.first) { struct { FileData *fd; Main *mainvar; } data; data.fd = fd; data.mainvar = mainvar; - + modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data); } - + expand_pose(fd, mainvar, ob->pose); expand_doit(fd, mainvar, ob->poselib); expand_constraints(fd, mainvar, &ob->constraints); - + expand_doit(fd, mainvar, ob->gpd); - + // XXX deprecated - old animation system (for version patching only) expand_doit(fd, mainvar, ob->ipo); expand_doit(fd, mainvar, ob->action); - + expand_constraint_channels(fd, mainvar, &ob->constraintChannels); - + for (strip=ob->nlastrips.first; strip; strip=strip->next) { expand_doit(fd, mainvar, strip->object); expand_doit(fd, mainvar, strip->act); expand_doit(fd, mainvar, strip->ipo); } // XXX deprecated - old animation system (for version patching only) - + if (ob->adt) expand_animdata(fd, mainvar, ob->adt); - + for (a = 0; a < ob->totcol; a++) { expand_doit(fd, mainvar, ob->mat[a]); } - + paf = blo_do_version_give_parteff_245(ob); - if (paf && paf->group) + if (paf && paf->group) expand_doit(fd, mainvar, paf->group); - + if (ob->dup_group) expand_doit(fd, mainvar, ob->dup_group); - + if (ob->proxy) expand_doit(fd, mainvar, ob->proxy); if (ob->proxy_group) expand_doit(fd, mainvar, ob->proxy_group); - + for (psys = ob->particlesystem.first; psys; psys = psys->next) expand_doit(fd, mainvar, psys->part); @@ -9626,23 +9626,23 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) SceneRenderLayer *srl; FreestyleModuleConfig *module; FreestyleLineSet *lineset; - + for (Base *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy->next) { expand_doit(fd, mainvar, base_legacy->object); } expand_doit(fd, mainvar, sce->camera); expand_doit(fd, mainvar, sce->world); - + if (sce->adt) expand_animdata(fd, mainvar, sce->adt); expand_keyingsets(fd, mainvar, &sce->keyingsets); - + if (sce->set) expand_doit(fd, mainvar, sce->set); - + if (sce->nodetree) expand_nodetree(fd, mainvar, sce->nodetree); - + for (srl = sce->r.layers.first; srl; srl = srl->next) { expand_doit(fd, mainvar, srl->mat_override); for (module = srl->freestyleConfig.modules.first; module; module = module->next) { @@ -9675,10 +9675,10 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) if (sce->gpd) expand_doit(fd, mainvar, sce->gpd); - + if (sce->ed) { Sequence *seq; - + SEQ_BEGIN (sce->ed, seq) { expand_idprops(fd, mainvar, seq->prop); @@ -9691,7 +9691,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) } SEQ_END } - + if (sce->rigidbody_world) { expand_doit(fd, mainvar, sce->rigidbody_world->group); expand_doit(fd, mainvar, sce->rigidbody_world->constraints); @@ -9719,7 +9719,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) static void expand_camera(FileData *fd, Main *mainvar, Camera *ca) { expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system - + if (ca->adt) expand_animdata(fd, mainvar, ca->adt); } @@ -9856,10 +9856,10 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) ID *id; int a; bool do_it = true; - + while (do_it) { do_it = false; - + a = set_listbasepointers(mainvar, lbarray); while (a--) { id = lbarray[a]->first; @@ -9955,10 +9955,10 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) default: break; } - + do_it = true; id->tag &= ~LIB_TAG_NEED_EXPAND; - + } id = id->next; } @@ -9968,17 +9968,17 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) /* ***************************** */ - + static bool object_in_any_scene(Main *bmain, Object *ob) { Scene *sce; - + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (BKE_scene_object_find(sce, ob)) { return true; } } - + return false; } @@ -10148,10 +10148,10 @@ static ID *link_named_part( else { id = NULL; } - + /* if we found the id but the id is NULL, this is really bad */ BLI_assert(!((bhead != NULL) && (id == NULL))); - + return id; } @@ -10188,7 +10188,7 @@ void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh) { FileData *fd = (FileData *)(bh); BHead *bhead; - + for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) { ID *id = NULL; @@ -10319,23 +10319,23 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa Main *mainl; (*fd)->mainlist = MEM_callocN(sizeof(ListBase), "FileData.mainlist"); - + /* clear for collection instantiating tag */ BKE_main_id_tag_listbase(&(mainvar->collection), LIB_TAG_DOIT, false); /* make mains */ blo_split_main((*fd)->mainlist, mainvar); - + /* which one do we need? */ mainl = blo_find_main(*fd, filepath, BKE_main_blendfile_path(mainvar)); - + /* needed for do_version */ mainl->versionfile = (*fd)->fileversion; read_file_version(*fd, mainl); #ifdef USE_GHASH_BHEAD read_file_bhead_idname_map_create(*fd); #endif - + return mainl; } @@ -10485,11 +10485,11 @@ static int mainvar_id_tag_any_check(Main *mainvar, const short tag) { ListBase *lbarray[MAX_LIBARRAY]; int a; - + a = set_listbasepointers(mainvar, lbarray); while (a--) { ID *id; - + for (id = lbarray[a]->first; id; id = id->next) { if (id->tag & tag) { return true; @@ -10507,13 +10507,13 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) GHash *loaded_ids = BLI_ghash_str_new(__func__); int a; bool do_it = true; - + /* expander now is callback function */ BLO_main_expander(expand_doit_library); - + while (do_it) { do_it = false; - + /* test 1: read libdata */ mainptr= mainl->next; while (mainptr) { @@ -10521,22 +10521,22 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) // printf("found LIB_TAG_READ %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name); FileData *fd = mainptr->curlib->filedata; - + if (fd == NULL) { - + /* printf and reports for now... its important users know this */ - + /* if packed file... */ if (mainptr->curlib->packedfile) { PackedFile *pf = mainptr->curlib->packedfile; - + blo_reportf_wrap( basefd->reports, RPT_INFO, TIP_("Read packed library: '%s', parent '%s'"), mainptr->curlib->name, library_parent_filepath(mainptr->curlib)); fd = blo_openblendermemory(pf->data, pf->size, basefd->reports); - - + + /* needed for library_append and read_libraries */ BLI_strncpy(fd->relabase, mainptr->curlib->filepath, sizeof(fd->relabase)); } @@ -10557,12 +10557,12 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) printf(" absolute lib: %s\n", mainptr->curlib->filepath); printf(" relative lib: %s\n", mainptr->curlib->name); printf(" enter a new path:\n"); - + if (scanf("%1023s", newlib_path) > 0) { /* Warning, keep length in sync with FILE_MAX! */ BLI_strncpy(mainptr->curlib->name, newlib_path, sizeof(mainptr->curlib->name)); BLI_strncpy(mainptr->curlib->filepath, newlib_path, sizeof(mainptr->curlib->filepath)); BLI_cleanup_path(BKE_main_blendfile_path_from_global(), mainptr->curlib->filepath); - + fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports); if (fd) { @@ -10572,7 +10572,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) } } } - + if (fd) { /* share the mainlist, so all libraries are added immediately in a * single list. it used to be that all FileData's had their own list, @@ -10581,15 +10581,15 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) fd->mainlist = mainlist; fd->reports = basefd->reports; - + if (fd->libmap) oldnewmap_free(fd->libmap); - + fd->libmap = oldnewmap_new(); - + mainptr->curlib->filedata = fd; mainptr->versionfile= fd->fileversion; - + /* subversion */ read_file_version(fd, mainptr); #ifdef USE_GHASH_BHEAD @@ -10604,7 +10604,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) mainptr->versionfile = mainptr->curlib->versionfile = mainl->versionfile; mainptr->subversionfile = mainptr->curlib->subversionfile = mainl->subversionfile; } - + if (fd == NULL) { blo_reportf_wrap(basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath); @@ -10651,7 +10651,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) } BLO_expand_main(fd, mainptr); } - + mainptr = mainptr->next; } } @@ -10665,7 +10665,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) a = set_listbasepointers(mainptr, lbarray); while (a--) { ID *id, *idn = NULL; - + for (id = lbarray[a]->first; id; id = idn) { idn = id->next; if (id->tag & LIB_TAG_READ) { @@ -10680,13 +10680,13 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) mainptr->curlib->filepath, library_parent_filepath(mainptr->curlib)); change_idid_adr(mainlist, basefd, id, NULL); - + MEM_freeN(id); } } } } - + /* do versions, link, and free */ Main *main_newid = BKE_main_new(); for (mainptr = mainl->next; mainptr; mainptr = mainptr->next) { @@ -10702,10 +10702,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) add_main_to_main(mainptr, main_newid); } - + if (mainptr->curlib->filedata) lib_link_all(mainptr->curlib->filedata, mainptr); - + if (mainptr->curlib->filedata) blo_freefiledata(mainptr->curlib->filedata); mainptr->curlib->filedata = NULL; } @@ -10722,17 +10722,17 @@ BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actual fd->filedes = file; fd->buffersize = actualsize; fd->read = fd_read_from_file; - + /* needed for library_append and read_libraries */ BLI_strncpy(fd->relabase, name, sizeof(fd->relabase)); - + fd = blo_decode_and_check(fd, reports); if (!fd) return NULL; - + fd->reports = reports; bfd = blo_read_file_internal(fd, ""); blo_freefiledata(fd); - + return bfd; } diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 7618c023882..65938c88192 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -66,23 +66,23 @@ typedef struct FileData { // now only in use for library appending char relabase[FILE_MAX]; - + // variables needed for reading from stream char headerdone; int inbuffer; - + // gzip stream for memory decompression z_stream strm; - + // general reading variables struct SDNA *filesdna; const struct SDNA *memsdna; const char *compflags; /* array of eSDNA_StructCompare */ - + int fileversion; int id_name_offs; /* used to retrieve ID names from (bhead+1) */ int globalf, fileflags; /* for do_versions patching */ - + eBLOReadSkip skip_flags; /* skip some data-blocks */ struct OldNewMap *datamap; @@ -92,13 +92,13 @@ typedef struct FileData { struct OldNewMap *movieclipmap; struct OldNewMap *soundmap; struct OldNewMap *packedmap; - + struct BHeadSort *bheadmap; int tot_bheadmap; /* see: USE_GHASH_BHEAD */ struct GHash *bhead_idname_hash; - + ListBase *mainlist; ListBase *old_mainlist; /* Used for undo. */ diff --git a/source/blender/blenloader/intern/runtime.c b/source/blender/blenloader/intern/runtime.c index ec496e1c866..ec0e8ba4738 100644 --- a/source/blender/blenloader/intern/runtime.c +++ b/source/blender/blenloader/intern/runtime.c @@ -73,9 +73,9 @@ int BLO_is_a_runtime(const char *path) if (fd == -1) goto cleanup; - + lseek(fd, -12, SEEK_END); - + datastart = handle_read_msb_int(fd); if (datastart == -1) @@ -107,7 +107,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports) BKE_reportf(reports, RPT_ERROR, "Unable to open '%s': %s", path, strerror(errno)); goto cleanup; } - + actualsize = BLI_file_descriptor_size(fd); lseek(fd, -12, SEEK_END); @@ -132,11 +132,11 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports) bfd = blo_read_blendafterruntime(fd, path, actualsize - datastart, reports); fd = -1; // file was closed in blo_read_blendafterruntime() } - + cleanup: if (fd != -1) close(fd); - + return bfd; } diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index e1ae267ea11..614a3be559b 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -64,7 +64,7 @@ void BLO_memfile_free(MemFile *memfile) { MemFileChunk *chunk; - + while ((chunk = BLI_pophead(&memfile->chunks))) { if (chunk->is_identical == false) { MEM_freeN((void *)chunk->buf); @@ -79,7 +79,7 @@ void BLO_memfile_free(MemFile *memfile) void BLO_memfile_merge(MemFile *first, MemFile *second) { MemFileChunk *fc, *sc; - + fc = first->chunks.first; sc = second->chunks.first; while (fc || sc) { @@ -92,7 +92,7 @@ void BLO_memfile_merge(MemFile *first, MemFile *second) if (fc) fc = fc->next; if (sc) sc = sc->next; } - + BLO_memfile_free(first); } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index d51289bee43..973591c49da 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -582,7 +582,7 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup, { // bNodeSocketType *stype = ntreeGetSocketType(type); bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket"); - + BLI_strncpy(gsock->name, name, sizeof(gsock->name)); gsock->type = type; @@ -592,14 +592,14 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup, /* assign new unique index */ gsock->own_index = ngroup->cur_index++; gsock->limit = (in_out==SOCK_IN ? 0xFFF : 1); - + // if (stype->value_structsize > 0) // gsock->default_value = MEM_callocN(stype->value_structsize, "default socket value"); - + BLI_addtail(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock); - + ngroup->update |= (in_out==SOCK_IN ? NTREE_UPDATE_GROUP_IN : NTREE_UPDATE_GROUP_OUT); - + return gsock; } @@ -615,10 +615,10 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock) bNodeSocketValueFloat *valfloat; bNodeSocketValueVector *valvector; bNodeSocketValueRGBA *valrgba; - + if (sock->default_value) return; - + switch (sock->type) { case SOCK_FLOAT: valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat), "default socket value"); @@ -1934,13 +1934,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) bNode *node; bNodeSocket *sock, *gsock; bNodeLink *link; - + /* node sockets are not exposed automatically any more, * this mimics the old behavior by adding all unlinked sockets to groups. */ for (ntree=bmain->nodetree.first; ntree; ntree=ntree->id.next) { /* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */ - + /* first make sure the own_index for new sockets is valid */ for (node=ntree->nodes.first; node; node=node->next) { for (sock = node->inputs.first; sock; sock = sock->next) @@ -1950,17 +1950,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (sock->own_index >= ntree->cur_index) ntree->cur_index = sock->own_index+1; } - + /* add ntree->inputs/ntree->outputs sockets for all unlinked sockets in the group tree. */ for (node=ntree->nodes.first; node; node=node->next) { for (sock = node->inputs.first; sock; sock = sock->next) { if (!sock->link && !nodeSocketIsHidden(sock)) { - + gsock = do_versions_node_group_add_socket_2_56_2(ntree, sock->name, sock->type, SOCK_IN); - + /* initialize the default socket value */ copy_v4_v4(gsock->ns.vec, sock->ns.vec); - + /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer, * have to create these directly here. These links are updated again in subsequent do_version! */ @@ -1971,17 +1971,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) link->tonode = node; link->tosock = sock; ntree->update |= NTREE_UPDATE_LINKS; - + sock->link = link; } } for (sock = node->outputs.first; sock; sock = sock->next) { if (nodeCountSocketLinks(ntree, sock)==0 && !nodeSocketIsHidden(sock)) { gsock = do_versions_node_group_add_socket_2_56_2(ntree, sock->name, sock->type, SOCK_OUT); - + /* initialize the default socket value */ copy_v4_v4(gsock->ns.vec, sock->ns.vec); - + /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer, * have to create these directly here. These links are updated again in subsequent do_version! */ @@ -1992,12 +1992,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) link->tonode = NULL; link->tosock = gsock; ntree->update |= NTREE_UPDATE_LINKS; - + gsock->link = link; } } } - + /* XXX The external group node sockets needs to adjust their own_index to point at * associated ntree inputs/outputs internal sockets. However, this can only happen * after lib-linking (needs access to internal node group tree)! @@ -2203,19 +2203,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) FOREACH_NODETREE(bmain, ntree, id) { bNode *node; bNodeSocket *sock; - + for (node=ntree->nodes.first; node; node=node->next) { for (sock = node->inputs.first; sock; sock = sock->next) do_versions_socket_default_value_259(sock); for (sock = node->outputs.first; sock; sock = sock->next) do_versions_socket_default_value_259(sock); } - + for (sock = ntree->inputs.first; sock; sock = sock->next) do_versions_socket_default_value_259(sock); for (sock = ntree->outputs.first; sock; sock = sock->next) do_versions_socket_default_value_259(sock); - + ntree->update |= NTREE_UPDATE; } FOREACH_NODETREE_END diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 2cded68f7ec..c405e385e9f 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -2438,10 +2438,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } - + if (!MAIN_VERSION_ATLEAST(bmain, 269, 9)) { Object *ob; - + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 7f5646eddc2..7a106611e64 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -171,7 +171,7 @@ static void do_version_constraints_stretch_to_limits(ListBase *lb) static void do_version_action_editor_properties_region(ListBase *regionbase) { ARegion *ar; - + for (ar = regionbase->first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_UI) { /* already exists */ @@ -180,13 +180,13 @@ static void do_version_action_editor_properties_region(ListBase *regionbase) else if (ar->regiontype == RGN_TYPE_WINDOW) { /* add new region here */ ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action"); - + BLI_insertlinkbefore(regionbase, ar, arnew); - + arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; arnew->flag = RGN_FLAG_HIDDEN; - + return; } } @@ -197,7 +197,7 @@ static void do_version_bones_super_bbone(ListBase *lb) for (Bone *bone = lb->first; bone; bone = bone->next) { bone->scaleIn = 1.0f; bone->scaleOut = 1.0f; - + do_version_bones_super_bbone(&bone->childbase); } } @@ -289,7 +289,7 @@ static void do_versions_compositor_render_passes(bNodeTree *ntree) static char *replace_bbone_easing_rnapath(char *old_path) { char *new_path = NULL; - + /* NOTE: This will break paths for any bones/custom-properties * which happen be named after the bbone property id's */ @@ -297,7 +297,7 @@ static char *replace_bbone_easing_rnapath(char *old_path) new_path = BLI_str_replaceN(old_path, "bbone_in", "bbone_easein"); else if (strstr(old_path, "bbone_out")) new_path = BLI_str_replaceN(old_path, "bbone_out", "bbone_easeout"); - + if (new_path) { MEM_freeN(old_path); return new_path; @@ -313,7 +313,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void if (fcu->rna_path) { fcu->rna_path = replace_bbone_easing_rnapath(fcu->rna_path); } - + /* Driver -> Driver Vars (for bbone_in/out) */ if (fcu->driver) { for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) { @@ -326,13 +326,13 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void DRIVER_TARGETS_LOOPER_END; } } - + /* FModifiers -> Stepped (for frame_start/end) */ if (fcu->modifiers.first) { for (FModifier *fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { if (fcm->type == FMODIFIER_TYPE_STEPPED) { FMod_Stepped *data = fcm->data; - + /* Modifier doesn't work if the modifier's copy of start/end frame are both 0 * as those were only getting written to the fcm->data copy (T52009) */ @@ -656,7 +656,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } - + if (!MAIN_VERSION_ATLEAST(bmain, 273, 3)) { ParticleSettings *part; for (part = bmain->particle.first; part; part = part->id.next) { @@ -1040,63 +1040,63 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 276, 4)) { for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; - + if (ts->gp_sculpt.brush[0].size == 0) { GP_BrushEdit_Settings *gset = &ts->gp_sculpt; GP_EditBrush_Data *brush; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH]; brush->size = 25; brush->strength = 0.3f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS]; brush->size = 25; brush->strength = 0.5f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB]; brush->size = 50; brush->strength = 0.3f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH]; brush->size = 25; brush->strength = 0.3f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST]; brush->size = 50; brush->strength = 0.3f; // XXX? brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH]; brush->size = 50; brush->strength = 0.5f; // XXX? brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMIZE]; brush->size = 25; brush->strength = 0.5f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_CLONE]; brush->size = 50; brush->strength = 1.0f; } - + if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "gpencil_v3d_align")) { #if 0 /* XXX: Cannot do this, as we get random crashes... */ if (scene->gpd) { bGPdata *gpd = scene->gpd; - + /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */ ts->gpencil_v3d_align = 0; - + if (gpd->flag & GP_DATA_VIEWALIGN) ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE; if (gpd->flag & GP_DATA_DEPTH_VIEW) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW; if (gpd->flag & GP_DATA_DEPTH_STROKE) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE; - + if (gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE_ENDPOINTS; } @@ -1105,17 +1105,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE; } #endif - + ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE; ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE; ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE; ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE; } } - + for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) { bool enabled = false; - + /* Ensure that the datablock's onionskinning toggle flag * stays in sync with the status of the actual layers */ @@ -1124,7 +1124,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) enabled = true; } } - + if (enabled) gpd->flag |= GP_DATA_SHOW_ONIONSKINS; else @@ -1239,7 +1239,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) do_version_action_editor_properties_region(&saction->regionbase); } } - + /* active spacedata info must be handled too... */ if (sa->spacetype == SPACE_ACTION) { do_version_action_editor_properties_region(&sa->regionbase); @@ -1261,7 +1261,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) /* see do_version_bones_super_bbone()... */ pchan->scaleIn = 1.0f; pchan->scaleOut = 1.0f; - + /* also make sure some legacy (unused for over a decade) flags are unset, * so that we can reuse them for stuff that matters now... * (i.e. POSE_IK_MAT, (unknown/unused x 4), POSE_HAS_IK) @@ -1381,19 +1381,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) /* set color attributes */ copy_v4_v4(palcolor->color, gpl->color); copy_v4_v4(palcolor->fill, gpl->fill); - + if (gpl->flag & GP_LAYER_HIDE) palcolor->flag |= PC_COLOR_HIDE; if (gpl->flag & GP_LAYER_LOCKED) palcolor->flag |= PC_COLOR_LOCKED; if (gpl->flag & GP_LAYER_ONIONSKIN) palcolor->flag |= PC_COLOR_ONIONSKIN; if (gpl->flag & GP_LAYER_VOLUMETRIC) palcolor->flag |= PC_COLOR_VOLUMETRIC; if (gpl->flag & GP_LAYER_HQ_FILL) palcolor->flag |= PC_COLOR_HQ_FILL; - + /* set layer opacity to 1 */ gpl->opacity = 1.0f; - + /* set tint color */ ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f); - + /* flush relevant layer-settings to strokes */ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { @@ -1402,7 +1402,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) gps->palcolor = NULL; gps->flag |= GP_STROKE_RECALC_COLOR; gps->thickness = gpl->thickness; - + /* set alpha strength to 1 */ for (int i = 0; i < gps->totpoints; i++) { gps->points[i].strength = 1.0f; @@ -1410,7 +1410,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } - + /* set thickness to 0 (now it is a factor to override stroke thickness) */ gpl->thickness = 0.0f; } @@ -1755,7 +1755,7 @@ void do_versions_after_linking_270(Main *bmain) } } FOREACH_NODETREE_END } - + if (!MAIN_VERSION_ATLEAST(bmain, 279, 2)) { /* B-Bones (bbone_in/out -> bbone_easein/out) + Stepped FMod Frame Start/End fix */ /* if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "bbone_easein")) */ diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index cbd6988655d..a500c562e20 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -149,7 +149,7 @@ void BLO_update_defaults_startup_blend(Main *bmain) sculpt->flags |= SCULPT_DYNTOPO_COLLAPSE; sculpt->detail_size = 12; } - + if (ts->vpaint) { VPaint *vp = ts->vpaint; vp->radial_symm[0] = vp->radial_symm[1] = vp->radial_symm[2] = 1; @@ -163,17 +163,17 @@ void BLO_update_defaults_startup_blend(Main *bmain) if (ts->gp_sculpt.brush[0].size == 0) { GP_BrushEdit_Settings *gset = &ts->gp_sculpt; GP_EditBrush_Data *brush; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH]; brush->size = 25; brush->strength = 0.3f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS]; brush->size = 25; brush->strength = 0.5f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH]; brush->size = 25; brush->strength = 0.5f; @@ -183,28 +183,28 @@ void BLO_update_defaults_startup_blend(Main *bmain) brush->size = 50; brush->strength = 0.3f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH]; brush->size = 25; brush->strength = 0.3f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST]; brush->size = 50; brush->strength = 0.3f; // XXX? brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH]; brush->size = 50; brush->strength = 0.5f; // XXX? brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; - + brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMIZE]; brush->size = 25; brush->strength = 0.5f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; } - + ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE; ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE; ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE; @@ -219,7 +219,7 @@ void BLO_update_defaults_startup_blend(Main *bmain) } scene->r.ffcodecdata.audio_mixrate = 48000; - + /* set av sync by default */ scene->audio.flag |= AUDIO_SYNC; scene->flag &= ~SCE_FRAME_DROP; |