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:
authorJacques Lucke <jacques@blender.org>2020-08-21 15:39:18 +0300
committerJacques Lucke <jacques@blender.org>2020-08-21 15:39:39 +0300
commit76689e85170027fa9fe2d6160b1a0921ccee6475 (patch)
tree0606a9125e7078fd9f4467df8ba708a10d9e3e3f /source/blender/blenloader
parent2e630297afc19ef4e69b8afe79dfd337171dbd60 (diff)
Cleanup: use LISTBASE_FOREACH in readfile.c
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c634
1 files changed, 192 insertions, 442 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8b4b526472c..35e504f87b0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1826,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) {
@@ -1852,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;
}
@@ -1872,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);
}
@@ -1923,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);
}
}
@@ -1968,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));
}
}
@@ -2277,8 +2255,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]);
}
@@ -2692,11 +2669,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);
@@ -2706,14 +2681,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);
}
}
@@ -2722,11 +2694,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);
}
}
@@ -2734,9 +2704,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);
}
}
@@ -2749,9 +2717,7 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas
static void lib_link_fmodifiers(BlendLibReader *reader, ID *id, ListBase *list)
{
- FModifier *fcm;
-
- for (fcm = list->first; fcm; fcm = fcm->next) {
+ LISTBASE_FOREACH (FModifier *, fcm, list) {
/* data for specific modifiers */
switch (fcm->type) {
case FMODIFIER_TYPE_PYTHON: {
@@ -2766,20 +2732,16 @@ static void lib_link_fmodifiers(BlendLibReader *reader, ID *id, ListBase *list)
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) {
+ LISTBASE_FOREACH (FCurve *, fcu, list) {
/* driver data */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
- DriverVar *dvar;
-
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* only relink if still used */
if (tarIndex < dvar->num_targets) {
@@ -2801,9 +2763,7 @@ static void lib_link_fcurves(BlendLibReader *reader, ID *id, ListBase *list)
/* 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) {
+ LISTBASE_FOREACH (FModifier *, fcm, list) {
/* relink general data */
BLO_read_data_address(reader, &fcm->data);
fcm->curve = curve;
@@ -2837,10 +2797,8 @@ static void direct_link_fmodifiers(BlendDataReader *reader, ListBase *list, FCur
/* 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) {
+ LISTBASE_FOREACH (FCurve *, fcu, list) {
/* curve data */
BLO_read_data_address(reader, &fcu->bezt);
BLO_read_data_address(reader, &fcu->fpt);
@@ -2860,7 +2818,6 @@ static void direct_link_fcurves(BlendDataReader *reader, ListBase *list)
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). */
@@ -2874,7 +2831,7 @@ static void direct_link_fcurves(BlendDataReader *reader, ListBase *list)
/* relink variables, targets and their paths */
BLO_read_list(reader, &driver->variables);
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* only relink the targets being used */
if (tarIndex < dvar->num_targets) {
@@ -2914,16 +2871,13 @@ 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);
@@ -2932,7 +2886,7 @@ static void direct_link_action(BlendDataReader *reader, bAction *act)
direct_link_fcurves(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);
}
@@ -2940,9 +2894,7 @@ static void direct_link_action(BlendDataReader *reader, bAction *act)
static void lib_link_nladata_strips(BlendLibReader *reader, ID *id, ListBase *list)
{
- NlaStrip *strip;
-
- for (strip = list->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (NlaStrip *, strip, list) {
/* check strip's children */
lib_link_nladata_strips(reader, id, &strip->strips);
@@ -2956,10 +2908,8 @@ static void lib_link_nladata_strips(BlendLibReader *reader, ID *id, ListBase *li
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) {
+ LISTBASE_FOREACH (NlaTrack *, nlt, list) {
lib_link_nladata_strips(reader, id, &nlt->strips);
}
}
@@ -2969,9 +2919,7 @@ static void lib_link_nladata(BlendLibReader *reader, ID *id, ListBase *list)
*/
static void direct_link_nladata_strips(BlendDataReader *reader, ListBase *list)
{
- NlaStrip *strip;
-
- for (strip = list->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (NlaStrip *, strip, list) {
/* strip's child strips */
BLO_read_list(reader, &strip->strips);
direct_link_nladata_strips(reader, &strip->strips);
@@ -2989,9 +2937,7 @@ static void direct_link_nladata_strips(BlendDataReader *reader, ListBase *list)
/* 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) {
+ LISTBASE_FOREACH (NlaTrack *, nlt, list) {
/* relink list of strips */
BLO_read_list(reader, &nlt->strips);
@@ -3004,12 +2950,9 @@ static void direct_link_nladata(BlendDataReader *reader, ListBase *list)
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);
}
}
@@ -3018,15 +2961,12 @@ 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);
}
@@ -3150,7 +3090,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);
}
@@ -3279,9 +3219,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;
@@ -3295,7 +3232,7 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
direct_link_animdata(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);
@@ -3305,7 +3242,7 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
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);
@@ -3384,14 +3321,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);
}
}
@@ -3399,14 +3336,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);
@@ -3443,10 +3380,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) {
@@ -3470,10 +3406,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) {
@@ -3600,8 +3534,6 @@ 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_BlendDataRead(reader, &bone->prop);
@@ -3613,15 +3545,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;
@@ -3631,7 +3561,7 @@ static void direct_link_armature(BlendDataReader *reader, bArmature *arm)
BLO_read_data_address(reader, &arm->adt);
direct_link_animdata(reader, arm->adt);
- for (bone = arm->bonebase.first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
direct_link_bones(reader, bone);
}
@@ -3705,10 +3635,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++;
}
}
@@ -3723,13 +3651,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;
+ int elemsize = key->elemsize;
+ char *data = kb->data;
- elemsize = key->elemsize;
- 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;
@@ -3737,11 +3662,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;
@@ -3752,8 +3678,6 @@ 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);
@@ -3761,7 +3685,7 @@ static void direct_link_key(BlendDataReader *reader, Key *key)
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)) {
@@ -3852,8 +3776,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;
@@ -3870,7 +3792,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;
@@ -3904,8 +3826,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));
@@ -3918,7 +3838,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;
@@ -3971,9 +3891,6 @@ 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);
@@ -3992,7 +3909,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);
@@ -4013,7 +3930,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);
@@ -4110,9 +4027,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 */
@@ -4129,7 +4044,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);
}
}
@@ -4157,9 +4072,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;
@@ -4222,11 +4136,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: {
@@ -4262,8 +4173,6 @@ 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);
@@ -4296,16 +4205,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]);
}
@@ -4318,16 +4226,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);
}
@@ -4356,11 +4259,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) {
@@ -4468,13 +4370,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))) {
@@ -4494,9 +4394,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);
@@ -4526,9 +4424,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);
@@ -4540,7 +4436,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);
@@ -4553,6 +4448,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];
@@ -4620,10 +4516,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));
@@ -4664,9 +4558,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);
}
}
@@ -4720,7 +4612,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;
}
}
@@ -4732,8 +4624,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;
}
}
@@ -4745,7 +4636,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;
}
}
@@ -4754,7 +4645,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);
@@ -4833,7 +4723,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]);
}
@@ -4915,8 +4805,7 @@ static void lib_link_object(BlendLibReader *reader, Object *ob)
}
{
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
+ LISTBASE_FOREACH (LodLevel *, level, &ob->lodlevels) {
BLO_read_id_address(reader, ob->id.lib, &level->source);
if (!level->source && level == ob->lodlevels.first) {
@@ -4948,8 +4837,6 @@ static void direct_link_motionpath(BlendDataReader *reader, bMotionPath *mpath)
static void direct_link_pose(BlendDataReader *reader, bPose *pose)
{
- bPoseChannel *pchan;
-
if (!pose) {
return;
}
@@ -4960,7 +4847,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);
@@ -5112,11 +4999,9 @@ 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;
@@ -5273,10 +5158,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);
@@ -5305,11 +5189,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 */
@@ -5386,11 +5268,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 */
@@ -5511,8 +5391,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]);
}
}
@@ -5668,9 +5547,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);
}
}
@@ -5701,9 +5579,7 @@ 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);
}
@@ -5770,8 +5646,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) {
@@ -5779,7 +5654,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);
}
}
@@ -5808,9 +5683,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;
}
@@ -5835,9 +5709,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);
}
@@ -5988,10 +5860,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) {
@@ -6114,7 +5983,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)) {
@@ -6131,11 +6000,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);
}
@@ -6180,11 +6047,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);
}
@@ -6204,13 +6069,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;
@@ -6284,7 +6142,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;
@@ -6293,6 +6151,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
/* recursive link sequences, lb will be correctly initialized */
link_recurs_seq(reader, &ed->seqbase);
+ Sequence *seq;
SEQ_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);
@@ -6386,7 +6245,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) {
@@ -6426,7 +6285,7 @@ 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_BlendDataRead(reader, &srl->prop);
BLO_read_list(reader, &(srl->freestyleConfig.modules));
@@ -6436,7 +6295,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);
@@ -6490,7 +6349,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);
}
@@ -6537,8 +6396,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;
@@ -6566,7 +6423,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);
}
}
@@ -6629,15 +6486,13 @@ 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);
@@ -6694,9 +6549,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));
@@ -6721,7 +6573,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);
}
@@ -6737,7 +6589,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
@@ -6746,7 +6598,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);
}
@@ -6801,8 +6653,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
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++) {
+ for (int i = 0; i < ts->usedelem; i++) {
TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
*new_elem = elems[i];
}
@@ -6884,7 +6735,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);
@@ -6895,8 +6745,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 */
@@ -7058,7 +6907,6 @@ static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area)
}
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);
@@ -7072,6 +6920,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 */
@@ -7087,6 +6936,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;
@@ -7169,12 +7019,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;
@@ -7709,8 +7557,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);
}
@@ -7765,9 +7612,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;
@@ -7872,10 +7717,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
@@ -7887,7 +7731,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. */
@@ -7990,26 +7834,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]);
}
@@ -8020,7 +7858,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);
@@ -8048,7 +7885,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);
@@ -8057,9 +7894,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);
}
}
@@ -8068,9 +7903,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);
}
}
@@ -8098,28 +7931,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) {
@@ -8136,8 +7963,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) {
@@ -8166,9 +7992,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);
@@ -8189,9 +8013,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 =
@@ -8201,7 +8023,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 =
@@ -8211,7 +8033,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 =
@@ -8397,28 +8219,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);
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]);
}
}
@@ -8568,7 +8387,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);
@@ -9279,11 +9098,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);
}
@@ -9572,11 +9389,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 */
@@ -9596,7 +9408,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;
@@ -9604,7 +9416,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);
@@ -9616,7 +9428,7 @@ 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);
}
}
@@ -9637,7 +9449,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
}
}
- for (addon = user->addons.first; addon; addon = addon->next) {
+ LISTBASE_FOREACH (bAddon *, addon, &user->addons) {
BLO_read_data_address(reader, &addon->prop);
IDP_BlendDataRead(reader, &addon->prop);
}
@@ -10098,8 +9910,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);
}
@@ -10109,17 +9920,14 @@ 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) {
+ LISTBASE_FOREACH (FModifier *, fcm, list) {
/* library data for specific F-Modifier types */
switch (fcm->type) {
case FMODIFIER_TYPE_PYTHON: {
@@ -10135,15 +9943,12 @@ static void expand_fmodifiers(BlendExpander *expander, ListBase *list)
static void expand_fcurves(BlendExpander *expander, ListBase *list)
{
- FCurve *fcu;
-
- for (fcu = list->first; fcu; fcu = fcu->next) {
+ LISTBASE_FOREACH (FCurve *, fcu, list) {
/* 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) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
// TODO: only expand those that are going to get used?
BLO_expand(expander, dtar->id);
@@ -10159,9 +9964,7 @@ static void expand_fcurves(BlendExpander *expander, ListBase *list)
static void expand_animdata_nlastrips(BlendExpander *expander, ListBase *list)
{
- NlaStrip *strip;
-
- for (strip = list->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (NlaStrip *, strip, list) {
/* check child strips */
expand_animdata_nlastrips(expander, &strip->strips);
@@ -10178,8 +9981,6 @@ static void expand_animdata_nlastrips(BlendExpander *expander, ListBase *list)
static void expand_animdata(BlendExpander *expander, AnimData *adt)
{
- NlaTrack *nlt;
-
/* own action */
BLO_expand(expander, adt->action);
BLO_expand(expander, adt->tmpact);
@@ -10188,7 +9989,7 @@ static void expand_animdata(BlendExpander *expander, AnimData *adt)
expand_fcurves(expander, &adt->drivers);
/* nla-data - referenced actions */
- for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
+ LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
expand_animdata_nlastrips(expander, &nlt->strips);
}
}
@@ -10234,10 +10035,8 @@ 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);
}
@@ -10255,12 +10054,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);
}
}
@@ -10268,15 +10064,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);
@@ -10297,11 +10091,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);
@@ -10385,13 +10176,11 @@ 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);
}
@@ -10452,18 +10241,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]);
}
@@ -10480,9 +10265,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]);
}
@@ -10502,12 +10285,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
}
@@ -10516,13 +10297,11 @@ 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);
IDP_BlendExpand(expander, chan->prop);
BLO_expand(expander, chan->custom);
@@ -10556,11 +10335,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() */
@@ -10590,18 +10364,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);
}
@@ -10617,7 +10391,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);
}
@@ -10640,8 +10414,7 @@ static void expand_object(BlendExpander *expander, Object *ob)
}
if (ob->currentlod) {
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
+ LISTBASE_FOREACH (LodLevel *, level, &ob->lodlevels) {
BLO_expand(expander, level->source);
}
}
@@ -10662,10 +10435,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);
}
@@ -10678,14 +10447,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);
}
@@ -10696,13 +10465,13 @@ static void expand_scene(BlendExpander *expander, Scene *sce)
LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
IDP_BlendExpand(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);
}
@@ -10813,17 +10582,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);
}
@@ -10834,27 +10596,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);
}
@@ -11077,9 +10836,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;
}
@@ -11090,9 +10847,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;
}
@@ -11116,7 +10871,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) {
@@ -11183,8 +10938,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);
@@ -11227,8 +10981,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)) {
@@ -11242,8 +10995,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) {
@@ -11469,9 +11221,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);
@@ -11917,8 +11667,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. */