Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/CMakeLists.txt14
-rw-r--r--source/blender/blenloader/intern/readblenentry.c45
-rw-r--r--source/blender/blenloader/intern/readfile.c1478
-rw-r--r--source/blender/blenloader/intern/versioning_250.c29
-rw-r--r--source/blender/blenloader/intern/versioning_260.c29
-rw-r--r--source/blender/blenloader/intern/versioning_270.c29
-rw-r--r--source/blender/blenloader/intern/versioning_280.c66
-rw-r--r--source/blender/blenloader/intern/versioning_290.c107
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c2
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c24
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c17
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c17
-rw-r--r--source/blender/blenloader/intern/writefile.c495
-rw-r--r--source/blender/blenloader/tests/blendfile_load_test.cc31
-rw-r--r--source/blender/blenloader/tests/blendfile_loading_base_test.cc162
-rw-r--r--source/blender/blenloader/tests/blendfile_loading_base_test.h64
16 files changed, 958 insertions, 1651 deletions
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 7eab0651d97..f5c7223a37c 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -98,3 +98,17 @@ blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# needed so writefile.c can use dna_type_offsets.h
add_dependencies(bf_blenloader bf_dna)
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/blendfile_load_test.cc
+ tests/blendfile_loading_base_test.cc
+ )
+ set(TEST_INC
+ )
+ set(TEST_LIB
+ bf_blenloader
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_blenloader_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+endif()
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index cb2094d050f..888863dda06 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -102,28 +102,27 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
if (bhead->code == ENDB) {
break;
}
- else {
- 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;
- buf[3] = (bhead->code >> 0) & 0xFF;
-
- buf[0] = buf[0] ? buf[0] : ' ';
- 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)));
- }
+
+ 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;
+ buf[3] = (bhead->code >> 0) & 0xFF;
+
+ buf[0] = buf[0] ? buf[0] : ' ';
+ 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)));
}
fprintf(fp, "]\n");
}
@@ -268,7 +267,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
if (bhead->code == ENDB) {
break;
}
- else if (BKE_idtype_idcode_is_valid(bhead->code)) {
+ if (BKE_idtype_idcode_is_valid(bhead->code)) {
if (BKE_idtype_idcode_is_linkable(bhead->code)) {
const char *str = BKE_idtype_idcode_to_name(bhead->code);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 134e23d36e8..c24db724222 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -121,6 +121,7 @@
#include "BKE_curve.h"
#include "BKE_curveprofile.h"
#include "BKE_effect.h"
+#include "BKE_fcurve.h"
#include "BKE_fcurve_driver.h"
#include "BKE_fluid.h"
#include "BKE_global.h" // for G
@@ -140,6 +141,7 @@
#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
+#include "BKE_nla.h"
#include "BKE_node.h" // for tree type defines
#include "BKE_object.h"
#include "BKE_paint.h"
@@ -263,8 +265,6 @@ static BHead *find_bhead_from_idname(FileData *fd, const char *idname);
#ifdef USE_COLLECTION_COMPAT_28
static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc);
#endif
-static void direct_link_animdata(BlendDataReader *reader, AnimData *adt);
-static void lib_link_animdata(BlendLibReader *reader, ID *id, AnimData *adt);
typedef struct BHeadN {
struct BHeadN *next, *prev;
@@ -373,7 +373,7 @@ static void oldnewmap_insert_or_replace(OldNewMap *onm, OldNew entry)
onm->nentries++;
break;
}
- else if (onm->entries[index].oldp == entry.oldp) {
+ if (onm->entries[index].oldp == entry.oldp) {
onm->entries[index] = entry;
break;
}
@@ -1112,9 +1112,8 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
return true;
}
- else {
- return false;
- }
+
+ return false;
}
else if (bhead->code == ENDB) {
break;
@@ -1135,7 +1134,7 @@ static int *read_file_thumbnail(FileData *fd)
const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
int *data = (int *)(bhead + 1);
- if (bhead->len < (2 * sizeof(int))) {
+ if (bhead->len < (sizeof(int[2]))) {
break;
}
@@ -1156,7 +1155,7 @@ static int *read_file_thumbnail(FileData *fd)
blend_thumb = data;
break;
}
- else if (bhead->code != REND) {
+ if (bhead->code != REND) {
/* Thumbnail is stored in TEST immediately after first REND... */
break;
}
@@ -1187,7 +1186,7 @@ static int fd_read_data_from_file(FileData *filedata,
filedata->file_offset += readsize;
}
- return (readsize);
+ return readsize;
}
static off64_t fd_seek_data_from_file(FileData *filedata, off64_t offset, int whence)
@@ -1212,7 +1211,7 @@ static int fd_read_gzip_from_file(FileData *filedata,
filedata->file_offset += readsize;
}
- return (readsize);
+ return readsize;
}
/* Memory reading. */
@@ -1228,7 +1227,7 @@ static int fd_read_from_memory(FileData *filedata,
memcpy(buffer, filedata->buffer + filedata->file_offset, readsize);
filedata->file_offset += readsize;
- return (readsize);
+ return readsize;
}
/* MemFile reading. */
@@ -1373,9 +1372,8 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
errno ? strerror(errno) : TIP_("insufficient content"));
return NULL;
}
- else {
- BLI_lseek(file, 0, SEEK_SET);
- }
+
+ BLI_lseek(file, 0, SEEK_SET);
/* Regular file. */
if (memcmp(header, "BLENDER", sizeof(header)) == 0) {
@@ -1397,12 +1395,11 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
errno ? strerror(errno) : TIP_("unknown error reading file"));
return NULL;
}
- else {
- /* 'seek_fn' is too slow for gzip, don't set it. */
- read_fn = fd_read_gzip_from_file;
- /* Caller must close. */
- file = -1;
- }
+
+ /* 'seek_fn' is too slow for gzip, don't set it. */
+ read_fn = fd_read_gzip_from_file;
+ /* Caller must close. */
+ file = -1;
}
if (read_fn == NULL) {
@@ -1487,14 +1484,14 @@ static int fd_read_gzip_from_memory(FileData *filedata,
if (err == Z_STREAM_END) {
return 0;
}
- else if (err != Z_OK) {
+ if (err != Z_OK) {
printf("fd_read_gzip_from_memory: zlib error\n");
return 0;
}
filedata->file_offset += size;
- return (size);
+ return size;
}
static int fd_read_gzip_from_memory_init(FileData *fd)
@@ -1521,28 +1518,27 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *rep
BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
return NULL;
}
- else {
- FileData *fd = filedata_new();
- const char *cp = mem;
- fd->buffer = mem;
- fd->buffersize = memsize;
+ FileData *fd = filedata_new();
+ const char *cp = mem;
- /* test if gzip */
- if (cp[0] == 0x1f && cp[1] == 0x8b) {
- if (0 == fd_read_gzip_from_memory_init(fd)) {
- blo_filedata_free(fd);
- return NULL;
- }
- }
- else {
- fd->read = fd_read_from_memory;
+ 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)) {
+ blo_filedata_free(fd);
+ return NULL;
}
+ }
+ else {
+ fd->read = fd_read_from_memory;
+ }
- fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
+ fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
- return blo_decode_and_check(fd, reports);
- }
+ return blo_decode_and_check(fd, reports);
}
FileData *blo_filedata_from_memfile(MemFile *memfile,
@@ -1553,16 +1549,15 @@ FileData *blo_filedata_from_memfile(MemFile *memfile,
BKE_report(reports, RPT_WARNING, "Unable to open blend <memory>");
return NULL;
}
- else {
- FileData *fd = filedata_new();
- fd->memfile = memfile;
- fd->undo_direction = params->undo_direction;
- fd->read = fd_read_from_memfile;
- fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
+ FileData *fd = filedata_new();
+ fd->memfile = memfile;
+ fd->undo_direction = params->undo_direction;
- return blo_decode_and_check(fd, reports);
- }
+ fd->read = fd_read_from_memfile;
+ fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
+
+ return blo_decode_and_check(fd, reports);
}
void blo_filedata_free(FileData *fd)
@@ -1695,7 +1690,7 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
break;
}
- else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
+ if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
break;
}
@@ -1831,9 +1826,7 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
void *old,
void *new)
{
- Main *mainptr;
-
- for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) {
+ LISTBASE_FOREACH (Main *, mainptr, mainlist) {
FileData *fd;
if (mainptr->curlib) {
@@ -1857,9 +1850,7 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
*/
void blo_clear_proxy_pointers_from_lib(Main *oldmain)
{
- Object *ob = oldmain->objects.first;
-
- for (; ob; ob = ob->id.next) {
+ LISTBASE_FOREACH (Object *, ob, &oldmain->objects) {
if (ob->id.lib != NULL && ob->proxy_from != NULL && ob->proxy_from->id.lib == NULL) {
ob->proxy_from = NULL;
}
@@ -1877,47 +1868,39 @@ static void insert_packedmap(FileData *fd, PackedFile *pf)
void blo_make_packed_pointer_map(FileData *fd, Main *oldmain)
{
- Image *ima;
- VFont *vfont;
- bSound *sound;
- Volume *volume;
- Library *lib;
-
fd->packedmap = oldnewmap_new();
- for (ima = oldmain->images.first; ima; ima = ima->id.next) {
- ImagePackedFile *imapf;
-
+ LISTBASE_FOREACH (Image *, ima, &oldmain->images) {
if (ima->packedfile) {
insert_packedmap(fd, ima->packedfile);
}
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
if (imapf->packedfile) {
insert_packedmap(fd, imapf->packedfile);
}
}
}
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next) {
+ LISTBASE_FOREACH (VFont *, vfont, &oldmain->fonts) {
if (vfont->packedfile) {
insert_packedmap(fd, vfont->packedfile);
}
}
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next) {
+ LISTBASE_FOREACH (bSound *, sound, &oldmain->sounds) {
if (sound->packedfile) {
insert_packedmap(fd, sound->packedfile);
}
}
- for (volume = oldmain->volumes.first; volume; volume = volume->id.next) {
+ LISTBASE_FOREACH (Volume *, volume, &oldmain->volumes) {
if (volume->packedfile) {
insert_packedmap(fd, volume->packedfile);
}
}
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next) {
+ LISTBASE_FOREACH (Library *, lib, &oldmain->libraries) {
if (lib->packedfile) {
insert_packedmap(fd, lib->packedfile);
}
@@ -1928,44 +1911,36 @@ void blo_make_packed_pointer_map(FileData *fd, Main *oldmain)
/* this works because freeing old main only happens after this call */
void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
{
- Image *ima;
- VFont *vfont;
- bSound *sound;
- Volume *volume;
- 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++) {
+ for (int i = 0; i < fd->packedmap->nentries; i++, entry++) {
if (entry->nr > 0) {
entry->newp = NULL;
}
}
- for (ima = oldmain->images.first; ima; ima = ima->id.next) {
- ImagePackedFile *imapf;
-
+ LISTBASE_FOREACH (Image *, ima, &oldmain->images) {
ima->packedfile = newpackedadr(fd, ima->packedfile);
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
imapf->packedfile = newpackedadr(fd, imapf->packedfile);
}
}
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next) {
+ LISTBASE_FOREACH (VFont *, vfont, &oldmain->fonts) {
vfont->packedfile = newpackedadr(fd, vfont->packedfile);
}
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next) {
+ LISTBASE_FOREACH (bSound *, sound, &oldmain->sounds) {
sound->packedfile = newpackedadr(fd, sound->packedfile);
}
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next) {
+ LISTBASE_FOREACH (Library *, lib, &oldmain->libraries) {
lib->packedfile = newpackedadr(fd, lib->packedfile);
}
- for (volume = oldmain->volumes.first; volume; volume = volume->id.next) {
+ LISTBASE_FOREACH (Volume *, volume, &oldmain->volumes) {
volume->packedfile = newpackedadr(fd, volume->packedfile);
}
}
@@ -1973,14 +1948,12 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
/* undo file support: add all library pointers in lookup */
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) {
+ LISTBASE_FOREACH (Main *, ptr, old_mainlist) {
int i = set_listbasepointers(ptr, lbarray);
while (i--) {
- ID *id;
- for (id = lbarray[i]->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lbarray[i]) {
oldnewmap_insert(fd->libmap, id, id, GS(id->name));
}
}
@@ -2008,7 +1981,7 @@ typedef struct BLOCacheStorage {
static void blo_cache_storage_entry_register(ID *id,
const IDCacheKey *key,
void **UNUSED(cache_p),
- eIDTypeInfoCacheCallbackFlags UNUSED(flags),
+ uint UNUSED(flags),
void *cache_storage_v)
{
BLI_assert(key->id_session_uuid == id->session_uuid);
@@ -2023,11 +1996,8 @@ static void blo_cache_storage_entry_register(ID *id,
}
/** Restore a cache data entry from old ID into new one, when reading some undo memfile. */
-static void blo_cache_storage_entry_restore_in_new(ID *UNUSED(id),
- const IDCacheKey *key,
- void **cache_p,
- eIDTypeInfoCacheCallbackFlags flags,
- void *cache_storage_v)
+static void blo_cache_storage_entry_restore_in_new(
+ ID *UNUSED(id), const IDCacheKey *key, void **cache_p, uint flags, void *cache_storage_v)
{
BLOCacheStorage *cache_storage = cache_storage_v;
@@ -2054,7 +2024,7 @@ static void blo_cache_storage_entry_restore_in_new(ID *UNUSED(id),
static void blo_cache_storage_entry_clear_in_old(ID *UNUSED(id),
const IDCacheKey *key,
void **cache_p,
- eIDTypeInfoCacheCallbackFlags UNUSED(flags),
+ uint UNUSED(flags),
void *cache_storage_v)
{
BLOCacheStorage *cache_storage = cache_storage_v;
@@ -2274,185 +2244,6 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Read ID Properties
- * \{ */
-
-static void IDP_DirectLinkProperty(IDProperty *prop, BlendDataReader *reader);
-static void IDP_LibLinkProperty(IDProperty *prop, BlendLibReader *reader);
-
-static void IDP_DirectLinkIDPArray(IDProperty *prop, BlendDataReader *reader)
-{
- IDProperty *array;
- int i;
-
- /* since we didn't save the extra buffer, set totallen to len */
- prop->totallen = prop->len;
- BLO_read_data_address(reader, &prop->data.pointer);
-
- array = (IDProperty *)prop->data.pointer;
-
- /* note!, idp-arrays didn't exist in 2.4x, so the pointer will be cleared
- * there's 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], reader);
- }
-}
-
-static void IDP_DirectLinkArray(IDProperty *prop, BlendDataReader *reader)
-{
- IDProperty **array;
- int i;
-
- /* since we didn't save the extra buffer, set totallen to len */
- prop->totallen = prop->len;
-
- if (prop->subtype == IDP_GROUP) {
- BLO_read_pointer_array(reader, &prop->data.pointer);
- array = prop->data.pointer;
-
- for (i = 0; i < prop->len; i++) {
- IDP_DirectLinkProperty(array[i], reader);
- }
- }
- else if (prop->subtype == IDP_DOUBLE) {
- BLO_read_double_array(reader, prop->len, (double **)&prop->data.pointer);
- }
- else {
- /* also used for floats */
- BLO_read_int32_array(reader, prop->len, (int **)&prop->data.pointer);
- }
-}
-
-static void IDP_DirectLinkString(IDProperty *prop, BlendDataReader *reader)
-{
- /*since we didn't save the extra string buffer, set totallen to len.*/
- prop->totallen = prop->len;
- BLO_read_data_address(reader, &prop->data.pointer);
-}
-
-static void IDP_DirectLinkGroup(IDProperty *prop, BlendDataReader *reader)
-{
- ListBase *lb = &prop->data.group;
- IDProperty *loop;
-
- BLO_read_list(reader, lb);
-
- /*Link child id properties now*/
- for (loop = prop->data.group.first; loop; loop = loop->next) {
- IDP_DirectLinkProperty(loop, reader);
- }
-}
-
-static void IDP_DirectLinkProperty(IDProperty *prop, BlendDataReader *reader)
-{
- switch (prop->type) {
- case IDP_GROUP:
- IDP_DirectLinkGroup(prop, reader);
- break;
- case IDP_STRING:
- IDP_DirectLinkString(prop, reader);
- break;
- case IDP_ARRAY:
- IDP_DirectLinkArray(prop, reader);
- break;
- case IDP_IDPARRAY:
- IDP_DirectLinkIDPArray(prop, reader);
- break;
- case IDP_DOUBLE:
- /* Workaround for doubles.
- * They are stored in the same field as `int val, val2` in the IDPropertyData struct,
- * they have to deal with endianness specifically.
- *
- * In theory, val and val2 would've already been swapped
- * if switch_endian is true, so we have to first unswap
- * them then re-swap them as a single 64-bit entity. */
- if (BLO_read_requires_endian_switch(reader)) {
- BLI_endian_switch_int32(&prop->data.val);
- BLI_endian_switch_int32(&prop->data.val2);
- BLI_endian_switch_int64((int64_t *)&prop->data.val);
- }
- break;
- case IDP_INT:
- case IDP_FLOAT:
- case IDP_ID:
- break; /* Nothing special to do here. */
- default:
- /* Unknown IDP type, nuke it (we cannot handle unknown types everywhere in code,
- * IDP are way too polymorphic to do it safely. */
- printf(
- "%s: found unknown IDProperty type %d, reset to Integer one !\n", __func__, prop->type);
- /* Note: we do not attempt to free unknown prop, we have no way to know how to do that! */
- prop->type = IDP_INT;
- prop->subtype = 0;
- IDP_Int(prop) = 0;
- }
-}
-
-#define IDP_DirectLinkGroup_OrFree(prop, reader) \
- _IDP_DirectLinkGroup_OrFree(prop, reader, __func__)
-
-static void _IDP_DirectLinkGroup_OrFree(IDProperty **prop,
- BlendDataReader *reader,
- const char *caller_func_id)
-{
- if (*prop) {
- if ((*prop)->type == IDP_GROUP) {
- IDP_DirectLinkGroup(*prop, reader);
- }
- else {
- /* corrupt file! */
- printf("%s: found non group data, freeing type %d!\n", caller_func_id, (*prop)->type);
- /* don't risk id, data's likely corrupt. */
- // IDP_FreePropertyContent(*prop);
- *prop = NULL;
- }
- }
-}
-
-static void IDP_LibLinkProperty(IDProperty *prop, BlendLibReader *reader)
-{
- if (!prop) {
- return;
- }
-
- switch (prop->type) {
- case IDP_ID: /* PointerProperty */
- {
- void *newaddr = BLO_read_get_new_id_address(reader, NULL, IDP_Id(prop));
- if (IDP_Id(prop) && !newaddr && G.debug) {
- printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
- }
- prop->data.pointer = newaddr;
- break;
- }
- case IDP_IDPARRAY: /* CollectionProperty */
- {
- IDProperty *idp_array = IDP_IDPArray(prop);
- for (int i = 0; i < prop->len; i++) {
- IDP_LibLinkProperty(&(idp_array[i]), reader);
- }
- break;
- }
- case IDP_GROUP: /* PointerProperty */
- {
- LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
- IDP_LibLinkProperty(loop, reader);
- }
- break;
- }
- default:
- break; /* Nothing to do for other IDProps. */
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Read Image Preview
* \{ */
@@ -2461,8 +2252,7 @@ static PreviewImage *direct_link_preview_image(BlendDataReader *reader, PreviewI
PreviewImage *prv = BLO_read_get_new_data_address(reader, old_prv);
if (prv) {
- int i;
- for (i = 0; i < NUM_ICON_SIZES; i++) {
+ for (int i = 0; i < NUM_ICON_SIZES; i++) {
if (prv->rect[i]) {
BLO_read_data_address(reader, &prv->rect[i]);
}
@@ -2508,11 +2298,11 @@ static void lib_link_id(BlendLibReader *reader, ID *id)
{
/* Note: WM IDProperties are never written to file, hence they should always be NULL here. */
BLI_assert((GS(id->name) != ID_WM) || id->properties == NULL);
- IDP_LibLinkProperty(id->properties, reader);
+ IDP_BlendReadLib(reader, id->properties);
AnimData *adt = BKE_animdata_from_id(id);
if (adt != NULL) {
- lib_link_animdata(reader, id, adt);
+ BKE_animdata_blend_read_lib(reader, id, adt);
}
if (id->override_library) {
@@ -2667,7 +2457,7 @@ static void direct_link_id_common(
if (id->properties) {
BLO_read_data_address(reader, &id->properties);
/* this case means the data was written incorrectly, it should not happen */
- IDP_DirectLinkGroup_OrFree(&id->properties, reader);
+ IDP_BlendDataRead(reader, &id->properties);
}
id->flag &= ~LIB_INDIRECT_WEAK_LINK;
@@ -2876,11 +2666,9 @@ static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo)
// XXX deprecated - old animation system
static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
{
- IpoCurve *icu;
-
BLO_read_list(reader, &(ipo->curve));
- for (icu = ipo->curve.first; icu; icu = icu->next) {
+ LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
BLO_read_data_address(reader, &icu->bezt);
BLO_read_data_address(reader, &icu->bp);
BLO_read_data_address(reader, &icu->driver);
@@ -2890,14 +2678,11 @@ static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
// XXX deprecated - old animation system
static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist)
{
- bActionStrip *strip;
- bActionModifier *amod;
-
- for (strip = striplist->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (bActionStrip *, strip, striplist) {
BLO_read_id_address(reader, id->lib, &strip->object);
BLO_read_id_address(reader, id->lib, &strip->act);
BLO_read_id_address(reader, id->lib, &strip->ipo);
- for (amod = strip->modifiers.first; amod; amod = amod->next) {
+ LISTBASE_FOREACH (bActionModifier *, amod, &strip->modifiers) {
BLO_read_id_address(reader, id->lib, &amod->ob);
}
}
@@ -2906,11 +2691,9 @@ static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *stripli
// XXX deprecated - old animation system
static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
{
- bActionStrip *strip;
-
BLO_read_list(reader, strips);
- for (strip = strips->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (bActionStrip *, strip, strips) {
BLO_read_list(reader, &strip->modifiers);
}
}
@@ -2918,9 +2701,7 @@ static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
// XXX deprecated - old animation system
static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
{
- bConstraintChannel *chan;
-
- for (chan = chanbase->first; chan; chan = chan->next) {
+ LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
BLO_read_id_address(reader, id->lib, &chan->ipo);
}
}
@@ -2931,153 +2712,6 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas
/** \name Read ID: Action
* \{ */
-static void lib_link_fmodifiers(BlendLibReader *reader, ID *id, ListBase *list)
-{
- FModifier *fcm;
-
- for (fcm = list->first; fcm; fcm = fcm->next) {
- /* data for specific modifiers */
- switch (fcm->type) {
- case FMODIFIER_TYPE_PYTHON: {
- FMod_Python *data = (FMod_Python *)fcm->data;
- BLO_read_id_address(reader, id->lib, &data->script);
-
- break;
- }
- }
- }
-}
-
-static void lib_link_fcurves(BlendLibReader *reader, 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_BEGIN (dvar) {
- /* only relink if still used */
- if (tarIndex < dvar->num_targets) {
- BLO_read_id_address(reader, id->lib, &dtar->id);
- }
- else {
- dtar->id = NULL;
- }
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
-
- /* modifiers */
- lib_link_fmodifiers(reader, id, &fcu->modifiers);
- }
-}
-
-/* NOTE: this assumes that link_list has already been called on the list */
-static void direct_link_fmodifiers(BlendDataReader *reader, ListBase *list, FCurve *curve)
-{
- FModifier *fcm;
-
- for (fcm = list->first; fcm; fcm = fcm->next) {
- /* relink general data */
- BLO_read_data_address(reader, &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;
- BLO_read_float_array(reader, data->arraysize, &data->coefficients);
- break;
- }
- case FMODIFIER_TYPE_ENVELOPE: {
- FMod_Envelope *data = (FMod_Envelope *)fcm->data;
-
- BLO_read_data_address(reader, &data->data);
-
- break;
- }
- case FMODIFIER_TYPE_PYTHON: {
- FMod_Python *data = (FMod_Python *)fcm->data;
-
- BLO_read_data_address(reader, &data->prop);
- IDP_DirectLinkGroup_OrFree(&data->prop, reader);
-
- break;
- }
- }
- }
-}
-
-/* NOTE: this assumes that link_list has already been called on the list */
-static void direct_link_fcurves(BlendDataReader *reader, 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 */
- BLO_read_data_address(reader, &fcu->bezt);
- BLO_read_data_address(reader, &fcu->fpt);
-
- /* rna path */
- BLO_read_data_address(reader, &fcu->rna_path);
-
- /* group */
- BLO_read_data_address(reader, &fcu->grp);
-
- /* 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 */
- BLO_read_data_address(reader, &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;
- driver->expr_simple = NULL;
-
- /* 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 */
- BLO_read_list(reader, &driver->variables);
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
- /* only relink the targets being used */
- if (tarIndex < dvar->num_targets) {
- BLO_read_data_address(reader, &dtar->rna_path);
- }
- else {
- dtar->rna_path = NULL;
- }
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
-
- /* modifiers */
- BLO_read_list(reader, &fcu->modifiers);
- direct_link_fmodifiers(reader, &fcu->modifiers, fcu);
- }
-}
-
static void lib_link_action(BlendLibReader *reader, bAction *act)
{
// XXX deprecated - old animation system <<<
@@ -3087,7 +2721,7 @@ static void lib_link_action(BlendLibReader *reader, bAction *act)
}
// >>> XXX deprecated - old animation system
- lib_link_fcurves(reader, &act->id, &act->curves);
+ BKE_fcurve_blend_read_lib(reader, &act->id, &act->curves);
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if (marker->camera) {
@@ -3098,102 +2732,34 @@ static void lib_link_action(BlendLibReader *reader, bAction *act)
static void direct_link_action(BlendDataReader *reader, bAction *act)
{
- bActionChannel *achan; // XXX deprecated - old animation system
- bActionGroup *agrp;
-
BLO_read_list(reader, &act->curves);
BLO_read_list(reader, &act->chanbase); // XXX deprecated - old animation system
BLO_read_list(reader, &act->groups);
BLO_read_list(reader, &act->markers);
// XXX deprecated - old animation system <<<
- for (achan = act->chanbase.first; achan; achan = achan->next) {
+ LISTBASE_FOREACH (bActionChannel *, achan, &act->chanbase) {
BLO_read_data_address(reader, &achan->grp);
BLO_read_list(reader, &achan->constraintChannels);
}
// >>> XXX deprecated - old animation system
- direct_link_fcurves(reader, &act->curves);
+ BKE_fcurve_blend_read_data(reader, &act->curves);
- for (agrp = act->groups.first; agrp; agrp = agrp->next) {
+ LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
BLO_read_data_address(reader, &agrp->channels.first);
BLO_read_data_address(reader, &agrp->channels.last);
}
}
-static void lib_link_nladata_strips(BlendLibReader *reader, ID *id, ListBase *list)
-{
- NlaStrip *strip;
-
- for (strip = list->first; strip; strip = strip->next) {
- /* check strip's children */
- lib_link_nladata_strips(reader, id, &strip->strips);
-
- /* check strip's F-Curves */
- lib_link_fcurves(reader, id, &strip->fcurves);
-
- /* reassign the counted-reference to action */
- BLO_read_id_address(reader, id->lib, &strip->act);
- }
-}
-
-static void lib_link_nladata(BlendLibReader *reader, 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(reader, id, &nlt->strips);
- }
-}
-
-/* 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(BlendDataReader *reader, ListBase *list)
-{
- NlaStrip *strip;
-
- for (strip = list->first; strip; strip = strip->next) {
- /* strip's child strips */
- BLO_read_list(reader, &strip->strips);
- direct_link_nladata_strips(reader, &strip->strips);
-
- /* strip's F-Curves */
- BLO_read_list(reader, &strip->fcurves);
- direct_link_fcurves(reader, &strip->fcurves);
-
- /* strip's F-Modifiers */
- BLO_read_list(reader, &strip->modifiers);
- direct_link_fmodifiers(reader, &strip->modifiers, NULL);
- }
-}
-
-/* NOTE: this assumes that BLO_read_list has already been called on the list */
-static void direct_link_nladata(BlendDataReader *reader, ListBase *list)
-{
- NlaTrack *nlt;
-
- for (nlt = list->first; nlt; nlt = nlt->next) {
- /* relink list of strips */
- BLO_read_list(reader, &nlt->strips);
-
- /* relink strip data */
- direct_link_nladata_strips(reader, &nlt->strips);
- }
-}
-
/* ------- */
static void lib_link_keyingsets(BlendLibReader *reader, 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) {
+ LISTBASE_FOREACH (KeyingSet *, ks, list) {
+ LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
BLO_read_id_address(reader, id->lib, &ksp->id);
}
}
@@ -3202,71 +2768,18 @@ static void lib_link_keyingsets(BlendLibReader *reader, ID *id, ListBase *list)
/* NOTE: this assumes that BLO_read_list has already been called on the list */
static void direct_link_keyingsets(BlendDataReader *reader, ListBase *list)
{
- KeyingSet *ks;
- KS_Path *ksp;
-
/* link KeyingSet data to KeyingSet again (non ID-libs) */
- for (ks = list->first; ks; ks = ks->next) {
+ LISTBASE_FOREACH (KeyingSet *, ks, list) {
/* paths */
BLO_read_list(reader, &ks->paths);
- for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
/* rna path */
BLO_read_data_address(reader, &ksp->rna_path);
}
}
}
-/* ------- */
-
-static void lib_link_animdata(BlendLibReader *reader, ID *id, AnimData *adt)
-{
- if (adt == NULL) {
- return;
- }
-
- /* link action data */
- BLO_read_id_address(reader, id->lib, &adt->action);
- BLO_read_id_address(reader, id->lib, &adt->tmpact);
-
- /* link drivers */
- lib_link_fcurves(reader, id, &adt->drivers);
-
- /* overrides don't have lib-link for now, so no need to do anything */
-
- /* link NLA-data */
- lib_link_nladata(reader, id, &adt->nla_tracks);
-}
-
-static void direct_link_animdata(BlendDataReader *reader, AnimData *adt)
-{
- /* NOTE: must have called newdataadr already before doing this... */
- if (adt == NULL) {
- return;
- }
-
- /* link drivers */
- BLO_read_list(reader, &adt->drivers);
- direct_link_fcurves(reader, &adt->drivers);
- adt->driver_array = NULL;
-
- /* link overrides */
- // TODO...
-
- /* link NLA-data */
- BLO_read_list(reader, &adt->nla_tracks);
- direct_link_nladata(reader, &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)
- */
- // TODO: it's not really nice that anyone should be able to save the file in this
- // state, but it's going to be too hard to enforce this single case...
- BLO_read_data_address(reader, &adt->act_track);
- BLO_read_data_address(reader, &adt->actstrip);
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -3286,7 +2799,7 @@ static void direct_link_cachefile(BlendDataReader *reader, CacheFile *cache_file
/* relink animdata */
BLO_read_data_address(reader, &cache_file->adt);
- direct_link_animdata(reader, cache_file->adt);
+ BKE_animdata_blend_read_data(reader, cache_file->adt);
}
/** \} */
@@ -3334,7 +2847,7 @@ static void direct_link_workspace(BlendDataReader *reader, WorkSpace *workspace,
/* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data
* when reading windows, so have to update windows after/when reading workspaces. */
- for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
+ LISTBASE_FOREACH (wmWindowManager *, wm, &main->wm) {
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
BLO_read_data_address(reader, &win->workspace_hook->act_layout);
}
@@ -3343,7 +2856,7 @@ static void direct_link_workspace(BlendDataReader *reader, WorkSpace *workspace,
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
tref->runtime = NULL;
BLO_read_data_address(reader, &tref->properties);
- IDP_DirectLinkGroup_OrFree(&tref->properties, reader);
+ IDP_BlendDataRead(reader, &tref->properties);
}
workspace->status_text = NULL;
@@ -3368,7 +2881,7 @@ static void lib_link_workspace_instance_hook(BlendLibReader *reader,
static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSocket *sock)
{
- IDP_LibLinkProperty(sock->prop, reader);
+ IDP_BlendReadLib(reader, sock->prop);
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
@@ -3415,7 +2928,7 @@ static void lib_link_ntree(BlendLibReader *reader, Library *lib, bNodeTree *ntre
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
- IDP_LibLinkProperty(node->prop, reader);
+ IDP_BlendReadLib(reader, node->prop);
BLO_read_id_address(reader, lib, &node->id);
@@ -3450,7 +2963,7 @@ static void lib_link_nodetree(BlendLibReader *reader, bNodeTree *ntree)
static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
{
BLO_read_data_address(reader, &sock->prop);
- IDP_DirectLinkGroup_OrFree(&sock->prop, reader);
+ IDP_BlendDataRead(reader, &sock->prop);
BLO_read_data_address(reader, &sock->link);
sock->typeinfo = NULL;
@@ -3463,9 +2976,6 @@ static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
{
/* note: writing and reading goes in sync, for speed */
- bNode *node;
- bNodeSocket *sock;
- bNodeLink *link;
ntree->init = 0; /* to set callbacks and force setting types */
ntree->is_updating = false;
@@ -3476,20 +2986,20 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
ntree->execdata = NULL;
BLO_read_data_address(reader, &ntree->adt);
- direct_link_animdata(reader, ntree->adt);
+ BKE_animdata_blend_read_data(reader, ntree->adt);
BLO_read_list(reader, &ntree->nodes);
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node->typeinfo = NULL;
BLO_read_list(reader, &node->inputs);
BLO_read_list(reader, &node->outputs);
BLO_read_data_address(reader, &node->prop);
- IDP_DirectLinkGroup_OrFree(&node->prop, reader);
+ IDP_BlendDataRead(reader, &node->prop);
BLO_read_list(reader, &node->internal_links);
- for (link = node->internal_links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &node->internal_links) {
BLO_read_data_address(reader, &link->fromnode);
BLO_read_data_address(reader, &link->fromsock);
BLO_read_data_address(reader, &link->tonode);
@@ -3568,14 +3078,14 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
BLO_read_list(reader, &ntree->links);
/* and we connect the rest */
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
BLO_read_data_address(reader, &node->parent);
node->lasty = 0;
- for (sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
direct_link_node_socket(reader, sock);
}
- for (sock = node->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
direct_link_node_socket(reader, sock);
}
}
@@ -3583,14 +3093,14 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
/* interface socket lists */
BLO_read_list(reader, &ntree->inputs);
BLO_read_list(reader, &ntree->outputs);
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) {
direct_link_node_socket(reader, sock);
}
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
direct_link_node_socket(reader, sock);
}
- for (link = ntree->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
BLO_read_data_address(reader, &link->fromnode);
BLO_read_data_address(reader, &link->tonode);
BLO_read_data_address(reader, &link->fromsock);
@@ -3627,10 +3137,9 @@ static void lib_link_constraint_cb(bConstraint *UNUSED(con),
static void lib_link_constraints(BlendLibReader *reader, ID *id, ListBase *conlist)
{
tConstraintLinkData cld;
- bConstraint *con;
/* legacy fixes */
- for (con = conlist->first; con; con = con->next) {
+ LISTBASE_FOREACH (bConstraint *, con, conlist) {
/* patch for error introduced by changing constraints (dunno how) */
/* if con->data type changes, dna cannot resolve the pointer! (ton) */
if (con->data == NULL) {
@@ -3654,10 +3163,8 @@ static void lib_link_constraints(BlendLibReader *reader, ID *id, ListBase *conli
static void direct_link_constraints(BlendDataReader *reader, ListBase *lb)
{
- bConstraint *con;
-
BLO_read_list(reader, lb);
- for (con = lb->first; con; con = con->next) {
+ LISTBASE_FOREACH (bConstraint *, con, lb) {
BLO_read_data_address(reader, &con->data);
switch (con->type) {
@@ -3667,7 +3174,7 @@ static void direct_link_constraints(BlendDataReader *reader, ListBase *lb)
BLO_read_list(reader, &data->targets);
BLO_read_data_address(reader, &data->prop);
- IDP_DirectLinkGroup_OrFree(&data->prop, reader);
+ IDP_BlendDataRead(reader, &data->prop);
break;
}
case CONSTRAINT_TYPE_ARMATURE: {
@@ -3746,7 +3253,7 @@ static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose)
pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
- IDP_LibLinkProperty(pchan->prop, reader);
+ IDP_BlendReadLib(reader, pchan->prop);
BLO_read_id_address(reader, arm->id.lib, &pchan->custom);
if (UNLIKELY(pchan->bone == NULL)) {
@@ -3768,7 +3275,7 @@ static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose)
static void lib_link_bones(BlendLibReader *reader, Bone *bone)
{
- IDP_LibLinkProperty(bone->prop, reader);
+ IDP_BlendReadLib(reader, bone->prop);
LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) {
lib_link_bones(reader, curbone);
@@ -3784,11 +3291,9 @@ static void lib_link_armature(BlendLibReader *reader, bArmature *arm)
static void direct_link_bones(BlendDataReader *reader, Bone *bone)
{
- Bone *child;
-
BLO_read_data_address(reader, &bone->parent);
BLO_read_data_address(reader, &bone->prop);
- IDP_DirectLinkGroup_OrFree(&bone->prop, reader);
+ IDP_BlendDataRead(reader, &bone->prop);
BLO_read_data_address(reader, &bone->bbone_next);
BLO_read_data_address(reader, &bone->bbone_prev);
@@ -3797,15 +3302,13 @@ static void direct_link_bones(BlendDataReader *reader, Bone *bone)
BLO_read_list(reader, &bone->childbase);
- for (child = bone->childbase.first; child; child = child->next) {
+ LISTBASE_FOREACH (Bone *, child, &bone->childbase) {
direct_link_bones(reader, child);
}
}
static void direct_link_armature(BlendDataReader *reader, bArmature *arm)
{
- Bone *bone;
-
BLO_read_list(reader, &arm->bonebase);
arm->bonehash = NULL;
arm->edbo = NULL;
@@ -3813,9 +3316,9 @@ static void direct_link_armature(BlendDataReader *reader, bArmature *arm)
arm->needs_flush_to_id = 0;
BLO_read_data_address(reader, &arm->adt);
- direct_link_animdata(reader, arm->adt);
+ BKE_animdata_blend_read_data(reader, arm->adt);
- for (bone = arm->bonebase.first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
direct_link_bones(reader, bone);
}
@@ -3847,7 +3350,7 @@ static void lib_link_camera(BlendLibReader *reader, Camera *ca)
static void direct_link_camera(BlendDataReader *reader, Camera *ca)
{
BLO_read_data_address(reader, &ca->adt);
- direct_link_animdata(reader, ca->adt);
+ BKE_animdata_blend_read_data(reader, ca->adt);
BLO_read_list(reader, &ca->bg_images);
@@ -3871,7 +3374,7 @@ static void lib_link_light(BlendLibReader *reader, Light *la)
static void direct_link_light(BlendDataReader *reader, Light *la)
{
BLO_read_data_address(reader, &la->adt);
- direct_link_animdata(reader, la->adt);
+ BKE_animdata_blend_read_data(reader, la->adt);
BLO_read_data_address(reader, &la->curfalloff);
if (la->curfalloff) {
@@ -3889,10 +3392,8 @@ static void direct_link_light(BlendDataReader *reader, Light *la)
void blo_do_versions_key_uidgen(Key *key)
{
- KeyBlock *block;
-
key->uidgen = 1;
- for (block = key->block.first; block; block = block->next) {
+ LISTBASE_FOREACH (KeyBlock *, block, &key->block) {
block->uid = key->uidgen++;
}
}
@@ -3907,13 +3408,10 @@ static void lib_link_key(BlendLibReader *reader, Key *key)
static void switch_endian_keyblock(Key *key, KeyBlock *kb)
{
- int elemsize, a, b;
- char *data;
-
- elemsize = key->elemsize;
- data = kb->data;
+ int elemsize = key->elemsize;
+ char *data = kb->data;
- for (a = 0; a < kb->totelem; a++) {
+ for (int a = 0; a < kb->totelem; a++) {
const char *cp = key->elemstr;
char *poin = data;
@@ -3921,11 +3419,12 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb)
switch (cp[1]) { /* cp[1] = type */
case IPO_FLOAT:
case IPO_BPOINT:
- case IPO_BEZTRIPLE:
- b = cp[0];
+ case IPO_BEZTRIPLE: {
+ int b = cp[0];
BLI_endian_switch_float_array((float *)poin, b);
poin += sizeof(float) * b;
break;
+ }
}
cp += 2;
@@ -3936,16 +3435,14 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb)
static void direct_link_key(BlendDataReader *reader, Key *key)
{
- KeyBlock *kb;
-
BLO_read_list(reader, &(key->block));
BLO_read_data_address(reader, &key->adt);
- direct_link_animdata(reader, key->adt);
+ BKE_animdata_blend_read_data(reader, key->adt);
BLO_read_data_address(reader, &key->refkey);
- for (kb = key->block.first; kb; kb = kb->next) {
+ LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
BLO_read_data_address(reader, &kb->data);
if (BLO_read_requires_endian_switch(reader)) {
@@ -3972,7 +3469,7 @@ static void lib_link_mball(BlendLibReader *reader, MetaBall *mb)
static void direct_link_mball(BlendDataReader *reader, MetaBall *mb)
{
BLO_read_data_address(reader, &mb->adt);
- direct_link_animdata(reader, mb->adt);
+ BKE_animdata_blend_read_data(reader, mb->adt);
BLO_read_pointer_array(reader, (void **)&mb->mat);
@@ -4001,7 +3498,7 @@ static void lib_link_world(BlendLibReader *reader, World *wrld)
static void direct_link_world(BlendDataReader *reader, World *wrld)
{
BLO_read_data_address(reader, &wrld->adt);
- direct_link_animdata(reader, wrld->adt);
+ BKE_animdata_blend_read_data(reader, wrld->adt);
wrld->preview = direct_link_preview_image(reader, wrld->preview);
BLI_listbase_clear(&wrld->gpumaterial);
@@ -4036,8 +3533,6 @@ static void lib_link_text(BlendLibReader *UNUSED(reader), Text *UNUSED(text))
static void direct_link_text(BlendDataReader *reader, Text *text)
{
- TextLine *ln;
-
BLO_read_data_address(reader, &text->filepath);
text->compiled = NULL;
@@ -4054,7 +3549,7 @@ static void direct_link_text(BlendDataReader *reader, Text *text)
BLO_read_data_address(reader, &text->curl);
BLO_read_data_address(reader, &text->sell);
- for (ln = text->lines.first; ln; ln = ln->next) {
+ LISTBASE_FOREACH (TextLine *, ln, &text->lines) {
BLO_read_data_address(reader, &ln->line);
ln->format = NULL;
@@ -4088,8 +3583,6 @@ static void lib_link_image(BlendLibReader *UNUSED(reader), Image *ima)
static void direct_link_image(BlendDataReader *reader, Image *ima)
{
- ImagePackedFile *imapf;
-
BLO_read_list(reader, &ima->tiles);
BLO_read_list(reader, &(ima->renderslots));
@@ -4102,7 +3595,7 @@ static void direct_link_image(BlendDataReader *reader, Image *ima)
BLO_read_list(reader, &(ima->packedfiles));
if (ima->packedfiles.first) {
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
imapf->packedfile = direct_link_packedfile(reader, imapf->packedfile);
}
ima->packedfile = NULL;
@@ -4155,14 +3648,11 @@ static void switch_endian_knots(Nurb *nu)
static void direct_link_curve(BlendDataReader *reader, Curve *cu)
{
- Nurb *nu;
- TextBox *tb;
-
BLO_read_data_address(reader, &cu->adt);
- direct_link_animdata(reader, cu->adt);
+ BKE_animdata_blend_read_data(reader, cu->adt);
/* Protect against integer overflow vulnerability. */
- CLAMP(cu->len_wchar, 0, INT_MAX - 4);
+ CLAMP(cu->len_char32, 0, INT_MAX - 4);
BLO_read_pointer_array(reader, (void **)&cu->mat);
@@ -4176,7 +3666,7 @@ static void direct_link_curve(BlendDataReader *reader, Curve *cu)
else {
cu->nurb.first = cu->nurb.last = NULL;
- tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBoxread");
+ TextBox *tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBoxread");
if (cu->tb) {
memcpy(tb, cu->tb, cu->totbox * sizeof(TextBox));
MEM_freeN(cu->tb);
@@ -4197,7 +3687,7 @@ static void direct_link_curve(BlendDataReader *reader, Curve *cu)
cu->editfont = NULL;
cu->batch_cache = NULL;
- for (nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
BLO_read_data_address(reader, &nu->bezt);
BLO_read_data_address(reader, &nu->bp);
BLO_read_data_address(reader, &nu->knotsu);
@@ -4228,7 +3718,7 @@ static void lib_link_texture(BlendLibReader *reader, Tex *tex)
static void direct_link_texture(BlendDataReader *reader, Tex *tex)
{
BLO_read_data_address(reader, &tex->adt);
- direct_link_animdata(reader, tex->adt);
+ BKE_animdata_blend_read_data(reader, tex->adt);
BLO_read_data_address(reader, &tex->coba);
@@ -4263,7 +3753,7 @@ static void lib_link_material(BlendLibReader *reader, Material *ma)
static void direct_link_material(BlendDataReader *reader, Material *ma)
{
BLO_read_data_address(reader, &ma->adt);
- direct_link_animdata(reader, ma->adt);
+ BKE_animdata_blend_read_data(reader, ma->adt);
ma->texpaintslot = NULL;
@@ -4294,9 +3784,7 @@ static const char *ptcache_data_struct[] = {
static void direct_link_pointcache_cb(BlendDataReader *reader, void *data)
{
PTCacheMem *pm = data;
- PTCacheExtra *extra;
- int i;
- for (i = 0; i < BPHYS_TOT_DATA; i++) {
+ for (int i = 0; i < BPHYS_TOT_DATA; i++) {
BLO_read_data_address(reader, &pm->data[i]);
/* the cache saves non-struct data without DNA */
@@ -4313,7 +3801,7 @@ static void direct_link_pointcache_cb(BlendDataReader *reader, void *data)
BLO_read_list(reader, &pm->extradata);
- for (extra = pm->extradata.first; extra; extra = extra->next) {
+ LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
BLO_read_data_address(reader, &extra->data);
}
}
@@ -4341,9 +3829,8 @@ static void direct_link_pointcache_list(BlendDataReader *reader,
int force_disk)
{
if (ptcaches->first) {
- PointCache *cache = NULL;
BLO_read_list(reader, ptcaches);
- for (cache = ptcaches->first; cache; cache = cache->next) {
+ LISTBASE_FOREACH (PointCache *, cache, ptcaches) {
direct_link_pointcache(reader, cache);
if (force_disk) {
cache->flag |= PTCACHE_DISK_CACHE;
@@ -4406,11 +3893,8 @@ static void lib_link_particlesettings(BlendLibReader *reader, ParticleSettings *
}
if (part->boids) {
- BoidState *state = part->boids->states.first;
- BoidRule *rule;
- for (; state; state = state->next) {
- rule = state->rules.first;
- for (; rule; rule = rule->next) {
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
+ LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
switch (rule->type) {
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid: {
@@ -4446,13 +3930,11 @@ static void direct_link_partdeflect(PartDeflect *pd)
static void direct_link_particlesettings(BlendDataReader *reader, ParticleSettings *part)
{
- int a;
-
BLO_read_data_address(reader, &part->adt);
BLO_read_data_address(reader, &part->pd);
BLO_read_data_address(reader, &part->pd2);
- direct_link_animdata(reader, part->adt);
+ BKE_animdata_blend_read_data(reader, part->adt);
direct_link_partdeflect(part->pd);
direct_link_partdeflect(part->pd2);
@@ -4480,16 +3962,15 @@ static void direct_link_particlesettings(BlendDataReader *reader, ParticleSettin
BLO_read_data_address(reader, &part->fluid);
if (part->boids) {
- BoidState *state;
BLO_read_list(reader, &part->boids->states);
- for (state = part->boids->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
BLO_read_list(reader, &state->rules);
BLO_read_list(reader, &state->conditions);
BLO_read_list(reader, &state->actions);
}
}
- for (a = 0; a < MAX_MTEX; a++) {
+ for (int a = 0; a < MAX_MTEX; a++) {
BLO_read_data_address(reader, &part->mtex[a]);
}
@@ -4502,16 +3983,11 @@ static void lib_link_particlesystems(BlendLibReader *reader,
ID *id,
ListBase *particles)
{
- ParticleSystem *psys, *psysnext;
-
- for (psys = particles->first; psys; psys = psysnext) {
- psysnext = psys->next;
+ LISTBASE_FOREACH_MUTABLE (ParticleSystem *, psys, particles) {
BLO_read_id_address(reader, id->lib, &psys->part);
if (psys->part) {
- ParticleTarget *pt = psys->targets.first;
-
- for (; pt; pt = pt->next) {
+ LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
BLO_read_id_address(reader, id->lib, &pt->ob);
}
@@ -4540,11 +4016,10 @@ static void lib_link_particlesystems(BlendLibReader *reader,
}
static void direct_link_particlesystems(BlendDataReader *reader, ListBase *particles)
{
- ParticleSystem *psys;
ParticleData *pa;
int a;
- for (psys = particles->first; psys; psys = psys->next) {
+ LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
BLO_read_data_address(reader, &psys->particles);
if (psys->particles && psys->particles->hair) {
@@ -4652,13 +4127,11 @@ static void lib_link_mesh(BlendLibReader *reader, Mesh *me)
static void direct_link_dverts(BlendDataReader *reader, int count, MDeformVert *mdverts)
{
- int i;
-
if (mdverts == NULL) {
return;
}
- for (i = count; i > 0; i--, mdverts++) {
+ for (int i = count; i > 0; i--, mdverts++) {
/*convert to vgroup allocation system*/
MDeformWeight *dw;
if (mdverts->dw && (dw = BLO_read_get_new_data_address(reader, mdverts->dw))) {
@@ -4678,9 +4151,7 @@ static void direct_link_dverts(BlendDataReader *reader, int count, MDeformVert *
static void direct_link_mdisps(BlendDataReader *reader, int count, MDisps *mdisps, int external)
{
if (mdisps) {
- int i;
-
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
BLO_read_data_address(reader, &mdisps[i].disps);
BLO_read_data_address(reader, &mdisps[i].hidden);
@@ -4710,9 +4181,7 @@ static void direct_link_grid_paint_mask(BlendDataReader *reader,
GridPaintMask *grid_paint_mask)
{
if (grid_paint_mask) {
- int i;
-
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
GridPaintMask *gpm = &grid_paint_mask[i];
if (gpm->data) {
BLO_read_data_address(reader, &gpm->data);
@@ -4724,7 +4193,6 @@ static void direct_link_grid_paint_mask(BlendDataReader *reader,
/*this isn't really a public api function, so prototyped here*/
static void direct_link_customdata(BlendDataReader *reader, CustomData *data, int count)
{
- int i = 0;
BLO_read_data_address(reader, &data->layers);
@@ -4737,6 +4205,7 @@ static void direct_link_customdata(BlendDataReader *reader, CustomData *data, in
BLO_read_data_address(reader, &data->external);
+ int i = 0;
while (i < data->totlayer) {
CustomDataLayer *layer = &data->layers[i];
@@ -4780,7 +4249,7 @@ static void direct_link_mesh(BlendDataReader *reader, Mesh *mesh)
/* animdata */
BLO_read_data_address(reader, &mesh->adt);
- direct_link_animdata(reader, mesh->adt);
+ BKE_animdata_blend_read_data(reader, mesh->adt);
/* Normally direct_link_dverts should be called in direct_link_customdata,
* but for backwards compatibility in do_versions to work we do it here. */
@@ -4804,10 +4273,8 @@ static void direct_link_mesh(BlendDataReader *reader, Mesh *mesh)
/* Multires data */
BLO_read_data_address(reader, &mesh->mr);
if (mesh->mr) {
- MultiresLevel *lvl;
-
BLO_read_list(reader, &mesh->mr->levels);
- lvl = mesh->mr->levels.first;
+ MultiresLevel *lvl = mesh->mr->levels.first;
direct_link_customdata(reader, &mesh->mr->vdata, lvl->totvert);
direct_link_dverts(reader, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
@@ -4848,9 +4315,7 @@ static void direct_link_mesh(BlendDataReader *reader, Mesh *mesh)
if ((BLO_read_requires_endian_switch(reader)) && mesh->tface) {
TFace *tf = mesh->tface;
- int i;
-
- for (i = 0; i < mesh->totface; i++, tf++) {
+ for (int i = 0; i < mesh->totface; i++, tf++) {
BLI_endian_switch_uint32_array(tf->col, 4);
}
}
@@ -4879,7 +4344,7 @@ static void direct_link_latt(BlendDataReader *reader, Lattice *lt)
lt->batch_cache = NULL;
BLO_read_data_address(reader, &lt->adt);
- direct_link_animdata(reader, lt->adt);
+ BKE_animdata_blend_read_data(reader, lt->adt);
}
/** \} */
@@ -4904,7 +4369,7 @@ static void lib_link_modifiers(BlendLibReader *reader, Object *ob)
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
- for (ModifierData *mod = ob->modifiers.first; mod != NULL; mod = mod->next) {
+ LISTBASE_FOREACH (ModifierData *, mod, &ob->modifiers) {
mod->flag &= ~eModifierFlag_OverrideLibrary_Local;
}
}
@@ -4916,8 +4381,7 @@ static void lib_link_gpencil_modifiers(BlendLibReader *reader, Object *ob)
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
- for (GpencilModifierData *mod = ob->greasepencil_modifiers.first; mod != NULL;
- mod = mod->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, mod, &ob->greasepencil_modifiers) {
mod->flag &= ~eGpencilModifierFlag_OverrideLibrary_Local;
}
}
@@ -4929,7 +4393,7 @@ static void lib_link_shaderfxs(BlendLibReader *reader, Object *ob)
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
- for (ShaderFxData *fx = ob->shader_fx.first; fx != NULL; fx = fx->next) {
+ LISTBASE_FOREACH (ShaderFxData *, fx, &ob->shader_fx) {
fx->flag &= ~eShaderFxFlag_OverrideLibrary_Local;
}
}
@@ -4938,7 +4402,6 @@ static void lib_link_shaderfxs(BlendLibReader *reader, Object *ob)
static void lib_link_object(BlendLibReader *reader, Object *ob)
{
bool warn = false;
- int a;
// XXX deprecated - old animation system <<<
BLO_read_id_address(reader, ob->id.lib, &ob->ipo);
@@ -5017,7 +4480,7 @@ static void lib_link_object(BlendLibReader *reader, Object *ob)
ob->mode &= ~OB_MODE_POSE;
}
}
- for (a = 0; a < ob->totcol; a++) {
+ for (int a = 0; a < ob->totcol; a++) {
BLO_read_id_address(reader, ob->id.lib, &ob->mat[a]);
}
@@ -5098,17 +4561,6 @@ static void lib_link_object(BlendLibReader *reader, Object *ob)
BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob2);
}
- {
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
- BLO_read_id_address(reader, ob->id.lib, &level->source);
-
- if (!level->source && level == ob->lodlevels.first) {
- level->source = ob;
- }
- }
- }
-
if (warn) {
BKE_report(reader->fd->reports, RPT_WARNING, "Warning in console");
}
@@ -5132,8 +4584,6 @@ static void direct_link_motionpath(BlendDataReader *reader, bMotionPath *mpath)
static void direct_link_pose(BlendDataReader *reader, bPose *pose)
{
- bPoseChannel *pchan;
-
if (!pose) {
return;
}
@@ -5144,7 +4594,7 @@ static void direct_link_pose(BlendDataReader *reader, bPose *pose)
pose->chanhash = NULL;
pose->chan_array = NULL;
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
BKE_pose_channel_runtime_reset(&pchan->runtime);
BKE_pose_channel_session_uuid_generate(pchan);
@@ -5159,7 +4609,7 @@ static void direct_link_pose(BlendDataReader *reader, bPose *pose)
direct_link_constraints(reader, &pchan->constraints);
BLO_read_data_address(reader, &pchan->prop);
- IDP_DirectLinkGroup_OrFree(&pchan->prop, reader);
+ IDP_BlendDataRead(reader, &pchan->prop);
BLO_read_data_address(reader, &pchan->mpath);
if (pchan->mpath) {
@@ -5296,11 +4746,11 @@ static ModifierData *modifier_replace_with_fluid(FileData *fd,
static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object *ob)
{
- ModifierData *md;
-
BLO_read_list(reader, lb);
- for (md = lb->first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, lb) {
+ BKE_modifier_session_uuid_generate(md);
+
md->error = NULL;
md->runtime = NULL;
@@ -5455,10 +4905,9 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object
pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
if (pmd->canvas->surfaces.first) {
- DynamicPaintSurface *surface;
BLO_read_list(reader, &pmd->canvas->surfaces);
- for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
surface->canvas = pmd->canvas;
surface->data = NULL;
direct_link_pointcache_list(reader, &(surface->ptcaches), &(surface->pointcache), 1);
@@ -5487,11 +4936,9 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object
static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
{
- GpencilModifierData *md;
-
BLO_read_list(reader, lb);
- for (md = lb->first; md; md = md->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, md, lb) {
md->error = NULL;
/* if modifiers disappear, or for upward compatibility */
@@ -5518,7 +4965,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
/* initialize the curve. Maybe this could be moved to modififer logic */
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Thick) {
@@ -5527,7 +4974,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_thickness);
if (gpmd->curve_thickness) {
BKE_curvemapping_blend_read(reader, gpmd->curve_thickness);
- BKE_curvemapping_initialize(gpmd->curve_thickness);
+ BKE_curvemapping_init(gpmd->curve_thickness);
}
}
else if (md->type == eGpencilModifierType_Tint) {
@@ -5536,7 +4983,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Smooth) {
@@ -5544,7 +4991,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Color) {
@@ -5552,7 +4999,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Opacity) {
@@ -5560,7 +5007,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
}
@@ -5568,11 +5015,9 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
static void direct_link_shaderfxs(BlendDataReader *reader, ListBase *lb)
{
- ShaderFxData *fx;
-
BLO_read_list(reader, lb);
- for (fx = lb->first; fx; fx = fx->next) {
+ LISTBASE_FOREACH (ShaderFxData *, fx, lb) {
fx->error = NULL;
/* if shader disappear, or for upward compatibility */
@@ -5604,7 +5049,7 @@ static void direct_link_object(BlendDataReader *reader, Object *ob)
}
BLO_read_data_address(reader, &ob->adt);
- direct_link_animdata(reader, ob->adt);
+ BKE_animdata_blend_read_data(reader, ob->adt);
BLO_read_data_address(reader, &ob->pose);
direct_link_pose(reader, ob->pose);
@@ -5693,8 +5138,7 @@ static void direct_link_object(BlendDataReader *reader, Object *ob)
/* still have to be loaded to be compatible with old files */
BLO_read_pointer_array(reader, (void **)&sb->keys);
if (sb->keys) {
- int a;
- for (a = 0; a < sb->totkey; a++) {
+ for (int a = 0; a < sb->totkey; a++) {
BLO_read_data_address(reader, &sb->keys[a]);
}
}
@@ -5781,9 +5225,6 @@ static void direct_link_object(BlendDataReader *reader, Object *ob)
}
}
- BLO_read_list(reader, &ob->lodlevels);
- ob->currentlod = ob->lodlevels.first;
-
ob->preview = direct_link_preview_image(reader, ob->preview);
}
@@ -5830,7 +5271,7 @@ static void direct_link_view_layer(BlendDataReader *reader, ViewLayer *view_laye
BLO_read_data_address(reader, &view_layer->active_collection);
BLO_read_data_address(reader, &view_layer->id_properties);
- IDP_DirectLinkGroup_OrFree(&view_layer->id_properties, reader);
+ IDP_BlendDataRead(reader, &view_layer->id_properties);
BLO_read_list(reader, &(view_layer->freestyle_config.modules));
BLO_read_list(reader, &(view_layer->freestyle_config.linesets));
@@ -5850,9 +5291,8 @@ static void lib_link_layer_collection(BlendLibReader *reader,
BLO_read_id_address(reader, lib, &layer_collection->collection);
}
- for (LayerCollection *layer_collection_nested = layer_collection->layer_collections.first;
- layer_collection_nested != NULL;
- layer_collection_nested = layer_collection_nested->next) {
+ LISTBASE_FOREACH (
+ LayerCollection *, layer_collection_nested, &layer_collection->layer_collections) {
lib_link_layer_collection(reader, lib, layer_collection_nested, false);
}
}
@@ -5883,15 +5323,13 @@ static void lib_link_view_layer(BlendLibReader *reader, Library *lib, ViewLayer
}
}
- for (LayerCollection *layer_collection = view_layer->layer_collections.first;
- layer_collection != NULL;
- layer_collection = layer_collection->next) {
+ LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
lib_link_layer_collection(reader, lib, layer_collection, true);
}
BLO_read_id_address(reader, lib, &view_layer->mat_override);
- IDP_LibLinkProperty(view_layer->id_properties, reader);
+ IDP_BlendReadLib(reader, view_layer->id_properties);
}
/** \} */
@@ -5952,8 +5390,7 @@ static void direct_link_collection(BlendDataReader *reader, Collection *collecti
static void lib_link_collection_data(BlendLibReader *reader, Library *lib, Collection *collection)
{
- for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
- cob_next = cob->next;
+ LISTBASE_FOREACH_MUTABLE (CollectionObject *, cob, &collection->gobject) {
BLO_read_id_address(reader, lib, &cob->ob);
if (cob->ob == NULL) {
@@ -5961,7 +5398,7 @@ static void lib_link_collection_data(BlendLibReader *reader, Library *lib, Colle
}
}
- for (CollectionChild *child = collection->children.first; child != NULL; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
BLO_read_id_address(reader, lib, &child->collection);
}
}
@@ -5990,9 +5427,8 @@ static void lib_link_collection(BlendLibReader *reader, Collection *collection)
/* patch for missing scene IDs, can't be in do-versions */
static void composite_patch(bNodeTree *ntree, Scene *scene)
{
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->id == NULL && node->type == CMP_NODE_R_LAYERS) {
node->id = &scene->id;
}
@@ -6017,9 +5453,7 @@ static void link_paint(BlendLibReader *reader, Scene *sce, Paint *p)
static void lib_link_sequence_modifiers(BlendLibReader *reader, Scene *scene, ListBase *lb)
{
- SequenceModifierData *smd;
-
- for (smd = lb->first; smd; smd = smd->next) {
+ LISTBASE_FOREACH (SequenceModifierData *, smd, lb) {
if (smd->mask_id) {
BLO_read_id_address(reader, scene->id.lib, &smd->mask_id);
}
@@ -6071,7 +5505,7 @@ static void direct_link_view3dshading(BlendDataReader *reader, View3DShading *sh
{
if (shading->prop) {
BLO_read_data_address(reader, &shading->prop);
- IDP_DirectLinkGroup_OrFree(&shading->prop, reader);
+ IDP_BlendDataRead(reader, &shading->prop);
}
}
@@ -6170,10 +5604,7 @@ static void lib_link_scene(BlendLibReader *reader, Scene *sce)
BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->gp_sculpt.guide.reference_object);
- for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy;
- base_legacy = base_legacy_next) {
- base_legacy_next = base_legacy->next;
-
+ LISTBASE_FOREACH_MUTABLE (Base *, base_legacy, &sce->base) {
BLO_read_id_address(reader, sce->id.lib, &base_legacy->object);
if (base_legacy->object == NULL) {
@@ -6190,8 +5621,8 @@ static void lib_link_scene(BlendLibReader *reader, Scene *sce)
}
Sequence *seq;
- SEQ_BEGIN (sce->ed, seq) {
- IDP_LibLinkProperty(seq->prop, reader);
+ SEQ_ALL_BEGIN (sce->ed, seq) {
+ IDP_BlendReadLib(reader, seq->prop);
if (seq->ipo) {
BLO_read_id_address(
@@ -6232,7 +5663,7 @@ static void lib_link_scene(BlendLibReader *reader, Scene *sce)
lib_link_sequence_modifiers(reader, sce, &seq->modifiers);
}
- SEQ_END;
+ SEQ_ALL_END;
LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
if (marker->camera) {
@@ -6296,7 +5727,7 @@ static void lib_link_scenes_check_set(Main *bmain)
{
#ifdef USE_SETSCENE_CHECK
const int totscene = BLI_listbase_count(&bmain->scenes);
- for (Scene *sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
if (sce->flag & SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK) {
sce->flag &= ~SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK;
if (!scene_validate_setscene__liblink(sce, totscene)) {
@@ -6313,11 +5744,9 @@ static void lib_link_scenes_check_set(Main *bmain)
static void link_recurs_seq(BlendDataReader *reader, ListBase *lb)
{
- Sequence *seq;
-
BLO_read_list(reader, lb);
- for (seq = lb->first; seq; seq = seq->next) {
+ LISTBASE_FOREACH (Sequence *, seq, lb) {
if (seq->seqbase.first) {
link_recurs_seq(reader, &seq->seqbase);
}
@@ -6362,11 +5791,9 @@ static void direct_link_paint_helper(BlendDataReader *reader, const Scene *scene
static void direct_link_sequence_modifiers(BlendDataReader *reader, ListBase *lb)
{
- SequenceModifierData *smd;
-
BLO_read_list(reader, lb);
- for (smd = lb->first; smd; smd = smd->next) {
+ LISTBASE_FOREACH (SequenceModifierData *, smd, lb) {
if (smd->mask_sequence) {
BLO_read_data_address(reader, &smd->mask_sequence);
}
@@ -6386,13 +5813,6 @@ static void direct_link_sequence_modifiers(BlendDataReader *reader, ListBase *lb
static void direct_link_scene(BlendDataReader *reader, Scene *sce)
{
- Editing *ed;
- Sequence *seq;
- MetaStack *ms;
- RigidBodyWorld *rbw;
- ViewLayer *view_layer;
- SceneRenderLayer *srl;
-
sce->depsgraph_hash = NULL;
sce->fps_info = NULL;
@@ -6407,7 +5827,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
BLO_read_list(reader, &(sce->base));
BLO_read_data_address(reader, &sce->adt);
- direct_link_animdata(reader, sce->adt);
+ BKE_animdata_blend_read_data(reader, sce->adt);
BLO_read_list(reader, &sce->keyingsets);
direct_link_keyingsets(reader, &sce->keyingsets);
@@ -6466,7 +5886,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
ListBase *old_seqbasep = &sce->ed->seqbase;
BLO_read_data_address(reader, &sce->ed);
- ed = sce->ed;
+ Editing *ed = sce->ed;
BLO_read_data_address(reader, &ed->act_seq);
ed->cache = NULL;
@@ -6475,7 +5895,8 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
/* recursive link sequences, lb will be correctly initialized */
link_recurs_seq(reader, &ed->seqbase);
- SEQ_BEGIN (ed, seq) {
+ Sequence *seq;
+ SEQ_ALL_BEGIN (ed, seq) {
/* Do as early as possible, so that other parts of reading can rely on valid session UUID. */
BKE_sequence_session_uuid_generate(seq);
@@ -6506,7 +5927,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
}
BLO_read_data_address(reader, &seq->prop);
- IDP_DirectLinkGroup_OrFree(&seq->prop, reader);
+ IDP_BlendDataRead(reader, &seq->prop);
BLO_read_data_address(reader, &seq->strip);
if (seq->strip && seq->strip->done == 0) {
@@ -6538,7 +5959,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
direct_link_sequence_modifiers(reader, &seq->modifiers);
}
- SEQ_END;
+ SEQ_ALL_END;
/* link metastack, slight abuse of structs here,
* have to restore pointer to internal part in struct */
@@ -6568,7 +5989,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
/* stack */
BLO_read_list(reader, &(ed->metastack));
- for (ms = ed->metastack.first; ms; ms = ms->next) {
+ LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
BLO_read_data_address(reader, &ms->parseq);
if (ms->oldbasep == old_seqbasep) {
@@ -6600,7 +6021,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
}
if (sce->r.ffcodecdata.properties) {
BLO_read_data_address(reader, &sce->r.ffcodecdata.properties);
- IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, reader);
+ IDP_BlendDataRead(reader, &sce->r.ffcodecdata.properties);
}
BLO_read_list(reader, &(sce->markers));
@@ -6608,9 +6029,9 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
BLO_read_list(reader, &(sce->r.layers));
BLO_read_list(reader, &(sce->r.views));
- for (srl = sce->r.layers.first; srl; srl = srl->next) {
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
BLO_read_data_address(reader, &srl->prop);
- IDP_DirectLinkGroup_OrFree(&srl->prop, reader);
+ IDP_BlendDataRead(reader, &srl->prop);
BLO_read_list(reader, &(srl->freestyleConfig.modules));
BLO_read_list(reader, &(srl->freestyleConfig.linesets));
}
@@ -6618,7 +6039,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
direct_link_view_settings(reader, &sce->view_settings);
BLO_read_data_address(reader, &sce->rigidbody_world);
- rbw = sce->rigidbody_world;
+ RigidBodyWorld *rbw = sce->rigidbody_world;
if (rbw) {
BLO_read_data_address(reader, &rbw->shared);
@@ -6672,7 +6093,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
/* insert into global old-new map for reading without UI (link_global accesses it again) */
link_glob_list(reader->fd, &sce->view_layers);
- for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
direct_link_view_layer(reader, view_layer);
}
@@ -6691,7 +6112,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
direct_link_view3dshading(reader, &sce->display.shading);
BLO_read_data_address(reader, &sce->layer_properties);
- IDP_DirectLinkGroup_OrFree(&sce->layer_properties, reader);
+ IDP_BlendDataRead(reader, &sce->layer_properties);
}
/** \} */
@@ -6719,8 +6140,6 @@ static void lib_link_gpencil(BlendLibReader *reader, bGPdata *gpd)
/* relinks grease-pencil data - used for direct_link and old file linkage */
static void direct_link_gpencil(BlendDataReader *reader, bGPdata *gpd)
{
- bGPDpalette *palette;
-
/* we must firstly have some grease-pencil data to link! */
if (gpd == NULL) {
return;
@@ -6728,7 +6147,7 @@ static void direct_link_gpencil(BlendDataReader *reader, bGPdata *gpd)
/* relink animdata */
BLO_read_data_address(reader, &gpd->adt);
- direct_link_animdata(reader, gpd->adt);
+ BKE_animdata_blend_read_data(reader, gpd->adt);
/* Ensure full objectmode for linked grease pencil. */
if (gpd->id.lib != NULL) {
@@ -6748,7 +6167,7 @@ static void direct_link_gpencil(BlendDataReader *reader, bGPdata *gpd)
/* relink palettes (old palettes deprecated, only to convert old files) */
BLO_read_list(reader, &gpd->palettes);
if (gpd->palettes.first != NULL) {
- for (palette = gpd->palettes.first; palette; palette = palette->next) {
+ LISTBASE_FOREACH (Palette *, palette, &gpd->palettes) {
BLO_read_list(reader, &palette->colors);
}
}
@@ -6811,19 +6230,17 @@ static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb)
static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
{
- uiList *ui_list;
-
direct_link_panel_list(reader, &region->panels);
BLO_read_list(reader, &region->panels_category_active);
BLO_read_list(reader, &region->ui_lists);
- for (ui_list = region->ui_lists.first; ui_list; ui_list = ui_list->next) {
+ LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
ui_list->type = NULL;
ui_list->dyn_data = NULL;
BLO_read_data_address(reader, &ui_list->properties);
- IDP_DirectLinkGroup_OrFree(&ui_list->properties, reader);
+ IDP_BlendDataRead(reader, &ui_list->properties);
}
BLO_read_list(reader, &region->ui_previews);
@@ -6876,9 +6293,6 @@ static void direct_link_region(BlendDataReader *reader, ARegion *region, int spa
static void direct_link_area(BlendDataReader *reader, ScrArea *area)
{
- SpaceLink *sl;
- ARegion *region;
-
BLO_read_list(reader, &(area->spacedata));
BLO_read_list(reader, &(area->regionbase));
@@ -6903,7 +6317,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
area->spacetype = SPACE_EMPTY;
}
- for (region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
direct_link_region(reader, region, area->spacetype);
}
@@ -6919,7 +6333,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
blo_do_versions_view3d_split_250(area->spacedata.first, &area->regionbase);
}
- for (sl = area->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
BLO_read_list(reader, &(sl->regionbase));
/* if we do not have the spacetype registered we cannot
@@ -6928,7 +6342,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
sl->spacetype = SPACE_EMPTY;
}
- for (region = sl->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
direct_link_region(reader, region, sl->spacetype);
}
@@ -6969,31 +6383,30 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
BLO_read_data_address(reader, &snla->ads);
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
/* use newdataadr_no_us and do not free old memory avoiding double
* frees and use of freed memory. this could happen because of a
* bug fixed in revision 58959 where the treestore memory address
* was not unique */
- TreeStore *ts = newdataadr_no_us(reader->fd, soops->treestore);
- soops->treestore = NULL;
+ TreeStore *ts = newdataadr_no_us(reader->fd, space_outliner->treestore);
+ space_outliner->treestore = NULL;
if (ts) {
TreeStoreElem *elems = newdataadr_no_us(reader->fd, ts->data);
- soops->treestore = BLI_mempool_create(
+ space_outliner->treestore = BLI_mempool_create(
sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
if (ts->usedelem && elems) {
- int i;
- for (i = 0; i < ts->usedelem; i++) {
- TreeStoreElem *new_elem = BLI_mempool_alloc(soops->treestore);
+ for (int i = 0; i < ts->usedelem; i++) {
+ TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
*new_elem = elems[i];
}
}
/* we only saved what was used */
- soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
+ space_outliner->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
}
- soops->treehash = NULL;
- soops->tree.first = soops->tree.last = NULL;
+ space_outliner->treehash = NULL;
+ space_outliner->tree.first = space_outliner->tree.last = NULL;
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
@@ -7066,7 +6479,6 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
}
else if (sl->spacetype == SPACE_CONSOLE) {
SpaceConsole *sconsole = (SpaceConsole *)sl;
- ConsoleLine *cl, *cl_next;
BLO_read_list(reader, &sconsole->scrollback);
BLO_read_list(reader, &sconsole->history);
@@ -7077,8 +6489,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
/* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
* from left to right. the right-most expression sets the result of the comma
* expression as a whole*/
- for (cl = sconsole->history.first; cl; cl = cl_next) {
- cl_next = cl->next;
+ LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
BLO_read_data_address(reader, &cl->line);
if (cl->line) {
/* the allocted length is not written, so reset here */
@@ -7220,27 +6631,26 @@ static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area)
break;
}
case SPACE_OUTLINER: {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- BLO_read_id_address(reader, NULL, &so->search_tse.id);
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id);
- if (so->treestore) {
+ if (space_outliner->treestore) {
TreeStoreElem *tselem;
BLI_mempool_iter iter;
- BLI_mempool_iternew(so->treestore, &iter);
+ BLI_mempool_iternew(space_outliner->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
BLO_read_id_address(reader, NULL, &tselem->id);
}
- if (so->treehash) {
+ if (space_outliner->treehash) {
/* rebuild hash table, because it depends on ids too */
- so->storeflag |= SO_TREESTORE_REBUILD;
+ space_outliner->storeflag |= SO_TREESTORE_REBUILD;
}
}
break;
}
case SPACE_NODE: {
SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path, *path_next;
/* node tree can be stored locally in id too, link this first */
BLO_read_id_address(reader, parent_id->lib, &snode->id);
@@ -7254,6 +6664,7 @@ static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area)
BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
}
+ bNodeTreePath *path;
for (path = snode->treepath.first; path; path = path->next) {
if (path == snode->treepath.first) {
/* first nodetree in path is same as snode->nodetree */
@@ -7269,6 +6680,7 @@ static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area)
}
/* remaining path entries are invalid, remove */
+ bNodeTreePath *path_next;
for (; path; path = path_next) {
path_next = path->next;
@@ -7351,12 +6763,10 @@ static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData
static void direct_link_windowmanager(BlendDataReader *reader, wmWindowManager *wm)
{
- wmWindow *win;
-
id_us_ensure_real(&wm->id);
BLO_read_list(reader, &wm->windows);
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
BLO_read_data_address(reader, &win->parent);
WorkSpaceInstanceHook *hook = win->workspace_hook;
@@ -7792,15 +7202,16 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
}
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- so->search_tse.id = restore_pointer_by_name(id_map, so->search_tse.id, USER_IGNORE);
+ space_outliner->search_tse.id = restore_pointer_by_name(
+ id_map, space_outliner->search_tse.id, USER_IGNORE);
- if (so->treestore) {
+ if (space_outliner->treestore) {
TreeStoreElem *tselem;
BLI_mempool_iter iter;
- BLI_mempool_iternew(so->treestore, &iter);
+ BLI_mempool_iternew(space_outliner->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
/* Do not try to restore pointers to drivers/sequence/etc.,
* can crash in undo case! */
@@ -7811,9 +7222,9 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
tselem->id = NULL;
}
}
- if (so->treehash) {
+ if (space_outliner->treehash) {
/* rebuild hash table, because it depends on ids too */
- so->storeflag |= SO_TREESTORE_REBUILD;
+ space_outliner->storeflag |= SO_TREESTORE_REBUILD;
}
}
}
@@ -7890,8 +7301,7 @@ void blo_lib_link_restore(Main *oldmain,
struct IDNameLib_Map *id_map = BKE_main_idmap_create(
newmain, true, oldmain, MAIN_IDMAP_TYPE_NAME);
- for (WorkSpace *workspace = newmain->workspaces.first; workspace;
- workspace = workspace->id.next) {
+ LISTBASE_FOREACH (WorkSpace *, workspace, &newmain->workspaces) {
LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
lib_link_workspace_layout_restore(id_map, newmain, layout);
}
@@ -7946,9 +7356,7 @@ void blo_lib_link_restore(Main *oldmain,
/* and as patch for 2.48 and older */
void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
{
- ARegion *region;
-
- for (region = regions->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, regions) {
if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == NULL) {
RegionView3D *rv3d;
@@ -8053,10 +7461,9 @@ static void lib_link_library(BlendLibReader *UNUSED(reader), Library *UNUSED(lib
* in relation to the blend file. */
static void fix_relpaths_library(const char *basepath, Main *main)
{
- Library *lib;
/* BLO_read_from_memory uses a blank filename */
if (basepath == NULL || basepath[0] == '\0') {
- for (lib = main->libraries.first; lib; lib = lib->id.next) {
+ LISTBASE_FOREACH (Library *, lib, &main->libraries) {
/* when loading a linked lib into a file which has not been saved,
* there is nothing we can be relative to, so instead we need to make
* it absolute. This can happen when appending an object with a relative
@@ -8068,7 +7475,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
}
}
else {
- for (lib = main->libraries.first; lib; lib = lib->id.next) {
+ LISTBASE_FOREACH (Library *, lib, &main->libraries) {
/* Libraries store both relative and abs paths, recreate relative paths,
* relative to the blend file since indirectly linked libs will be
* relative to their direct linked library. */
@@ -8094,7 +7501,7 @@ static void lib_link_lightprobe(BlendLibReader *reader, LightProbe *prb)
static void direct_link_lightprobe(BlendDataReader *reader, LightProbe *prb)
{
BLO_read_data_address(reader, &prb->adt);
- direct_link_animdata(reader, prb->adt);
+ BKE_animdata_blend_read_data(reader, prb->adt);
}
/** \} */
@@ -8111,7 +7518,7 @@ static void lib_link_speaker(BlendLibReader *reader, Speaker *spk)
static void direct_link_speaker(BlendDataReader *reader, Speaker *spk)
{
BLO_read_data_address(reader, &spk->adt);
- direct_link_animdata(reader, spk->adt);
+ BKE_animdata_blend_read_data(reader, spk->adt);
#if 0
spk->sound = newdataadr(fd, spk->sound);
@@ -8171,26 +7578,20 @@ static void direct_link_movieReconstruction(BlendDataReader *reader,
static void direct_link_movieTracks(BlendDataReader *reader, ListBase *tracksbase)
{
- MovieTrackingTrack *track;
-
BLO_read_list(reader, tracksbase);
- for (track = tracksbase->first; track; track = track->next) {
+ LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
BLO_read_data_address(reader, &track->markers);
}
}
static void direct_link_moviePlaneTracks(BlendDataReader *reader, ListBase *plane_tracks_base)
{
- MovieTrackingPlaneTrack *plane_track;
-
BLO_read_list(reader, plane_tracks_base);
- for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
- int i;
-
+ LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
BLO_read_pointer_array(reader, (void **)&plane_track->point_tracks);
- for (i = 0; i < plane_track->point_tracksnr; i++) {
+ for (int i = 0; i < plane_track->point_tracksnr; i++) {
BLO_read_data_address(reader, &plane_track->point_tracks[i]);
}
@@ -8201,7 +7602,6 @@ static void direct_link_moviePlaneTracks(BlendDataReader *reader, ListBase *plan
static void direct_link_movieclip(BlendDataReader *reader, MovieClip *clip)
{
MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object;
BLO_read_data_address(reader, &clip->adt);
@@ -8229,7 +7629,7 @@ static void direct_link_movieclip(BlendDataReader *reader, MovieClip *clip)
BLO_read_list(reader, &tracking->objects);
- for (object = tracking->objects.first; object; object = object->next) {
+ LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) {
direct_link_movieTracks(reader, &object->tracks);
direct_link_moviePlaneTracks(reader, &object->plane_tracks);
direct_link_movieReconstruction(reader, &object->reconstruction);
@@ -8238,9 +7638,7 @@ static void direct_link_movieclip(BlendDataReader *reader, MovieClip *clip)
static void lib_link_movieTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase)
{
- MovieTrackingTrack *track;
-
- for (track = tracksbase->first; track; track = track->next) {
+ LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
BLO_read_id_address(reader, clip->id.lib, &track->gpd);
}
}
@@ -8249,9 +7647,7 @@ static void lib_link_moviePlaneTracks(BlendLibReader *reader,
MovieClip *clip,
ListBase *tracksbase)
{
- MovieTrackingPlaneTrack *plane_track;
-
- for (plane_track = tracksbase->first; plane_track; plane_track = plane_track->next) {
+ LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, tracksbase) {
BLO_read_id_address(reader, clip->id.lib, &plane_track->image);
}
}
@@ -8279,28 +7675,22 @@ static void lib_link_movieclip(BlendLibReader *reader, MovieClip *clip)
static void direct_link_mask(BlendDataReader *reader, Mask *mask)
{
- MaskLayer *masklay;
-
BLO_read_data_address(reader, &mask->adt);
BLO_read_list(reader, &mask->masklayers);
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- MaskLayerShape *masklay_shape;
-
+ LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
/* can't use newdataadr since it's a pointer within an array */
MaskSplinePoint *act_point_search = NULL;
BLO_read_list(reader, &masklay->splines);
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &masklay->splines) {
MaskSplinePoint *points_old = spline->points;
- int i;
BLO_read_data_address(reader, &spline->points);
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (point->tot_uw) {
@@ -8317,8 +7707,7 @@ static void direct_link_mask(BlendDataReader *reader, Mask *mask)
BLO_read_list(reader, &masklay->splines_shapes);
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
+ LISTBASE_FOREACH (MaskLayerShape *, masklay_shape, &masklay->splines_shapes) {
BLO_read_data_address(reader, &masklay_shape->data);
if (masklay_shape->tot_vert) {
@@ -8347,9 +7736,7 @@ static void lib_link_mask(BlendLibReader *reader, Mask *mask)
spline = masklay->splines.first;
while (spline) {
- int i;
-
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
lib_link_mask_parent(reader, mask, &point->parent);
@@ -8370,9 +7757,7 @@ static void lib_link_mask(BlendLibReader *reader, Mask *mask)
static void lib_link_linestyle(BlendLibReader *reader, FreestyleLineStyle *linestyle)
{
- LineStyleModifier *m;
-
- for (m = linestyle->color_modifiers.first; m; m = m->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->color_modifiers) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleColorModifier_DistanceFromObject *cm =
@@ -8382,7 +7767,7 @@ static void lib_link_linestyle(BlendLibReader *reader, FreestyleLineStyle *lines
}
}
}
- for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->alpha_modifiers) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleAlphaModifier_DistanceFromObject *am =
@@ -8392,7 +7777,7 @@ static void lib_link_linestyle(BlendLibReader *reader, FreestyleLineStyle *lines
}
}
}
- for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->thickness_modifiers) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleThicknessModifier_DistanceFromObject *tm =
@@ -8578,28 +7963,25 @@ static void direct_link_linestyle_geometry_modifier(BlendDataReader *UNUSED(read
static void direct_link_linestyle(BlendDataReader *reader, FreestyleLineStyle *linestyle)
{
- int a;
- LineStyleModifier *modifier;
-
BLO_read_data_address(reader, &linestyle->adt);
- direct_link_animdata(reader, linestyle->adt);
+ BKE_animdata_blend_read_data(reader, linestyle->adt);
BLO_read_list(reader, &linestyle->color_modifiers);
- for (modifier = linestyle->color_modifiers.first; modifier; modifier = modifier->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->color_modifiers) {
direct_link_linestyle_color_modifier(reader, modifier);
}
BLO_read_list(reader, &linestyle->alpha_modifiers);
- for (modifier = linestyle->alpha_modifiers.first; modifier; modifier = modifier->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->alpha_modifiers) {
direct_link_linestyle_alpha_modifier(reader, modifier);
}
BLO_read_list(reader, &linestyle->thickness_modifiers);
- for (modifier = linestyle->thickness_modifiers.first; modifier; modifier = modifier->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->thickness_modifiers) {
direct_link_linestyle_thickness_modifier(reader, modifier);
}
BLO_read_list(reader, &linestyle->geometry_modifiers);
- for (modifier = linestyle->geometry_modifiers.first; modifier; modifier = modifier->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->geometry_modifiers) {
direct_link_linestyle_geometry_modifier(reader, modifier);
}
- for (a = 0; a < MAX_MTEX; a++) {
+ for (int a = 0; a < MAX_MTEX; a++) {
BLO_read_data_address(reader, &linestyle->mtex[a]);
}
}
@@ -8620,7 +8002,7 @@ static void lib_link_hair(BlendLibReader *reader, Hair *hair)
static void direct_link_hair(BlendDataReader *reader, Hair *hair)
{
BLO_read_data_address(reader, &hair->adt);
- direct_link_animdata(reader, hair->adt);
+ BKE_animdata_blend_read_data(reader, hair->adt);
/* Geometry */
direct_link_customdata(reader, &hair->pdata, hair->totpoint);
@@ -8647,7 +8029,7 @@ static void lib_link_pointcloud(BlendLibReader *reader, PointCloud *pointcloud)
static void direct_link_pointcloud(BlendDataReader *reader, PointCloud *pointcloud)
{
BLO_read_data_address(reader, &pointcloud->adt);
- direct_link_animdata(reader, pointcloud->adt);
+ BKE_animdata_blend_read_data(reader, pointcloud->adt);
/* Geometry */
direct_link_customdata(reader, &pointcloud->pdata, pointcloud->totpoint);
@@ -8678,7 +8060,7 @@ static void lib_link_volume(BlendLibReader *reader, Volume *volume)
static void direct_link_volume(BlendDataReader *reader, Volume *volume)
{
BLO_read_data_address(reader, &volume->adt);
- direct_link_animdata(reader, volume->adt);
+ BKE_animdata_blend_read_data(reader, volume->adt);
volume->packedfile = direct_link_packedfile(reader, volume->packedfile);
volume->runtime.frame = 0;
@@ -8695,16 +8077,15 @@ static void direct_link_volume(BlendDataReader *reader, Volume *volume)
static void lib_link_simulation(BlendLibReader *reader, Simulation *simulation)
{
- LISTBASE_FOREACH (
- PersistentDataHandleItem *, handle_item, &simulation->persistent_data_handles) {
- BLO_read_id_address(reader, simulation->id.lib, &handle_item->id);
+ LISTBASE_FOREACH (SimulationDependency *, dependency, &simulation->dependencies) {
+ BLO_read_id_address(reader, simulation->id.lib, &dependency->id);
}
}
static void direct_link_simulation(BlendDataReader *reader, Simulation *simulation)
{
BLO_read_data_address(reader, &simulation->adt);
- direct_link_animdata(reader, simulation->adt);
+ BKE_animdata_blend_read_data(reader, simulation->adt);
BLO_read_list(reader, &simulation->states);
LISTBASE_FOREACH (SimulationState *, state, &simulation->states) {
@@ -8716,7 +8097,7 @@ static void direct_link_simulation(BlendDataReader *reader, Simulation *simulati
}
}
- BLO_read_list(reader, &simulation->persistent_data_handles);
+ BLO_read_list(reader, &simulation->dependencies);
}
/** \} */
@@ -8750,7 +8131,7 @@ static void placeholders_ensure_valid(Main *bmain)
{
/* Placeholder ObData IDs won't have any material, we have to update their objects for that,
* otherwise the inconsistency between both will lead to crashes (especially in Eevee?). */
- for (Object *ob = bmain->objects.first; ob != NULL; ob = ob->id.next) {
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
ID *obdata = ob->data;
if (obdata != NULL && obdata->tag & LIB_TAG_MISSING) {
BKE_object_materials_test(bmain, ob, obdata);
@@ -8859,6 +8240,9 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
}
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_read_data != NULL) {
+ id_type->blend_read_data(&reader, id);
+ }
/* XXX Very weakly handled currently, see comment in read_libblock() before trying to
* use it for anything new. */
@@ -9254,17 +8638,16 @@ static bool read_libblock_undo_restore(
*r_id_old = id_old;
return true;
}
- else if (id_old != NULL) {
+ if (id_old != NULL) {
/* Local datablock was changed. Restore at the address of the old datablock. */
DEBUG_PRINTF("read to old existing address\n");
*r_id_old = id_old;
return false;
}
- else {
- /* Local datablock does not exist in the undo step, so read from scratch. */
- DEBUG_PRINTF("read at new address\n");
- return false;
- }
+
+ /* Local datablock does not exist in the undo step, so read from scratch. */
+ DEBUG_PRINTF("read at new address\n");
+ return false;
}
/* This routine reads a datablock and its direct data, and advances bhead to
@@ -9462,11 +8845,9 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
}
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) {
+ LISTBASE_FOREACH (bTheme *, btheme, &user->themes) {
copy_v4_v4_uchar(btheme->space_node.grid, btheme->space_node.back);
copy_v4_v4_uchar(btheme->space_sequencer.grid, btheme->space_sequencer.back);
}
@@ -9581,6 +8962,11 @@ static void lib_link_all(FileData *fd, Main *bmain)
lib_link_id(&reader, id);
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_read_lib != NULL) {
+ id_type->blend_read_lib(&reader, id);
+ }
+
/* Note: ID types are processed in reverse order as defined by INDEX_ID_XXX enums in DNA_ID.h.
* This ensures handling of most dependencies in proper order, as elsewhere in code.
* Please keep order of entries in that switch matching that order, it's easier to quickly see
@@ -9747,7 +9133,7 @@ static void lib_link_all(FileData *fd, Main *bmain)
static void direct_link_keymapitem(BlendDataReader *reader, wmKeyMapItem *kmi)
{
BLO_read_data_address(reader, &kmi->properties);
- IDP_DirectLinkGroup_OrFree(&kmi->properties, reader);
+ IDP_BlendDataRead(reader, &kmi->properties);
kmi->ptr = NULL;
kmi->flag &= ~KMI_UPDATE;
}
@@ -9755,11 +9141,6 @@ static void direct_link_keymapitem(BlendDataReader *reader, wmKeyMapItem *kmi)
static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
{
UserDef *user;
- wmKeyMap *keymap;
- wmKeyMapItem *kmi;
- wmKeyMapDiffItem *kmdi;
- bAddon *addon;
-
bfd->user = user = read_struct(fd, bhead, "user def");
/* User struct has separate do-version handling */
@@ -9779,7 +9160,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
BLO_read_list(reader, &user->addons);
BLO_read_list(reader, &user->autoexec_paths);
- for (keymap = user->user_keymaps.first; keymap; keymap = keymap->next) {
+ LISTBASE_FOREACH (wmKeyMap *, keymap, &user->user_keymaps) {
keymap->modal_items = NULL;
keymap->poll = NULL;
keymap->flag &= ~KEYMAP_UPDATE;
@@ -9787,7 +9168,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
BLO_read_list(reader, &keymap->diff_items);
BLO_read_list(reader, &keymap->items);
- for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
+ LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &keymap->diff_items) {
BLO_read_data_address(reader, &kmdi->remove_item);
BLO_read_data_address(reader, &kmdi->add_item);
@@ -9799,14 +9180,14 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
}
}
- for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
direct_link_keymapitem(reader, kmi);
}
}
LISTBASE_FOREACH (wmKeyConfigPref *, kpt, &user->user_keyconfig_prefs) {
BLO_read_data_address(reader, &kpt->prop);
- IDP_DirectLinkGroup_OrFree(&kpt->prop, reader);
+ IDP_BlendDataRead(reader, &kpt->prop);
}
LISTBASE_FOREACH (bUserMenu *, um, &user->user_menus) {
@@ -9815,14 +9196,14 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
if (umi->type == USER_MENU_TYPE_OPERATOR) {
bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
BLO_read_data_address(reader, &umi_op->prop);
- IDP_DirectLinkGroup_OrFree(&umi_op->prop, reader);
+ IDP_BlendDataRead(reader, &umi_op->prop);
}
}
}
- for (addon = user->addons.first; addon; addon = addon->next) {
+ LISTBASE_FOREACH (bAddon *, addon, &user->addons) {
BLO_read_data_address(reader, &addon->prop);
- IDP_DirectLinkGroup_OrFree(&addon->prop, reader);
+ IDP_BlendDataRead(reader, &addon->prop);
}
// XXX
@@ -10035,7 +9416,7 @@ static int verg_bheadsort(const void *v1, const void *v2)
if (x1->old > x2->old) {
return 1;
}
- else if (x1->old < x2->old) {
+ if (x1->old < x2->old) {
return -1;
}
return 0;
@@ -10281,8 +9662,7 @@ static BLOExpandDoitCallback expand_doit;
// XXX deprecated - old animation system
static void expand_ipo(BlendExpander *expander, Ipo *ipo)
{
- IpoCurve *icu;
- for (icu = ipo->curve.first; icu; icu = icu->next) {
+ LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
if (icu->driver) {
BLO_expand(expander, icu->driver->ob);
}
@@ -10292,115 +9672,11 @@ static void expand_ipo(BlendExpander *expander, Ipo *ipo)
// XXX deprecated - old animation system
static void expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
{
- bConstraintChannel *chan;
- for (chan = chanbase->first; chan; chan = chan->next) {
+ LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
BLO_expand(expander, chan->ipo);
}
}
-static void expand_fmodifiers(BlendExpander *expander, 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;
-
- BLO_expand(expander, data->script);
-
- break;
- }
- }
- }
-}
-
-static void expand_fcurves(BlendExpander *expander, 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_BEGIN (dvar) {
- // TODO: only expand those that are going to get used?
- BLO_expand(expander, dtar->id);
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
-
- /* F-Curve Modifiers */
- expand_fmodifiers(expander, &fcu->modifiers);
- }
-}
-
-static void expand_animdata_nlastrips(BlendExpander *expander, ListBase *list)
-{
- NlaStrip *strip;
-
- for (strip = list->first; strip; strip = strip->next) {
- /* check child strips */
- expand_animdata_nlastrips(expander, &strip->strips);
-
- /* check F-Curves */
- expand_fcurves(expander, &strip->fcurves);
-
- /* check F-Modifiers */
- expand_fmodifiers(expander, &strip->modifiers);
-
- /* relink referenced action */
- BLO_expand(expander, strip->act);
- }
-}
-
-static void expand_animdata(BlendExpander *expander, AnimData *adt)
-{
- NlaTrack *nlt;
-
- /* own action */
- BLO_expand(expander, adt->action);
- BLO_expand(expander, adt->tmpact);
-
- /* drivers - assume that these F-Curves have driver data to be in this list... */
- expand_fcurves(expander, &adt->drivers);
-
- /* nla-data - referenced actions */
- for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
- expand_animdata_nlastrips(expander, &nlt->strips);
- }
-}
-
-static void expand_idprops(BlendExpander *expander, IDProperty *prop)
-{
- if (!prop) {
- return;
- }
-
- switch (prop->type) {
- case IDP_ID:
- BLO_expand(expander, IDP_Id(prop));
- break;
- case IDP_IDPARRAY: {
- IDProperty *idp_array = IDP_IDPArray(prop);
- for (int i = 0; i < prop->len; i++) {
- expand_idprops(expander, &idp_array[i]);
- }
- break;
- }
- case IDP_GROUP:
- LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
- expand_idprops(expander, loop);
- }
- break;
- }
-}
-
static void expand_id(BlendExpander *expander, ID *id);
static void expand_nodetree(BlendExpander *expander, bNodeTree *ntree);
static void expand_collection(BlendExpander *expander, Collection *collection);
@@ -10425,7 +9701,7 @@ static void expand_id_embedded_id(BlendExpander *expander, ID *id)
static void expand_id(BlendExpander *expander, ID *id)
{
- expand_idprops(expander, id->properties);
+ IDP_BlendReadExpand(expander, id->properties);
if (id->override_library) {
BLO_expand(expander, id->override_library->reference);
@@ -10434,7 +9710,7 @@ static void expand_id(BlendExpander *expander, ID *id)
AnimData *adt = BKE_animdata_from_id(id);
if (adt != NULL) {
- expand_animdata(expander, adt);
+ BKE_animdata_blend_read_expand(expander, adt);
}
expand_id_embedded_id(expander, id);
@@ -10442,17 +9718,15 @@ static void expand_id(BlendExpander *expander, ID *id)
static void expand_action(BlendExpander *expander, bAction *act)
{
- bActionChannel *chan;
-
// XXX deprecated - old animation system --------------
- for (chan = act->chanbase.first; chan; chan = chan->next) {
+ LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
BLO_expand(expander, chan->ipo);
expand_constraint_channels(expander, &chan->constraintChannels);
}
// ---------------------------------------------------
/* F-Curves in Action */
- expand_fcurves(expander, &act->curves);
+ BKE_fcurve_blend_read_expand(expander, &act->curves);
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if (marker->camera) {
@@ -10463,12 +9737,9 @@ static void expand_action(BlendExpander *expander, bAction *act)
static void expand_keyingsets(BlendExpander *expander, 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) {
+ LISTBASE_FOREACH (KeyingSet *, ks, list) {
+ LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
BLO_expand(expander, ksp->id);
}
}
@@ -10476,15 +9747,13 @@ static void expand_keyingsets(BlendExpander *expander, ListBase *list)
static void expand_particlesettings(BlendExpander *expander, ParticleSettings *part)
{
- int a;
-
BLO_expand(expander, part->instance_object);
BLO_expand(expander, part->instance_collection);
BLO_expand(expander, part->force_group);
BLO_expand(expander, part->bb_ob);
BLO_expand(expander, part->collision_group);
- for (a = 0; a < MAX_MTEX; a++) {
+ for (int a = 0; a < MAX_MTEX; a++) {
if (part->mtex[a]) {
BLO_expand(expander, part->mtex[a]->tex);
BLO_expand(expander, part->mtex[a]->object);
@@ -10505,11 +9774,8 @@ static void expand_particlesettings(BlendExpander *expander, ParticleSettings *p
}
if (part->boids) {
- BoidState *state;
- BoidRule *rule;
-
- for (state = part->boids->states.first; state; state = state->next) {
- for (rule = state->rules.first; rule; rule = rule->next) {
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
+ LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
if (rule->type == eBoidRuleType_Avoid) {
BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
BLO_expand(expander, gabr->ob);
@@ -10551,7 +9817,7 @@ static void expand_key(BlendExpander *expander, Key *key)
static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock)
{
- expand_idprops(expander, sock->prop);
+ IDP_BlendReadExpand(expander, sock->prop);
if (sock->default_value != NULL) {
@@ -10593,18 +9859,16 @@ static void expand_node_sockets(BlendExpander *expander, ListBase *sockets)
static void expand_nodetree(BlendExpander *expander, bNodeTree *ntree)
{
- bNode *node;
-
if (ntree->gpd) {
BLO_expand(expander, ntree->gpd);
}
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->id && node->type != CMP_NODE_R_LAYERS) {
BLO_expand(expander, node->id);
}
- expand_idprops(expander, node->prop);
+ IDP_BlendReadExpand(expander, node->prop);
expand_node_sockets(expander, &node->inputs);
expand_node_sockets(expander, &node->outputs);
@@ -10660,18 +9924,14 @@ static void expand_world(BlendExpander *expander, World *wrld)
static void expand_mball(BlendExpander *expander, MetaBall *mb)
{
- int a;
-
- for (a = 0; a < mb->totcol; a++) {
+ for (int a = 0; a < mb->totcol; a++) {
BLO_expand(expander, mb->mat[a]);
}
}
static void expand_curve(BlendExpander *expander, Curve *cu)
{
- int a;
-
- for (a = 0; a < cu->totcol; a++) {
+ for (int a = 0; a < cu->totcol; a++) {
BLO_expand(expander, cu->mat[a]);
}
@@ -10688,9 +9948,7 @@ static void expand_curve(BlendExpander *expander, Curve *cu)
static void expand_mesh(BlendExpander *expander, Mesh *me)
{
- int a;
-
- for (a = 0; a < me->totcol; a++) {
+ for (int a = 0; a < me->totcol; a++) {
BLO_expand(expander, me->mat[a]);
}
@@ -10710,12 +9968,10 @@ static void expand_constraint_cb(bConstraint *UNUSED(con),
static void expand_constraints(BlendExpander *expander, ListBase *lb)
{
- bConstraint *curcon;
-
BKE_constraints_id_loop(lb, expand_constraint_cb, expander);
/* deprecated manual expansion stuff */
- for (curcon = lb->first; curcon; curcon = curcon->next) {
+ LISTBASE_FOREACH (bConstraint *, curcon, lb) {
if (curcon->ipo) {
BLO_expand(expander, curcon->ipo); // XXX deprecated - old animation system
}
@@ -10724,22 +9980,20 @@ static void expand_constraints(BlendExpander *expander, ListBase *lb)
static void expand_pose(BlendExpander *expander, bPose *pose)
{
- bPoseChannel *chan;
-
if (!pose) {
return;
}
- for (chan = pose->chanbase.first; chan; chan = chan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
expand_constraints(expander, &chan->constraints);
- expand_idprops(expander, chan->prop);
+ IDP_BlendReadExpand(expander, chan->prop);
BLO_expand(expander, chan->custom);
}
}
static void expand_bones(BlendExpander *expander, Bone *bone)
{
- expand_idprops(expander, bone->prop);
+ IDP_BlendReadExpand(expander, bone->prop);
LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) {
expand_bones(expander, curBone);
@@ -10764,11 +10018,6 @@ static void expand_object_expandModifiers(void *userData,
static void expand_object(BlendExpander *expander, Object *ob)
{
- ParticleSystem *psys;
- bActionStrip *strip;
- PartEff *paf;
- int a;
-
BLO_expand(expander, ob->data);
/* expand_object_expandModifier() */
@@ -10798,18 +10047,18 @@ static void expand_object(BlendExpander *expander, Object *ob)
expand_constraint_channels(expander, &ob->constraintChannels);
- for (strip = ob->nlastrips.first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (bActionStrip *, strip, &ob->nlastrips) {
BLO_expand(expander, strip->object);
BLO_expand(expander, strip->act);
BLO_expand(expander, strip->ipo);
}
// XXX deprecated - old animation system (for version patching only)
- for (a = 0; a < ob->totcol; a++) {
+ for (int a = 0; a < ob->totcol; a++) {
BLO_expand(expander, ob->mat[a]);
}
- paf = blo_do_version_give_parteff_245(ob);
+ PartEff *paf = blo_do_version_give_parteff_245(ob);
if (paf && paf->group) {
BLO_expand(expander, paf->group);
}
@@ -10825,7 +10074,7 @@ static void expand_object(BlendExpander *expander, Object *ob)
BLO_expand(expander, ob->proxy_group);
}
- for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+ LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
BLO_expand(expander, psys->part);
}
@@ -10846,13 +10095,6 @@ static void expand_object(BlendExpander *expander, Object *ob)
BLO_expand(expander, ob->rigidbody_constraint->ob1);
BLO_expand(expander, ob->rigidbody_constraint->ob2);
}
-
- if (ob->currentlod) {
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
- BLO_expand(expander, level->source);
- }
- }
}
#ifdef USE_COLLECTION_COMPAT_28
@@ -10870,10 +10112,6 @@ static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc
static void expand_scene(BlendExpander *expander, Scene *sce)
{
- SceneRenderLayer *srl;
- FreestyleModuleConfig *module;
- FreestyleLineSet *lineset;
-
LISTBASE_FOREACH (Base *, base_legacy, &sce->base) {
BLO_expand(expander, base_legacy->object);
}
@@ -10886,14 +10124,14 @@ static void expand_scene(BlendExpander *expander, Scene *sce)
BLO_expand(expander, sce->set);
}
- for (srl = sce->r.layers.first; srl; srl = srl->next) {
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
BLO_expand(expander, srl->mat_override);
- for (module = srl->freestyleConfig.modules.first; module; module = module->next) {
+ LISTBASE_FOREACH (FreestyleModuleConfig *, module, &srl->freestyleConfig.modules) {
if (module->script) {
BLO_expand(expander, module->script);
}
}
- for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+ LISTBASE_FOREACH (FreestyleLineSet *, lineset, &srl->freestyleConfig.linesets) {
if (lineset->group) {
BLO_expand(expander, lineset->group);
}
@@ -10902,15 +10140,15 @@ static void expand_scene(BlendExpander *expander, Scene *sce)
}
LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
- expand_idprops(expander, view_layer->id_properties);
+ IDP_BlendReadExpand(expander, view_layer->id_properties);
- for (module = view_layer->freestyle_config.modules.first; module; module = module->next) {
+ LISTBASE_FOREACH (FreestyleModuleConfig *, module, &view_layer->freestyle_config.modules) {
if (module->script) {
BLO_expand(expander, module->script);
}
}
- for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) {
+ LISTBASE_FOREACH (FreestyleLineSet *, lineset, &view_layer->freestyle_config.linesets) {
if (lineset->group) {
BLO_expand(expander, lineset->group);
}
@@ -10925,8 +10163,8 @@ static void expand_scene(BlendExpander *expander, Scene *sce)
if (sce->ed) {
Sequence *seq;
- SEQ_BEGIN (sce->ed, seq) {
- expand_idprops(expander, seq->prop);
+ SEQ_ALL_BEGIN (sce->ed, seq) {
+ IDP_BlendReadExpand(expander, seq->prop);
if (seq->scene) {
BLO_expand(expander, seq->scene);
@@ -10949,7 +10187,7 @@ static void expand_scene(BlendExpander *expander, Scene *sce)
BLO_expand(expander, data->text_font);
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
if (sce->rigidbody_world) {
@@ -11021,17 +10259,10 @@ static void expand_mask_parent(BlendExpander *expander, MaskParent *parent)
static void expand_mask(BlendExpander *expander, Mask *mask)
{
- MaskLayer *mask_layer;
-
- for (mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- MaskSpline *spline;
-
- for (spline = mask_layer->splines.first; spline; spline = spline->next) {
- int i;
-
- for (i = 0; i < spline->tot_point; i++) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
-
expand_mask_parent(expander, &point->parent);
}
@@ -11042,27 +10273,24 @@ static void expand_mask(BlendExpander *expander, Mask *mask)
static void expand_linestyle(BlendExpander *expander, FreestyleLineStyle *linestyle)
{
- int a;
- LineStyleModifier *m;
-
- for (a = 0; a < MAX_MTEX; a++) {
+ for (int a = 0; a < MAX_MTEX; a++) {
if (linestyle->mtex[a]) {
BLO_expand(expander, linestyle->mtex[a]->tex);
BLO_expand(expander, linestyle->mtex[a]->object);
}
}
- for (m = linestyle->color_modifiers.first; m; m = m->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->color_modifiers) {
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
BLO_expand(expander, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
}
}
- for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->alpha_modifiers) {
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
BLO_expand(expander, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
}
}
- for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
+ LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->thickness_modifiers) {
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
BLO_expand(expander, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
}
@@ -11092,10 +10320,6 @@ static void expand_hair(BlendExpander *expander, Hair *hair)
for (int a = 0; a < hair->totcol; a++) {
BLO_expand(expander, hair->mat[a]);
}
-
- if (hair->adt) {
- expand_animdata(expander, hair->adt);
- }
}
static void expand_pointcloud(BlendExpander *expander, PointCloud *pointcloud)
@@ -11103,10 +10327,6 @@ static void expand_pointcloud(BlendExpander *expander, PointCloud *pointcloud)
for (int a = 0; a < pointcloud->totcol; a++) {
BLO_expand(expander, pointcloud->mat[a]);
}
-
- if (pointcloud->adt) {
- expand_animdata(expander, pointcloud->adt);
- }
}
static void expand_volume(BlendExpander *expander, Volume *volume)
@@ -11114,20 +10334,12 @@ static void expand_volume(BlendExpander *expander, Volume *volume)
for (int a = 0; a < volume->totcol; a++) {
BLO_expand(expander, volume->mat[a]);
}
-
- if (volume->adt) {
- expand_animdata(expander, volume->adt);
- }
}
static void expand_simulation(BlendExpander *expander, Simulation *simulation)
{
- if (simulation->adt) {
- expand_animdata(expander, simulation->adt);
- }
- LISTBASE_FOREACH (
- PersistentDataHandleItem *, handle_item, &simulation->persistent_data_handles) {
- BLO_expand(expander, handle_item->id);
+ LISTBASE_FOREACH (SimulationDependency *, dependency, &simulation->dependencies) {
+ BLO_expand(expander, dependency->id);
}
}
@@ -11168,6 +10380,11 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
if (id->tag & LIB_TAG_NEED_EXPAND) {
expand_id(&expander, id);
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_read_expand != NULL) {
+ id_type->blend_read_expand(&expander, id);
+ }
+
switch (GS(id->name)) {
case ID_OB:
expand_object(&expander, (Object *)id);
@@ -11286,9 +10503,7 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
static bool object_in_any_scene(Main *bmain, Object *ob)
{
- Scene *sce;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
if (BKE_scene_object_find(sce, ob)) {
return true;
}
@@ -11299,9 +10514,7 @@ static bool object_in_any_scene(Main *bmain, Object *ob)
static bool object_in_any_collection(Main *bmain, Object *ob)
{
- Collection *collection;
-
- for (collection = bmain->collections.first; collection; collection = collection->id.next) {
+ LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
if (BKE_collection_has_object(collection, ob)) {
return true;
}
@@ -11325,7 +10538,7 @@ static void add_loose_objects_to_scene(Main *mainvar,
/* Give all objects which are LIB_TAG_INDIRECT a base,
* or for a collection when *lib has been set. */
- for (Object *ob = mainvar->objects.first; ob; ob = ob->id.next) {
+ LISTBASE_FOREACH (Object *, ob, &mainvar->objects) {
bool do_it = (ob->id.tag & LIB_TAG_DOIT) != 0;
if (do_it || ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0)) {
if (do_append) {
@@ -11392,8 +10605,7 @@ static void add_collections_to_scene(Main *mainvar,
}
/* Give all objects which are tagged a base. */
- for (Collection *collection = mainvar->collections.first; collection;
- collection = collection->id.next) {
+ LISTBASE_FOREACH (Collection *, collection, &mainvar->collections) {
if ((flag & FILE_GROUP_INSTANCE) && (collection->id.tag & LIB_TAG_DOIT)) {
/* Any indirect collection should not have been tagged. */
BLI_assert((collection->id.tag & LIB_TAG_INDIRECT) == 0);
@@ -11436,8 +10648,7 @@ static void add_collections_to_scene(Main *mainvar,
* Note that we only check object directly into that collection,
* not recursively into its children.
*/
- for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL;
- coll_ob = coll_ob->next) {
+ LISTBASE_FOREACH (CollectionObject *, coll_ob, &collection->gobject) {
Object *ob = coll_ob->ob;
if ((ob->id.tag & (LIB_TAG_PRE_EXISTING | LIB_TAG_DOIT | LIB_TAG_INDIRECT)) == 0 &&
(ob->id.lib == lib) && (object_in_any_scene(bmain, ob) == 0)) {
@@ -11451,8 +10662,7 @@ static void add_collections_to_scene(Main *mainvar,
BKE_collection_child_add(bmain, active_collection, collection);
if (flag & FILE_AUTOSELECT) {
- for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL;
- coll_ob = coll_ob->next) {
+ LISTBASE_FOREACH (CollectionObject *, coll_ob, &collection->gobject) {
Object *ob = coll_ob->ob;
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (base) {
@@ -11678,9 +10888,7 @@ static void split_main_newid(Main *mainptr, Main *main_newid)
while (i--) {
BLI_listbase_clear(lbarray_newid[i]);
- for (ID *id = lbarray[i]->first, *idnext; id; id = idnext) {
- idnext = id->next;
-
+ LISTBASE_FOREACH_MUTABLE (ID *, id, lbarray[i]) {
if (id->tag & LIB_TAG_NEW) {
BLI_remlink(lbarray[i], id);
BLI_addtail(lbarray_newid[i], id);
@@ -12126,8 +11334,8 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
}
/* Note: No need to call #do_versions_after_linking() or #BKE_main_id_refcount_recompute()
- * here, as this function is only called for library 'subset' data handling, as part of either
- * full blendfile reading (#blo_read_file_internal()), or library-data linking
+ * here, as this function is only called for library 'subset' data handling, as part of
+ * either full blendfile reading (#blo_read_file_internal()), or library-data linking
* (#library_link_end()). */
/* Free file data we no longer need. */
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 3ed59a0baa1..dad86f80813 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -270,9 +270,9 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
break;
case SPACE_OUTLINER: {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- memcpy(&region->v2d, &soops->v2d, sizeof(View2D));
+ memcpy(&region->v2d, &space_outliner->v2d, sizeof(View2D));
region->v2d.scroll &= ~V2D_SCROLL_LEFT;
region->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
@@ -280,7 +280,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
region->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT);
region->v2d.keeptot = V2D_KEEPTOT_STRICT;
region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
- // region->v2d.flag |= V2D_IS_INITIALISED;
+ // region->v2d.flag |= V2D_IS_INIT;
break;
}
case SPACE_GRAPH: {
@@ -297,7 +297,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
region->v2d.max[0] = MAXFRAMEF;
region->v2d.max[1] = FLT_MAX;
- // region->v2d.flag |= V2D_IS_INITIALISED;
+ // region->v2d.flag |= V2D_IS_INIT;
break;
}
case SPACE_NLA: {
@@ -355,7 +355,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES);
region->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_VERTICAL_HANDLES);
region->v2d.align = V2D_ALIGN_NO_NEG_Y;
- region->v2d.flag |= V2D_IS_INITIALISED;
+ region->v2d.flag |= V2D_IS_INIT;
break;
}
case SPACE_NODE: {
@@ -635,6 +635,7 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock)
}
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -665,7 +666,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (scene->ed && scene->ed->seqbasep) {
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
if (seq->type == SEQ_TYPE_SOUND_HD) {
char str[FILE_MAX];
BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
@@ -681,7 +682,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE
}
- SEQ_END;
+ SEQ_ALL_END;
}
}
@@ -965,7 +966,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* just need to initialise rotation axis properly... */
+ /* Just need to initialize rotation axis properly. */
pchan->rotAxis[1] = 1.0f;
}
}
@@ -1408,10 +1409,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
}
- SEQ_BEGIN (sce->ed, seq) {
+ SEQ_ALL_BEGIN (sce->ed, seq) {
seq->volume = 1.0f;
}
- SEQ_END;
+ SEQ_ALL_END;
}
/* particle brush strength factor was changed from int to float */
@@ -1680,12 +1681,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
Sequence *seq;
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
if (seq->sat == 0.0f) {
seq->sat = 1.0f;
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
/* GSOC 2010 Sculpt - New settings for Brush */
@@ -2165,10 +2166,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->r.ffcodecdata.audio_channels = 2;
scene->audio.volume = 1.0f;
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
seq->pitch = 1.0f;
}
- SEQ_END;
+ SEQ_ALL_END;
}
}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index b3bf8991c3e..dec5c8d495a 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -658,6 +658,7 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
}
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
if (bmain->versionfile < 260) {
@@ -1205,7 +1206,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (region->regiontype == RGN_TYPE_PREVIEW) {
if (region->alignment != RGN_ALIGN_NONE) {
region->flag |= RGN_FLAG_HIDDEN;
- region->v2d.flag &= ~V2D_IS_INITIALISED;
+ region->v2d.flag &= ~V2D_IS_INIT;
region->alignment = RGN_ALIGN_NONE;
hide = true;
@@ -1488,7 +1489,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (scene->ed) {
Sequence *seq;
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
Strip *strip = seq->strip;
if (strip && strip->color_balance) {
@@ -1511,7 +1512,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
strip->color_balance = NULL;
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
}
}
@@ -1803,7 +1804,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
Sequence *seq;
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
enum { SEQ_MAKE_PREMUL = (1 << 6) };
if (seq->flag & SEQ_MAKE_PREMUL) {
seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
@@ -1812,7 +1813,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
BKE_sequence_alpha_mode_from_extension(seq);
}
}
- SEQ_END;
+ SEQ_ALL_END;
if (scene->r.bake_samples == 0) {
scene->r.bake_samples = 256;
@@ -2348,10 +2349,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (area = screen->areabase.first; area; area = area->next) {
for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
-
- if (!ELEM(so->outlinevis, SO_SCENES, SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API)) {
- so->outlinevis = SO_SCENES;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+
+ if (!ELEM(space_outliner->outlinevis,
+ SO_SCENES,
+ SO_LIBRARIES,
+ SO_SEQUENCE,
+ SO_DATA_API)) {
+ space_outliner->outlinevis = SO_SCENES;
}
}
}
@@ -2442,13 +2447,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
Sequence *seq;
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
if (seq->type == SEQ_TYPE_WIPE) {
WipeVars *wv = seq->effectdata;
wv->angle = DEG2RADF(wv->angle);
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
@@ -2520,7 +2525,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (cu = bmain->curves.first; cu; cu = cu->id.next) {
if (cu->str) {
- cu->len_wchar = BLI_strlen_utf8(cu->str);
+ cu->len_char32 = BLI_strlen_utf8(cu->str);
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 521fc4b9b82..2452ac43bd4 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -242,7 +242,7 @@ static void do_version_action_editor_properties_region(ListBase *regionbase)
/* already exists */
return;
}
- else if (region->regiontype == RGN_TYPE_WINDOW) {
+ if (region->regiontype == RGN_TYPE_WINDOW) {
/* add new region here */
ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
@@ -377,9 +377,8 @@ static char *replace_bbone_easing_rnapath(char *old_path)
MEM_freeN(old_path);
return new_path;
}
- else {
- return old_path;
- }
+
+ return old_path;
}
static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),
@@ -421,6 +420,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),
}
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
if (!MAIN_VERSION_ATLEAST(bmain, 270, 0)) {
@@ -891,17 +891,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
-
- /* hysteresis set to 10% but not activated */
- if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
- level->obhysteresis = 10;
- }
- }
- }
}
if (!MAIN_VERSION_ATLEAST(bmain, 274, 4)) {
@@ -924,7 +913,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
srv = scene->r.views.last;
BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
@@ -940,7 +929,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE
}
- SEQ_END;
+ SEQ_ALL_END;
}
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
@@ -1108,7 +1097,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
BKE_curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(curve_mapping);
+ BKE_curvemapping_init(curve_mapping);
BKE_curvemap_reset(
curve_mapping->cm, &curve_mapping->clipr, CURVE_PRESET_MAX, CURVEMAP_SLOPE_POS_NEG);
}
@@ -1225,7 +1214,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
Sequence *seq;
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
if (seq->type != SEQ_TYPE_TEXT) {
continue;
}
@@ -1241,7 +1230,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
data->shadow_color[3] = 1.0f;
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
/* Adding "Properties" region to DopeSheet */
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 51df61143e0..2434d9e9f74 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -190,7 +190,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene)
{
SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION);
- SpaceAction *saction = (SpaceAction *)stype->new (area, scene);
+ SpaceAction *saction = (SpaceAction *)stype->create(area, scene);
ARegion *region_channels;
/* Properly free current regions */
@@ -1201,7 +1201,7 @@ static void do_version_fcurve_hide_viewport_fix(struct ID *UNUSED(id),
struct FCurve *fcu,
void *UNUSED(user_data))
{
- if (strcmp(fcu->rna_path, "hide")) {
+ if (!STREQ(fcu->rna_path, "hide")) {
return;
}
@@ -1282,20 +1282,20 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
if (space->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soutliner = (SpaceOutliner *)space;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)space;
- soutliner->outlinevis = SO_VIEW_LAYER;
+ space_outliner->outlinevis = SO_VIEW_LAYER;
if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) {
- if (soutliner->treestore == NULL) {
- soutliner->treestore = BLI_mempool_create(
+ if (space_outliner->treestore == NULL) {
+ space_outliner->treestore = BLI_mempool_create(
sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
}
/* Create a tree store element for the collection. This is normally
* done in check_persistent (outliner_tree.c), but we need to access
* it here :/ (expand element if it's the only one) */
- TreeStoreElem *tselem = BLI_mempool_calloc(soutliner->treestore);
+ TreeStoreElem *tselem = BLI_mempool_calloc(space_outliner->treestore);
tselem->type = TSE_LAYER_COLLECTION;
tselem->id = layer->layer_collections.first;
tselem->nr = tselem->used = 0;
@@ -1792,6 +1792,7 @@ static void do_versions_seq_set_cache_defaults(Editing *ed)
ed->recycle_max_cost = 10.0f;
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
bool use_collection_compat_28 = true;
@@ -1958,7 +1959,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if ((gset) && (gset->cur_falloff == NULL)) {
gset->cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(gset->cur_falloff);
+ BKE_curvemapping_init(gset->cur_falloff);
BKE_curvemap_reset(gset->cur_falloff->cm,
&gset->cur_falloff->clipr,
CURVE_PRESET_GAUSS,
@@ -2024,15 +2025,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (area = screen->areabase.first; area; area = area->next) {
for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- if (!ELEM(so->outlinevis,
+ if (!ELEM(space_outliner->outlinevis,
SO_SCENES,
SO_LIBRARIES,
SO_SEQUENCE,
SO_DATA_API,
SO_ID_ORPHANS)) {
- so->outlinevis = SO_VIEW_LAYER;
+ space_outliner->outlinevis = SO_VIEW_LAYER;
}
}
}
@@ -2412,9 +2413,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
- soops->filter_id_type = ID_GR;
- soops->outlinevis = SO_VIEW_LAYER;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->filter_id_type = ID_GR;
+ space_outliner->outlinevis = SO_VIEW_LAYER;
}
}
}
@@ -3341,7 +3342,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256);
+ memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char[256]));
}
}
}
@@ -3371,7 +3372,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if ((gset) && (gset->cur_primitive == NULL)) {
gset->cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(gset->cur_primitive);
+ BKE_curvemapping_init(gset->cur_primitive);
BKE_curvemap_reset(gset->cur_primitive->cm,
&gset->cur_primitive->clipr,
CURVE_PRESET_BELL,
@@ -3411,9 +3412,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
break;
}
case SPACE_OUTLINER: {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- so->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 | SO_FILTER_UNUSED_12);
- so->storeflag &= ~(SO_TREESTORE_UNUSED_1);
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 |
+ SO_FILTER_UNUSED_12);
+ space_outliner->storeflag &= ~(SO_TREESTORE_UNUSED_1);
break;
}
case SPACE_FILE: {
@@ -3461,7 +3463,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (scene->ed) {
Sequence *seq;
- SEQ_BEGIN (scene->ed, seq) {
+ SEQ_ALL_BEGIN (scene->ed, seq) {
seq->flag &= ~(SEQ_FLAG_UNUSED_6 | SEQ_FLAG_UNUSED_18 | SEQ_FLAG_UNUSED_19 |
SEQ_FLAG_UNUSED_21);
if (seq->type == SEQ_TYPE_SPEED) {
@@ -3469,7 +3471,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
s->flags &= ~(SEQ_SPEED_UNUSED_1);
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
}
@@ -4027,9 +4029,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (sl->spacetype != SPACE_OUTLINER) {
continue;
}
- SpaceOutliner *so = (SpaceOutliner *)sl;
- so->filter &= ~SO_FLAG_UNUSED_1;
- so->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->filter &= ~SO_FLAG_UNUSED_1;
+ space_outliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
}
}
}
@@ -4161,9 +4163,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
/* Mark outliners as dirty for syncing and enable synced selection */
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soutliner = (SpaceOutliner *)sl;
- soutliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
- soutliner->flag |= SO_SYNC_SELECT;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
+ space_outliner->flag |= SO_SYNC_SELECT;
}
}
}
@@ -4767,7 +4769,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4778,7 +4780,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4788,7 +4790,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4798,7 +4800,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4808,7 +4810,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index aef2a59580c..00214c16eb0 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -22,9 +22,11 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
+#include "DNA_cachefile_types.h"
#include "DNA_constraint_types.h"
#include "DNA_genfile.h"
#include "DNA_gpencil_modifier_types.h"
@@ -206,6 +208,17 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 291, 1)) {
+ LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
+ if (BKE_collection_cycles_fix(bmain, collection)) {
+ printf(
+ "WARNING: Cycle detected in collection '%s', fixed as best as possible.\n"
+ "You may have to reconstruct your View Layers...\n",
+ collection->id.name);
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -217,18 +230,26 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
* \note Keep this message at the bottom of the function.
*/
{
- LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
- if (BKE_collection_cycles_fix(bmain, collection)) {
- printf(
- "WARNING: Cycle detected in collection '%s', fixed as best as possible.\n"
- "You may have to reconstruct your View Layers...\n",
- collection->id.name);
- }
- }
+
/* Keep this block, even when empty. */
}
}
+static void panels_remove_x_closed_flag_recursive(Panel *panel)
+{
+ const bool was_closed_x = panel->flag & PNL_UNUSED_1;
+ const bool was_closed_y = panel->flag & PNL_CLOSED; /* That value was the Y closed flag. */
+
+ SET_FLAG_FROM_TEST(panel->flag, was_closed_x || was_closed_y, PNL_CLOSED);
+
+ /* Clear the old PNL_CLOSEDX flag. */
+ panel->flag &= ~PNL_UNUSED_1;
+
+ LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
+ panels_remove_x_closed_flag_recursive(child_panel);
+ }
+}
+
void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
UNUSED_VARS(fd);
@@ -407,17 +428,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /**
- * Versioning code until next subversion bump goes here.
- *
- * \note Be sure to check when bumping the version:
- * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
- * - "versioning_userdef.c", #do_versions_theme
- *
- * \note Keep this message at the bottom of the function.
- */
- {
- /* Keep this block, even when empty. */
+ if (!MAIN_VERSION_ATLEAST(bmain, 291, 1)) {
/* Initialize additional parameter of the Nishita sky model and change altitude unit. */
if (!DNA_struct_elem_find(fd->filesdna, "NodeTexSky", "float", "sun_intensity")) {
@@ -448,5 +459,63 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Initialise additional velocity parameter for CacheFiles. */
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "MeshSeqCacheModifierData", "float", "velocity_scale")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
+ if (md->type == eModifierType_MeshSequenceCache) {
+ MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
+ mcmd->velocity_scale = 1.0f;
+ mcmd->vertex_velocities = NULL;
+ mcmd->num_vertices = 0;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "CacheFile", "char", "velocity_unit")) {
+ for (CacheFile *cache_file = bmain->cachefiles.first; cache_file != NULL;
+ cache_file = cache_file->id.next) {
+ BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
+ cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "OceanModifierData", "int", "viewport_resolution")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
+ if (md->type == eModifierType_Ocean) {
+ OceanModifierData *omd = (OceanModifierData *)md;
+ omd->viewport_resolution = omd->resolution;
+ }
+ }
+ }
+ }
+
+ /* Remove panel X axis collapsing, a remnant of horizontal panel alignment. */
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+ LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+ panels_remove_x_closed_flag_recursive(panel);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Versioning code until next subversion bump goes here.
+ *
+ * \note Be sure to check when bumping the version:
+ * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
+ * - "versioning_userdef.c", #do_versions_theme
+ *
+ * \note Keep this message at the bottom of the function.
+ */
+ {
+ /* Keep this block, even when empty. */
}
}
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
index 46faddf6e5a..26329fca6fa 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -1447,7 +1447,7 @@ void do_versions_after_linking_cycles(Main *bmain)
if (is_fstop) {
continue;
}
- else if (aperture_size > 0.0f) {
+ if (aperture_size > 0.0f) {
if (camera->type == CAM_ORTHO) {
camera->dof.aperture_fstop = 1.0f / (2.0f * aperture_size);
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 7f75c0100b8..b4bee9a3c7e 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -106,7 +106,7 @@ static void blo_update_defaults_screen(bScreen *screen,
/* Some toolbars have been saved as initialized,
* we don't want them to have odd zoom-level or scrolling set, see: T47047 */
if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
- region->v2d.flag &= ~V2D_IS_INITIALISED;
+ region->v2d.flag &= ~V2D_IS_INIT;
}
}
@@ -174,7 +174,7 @@ static void blo_update_defaults_screen(bScreen *screen,
}
else if (area->spacetype == SPACE_SEQ) {
SpaceSeq *seq = area->spacedata.first;
- seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES;
+ seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES | SEQ_ZOOM_TO_FIT;
}
else if (area->spacetype == SPACE_TEXT) {
/* Show syntax and line numbers in Script workspace text editor. */
@@ -326,7 +326,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
if (ts->gp_sculpt.cur_falloff == NULL) {
ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
- BKE_curvemapping_initialize(gp_falloff_curve);
+ BKE_curvemapping_init(gp_falloff_curve);
BKE_curvemap_reset(gp_falloff_curve->cm,
&gp_falloff_curve->clipr,
CURVE_PRESET_GAUSS,
@@ -335,7 +335,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
if (ts->gp_sculpt.cur_primitive == NULL) {
ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive;
- BKE_curvemapping_initialize(gp_primitive_curve);
+ BKE_curvemapping_init(gp_primitive_curve);
BKE_curvemap_reset(gp_primitive_curve->cm,
&gp_primitive_curve->clipr,
CURVE_PRESET_BELL,
@@ -698,6 +698,14 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
brush->sculpt_tool = SCULPT_TOOL_SMEAR;
}
+ brush_name = "Boundary";
+ brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
+ if (!brush) {
+ brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
+ id_us_min(&brush->id);
+ brush->sculpt_tool = SCULPT_TOOL_BOUNDARY;
+ }
+
brush_name = "Simplify";
brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
if (!brush) {
@@ -714,6 +722,14 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
brush->sculpt_tool = SCULPT_TOOL_DRAW_FACE_SETS;
}
+ brush_name = "Multires Displacement Eraser";
+ brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
+ if (!brush) {
+ brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
+ id_us_min(&brush->id);
+ brush->sculpt_tool = SCULPT_TOOL_DISPLACEMENT_ERASER;
+ }
+
/* Use the same tool icon color in the brush cursor */
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
if (brush->ob_mode & OB_MODE_SCULPT) {
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 44c7c35e47d..58d57f12b8f 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -102,7 +102,7 @@ static void vcol_to_fcol(Mesh *me)
return;
}
- mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln");
+ mcoln = mcolmain = MEM_malloc_arrayN(me->totface, sizeof(int[4]), "mcoln");
mcol = (uint *)me->mcol;
mface = me->mface;
for (a = me->totface; a > 0; a--, mface++) {
@@ -493,6 +493,7 @@ void blo_do_version_old_trackto_to_constraints(Object *ob)
ob->track = NULL;
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -1250,12 +1251,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
while (sce) {
ed = sce->ed;
if (ed) {
- SEQ_BEGIN (sce->ed, seq) {
+ SEQ_ALL_BEGIN (sce->ed, seq) {
if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE) {
seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
sce = sce->id.next;
@@ -2096,7 +2097,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (la->curfalloff == NULL) {
la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- BKE_curvemapping_initialize(la->curfalloff);
+ BKE_curvemapping_init(la->curfalloff);
}
}
}
@@ -2441,12 +2442,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Sequence *seq;
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- SEQ_BEGIN (sce->ed, seq) {
+ SEQ_ALL_BEGIN (sce->ed, seq) {
if (seq->blend_mode == 0) {
seq->blend_opacity = 100.0f;
}
}
- SEQ_END;
+ SEQ_ALL_END;
}
}
@@ -2594,12 +2595,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
while (sce) {
ed = sce->ed;
if (ed) {
- SEQP_BEGIN (ed, seq) {
+ SEQ_CURRENT_BEGIN (ed, seq) {
if (seq->strip && seq->strip->proxy) {
seq->strip->proxy->quality = 90;
}
}
- SEQ_END;
+ SEQ_CURRENT_END;
}
sce = sce->id.next;
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index ec631eb64f3..d04907872b7 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -228,6 +228,11 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
*/
{
/* Keep this block, even when empty. */
+
+ /* The new defaults for the file browser theme are the same as
+ * the outliner's, and it's less disruptive to just copy them. */
+ copy_v4_v4_uchar(btheme->space_file.back, btheme->space_outliner.back);
+ copy_v4_v4_uchar(btheme->space_file.row_alternate, btheme->space_outliner.row_alternate);
}
#undef FROM_DEFAULT_V4_UCHAR
@@ -367,7 +372,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
}
if (!USER_VERSION_ATLEAST(250, 0)) {
/* adjust grease-pencil distances */
- userdef->gp_manhattendist = 1;
+ userdef->gp_manhattandist = 1;
userdef->gp_euclideandist = 2;
/* adjust default interpolation for new IPO-curves */
@@ -758,6 +763,12 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->statusbar_flag = STATUSBAR_SHOW_VERSION;
}
+ if (!USER_VERSION_ATLEAST(291, 1)) {
+ if (userdef->collection_instance_empty_size == 0) {
+ userdef->collection_instance_empty_size = 1.0f;
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -769,10 +780,6 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
*/
{
/* Keep this block, even when empty. */
-
- if (userdef->collection_instance_empty_size == 0) {
- userdef->collection_instance_empty_size = 1.0f;
- }
}
if (userdef->pixelsize == 0.0f) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 6f9f3eec31d..6ce822a09c1 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -152,6 +152,7 @@
#include "MEM_guardedalloc.h" // MEM_freeN
#include "BKE_action.h"
+#include "BKE_anim_data.h"
#include "BKE_armature.h"
#include "BKE_blender_version.h"
#include "BKE_bpath.h"
@@ -164,6 +165,7 @@
#include "BKE_fcurve_driver.h"
#include "BKE_global.h" // for G
#include "BKE_gpencil_modifier.h"
+#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
@@ -241,9 +243,8 @@ static bool ww_open_none(WriteWrap *ww, const char *filepath)
FILE_HANDLE(ww) = file;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static bool ww_close_none(WriteWrap *ww)
{
@@ -268,9 +269,8 @@ static bool ww_open_zlib(WriteWrap *ww, const char *filepath)
FILE_HANDLE(ww) = file;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static bool ww_close_zlib(WriteWrap *ww)
{
@@ -658,86 +658,11 @@ static void writelist_id(WriteData *wd, int filecode, const char *structname, co
* These functions are used by blender's .blend system for file saving/loading.
* \{ */
-void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer);
-void IDP_WriteProperty(const IDProperty *prop, BlendWriter *writer);
-
-static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer)
-{
- /*REMEMBER to set totalen to len in the linking code!!*/
- if (prop->data.pointer) {
- BLO_write_raw(writer, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
-
- if (prop->subtype == IDP_GROUP) {
- IDProperty **array = prop->data.pointer;
- int a;
-
- for (a = 0; a < prop->len; a++) {
- IDP_WriteProperty(array[a], writer);
- }
- }
- }
-}
-
-static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer)
-{
- /*REMEMBER to set totalen to len in the linking code!!*/
- if (prop->data.pointer) {
- const IDProperty *array = prop->data.pointer;
- int a;
-
- BLO_write_struct_array(writer, IDProperty, prop->len, array);
-
- for (a = 0; a < prop->len; a++) {
- IDP_WriteProperty_OnlyData(&array[a], writer);
- }
- }
-}
-
-static void IDP_WriteString(const IDProperty *prop, BlendWriter *writer)
-{
- /*REMEMBER to set totalen to len in the linking code!!*/
- BLO_write_raw(writer, prop->len, prop->data.pointer);
-}
-
-static void IDP_WriteGroup(const IDProperty *prop, BlendWriter *writer)
-{
- IDProperty *loop;
-
- for (loop = prop->data.group.first; loop; loop = loop->next) {
- IDP_WriteProperty(loop, writer);
- }
-}
-
-/* Functions to read/write ID Properties */
-void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer)
-{
- switch (prop->type) {
- case IDP_GROUP:
- IDP_WriteGroup(prop, writer);
- break;
- case IDP_STRING:
- IDP_WriteString(prop, writer);
- break;
- case IDP_ARRAY:
- IDP_WriteArray(prop, writer);
- break;
- case IDP_IDPARRAY:
- IDP_WriteIDPArray(prop, writer);
- break;
- }
-}
-
-void IDP_WriteProperty(const IDProperty *prop, BlendWriter *writer)
-{
- BLO_write_struct(writer, IDProperty, prop);
- IDP_WriteProperty_OnlyData(prop, writer);
-}
-
static void write_iddata(BlendWriter *writer, ID *id)
{
/* ID_WM's id->properties are considered runtime only, and never written in .blend file. */
if (id->properties && !ELEM(GS(id->name), ID_WM)) {
- IDP_WriteProperty(id->properties, writer);
+ IDP_BlendWrite(writer, id->properties);
}
if (id->override_library) {
@@ -784,107 +709,13 @@ static void write_previews(BlendWriter *writer, const PreviewImage *prv_orig)
}
}
-static void write_fmodifiers(BlendWriter *writer, ListBase *fmodifiers)
-{
- FModifier *fcm;
-
- /* Write all modifiers first (for faster reloading) */
- BLO_write_struct_list(writer, FModifier, fmodifiers);
-
- /* Modifiers */
- for (fcm = fmodifiers->first; fcm; fcm = fcm->next) {
- const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
-
- /* Write the specific data */
- if (fmi && fcm->data) {
- /* firstly, just write the plain fmi->data struct */
- BLO_write_struct_by_name(writer, fmi->structName, fcm->data);
-
- /* do any modifier specific stuff */
- switch (fcm->type) {
- case FMODIFIER_TYPE_GENERATOR: {
- FMod_Generator *data = fcm->data;
-
- /* write coefficients array */
- if (data->coefficients) {
- BLO_write_float_array(writer, data->arraysize, data->coefficients);
- }
-
- break;
- }
- case FMODIFIER_TYPE_ENVELOPE: {
- FMod_Envelope *data = fcm->data;
-
- /* write envelope data */
- if (data->data) {
- BLO_write_struct_array(writer, FCM_EnvelopeData, data->totvert, data->data);
- }
-
- break;
- }
- case FMODIFIER_TYPE_PYTHON: {
- FMod_Python *data = fcm->data;
-
- /* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- IDP_WriteProperty(data->prop, writer);
-
- break;
- }
- }
- }
- }
-}
-
-static void write_fcurves(BlendWriter *writer, ListBase *fcurves)
-{
- FCurve *fcu;
-
- BLO_write_struct_list(writer, FCurve, fcurves);
- for (fcu = fcurves->first; fcu; fcu = fcu->next) {
- /* curve data */
- if (fcu->bezt) {
- BLO_write_struct_array(writer, BezTriple, fcu->totvert, fcu->bezt);
- }
- if (fcu->fpt) {
- BLO_write_struct_array(writer, FPoint, fcu->totvert, fcu->fpt);
- }
-
- if (fcu->rna_path) {
- BLO_write_string(writer, fcu->rna_path);
- }
-
- /* driver data */
- if (fcu->driver) {
- ChannelDriver *driver = fcu->driver;
- DriverVar *dvar;
-
- BLO_write_struct(writer, ChannelDriver, driver);
-
- /* variables */
- BLO_write_struct_list(writer, DriverVar, &driver->variables);
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
- if (dtar->rna_path) {
- BLO_write_string(writer, dtar->rna_path);
- }
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
-
- /* write F-Modifiers */
- write_fmodifiers(writer, &fcu->modifiers);
- }
-}
-
static void write_action(BlendWriter *writer, bAction *act, const void *id_address)
{
if (act->id.us > 0 || BLO_write_is_undo(writer)) {
BLO_write_id_struct(writer, bAction, id_address, &act->id);
write_iddata(writer, &act->id);
- write_fcurves(writer, &act->curves);
+ BKE_fcurve_blend_write(writer, &act->curves);
LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
BLO_write_struct(writer, bActionGroup, grp);
@@ -898,15 +729,12 @@ static void write_action(BlendWriter *writer, bAction *act, const void *id_addre
static void write_keyingsets(BlendWriter *writer, ListBase *list)
{
- KeyingSet *ks;
- KS_Path *ksp;
-
- for (ks = list->first; ks; ks = ks->next) {
+ LISTBASE_FOREACH (KeyingSet *, ks, list) {
/* KeyingSet */
BLO_write_struct(writer, KeyingSet, ks);
/* Paths */
- for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
/* Path */
BLO_write_struct(writer, KS_Path, ksp);
@@ -917,59 +745,6 @@ static void write_keyingsets(BlendWriter *writer, ListBase *list)
}
}
-static void write_nlastrips(BlendWriter *writer, ListBase *strips)
-{
- NlaStrip *strip;
-
- BLO_write_struct_list(writer, NlaStrip, strips);
- for (strip = strips->first; strip; strip = strip->next) {
- /* write the strip's F-Curves and modifiers */
- write_fcurves(writer, &strip->fcurves);
- write_fmodifiers(writer, &strip->modifiers);
-
- /* write the strip's children */
- write_nlastrips(writer, &strip->strips);
- }
-}
-
-static void write_nladata(BlendWriter *writer, ListBase *nlabase)
-{
- NlaTrack *nlt;
-
- /* write all the tracks */
- for (nlt = nlabase->first; nlt; nlt = nlt->next) {
- /* write the track first */
- BLO_write_struct(writer, NlaTrack, nlt);
-
- /* write the track's strips */
- write_nlastrips(writer, &nlt->strips);
- }
-}
-
-static void write_animdata(BlendWriter *writer, AnimData *adt)
-{
- AnimOverride *aor;
-
- /* firstly, just write the AnimData block */
- BLO_write_struct(writer, AnimData, adt);
-
- /* write drivers */
- write_fcurves(writer, &adt->drivers);
-
- /* write overrides */
- // FIXME: are these needed?
- for (aor = adt->overrides.first; aor; aor = aor->next) {
- /* overrides consist of base data + rna_path */
- BLO_write_struct(writer, AnimOverride, aor);
- BLO_write_string(writer, aor->rna_path);
- }
-
- // TODO write the remaps (if they are needed)
-
- /* write NLA data */
- write_nladata(writer, &adt->nla_tracks);
-}
-
static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *sock)
{
if (sock->default_value == NULL) {
@@ -1019,7 +794,7 @@ static void write_node_socket(BlendWriter *writer, bNodeSocket *sock)
BLO_write_struct(writer, bNodeSocket, sock);
if (sock->prop) {
- IDP_WriteProperty(sock->prop, writer);
+ IDP_BlendWrite(writer, sock->prop);
}
write_node_socket_default_value(writer, sock);
@@ -1030,7 +805,7 @@ static void write_node_socket_interface(BlendWriter *writer, bNodeSocket *sock)
BLO_write_struct(writer, bNodeSocket, sock);
if (sock->prop) {
- IDP_WriteProperty(sock->prop, writer);
+ IDP_BlendWrite(writer, sock->prop);
}
write_node_socket_default_value(writer, sock);
@@ -1038,31 +813,27 @@ static void write_node_socket_interface(BlendWriter *writer, bNodeSocket *sock)
/* this is only direct data, tree itself should have been written */
static void write_nodetree_nolib(BlendWriter *writer, bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
- bNodeLink *link;
-
/* for link_list() speed, we write per list */
if (ntree->adt) {
- write_animdata(writer, ntree->adt);
+ BKE_animdata_blend_write(writer, ntree->adt);
}
- for (node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
BLO_write_struct(writer, bNode, node);
if (node->prop) {
- IDP_WriteProperty(node->prop, writer);
+ IDP_BlendWrite(writer, node->prop);
}
- for (sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
write_node_socket(writer, sock);
}
- for (sock = node->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
write_node_socket(writer, sock);
}
- for (link = node->internal_links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &node->internal_links) {
BLO_write_struct(writer, bNodeLink, link);
}
@@ -1126,26 +897,26 @@ static void write_nodetree_nolib(BlendWriter *writer, bNodeTree *ntree)
if (node->type == CMP_NODE_OUTPUT_FILE) {
/* inputs have own storage data */
- for (sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
BLO_write_struct(writer, NodeImageMultiFileSocket, sock->storage);
}
}
if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
/* write extra socket info */
- for (sock = node->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
BLO_write_struct(writer, NodeImageLayer, sock->storage);
}
}
}
- for (link = ntree->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
BLO_write_struct(writer, bNodeLink, link);
}
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) {
write_node_socket_interface(writer, sock);
}
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
write_node_socket_interface(writer, sock);
}
}
@@ -1207,15 +978,15 @@ typedef struct RenderInfo {
static void write_renderinfo(WriteData *wd, Main *mainvar)
{
bScreen *curscreen;
- Scene *sce, *curscene = NULL;
+ Scene *curscene = NULL;
ViewLayer *view_layer;
- RenderInfo data;
/* XXX in future, handle multiple windows with multiple screens? */
current_screen_compat(mainvar, false, &curscreen, &curscene, &view_layer);
- for (sce = mainvar->scenes.first; sce; sce = sce->id.next) {
+ LISTBASE_FOREACH (Scene *, sce, &mainvar->scenes) {
if (sce->id.lib == NULL && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
+ RenderInfo data;
data.sfra = sce->r.sfra;
data.efra = sce->r.efra;
memset(data.scene_name, 0, sizeof(data.scene_name));
@@ -1231,7 +1002,7 @@ static void write_keymapitem(BlendWriter *writer, const wmKeyMapItem *kmi)
{
BLO_write_struct(writer, wmKeyMapItem, kmi);
if (kmi->properties) {
- IDP_WriteProperty(kmi->properties, writer);
+ IDP_BlendWrite(writer, kmi->properties);
}
}
@@ -1264,7 +1035,7 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef)
LISTBASE_FOREACH (const wmKeyConfigPref *, kpt, &userdef->user_keyconfig_prefs) {
BLO_write_struct(writer, wmKeyConfigPref, kpt);
if (kpt->prop) {
- IDP_WriteProperty(kpt->prop, writer);
+ IDP_BlendWrite(writer, kpt->prop);
}
}
@@ -1275,7 +1046,7 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef)
const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi;
BLO_write_struct(writer, bUserMenuItem_Op, umi_op);
if (umi_op->prop) {
- IDP_WriteProperty(umi_op->prop, writer);
+ IDP_BlendWrite(writer, umi_op->prop);
}
}
else if (umi->type == USER_MENU_TYPE_MENU) {
@@ -1295,7 +1066,7 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef)
LISTBASE_FOREACH (const bAddon *, bext, &userdef->addons) {
BLO_write_struct(writer, bAddon, bext);
if (bext->prop) {
- IDP_WriteProperty(bext->prop, writer);
+ IDP_BlendWrite(writer, bext->prop);
}
}
@@ -1310,11 +1081,9 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef)
static void write_boid_state(BlendWriter *writer, BoidState *state)
{
- BoidRule *rule = state->rules.first;
-
BLO_write_struct(writer, BoidState, state);
- for (; rule; rule = rule->next) {
+ LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
switch (rule->type) {
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid:
@@ -1363,21 +1132,14 @@ static const char *ptcache_extra_struct[] = {
};
static void write_pointcaches(BlendWriter *writer, ListBase *ptcaches)
{
- PointCache *cache = ptcaches->first;
- int i;
-
- for (; cache; cache = cache->next) {
+ LISTBASE_FOREACH (PointCache *, cache, ptcaches) {
BLO_write_struct(writer, PointCache, cache);
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
- PTCacheMem *pm = cache->mem_cache.first;
-
- for (; pm; pm = pm->next) {
- PTCacheExtra *extra = pm->extradata.first;
-
+ LISTBASE_FOREACH (PTCacheMem *, pm, &cache->mem_cache) {
BLO_write_struct(writer, PTCacheMem, pm);
- for (i = 0; i < BPHYS_TOT_DATA; i++) {
+ for (int i = 0; i < BPHYS_TOT_DATA; i++) {
if (pm->data[i] && pm->data_types & (1 << i)) {
if (ptcache_data_struct[i][0] == '\0') {
BLO_write_raw(writer, MEM_allocN_len(pm->data[i]), pm->data[i]);
@@ -1389,7 +1151,7 @@ static void write_pointcaches(BlendWriter *writer, ListBase *ptcaches)
}
}
- for (; extra; extra = extra->next) {
+ LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
if (ptcache_extra_struct[extra->type][0] == '\0') {
continue;
}
@@ -1412,7 +1174,7 @@ static void write_particlesettings(BlendWriter *writer,
write_iddata(writer, &part->id);
if (part->adt) {
- write_animdata(writer, part->adt);
+ BKE_animdata_blend_write(writer, part->adt);
}
BLO_write_struct(writer, PartDeflect, part->pd);
BLO_write_struct(writer, PartDeflect, part->pd2);
@@ -1466,11 +1228,7 @@ static void write_particlesettings(BlendWriter *writer,
static void write_particlesystems(BlendWriter *writer, ListBase *particles)
{
- ParticleSystem *psys = particles->first;
- ParticleTarget *pt;
- int a;
-
- for (; psys; psys = psys->next) {
+ LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
BLO_write_struct(writer, ParticleSystem, psys);
if (psys->particles) {
@@ -1479,7 +1237,7 @@ static void write_particlesystems(BlendWriter *writer, ListBase *particles)
if (psys->particles->hair) {
ParticleData *pa = psys->particles;
- for (a = 0; a < psys->totpart; a++, pa++) {
+ for (int a = 0; a < psys->totpart; a++, pa++) {
BLO_write_struct_array(writer, HairKey, pa->totkey, pa->hair);
}
}
@@ -1494,8 +1252,7 @@ static void write_particlesystems(BlendWriter *writer, ListBase *particles)
writer, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
}
}
- pt = psys->targets.first;
- for (; pt; pt = pt->next) {
+ LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
BLO_write_struct(writer, ParticleTarget, pt);
}
@@ -1529,9 +1286,7 @@ static void write_motionpath(BlendWriter *writer, bMotionPath *mpath)
static void write_constraints(BlendWriter *writer, ListBase *conlist)
{
- bConstraint *con;
-
- for (con = conlist->first; con; con = con->next) {
+ LISTBASE_FOREACH (bConstraint *, con, conlist) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
/* Write the specific data */
@@ -1543,25 +1298,23 @@ static void write_constraints(BlendWriter *writer, ListBase *conlist)
switch (con->type) {
case CONSTRAINT_TYPE_PYTHON: {
bPythonConstraint *data = con->data;
- bConstraintTarget *ct;
/* write targets */
- for (ct = data->targets.first; ct; ct = ct->next) {
+ LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
BLO_write_struct(writer, bConstraintTarget, ct);
}
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
- IDP_WriteProperty(data->prop, writer);
+ IDP_BlendWrite(writer, data->prop);
break;
}
case CONSTRAINT_TYPE_ARMATURE: {
bArmatureConstraint *data = con->data;
- bConstraintTarget *ct;
/* write targets */
- for (ct = data->targets.first; ct; ct = ct->next) {
+ LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
BLO_write_struct(writer, bConstraintTarget, ct);
}
@@ -1585,9 +1338,6 @@ static void write_constraints(BlendWriter *writer, ListBase *conlist)
static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm)
{
- bPoseChannel *chan;
- bActionGroup *grp;
-
/* Write each channel */
if (pose == NULL) {
return;
@@ -1596,11 +1346,11 @@ static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm)
BLI_assert(arm != NULL);
/* Write channels */
- for (chan = pose->chanbase.first; chan; chan = chan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
if (chan->prop) {
- IDP_WriteProperty(chan->prop, writer);
+ IDP_BlendWrite(writer, chan->prop);
}
write_constraints(writer, &chan->constraints);
@@ -1622,7 +1372,7 @@ static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm)
}
/* Write groups */
- for (grp = pose->agroups.first; grp; grp = grp->next) {
+ LISTBASE_FOREACH (bActionGroup *, grp, &pose->agroups) {
BLO_write_struct(writer, bActionGroup, grp);
}
@@ -1654,13 +1404,11 @@ static void write_fmaps(BlendWriter *writer, ListBase *fbase)
static void write_modifiers(BlendWriter *writer, ListBase *modbase)
{
- ModifierData *md;
-
if (modbase == NULL) {
return;
}
- for (md = modbase->first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, modbase) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
if (mti == NULL) {
return;
@@ -1719,15 +1467,14 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase)
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
- DynamicPaintSurface *surface;
BLO_write_struct(writer, DynamicPaintCanvasSettings, pmd->canvas);
/* write surfaces */
- for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
BLO_write_struct(writer, DynamicPaintSurface, surface);
}
/* write caches and effector weights */
- for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
write_pointcaches(writer, &(surface->ptcaches));
BLO_write_struct(writer, EffectorWeights, surface->effector_weights);
@@ -1759,13 +1506,11 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase)
static void write_gpencil_modifiers(BlendWriter *writer, ListBase *modbase)
{
- GpencilModifierData *md;
-
if (modbase == NULL) {
return;
}
- for (md = modbase->first; md; md = md->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, md, modbase) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
if (mti == NULL) {
return;
@@ -1826,13 +1571,11 @@ static void write_gpencil_modifiers(BlendWriter *writer, ListBase *modbase)
static void write_shaderfxs(BlendWriter *writer, ListBase *fxbase)
{
- ShaderFxData *fx;
-
if (fxbase == NULL) {
return;
}
- for (fx = fxbase->first; fx; fx = fx->next) {
+ LISTBASE_FOREACH (ShaderFxData *, fx, fxbase) {
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type);
if (fxi == NULL) {
return;
@@ -1853,7 +1596,7 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address
write_iddata(writer, &ob->id);
if (ob->adt) {
- write_animdata(writer, ob->adt);
+ BKE_animdata_blend_write(writer, ob->adt);
}
/* direct data */
@@ -1904,7 +1647,6 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address
write_shaderfxs(writer, &ob->shader_fx);
BLO_write_struct_list(writer, LinkData, &ob->pc_ids);
- BLO_write_struct_list(writer, LodLevel, &ob->lodlevels);
write_previews(writer, ob->preview);
}
@@ -1938,7 +1680,7 @@ static void write_key(BlendWriter *writer, Key *key, const void *id_address)
write_iddata(writer, &key->id);
if (key->adt) {
- write_animdata(writer, key->adt);
+ BKE_animdata_blend_write(writer, key->adt);
}
/* direct data */
@@ -1959,7 +1701,7 @@ static void write_camera(BlendWriter *writer, Camera *cam, const void *id_addres
write_iddata(writer, &cam->id);
if (cam->adt) {
- write_animdata(writer, cam->adt);
+ BKE_animdata_blend_write(writer, cam->adt);
}
LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
@@ -1986,7 +1728,7 @@ static void write_mball(BlendWriter *writer, MetaBall *mb, const void *id_addres
/* direct data */
BLO_write_pointer_array(writer, mb->totcol, mb->mat);
if (mb->adt) {
- write_animdata(writer, mb->adt);
+ BKE_animdata_blend_write(writer, mb->adt);
}
LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) {
@@ -2010,12 +1752,12 @@ static void write_curve(BlendWriter *writer, Curve *cu, const void *id_address)
/* direct data */
BLO_write_pointer_array(writer, cu->totcol, cu->mat);
if (cu->adt) {
- write_animdata(writer, cu->adt);
+ BKE_animdata_blend_write(writer, cu->adt);
}
if (cu->vfont) {
BLO_write_raw(writer, cu->len + 1, cu->str);
- BLO_write_struct_array(writer, CharInfo, cu->len_wchar + 1, cu->strinfo);
+ BLO_write_struct_array(writer, CharInfo, cu->len_char32 + 1, cu->strinfo);
BLO_write_struct_array(writer, TextBox, cu->totbox, cu->tb);
}
else {
@@ -2061,10 +1803,8 @@ static void write_dverts(BlendWriter *writer, int count, MDeformVert *dvlist)
static void write_mdisps(BlendWriter *writer, int count, MDisps *mdlist, int external)
{
if (mdlist) {
- int i;
-
BLO_write_struct_array(writer, MDisps, count, mdlist);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
MDisps *md = &mdlist[i];
if (md->disps) {
if (!external) {
@@ -2082,10 +1822,8 @@ static void write_mdisps(BlendWriter *writer, int count, MDisps *mdlist, int ext
static void write_grid_paint_mask(BlendWriter *writer, int count, GridPaintMask *grid_paint_mask)
{
if (grid_paint_mask) {
- int i;
-
BLO_write_struct_array(writer, GridPaintMask, count, grid_paint_mask);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
GridPaintMask *gpm = &grid_paint_mask[i];
if (gpm->data) {
const int gridsize = BKE_ccg_gridsize(gpm->level);
@@ -2102,8 +1840,6 @@ static void write_customdata(BlendWriter *writer,
CustomDataLayer *layers,
CustomDataMask cddata_mask)
{
- int i;
-
/* write external customdata (not for undo) */
if (data->external && !BLO_write_is_undo(writer)) {
CustomData_external_write(data, id, cddata_mask, count, 0);
@@ -2111,7 +1847,7 @@ static void write_customdata(BlendWriter *writer,
BLO_write_struct_array_at_address(writer, CustomDataLayer, data->totlayer, data->layers, layers);
- for (i = 0; i < data->totlayer; i++) {
+ for (int i = 0; i < data->totlayer; i++) {
CustomDataLayer *layer = &layers[i];
const char *structname;
int structnum, datasize;
@@ -2187,7 +1923,7 @@ static void write_mesh(BlendWriter *writer, Mesh *mesh, const void *id_address)
/* direct data */
if (mesh->adt) {
- write_animdata(writer, mesh->adt);
+ BKE_animdata_blend_write(writer, mesh->adt);
}
BLO_write_pointer_array(writer, mesh->totcol, mesh->mat);
@@ -2232,7 +1968,7 @@ static void write_lattice(BlendWriter *writer, Lattice *lt, const void *id_addre
/* write animdata */
if (lt->adt) {
- write_animdata(writer, lt->adt);
+ BKE_animdata_blend_write(writer, lt->adt);
}
/* direct data */
@@ -2290,7 +2026,7 @@ static void write_texture(BlendWriter *writer, Tex *tex, const void *id_address)
write_iddata(writer, &tex->id);
if (tex->adt) {
- write_animdata(writer, tex->adt);
+ BKE_animdata_blend_write(writer, tex->adt);
}
/* direct data */
@@ -2320,7 +2056,7 @@ static void write_material(BlendWriter *writer, Material *ma, const void *id_add
write_iddata(writer, &ma->id);
if (ma->adt) {
- write_animdata(writer, ma->adt);
+ BKE_animdata_blend_write(writer, ma->adt);
}
/* nodetree is integral part of material, no libdata */
@@ -2349,7 +2085,7 @@ static void write_world(BlendWriter *writer, World *wrld, const void *id_address
write_iddata(writer, &wrld->id);
if (wrld->adt) {
- write_animdata(writer, wrld->adt);
+ BKE_animdata_blend_write(writer, wrld->adt);
}
/* nodetree is integral part of world, no libdata */
@@ -2370,7 +2106,7 @@ static void write_light(BlendWriter *writer, Light *la, const void *id_address)
write_iddata(writer, &la->id);
if (la->adt) {
- write_animdata(writer, la->adt);
+ BKE_animdata_blend_write(writer, la->adt);
}
if (la->curfalloff) {
@@ -2420,9 +2156,7 @@ static void write_collection(BlendWriter *writer, Collection *collection, const
static void write_sequence_modifiers(BlendWriter *writer, ListBase *modbase)
{
- SequenceModifierData *smd;
-
- for (smd = modbase->first; smd; smd = smd->next) {
+ LISTBASE_FOREACH (SequenceModifierData *, smd, modbase) {
const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
if (smti) {
@@ -2455,7 +2189,7 @@ static void write_view_settings(BlendWriter *writer, ColorManagedViewSettings *v
static void write_view3dshading(BlendWriter *writer, View3DShading *shading)
{
if (shading->prop) {
- IDP_WriteProperty(shading->prop, writer);
+ IDP_BlendWrite(writer, shading->prop);
}
}
@@ -2482,7 +2216,7 @@ static void write_view_layer(BlendWriter *writer, ViewLayer *view_layer)
BLO_write_struct_list(writer, Base, &view_layer->object_bases);
if (view_layer->id_properties) {
- IDP_WriteProperty(view_layer->id_properties, writer);
+ IDP_BlendWrite(writer, view_layer->id_properties);
}
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
@@ -2543,7 +2277,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
write_iddata(writer, &sce->id);
if (sce->adt) {
- write_animdata(writer, sce->adt);
+ BKE_animdata_blend_write(writer, sce->adt);
}
write_keyingsets(writer, &sce->keyingsets);
@@ -2609,15 +2343,15 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
/* reset write flags too */
- SEQ_BEGIN (ed, seq) {
+ SEQ_ALL_BEGIN (ed, seq) {
if (seq->strip) {
seq->strip->done = false;
}
BLO_write_struct(writer, Sequence, seq);
}
- SEQ_END;
+ SEQ_ALL_END;
- SEQ_BEGIN (ed, seq) {
+ SEQ_ALL_BEGIN (ed, seq) {
if (seq->strip && seq->strip->done == 0) {
/* write strip with 'done' at 0 because readfile */
@@ -2677,12 +2411,12 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
}
if (seq->prop) {
- IDP_WriteProperty(seq->prop, writer);
+ IDP_BlendWrite(writer, seq->prop);
}
write_sequence_modifiers(writer, &seq->modifiers);
}
- SEQ_END;
+ SEQ_ALL_END;
/* new; meta stack too, even when its nasty restore code */
LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
@@ -2700,7 +2434,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
}
}
if (sce->r.ffcodecdata.properties) {
- IDP_WriteProperty(sce->r.ffcodecdata.properties, writer);
+ IDP_BlendWrite(writer, sce->r.ffcodecdata.properties);
}
/* writing dynamic list of TimeMarkers to the blend file */
@@ -2777,7 +2511,7 @@ static void write_gpencil(BlendWriter *writer, bGPdata *gpd, const void *id_addr
write_iddata(writer, &gpd->id);
if (gpd->adt) {
- write_animdata(writer, gpd->adt);
+ BKE_animdata_blend_write(writer, gpd->adt);
}
BLO_write_pointer_array(writer, gpd->totcol, gpd->mat);
@@ -2844,16 +2578,16 @@ static void write_uilist(BlendWriter *writer, uiList *ui_list)
BLO_write_struct(writer, uiList, ui_list);
if (ui_list->properties) {
- IDP_WriteProperty(ui_list->properties, writer);
+ IDP_BlendWrite(writer, ui_list->properties);
}
}
-static void write_soops(BlendWriter *writer, SpaceOutliner *so)
+static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
{
- BLI_mempool *ts = so->treestore;
+ BLI_mempool *ts = space_outliner->treestore;
if (ts) {
- SpaceOutliner so_flat = *so;
+ SpaceOutliner space_outliner_flat = *space_outliner;
int elems = BLI_mempool_len(ts);
/* linearize mempool to array */
@@ -2874,7 +2608,7 @@ static void write_soops(BlendWriter *writer, SpaceOutliner *so)
ts_flat.totelem = elems;
ts_flat.data = data_addr;
- BLO_write_struct(writer, SpaceOutliner, so);
+ BLO_write_struct(writer, SpaceOutliner, space_outliner);
BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
@@ -2882,12 +2616,12 @@ static void write_soops(BlendWriter *writer, SpaceOutliner *so)
MEM_freeN(data);
}
else {
- so_flat.treestore = NULL;
- BLO_write_struct_at_address(writer, SpaceOutliner, so, &so_flat);
+ space_outliner_flat.treestore = NULL;
+ BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
}
}
else {
- BLO_write_struct(writer, SpaceOutliner, so);
+ BLO_write_struct(writer, SpaceOutliner, space_outliner);
}
}
@@ -2963,8 +2697,8 @@ static void write_area_regions(BlendWriter *writer, ScrArea *area)
BLO_write_struct(writer, SpaceSeq, sl);
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- write_soops(writer, so);
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ write_space_outliner(writer, space_outliner);
}
else if (sl->spacetype == SPACE_IMAGE) {
BLO_write_struct(writer, SpaceImage, sl);
@@ -2990,18 +2724,16 @@ static void write_area_regions(BlendWriter *writer, ScrArea *area)
}
else if (sl->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path;
BLO_write_struct(writer, SpaceNode, snode);
- for (path = snode->treepath.first; path; path = path->next) {
+ LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
BLO_write_struct(writer, bNodeTreePath, path);
}
}
else if (sl->spacetype == SPACE_CONSOLE) {
SpaceConsole *con = (SpaceConsole *)sl;
- ConsoleLine *cl;
- for (cl = con->history.first; cl; cl = cl->next) {
+ LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
/* 'len_alloc' is invalid on write, set from 'len' on read */
BLO_write_struct(writer, ConsoleLine, cl);
BLO_write_raw(writer, cl->len + 1, cl->line);
@@ -3105,7 +2837,7 @@ static void write_bone(BlendWriter *writer, Bone *bone)
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
if (bone->prop) {
- IDP_WriteProperty(bone->prop, writer);
+ IDP_BlendWrite(writer, bone->prop);
}
/* Write Children */
@@ -3128,7 +2860,7 @@ static void write_armature(BlendWriter *writer, bArmature *arm, const void *id_a
write_iddata(writer, &arm->id);
if (arm->adt) {
- write_animdata(writer, arm->adt);
+ BKE_animdata_blend_write(writer, arm->adt);
}
/* Direct data */
@@ -3176,7 +2908,7 @@ static void write_speaker(BlendWriter *writer, Speaker *spk, const void *id_addr
write_iddata(writer, &spk->id);
if (spk->adt) {
- write_animdata(writer, spk->adt);
+ BKE_animdata_blend_write(writer, spk->adt);
}
}
}
@@ -3210,7 +2942,7 @@ static void write_probe(BlendWriter *writer, LightProbe *prb, const void *id_add
write_iddata(writer, &prb->id);
if (prb->adt) {
- write_animdata(writer, prb->adt);
+ BKE_animdata_blend_write(writer, prb->adt);
}
}
}
@@ -3358,7 +3090,7 @@ static void write_movieclip(BlendWriter *writer, MovieClip *clip, const void *id
write_iddata(writer, &clip->id);
if (clip->adt) {
- write_animdata(writer, clip->adt);
+ BKE_animdata_blend_write(writer, clip->adt);
}
write_movieTracks(writer, &tracking->tracks);
@@ -3387,7 +3119,7 @@ static void write_mask(BlendWriter *writer, Mask *mask, const void *id_address)
write_iddata(writer, &mask->id);
if (mask->adt) {
- write_animdata(writer, mask->adt);
+ BKE_animdata_blend_write(writer, mask->adt);
}
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
@@ -3697,7 +3429,7 @@ static void write_linestyle(BlendWriter *writer,
write_iddata(writer, &linestyle->id);
if (linestyle->adt) {
- write_animdata(writer, linestyle->adt);
+ BKE_animdata_blend_write(writer, linestyle->adt);
}
write_linestyle_color_modifiers(writer, &linestyle->color_modifiers);
@@ -3728,7 +3460,7 @@ static void write_cachefile(BlendWriter *writer, CacheFile *cache_file, const vo
BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
if (cache_file->adt) {
- write_animdata(writer, cache_file->adt);
+ BKE_animdata_blend_write(writer, cache_file->adt);
}
}
}
@@ -3743,7 +3475,7 @@ static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const voi
BLO_write_struct_list(writer, bToolRef, &workspace->tools);
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
if (tref->properties) {
- IDP_WriteProperty(tref->properties, writer);
+ IDP_BlendWrite(writer, tref->properties);
}
}
}
@@ -3765,7 +3497,7 @@ static void write_hair(BlendWriter *writer, Hair *hair, const void *id_address)
write_customdata(writer, &hair->id, hair->totcurve, &hair->cdata, clayers, CD_MASK_ALL);
BLO_write_pointer_array(writer, hair->totcol, hair->mat);
if (hair->adt) {
- write_animdata(writer, hair->adt);
+ BKE_animdata_blend_write(writer, hair->adt);
}
/* Remove temporary data. */
@@ -3794,7 +3526,7 @@ static void write_pointcloud(BlendWriter *writer, PointCloud *pointcloud, const
writer, &pointcloud->id, pointcloud->totpoint, &pointcloud->pdata, players, CD_MASK_ALL);
BLO_write_pointer_array(writer, pointcloud->totcol, pointcloud->mat);
if (pointcloud->adt) {
- write_animdata(writer, pointcloud->adt);
+ BKE_animdata_blend_write(writer, pointcloud->adt);
}
/* Remove temporary data. */
@@ -3817,7 +3549,7 @@ static void write_volume(BlendWriter *writer, Volume *volume, const void *id_add
/* direct data */
BLO_write_pointer_array(writer, volume->totcol, volume->mat);
if (volume->adt) {
- write_animdata(writer, volume->adt);
+ BKE_animdata_blend_write(writer, volume->adt);
}
if (volume->packedfile) {
@@ -3835,7 +3567,7 @@ static void write_simulation(BlendWriter *writer, Simulation *simulation, const
write_iddata(writer, &simulation->id);
if (simulation->adt) {
- write_animdata(writer, simulation->adt);
+ BKE_animdata_blend_write(writer, simulation->adt);
}
/* nodetree is integral part of simulation, no libdata */
@@ -3875,7 +3607,7 @@ static void write_simulation(BlendWriter *writer, Simulation *simulation, const
}
}
- BLO_write_struct_list(writer, PersistentDataHandleItem, &simulation->persistent_data_handles);
+ BLO_write_struct_list(writer, SimulationDependency, &simulation->dependencies);
}
}
@@ -4060,8 +3792,9 @@ static bool write_file_handle(Main *mainvar,
* avoid thumbnail detecting changes because of this. */
mywrite_flush(wd);
- OverrideLibraryStorage *override_storage =
- wd->use_memfile ? NULL : BKE_lib_override_library_operations_store_initialize();
+ OverrideLibraryStorage *override_storage = wd->use_memfile ?
+ NULL :
+ BKE_lib_override_library_operations_store_init();
#define ID_BUFFER_STATIC_SIZE 8192
/* This outer loop allows to save first data-blocks from real mainvar,
@@ -4126,12 +3859,17 @@ static bool write_file_handle(Main *mainvar,
memcpy(id_buffer, id, idtype_struct_size);
((ID *)id_buffer)->tag = 0;
- /* Those listbase data change every time we add/remove an ID, and also often when renaming
- * one (due to re-sorting). This avoids generating a lot of false 'is changed' detections
- * between undo steps. */
+ /* Those listbase data change every time we add/remove an ID, and also often when
+ * renaming one (due to re-sorting). This avoids generating a lot of false 'is changed'
+ * detections between undo steps. */
((ID *)id_buffer)->prev = NULL;
((ID *)id_buffer)->next = NULL;
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_write != NULL) {
+ id_type->blend_write(&writer, (ID *)id_buffer, id);
+ }
+
switch ((ID_Type)GS(id->name)) {
case ID_WM:
write_windowmanager(&writer, (wmWindowManager *)id_buffer, id);
@@ -4405,7 +4143,8 @@ bool BLO_write_file(Main *mainvar,
if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) {
if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) {
- /* Make all relative as none of the existing paths can be relative in an unsaved document. */
+ /* Make all relative as none of the existing paths can be relative in an unsaved document.
+ */
if (G.relbase_valid == false) {
remap_mode = BLO_WRITE_PATH_REMAP_RELATIVE_ALL;
}
@@ -4612,7 +4351,7 @@ void BLO_write_pointer_array(BlendWriter *writer, int size, const void *data_ptr
void BLO_write_float3_array(BlendWriter *writer, int size, const float *data_ptr)
{
- BLO_write_raw(writer, sizeof(float) * 3 * size, data_ptr);
+ BLO_write_raw(writer, sizeof(float[3]) * size, data_ptr);
}
/**
diff --git a/source/blender/blenloader/tests/blendfile_load_test.cc b/source/blender/blenloader/tests/blendfile_load_test.cc
new file mode 100644
index 00000000000..2ba3e3fcd88
--- /dev/null
+++ b/source/blender/blenloader/tests/blendfile_load_test.cc
@@ -0,0 +1,31 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2019 by Blender Foundation.
+ */
+#include "blendfile_loading_base_test.h"
+
+class BlendfileLoadingTest : public BlendfileLoadingBaseTest {
+};
+
+TEST_F(BlendfileLoadingTest, CanaryTest)
+{
+ /* Load the smallest blend file we have in the SVN lib/tests directory. */
+ if (!blendfile_load("modifier_stack/array_test.blend")) {
+ return;
+ }
+ depsgraph_create(DAG_EVAL_RENDER);
+ EXPECT_NE(nullptr, this->depsgraph);
+}
diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
new file mode 100644
index 00000000000..c743e6bcd3f
--- /dev/null
+++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
@@ -0,0 +1,162 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2019 by Blender Foundation.
+ */
+#include "blendfile_loading_base_test.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_appdir.h"
+#include "BKE_blender.h"
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_idtype.h"
+#include "BKE_image.h"
+#include "BKE_main.h"
+#include "BKE_modifier.h"
+#include "BKE_node.h"
+#include "BKE_scene.h"
+
+#include "BLI_path_util.h"
+#include "BLI_threads.h"
+
+#include "BLO_readfile.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
+#include "DNA_genfile.h" /* for DNA_sdna_current_init() */
+#include "DNA_windowmanager_types.h"
+
+#include "IMB_imbuf.h"
+
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "wm.h"
+
+BlendfileLoadingBaseTest::~BlendfileLoadingBaseTest()
+{
+}
+
+void BlendfileLoadingBaseTest::SetUpTestCase()
+{
+ testing::Test::SetUpTestCase();
+
+ /* Minimal code to make loading a blendfile and constructing a depsgraph not crash, copied from
+ * main() in creator.c. */
+ BLI_threadapi_init();
+
+ DNA_sdna_current_init();
+ BKE_blender_globals_init();
+
+ BKE_idtype_init();
+ IMB_init();
+ BKE_images_init();
+ BKE_modifier_init();
+ DEG_register_node_types();
+ RNA_init();
+ init_nodesystem();
+
+ G.background = true;
+ G.factory_startup = true;
+
+ /* Allocate a dummy window manager. The real window manager will try and load Python scripts from
+ * the release directory, which it won't be able to find. */
+ ASSERT_EQ(G.main->wm.first, nullptr);
+ G.main->wm.first = MEM_callocN(sizeof(wmWindowManager), __func__);
+}
+
+void BlendfileLoadingBaseTest::TearDownTestCase()
+{
+ if (G.main->wm.first != nullptr) {
+ MEM_freeN(G.main->wm.first);
+ G.main->wm.first = nullptr;
+ }
+
+ /* Copied from WM_exit_ex() in wm_init_exit.c, and cherry-picked those lines that match the
+ * allocation/initialization done in SetUpTestCase(). */
+ BKE_blender_free();
+ RNA_exit();
+
+ DEG_free_node_types();
+ DNA_sdna_current_free();
+ BLI_threadapi_exit();
+
+ BKE_blender_atexit();
+
+ BKE_tempdir_session_purge();
+
+ testing::Test::TearDownTestCase();
+}
+
+void BlendfileLoadingBaseTest::TearDown()
+{
+ depsgraph_free();
+ blendfile_free();
+
+ testing::Test::TearDown();
+}
+
+bool BlendfileLoadingBaseTest::blendfile_load(const char *filepath)
+{
+ const std::string &test_assets_dir = blender::tests::flags_test_asset_dir();
+ if (test_assets_dir.empty()) {
+ return false;
+ }
+
+ char abspath[FILENAME_MAX];
+ BLI_path_join(abspath, sizeof(abspath), test_assets_dir.c_str(), filepath, NULL);
+
+ bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, NULL /* reports */);
+ if (bfile == nullptr) {
+ ADD_FAILURE() << "Unable to load file '" << filepath << "' from test assets dir '"
+ << test_assets_dir << "'";
+ return false;
+ }
+ return true;
+}
+
+void BlendfileLoadingBaseTest::blendfile_free()
+{
+ if (bfile == nullptr) {
+ return;
+ }
+
+ wmWindowManager *wm = static_cast<wmWindowManager *>(bfile->main->wm.first);
+ if (wm != nullptr) {
+ wm_close_and_free(NULL, wm);
+ }
+ BLO_blendfiledata_free(bfile);
+ bfile = nullptr;
+}
+
+void BlendfileLoadingBaseTest::depsgraph_create(eEvaluationMode depsgraph_evaluation_mode)
+{
+ depsgraph = DEG_graph_new(
+ bfile->main, bfile->curscene, bfile->cur_view_layer, depsgraph_evaluation_mode);
+ DEG_graph_build_from_view_layer(depsgraph);
+ BKE_scene_graph_update_tagged(depsgraph, bfile->main);
+}
+
+void BlendfileLoadingBaseTest::depsgraph_free()
+{
+ if (depsgraph == nullptr) {
+ return;
+ }
+ DEG_graph_free(depsgraph);
+ depsgraph = nullptr;
+}
diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.h b/source/blender/blenloader/tests/blendfile_loading_base_test.h
new file mode 100644
index 00000000000..f90e07218fb
--- /dev/null
+++ b/source/blender/blenloader/tests/blendfile_loading_base_test.h
@@ -0,0 +1,64 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2019 by Blender Foundation.
+ */
+#ifndef __BLENDFILE_LOADING_BASE_TEST_H__
+#define __BLENDFILE_LOADING_BASE_TEST_H__
+
+#include "DEG_depsgraph.h"
+#include "testing/testing.h"
+
+struct BlendFileData;
+struct Depsgraph;
+
+class BlendfileLoadingBaseTest : public testing::Test {
+ protected:
+ struct BlendFileData *bfile = nullptr;
+ struct Depsgraph *depsgraph = nullptr;
+
+ public:
+ virtual ~BlendfileLoadingBaseTest();
+
+ /* Sets up Blender just enough to not crash on loading
+ * a blendfile and constructing a depsgraph. */
+ static void SetUpTestCase();
+ static void TearDownTestCase();
+
+ protected:
+ /* Frees the depsgraph & blendfile. */
+ virtual void TearDown();
+
+ /* Loads a blend file from the lib/tests directory from SVN.
+ * Returns 'ok' flag (true=good, false=bad) and sets this->bfile.
+ * Fails the test if the file cannot be loaded (still returns though).
+ * Requires the CLI argument --test-asset-dir to point to ../../lib/tests.
+ *
+ * WARNING: only files saved with Blender 2.80+ can be loaded. Since Blender
+ * is only partially initialized (most importantly, without window manager),
+ * the space types are not registered, so any versioning code that handles
+ * those will SEGFAULT.
+ */
+ bool blendfile_load(const char *filepath);
+ /* Free bfile if it is not nullptr. */
+ void blendfile_free();
+
+ /* Create a depsgraph. Assumes a blend file has been loaded to this->bfile. */
+ virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode);
+ /* Free the depsgraph if it's not nullptr. */
+ virtual void depsgraph_free();
+};
+
+#endif /* __BLENDFILE_LOADING_BASE_TEST_H__ */