Cleanup: use LISTBASE_FOREACH & LISTBASE_FOREACH_BACKWARD macros

This commit is contained in:
Campbell Barton 2023-08-04 08:51:13 +10:00
parent f7be60eff0
commit adf58a77ff
209 changed files with 1006 additions and 2109 deletions

View File

@ -364,15 +364,13 @@ bActionGroup *get_active_actiongroup(bAction *act)
void set_active_action_group(bAction *act, bActionGroup *agrp, short select)
{
bActionGroup *grp;
/* sanity checks */
if (act == nullptr) {
return;
}
/* Deactivate all others */
for (grp = static_cast<bActionGroup *>(act->groups.first); grp; grp = grp->next) {
LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
if ((grp == agrp) && (select)) {
grp->flag |= AGRP_ACTIVE;
}
@ -598,15 +596,13 @@ bActionGroup *BKE_action_group_find_name(bAction *act, const char name[])
void action_groups_clear_tempflags(bAction *act)
{
bActionGroup *agrp;
/* sanity checks */
if (ELEM(nullptr, act, act->groups.first)) {
return;
}
/* flag clearing loop */
for (agrp = static_cast<bActionGroup *>(act->groups.first); agrp; agrp = agrp->next) {
LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
agrp->flag &= ~AGRP_TEMP;
}
}
@ -706,14 +702,12 @@ bool BKE_pose_is_layer_visible(const bArmature *arm, const bPoseChannel *pchan)
bPoseChannel *BKE_pose_channel_active(Object *ob, const bool check_arm_layer)
{
bArmature *arm = static_cast<bArmature *>((ob) ? ob->data : nullptr);
bPoseChannel *pchan;
if (ELEM(nullptr, ob, ob->pose, arm)) {
return nullptr;
}
/* find active */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if ((pchan->bone) && (pchan->bone == arm->act_bone)) {
if (!check_arm_layer || BKE_pose_is_layer_visible(arm, pchan)) {
return pchan;
@ -742,7 +736,7 @@ bPoseChannel *BKE_pose_channel_active_or_first_selected(Object *ob)
return pchan;
}
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->bone != nullptr) {
if ((pchan->bone->flag & BONE_SELECTED) && PBONE_VISIBLE(arm, pchan->bone)) {
return pchan;
@ -784,7 +778,6 @@ void BKE_pose_copy_data_ex(bPose **dst,
const bool copy_constraints)
{
bPose *outPose;
bPoseChannel *pchan;
ListBase listb;
if (!src) {
@ -810,7 +803,7 @@ void BKE_pose_copy_data_ex(bPose **dst,
outPose->ikparam = MEM_dupallocN(src->ikparam);
outPose->avs = src->avs;
for (pchan = static_cast<bPoseChannel *>(outPose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &outPose->chanbase) {
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
id_us_plus((ID *)pchan->custom);
}
@ -900,12 +893,9 @@ void BKE_pose_ikparam_init(bPose *pose)
/* only for real IK, not for auto-IK */
static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
{
bConstraint *con;
Bone *bone;
/* No need to check if constraint is active (has influence),
* since all constraints with CONSTRAINT_IK_AUTO are active */
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = static_cast<bKinematicConstraint *>(con->data);
if ((data->rootbone == 0) || (data->rootbone > level)) {
@ -915,7 +905,7 @@ static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
}
}
}
for (bone = static_cast<Bone *>(pchan->bone->childbase.first); bone; bone = bone->next) {
LISTBASE_FOREACH (Bone *, bone, &pchan->bone->childbase) {
pchan = BKE_pose_channel_find_name(ob->pose, bone->name);
if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) {
return true;
@ -932,10 +922,8 @@ bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
void BKE_pose_channels_hash_ensure(bPose *pose)
{
if (!pose->chanhash) {
bPoseChannel *pchan;
pose->chanhash = BLI_ghash_str_new("make_pose_chan gh");
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
}
}
@ -971,7 +959,6 @@ void BKE_pose_channels_remove(Object *ob,
/* Erase any associated pose channel, along with any references to them */
if (ob->pose) {
bPoseChannel *pchan, *pchan_next;
bConstraint *con;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan_next)
{
@ -988,12 +975,10 @@ void BKE_pose_channels_remove(Object *ob,
}
else {
/* Maybe something the bone references is being removed instead? */
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
ListBase targets = {nullptr, nullptr};
bConstraintTarget *ct;
if (BKE_constraint_targets_get(con, &targets)) {
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
if (ct->tar == ob) {
if (ct->subtarget[0]) {
if (filter_fn(ct->subtarget, user_data)) {
@ -1090,10 +1075,8 @@ void BKE_pose_channel_free(bPoseChannel *pchan)
void BKE_pose_channels_free_ex(bPose *pose, bool do_id_user)
{
bPoseChannel *pchan;
if (pose->chanbase.first) {
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
if (!BLI_listbase_is_empty(&pose->chanbase)) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
BKE_pose_channel_free_ex(pchan, do_id_user);
}
@ -1199,18 +1182,17 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
void BKE_pose_update_constraint_flags(bPose *pose)
{
bPoseChannel *pchan, *parchan;
bConstraint *con;
bPoseChannel *parchan;
/* clear */
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
pchan->constflag = 0;
}
pose->flag &= ~POSE_CONSTRAINTS_TIMEDEPEND;
/* detect */
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = (bKinematicConstraint *)con->data;
@ -1291,7 +1273,6 @@ bActionGroup *BKE_pose_add_group(bPose *pose, const char *name)
void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
{
bPoseChannel *pchan;
int idx = index;
if (idx < 1) {
@ -1304,7 +1285,7 @@ void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
* - firstly, make sure nothing references it
* - also, make sure that those after this item get corrected
*/
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
if (pchan->agrp_index == idx) {
pchan->agrp_index = 0;
}
@ -1342,11 +1323,9 @@ void BKE_pose_remove_group_index(bPose *pose, const int index)
bool BKE_action_has_motion(const bAction *act)
{
FCurve *fcu;
/* return on the first F-Curve that has some keyframes/samples defined */
if (act) {
for (fcu = static_cast<FCurve *>(act->curves.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
if (fcu->totvert) {
return true;
}
@ -1404,12 +1383,11 @@ void BKE_action_frame_range_calc(const bAction *act,
float *r_start,
float *r_end)
{
FCurve *fcu;
float min = 999999999.0f, max = -999999999.0f;
short foundvert = 0, foundmod = 0;
if (act) {
for (fcu = static_cast<FCurve *>(act->curves.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
/* if curve has keyframes, consider them first */
if (fcu->totvert) {
float nmin, nmax;
@ -1516,7 +1494,6 @@ eAction_TransformFlags BKE_action_get_item_transform_flags(bAction *act,
ListBase *curves)
{
PointerRNA ptr;
FCurve *fcu;
char *basePath = nullptr;
short flags = 0;
@ -1540,7 +1517,7 @@ eAction_TransformFlags BKE_action_get_item_transform_flags(bAction *act,
/* search F-Curves for the given properties
* - we cannot use the groups, since they may not be grouped in that way...
*/
for (fcu = static_cast<FCurve *>(act->curves.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
const char *bPtr = nullptr, *pPtr = nullptr;
/* If enough flags have been found,
@ -1645,8 +1622,6 @@ eAction_TransformFlags BKE_action_get_item_transform_flags(bAction *act,
void BKE_pose_rest(bPose *pose, bool selected_bones_only)
{
bPoseChannel *pchan;
if (!pose) {
return;
}
@ -1654,7 +1629,7 @@ void BKE_pose_rest(bPose *pose, bool selected_bones_only)
memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
if (selected_bones_only && pchan->bone != nullptr && (pchan->bone->flag & BONE_SELECTED) == 0)
{
continue;
@ -1710,8 +1685,6 @@ void BKE_pose_copy_pchan_result(bPoseChannel *pchanto, const bPoseChannel *pchan
bool BKE_pose_copy_result(bPose *to, bPose *from)
{
bPoseChannel *pchanto, *pchanfrom;
if (to == nullptr || from == nullptr) {
CLOG_ERROR(
&LOG, "Pose copy error, pose to:%p from:%p", (void *)to, (void *)from); /* debug temp */
@ -1723,10 +1696,8 @@ bool BKE_pose_copy_result(bPose *to, bPose *from)
return false;
}
for (pchanfrom = static_cast<bPoseChannel *>(from->chanbase.first); pchanfrom;
pchanfrom = pchanfrom->next)
{
pchanto = BKE_pose_channel_find_name(to, pchanfrom->name);
LISTBASE_FOREACH (bPoseChannel *, pchanfrom, &from->chanbase) {
bPoseChannel *pchanto = BKE_pose_channel_find_name(to, pchanfrom->name);
if (pchanto != nullptr) {
BKE_pose_copy_pchan_result(pchanto, pchanfrom);
}

View File

@ -469,13 +469,9 @@ void BKE_animdata_merge_copy(
* - This assumes that the src ID is being merged into the dst ID
*/
if (fix_drivers) {
FCurve *fcu;
for (fcu = static_cast<FCurve *>(drivers.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &drivers) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
for (dvar = static_cast<DriverVar *>(driver->variables.first); dvar; dvar = dvar->next) {
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
if (dtar->id == src_id) {
dtar->id = dst_id;
@ -782,10 +778,9 @@ static bool fcurves_path_rename_fix(ID *owner_id,
ListBase *curves,
bool verify_paths)
{
FCurve *fcu;
bool is_changed = false;
/* We need to check every curve. */
for (fcu = static_cast<FCurve *>(curves->first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, curves) {
if (fcu->rna_path == nullptr) {
continue;
}
@ -819,9 +814,8 @@ static bool drivers_path_rename_fix(ID *owner_id,
bool verify_paths)
{
bool is_changed = false;
FCurve *fcu;
/* We need to check every curve - drivers are F-Curves too. */
for (fcu = static_cast<FCurve *>(curves->first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, curves) {
/* firstly, handle the F-Curve's own path */
if (fcu->rna_path != nullptr) {
const char *old_rna_path = fcu->rna_path;
@ -833,9 +827,8 @@ static bool drivers_path_rename_fix(ID *owner_id,
continue;
}
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
/* driver variables */
for (dvar = static_cast<DriverVar *>(driver->variables.first); dvar; dvar = dvar->next) {
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
/* only change the used targets, since the others will need fixing manually anyway */
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
/* rename RNA path */
@ -872,10 +865,9 @@ static bool nlastrips_path_rename_fix(ID *owner_id,
ListBase *strips,
bool verify_paths)
{
NlaStrip *strip;
bool is_changed = false;
/* Recursively check strips, fixing only actions. */
for (strip = static_cast<NlaStrip *>(strips->first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* fix strip's action */
if (strip->act != nullptr) {
is_changed |= fcurves_path_rename_fix(
@ -1003,7 +995,6 @@ void BKE_animdata_fix_paths_rename(ID *owner_id,
int newSubscript,
bool verify_paths)
{
NlaTrack *nlt;
char *oldN, *newN;
/* If no AnimData, no need to proceed. */
if (ELEM(nullptr, owner_id, adt)) {
@ -1048,7 +1039,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id,
is_self_changed |= drivers_path_rename_fix(
owner_id, ref_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths);
/* NLA Data - Animation Data for Strips */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
is_self_changed |= nlastrips_path_rename_fix(
owner_id, prefix, oldName, newName, oldN, newN, &nlt->strips, verify_paths);
}
@ -1090,11 +1081,10 @@ static bool fcurves_path_remove_fix(const char *prefix, ListBase *curves)
/* Check RNA-Paths for a list of F-Curves */
static bool nlastrips_path_remove_fix(const char *prefix, ListBase *strips)
{
NlaStrip *strip;
bool any_removed = false;
/* recursively check strips, fixing only actions... */
for (strip = static_cast<NlaStrip *>(strips->first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* fix strip's action */
if (strip->act) {
any_removed |= fcurves_path_remove_fix(prefix, &strip->act->curves);
@ -1150,9 +1140,7 @@ static void fcurves_apply_cb(ID *id,
ID_FCurve_Edit_Callback func,
void *user_data)
{
FCurve *fcu;
for (fcu = static_cast<FCurve *>(fcurves->first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, fcurves) {
func(id, fcu, user_data);
}
}
@ -1160,9 +1148,7 @@ static void fcurves_apply_cb(ID *id,
/* Helper for adt_apply_all_fcurves_cb() - Recursively go through each NLA strip */
static void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCbWrapper *wrapper)
{
NlaStrip *strip;
for (strip = static_cast<NlaStrip *>(strips->first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* fix strip's action */
if (strip->act) {
fcurves_apply_cb(id, &strip->act->curves, wrapper->func, wrapper->user_data);
@ -1177,7 +1163,6 @@ static void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCb
static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data)
{
AllFCurvesCbWrapper *wrapper = static_cast<AllFCurvesCbWrapper *>(wrapper_data);
NlaTrack *nlt;
if (adt->action) {
fcurves_apply_cb(id, &adt->action->curves, wrapper->func, wrapper->user_data);
@ -1191,7 +1176,7 @@ static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data)
fcurves_apply_cb(id, &adt->drivers, wrapper->func, wrapper->user_data);
/* NLA Data - Animation Data for Strips */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
nlastrips_apply_all_curves_cb(id, &nlt->strips, wrapper);
}
}

View File

@ -79,8 +79,6 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks,
int array_index,
int /*group_mode*/)
{
KS_Path *ksp;
/* sanity checks */
if (ELEM(nullptr, ks, rna_path, id)) {
return nullptr;
@ -89,7 +87,7 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks,
/* loop over paths in the current KeyingSet, finding the first one where all settings match
* (i.e. the first one where none of the checks fail and equal 0)
*/
for (ksp = static_cast<KS_Path *>(ks->paths.first); ksp; ksp = ksp->next) {
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
short eq_id = 1, eq_path = 1, eq_index = 1, eq_group = 1;
/* id */
@ -235,15 +233,12 @@ void BKE_keyingset_free_path(KeyingSet *ks, KS_Path *ksp)
void BKE_keyingsets_copy(ListBase *newlist, const ListBase *list)
{
KeyingSet *ksn;
KS_Path *kspn;
BLI_duplicatelist(newlist, list);
for (ksn = static_cast<KeyingSet *>(newlist->first); ksn; ksn = ksn->next) {
LISTBASE_FOREACH (KeyingSet *, ksn, newlist) {
BLI_duplicatelist(&ksn->paths, &ksn->paths);
for (kspn = static_cast<KS_Path *>(ksn->paths.first); kspn; kspn = kspn->next) {
LISTBASE_FOREACH (KS_Path *, kspn, &ksn->paths) {
kspn->rna_path = static_cast<char *>(MEM_dupallocN(kspn->rna_path));
}
}
@ -251,8 +246,8 @@ void BKE_keyingsets_copy(ListBase *newlist, const ListBase *list)
void BKE_keyingsets_foreach_id(LibraryForeachIDData *data, const ListBase *keyingsets)
{
for (KeyingSet *ksn = static_cast<KeyingSet *>(keyingsets->first); ksn; ksn = ksn->next) {
for (KS_Path *kspn = static_cast<KS_Path *>(ksn->paths.first); kspn; kspn = kspn->next) {
LISTBASE_FOREACH (KeyingSet *, ksn, keyingsets) {
LISTBASE_FOREACH (KS_Path *, kspn, &ksn->paths) {
BKE_LIB_FOREACHID_PROCESS_ID(data, kspn->id, IDWALK_CB_NOP);
}
}
@ -773,12 +768,10 @@ static void animsys_evaluate_drivers(PointerRNA *ptr,
AnimData *adt,
const AnimationEvalContext *anim_eval_context)
{
FCurve *fcu;
/* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if
* the depsgraph requested that this driver be evaluated...
*/
for (fcu = static_cast<FCurve *>(adt->drivers.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
ChannelDriver *driver = fcu->driver;
bool ok = false;
@ -981,13 +974,13 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list,
const AnimationEvalContext *anim_eval_context,
const bool flush_to_original)
{
NlaStrip *strip, *estrip = nullptr;
NlaStrip *estrip = nullptr;
NlaEvalStrip *nes;
short side = 0;
float ctime = anim_eval_context->eval_time;
/* loop over strips, checking if they fall within the range */
for (strip = static_cast<NlaStrip *>(strips->first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* Check if current time occurs within this strip. */
if (IN_RANGE_INCL(ctime, strip->start, strip->end) ||
(strip->flag & NLASTRIP_FLAG_NO_TIME_MAP)) {
@ -2608,8 +2601,6 @@ static void nlasnapshot_from_action(PointerRNA *ptr,
const float evaltime,
NlaEvalSnapshot *r_snapshot)
{
FCurve *fcu;
action_idcode_patch_check(ptr->owner_id, action);
/* Evaluate modifiers which modify time to evaluate the base curves at. */
@ -2621,7 +2612,7 @@ static void nlasnapshot_from_action(PointerRNA *ptr,
const float modified_evaltime = evaluate_time_fmodifiers(
&storage, modifiers, nullptr, 0.0f, evaltime);
for (fcu = static_cast<FCurve *>(action->curves.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &action->curves) {
if (!is_fcurve_evaluatable(fcu)) {
continue;
}
@ -3329,14 +3320,12 @@ static bool is_action_track_evaluated_without_nla(const AnimData *adt,
*/
static NlaTrack *nlatrack_find_tweaked(const AnimData *adt)
{
NlaTrack *nlt;
if (adt == nullptr) {
return nullptr;
}
/* Since the track itself gets disabled, we want the first disabled. */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
if (nlt->flag & NLATRACK_DISABLED) {
return nlt;
}
@ -3402,7 +3391,7 @@ static bool animsys_evaluate_nla_for_flush(NlaEvalData *echannels,
nlastrips_ctime_get_strip_single(&estrips, &action_strip, anim_eval_context, flush_to_original);
/* Per strip, evaluate and accumulate on top of existing channels. */
for (nes = static_cast<NlaEvalStrip *>(estrips.first); nes; nes = nes->next) {
LISTBASE_FOREACH (NlaEvalStrip *, nes, &estrips) {
nlasnapshot_blend_strip(ptr,
echannels,
nullptr,
@ -3537,7 +3526,7 @@ static void animsys_evaluate_nla_for_keyframing(PointerRNA *ptr,
}
/* For each strip, evaluate then accumulate on top of existing channels. */
for (nes = static_cast<NlaEvalStrip *>(lower_estrips.first); nes; nes = nes->next) {
LISTBASE_FOREACH (NlaEvalStrip *, nes, &lower_estrips) {
nlasnapshot_blend_strip(ptr,
&r_context->lower_eval_data,
nullptr,
@ -3871,10 +3860,8 @@ void BKE_animsys_free_nla_keyframing_context_cache(ListBase *cache)
/* Evaluate Overrides */
static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
{
AnimOverride *aor;
/* for each override, simply execute... */
for (aor = static_cast<AnimOverride *>(adt->overrides.first); aor; aor = aor->next) {
LISTBASE_FOREACH (AnimOverride *, aor, &adt->overrides) {
PathResolvedRNA anim_rna;
if (BKE_animsys_rna_path_resolve(ptr, aor->rna_path, aor->array_index, &anim_rna)) {
BKE_animsys_write_to_rna_path(&anim_rna, aor->value);

View File

@ -364,9 +364,7 @@ int BKE_armature_bonelist_count(const ListBase *lb)
void BKE_armature_bonelist_free(ListBase *lb, const bool do_id_user)
{
Bone *bone;
for (bone = static_cast<Bone *>(lb->first); bone; bone = bone->next) {
LISTBASE_FOREACH (Bone *, bone, lb) {
if (bone->prop) {
IDP_FreeProperty_ex(bone->prop, do_id_user);
}
@ -583,14 +581,12 @@ void BKE_armature_transform(bArmature *arm, const float mat[4][4], const bool do
static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
{
Bone *curBone, *rbone;
for (curBone = static_cast<Bone *>(lb->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (Bone *, curBone, lb) {
if (STREQ(curBone->name, name)) {
return curBone;
}
rbone = get_named_bone_bonechildren(&curBone->childbase, name);
Bone *rbone = get_named_bone_bonechildren(&curBone->childbase, name);
if (rbone) {
return rbone;
}
@ -2288,10 +2284,8 @@ void BKE_armature_where_is_bone(Bone *bone, const Bone *bone_parent, const bool
void BKE_armature_where_is(bArmature *arm)
{
Bone *bone;
/* hierarchical from root to children */
for (bone = static_cast<Bone *>(arm->bonebase.first); bone; bone = bone->next) {
LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
BKE_armature_where_is_bone(bone, nullptr, true);
}
}
@ -2388,9 +2382,7 @@ void BKE_pose_channels_clear_with_null_bone(bPose *pose, const bool do_id_user)
void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_user)
{
Bone *bone;
bPose *pose;
bPoseChannel *pchan;
int counter = 0;
/* only done here */
@ -2408,7 +2400,7 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
/* first step, check if all channels are there */
Bone *prev_bone = nullptr;
for (bone = static_cast<Bone *>(arm->bonebase.first); bone; bone = bone->next) {
LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
counter = rebuild_pose_bone(pose, bone, nullptr, counter, &prev_bone);
}
@ -2417,7 +2409,7 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
BKE_pose_channels_hash_ensure(pose);
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
/* Find the custom B-Bone handles. */
BKE_pchan_rebuild_bbone_handles(pose, pchan);
/* Re-validate that we are still using a valid pchan form custom transform. */
@ -2566,7 +2558,6 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
bArmature *arm;
Bone *bone;
bPoseChannel *pchan;
float imat[4][4];
float ctime;
@ -2586,8 +2577,7 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob)
/* In edit-mode or rest-position we read the data from the bones. */
if (arm->edbo || (arm->flag & ARM_RESTPOS)) {
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
bone = pchan->bone;
if (bone) {
copy_m4_m4(pchan->pose_mat, bone->arm_mat);
@ -2600,8 +2590,7 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob)
invert_m4_m4(ob->world_to_object, ob->object_to_world); /* world_to_object is needed */
/* 1. clear flags */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE);
}
@ -2615,8 +2604,7 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob)
BKE_pose_splineik_init_tree(scene, ob, ctime);
/* 3. the main loop, channels are already hierarchical sorted from root to children */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
/* 4a. if we find an IK root, we handle it separated */
if (pchan->flag & POSE_IKTREE) {
BIK_execute_tree(depsgraph, scene, ob, pchan, ctime);
@ -2635,7 +2623,7 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob)
}
/* calculating deform matrices */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->bone) {
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
@ -2651,11 +2639,9 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob)
static int minmax_armature(Object *ob, float r_min[3], float r_max[3])
{
bPoseChannel *pchan;
/* For now, we assume BKE_pose_where_is has already been called
* (hence we have valid data in pachan). */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
minmax_v3v3_v3(r_min, r_max, pchan->pose_head);
minmax_v3v3_v3(r_min, r_max, pchan->pose_tail);
}
@ -2745,10 +2731,8 @@ bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden
if (ob->pose) {
bArmature *arm = static_cast<bArmature *>(ob->data);
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
/* XXX pchan->bone may be nullptr for duplicated bones, see duplicateEditBoneObjects()
* comment (editarmature.c:2592)... Skip in this case too! */
if (pchan->bone && (!((use_hidden == false) && (PBONE_VISIBLE(arm, pchan->bone) == false)) &&

View File

@ -182,11 +182,9 @@ static void splineik_init_tree_from_pchan(Scene * /*scene*/,
/* Tag which bones are members of Spline IK chains. */
static void splineik_init_tree(Scene *scene, Object *ob, float /*ctime*/)
{
bPoseChannel *pchan;
/* Find the tips of Spline IK chains,
* which are simply the bones which have been tagged as such. */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->constflag & PCHAN_HAS_SPLINEIK) {
splineik_init_tree_from_pchan(scene, ob, pchan);
}

View File

@ -205,8 +205,7 @@ static void clean_paths(Main *bmain)
static bool wm_scene_is_visible(wmWindowManager *wm, Scene *scene)
{
wmWindow *win;
for (win = static_cast<wmWindow *>(wm->windows.first); win; win = win->next) {
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->scene == scene) {
return true;
}

View File

@ -74,7 +74,7 @@ static bool rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
BoidParticle *bpa = pa->boid;
EffectedPoint epoint;
ListBase *effectors = bbd->sim->psys->effectors;
EffectorCache *cur, *eff = nullptr;
EffectorCache *eff = nullptr;
EffectorCache temp_eff;
EffectorData efd, cur_efd;
float mul = (rule->type == eBoidRuleType_Avoid ? 1.0 : -1.0);
@ -88,7 +88,7 @@ static bool rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
/* first find out goal/predator with highest priority */
if (effectors) {
for (cur = static_cast<EffectorCache *>(effectors->first); cur; cur = cur->next) {
LISTBASE_FOREACH (EffectorCache *, cur, effectors) {
Object *eob = cur->ob;
PartDeflect *pd = cur->pd;
@ -211,9 +211,7 @@ static bool rule_avoid_collision(BoidRule *rule,
const int raycast_flag = BVH_RAYCAST_DEFAULT & ~BVH_RAYCAST_WATERTIGHT;
BoidRuleAvoidCollision *acbr = (BoidRuleAvoidCollision *)rule;
KDTreeNearest_3d *ptn = nullptr;
ParticleTarget *pt;
BoidParticle *bpa = pa->boid;
ColliderCache *coll;
float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f};
float co1[3], vel1[3], co2[3], vel2[3];
float len, t, inp, t_min = 2.0f;
@ -237,8 +235,7 @@ static bool rule_avoid_collision(BoidRule *rule,
hit.dist = col.original_ray_length = normalize_v3(ray_dir);
/* find out closest deflector object */
for (coll = static_cast<ColliderCache *>(bbd->sim->colliders->first); coll; coll = coll->next)
{
LISTBASE_FOREACH (ColliderCache *, coll, bbd->sim->colliders) {
/* don't check with current ground object */
if (coll->ob == bpa->ground) {
continue;
@ -335,7 +332,7 @@ static bool rule_avoid_collision(BoidRule *rule,
MEM_SAFE_FREE(ptn);
/* check boids in other systems */
for (pt = static_cast<ParticleTarget *>(bbd->sim->psys->targets.first); pt; pt = pt->next) {
LISTBASE_FOREACH (ParticleTarget *, pt, &bbd->sim->psys->targets) {
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
if (epsys) {
@ -404,7 +401,6 @@ static bool rule_separate(BoidRule * /*rule*/,
ParticleData *pa)
{
KDTreeNearest_3d *ptn = nullptr;
ParticleTarget *pt;
float len = 2.0f * val->personal_space * pa->size + 1.0f;
float vec[3] = {0.0f, 0.0f, 0.0f};
int neighbors = BLI_kdtree_3d_range_search(
@ -422,7 +418,7 @@ static bool rule_separate(BoidRule * /*rule*/,
MEM_SAFE_FREE(ptn);
/* check other boid systems */
for (pt = static_cast<ParticleTarget *>(bbd->sim->psys->targets.first); pt; pt = pt->next) {
LISTBASE_FOREACH (ParticleTarget *, pt, &bbd->sim->psys->targets) {
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
if (epsys) {
@ -679,7 +675,6 @@ static bool rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Part
{
BoidRuleFight *fbr = (BoidRuleFight *)rule;
KDTreeNearest_3d *ptn = nullptr;
ParticleTarget *pt;
ParticleData *epars;
ParticleData *enemy_pa = nullptr;
BoidParticle *bpa;
@ -704,7 +699,7 @@ static bool rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Part
MEM_SAFE_FREE(ptn);
/* add other friendlies and calculate enemy strength and find closest enemy */
for (pt = static_cast<ParticleTarget *>(bbd->sim->psys->targets.first); pt; pt = pt->next) {
LISTBASE_FOREACH (ParticleTarget *, pt, &bbd->sim->psys->targets) {
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
if (epsys) {
epars = epsys->particles;
@ -853,7 +848,6 @@ static Object *boid_find_ground(BoidBrainData *bbd,
const float zvec[3] = {0.0f, 0.0f, 2000.0f};
ParticleCollision col;
ColliderCache *coll;
BVHTreeRayHit hit;
float radius = 0.0f, t, ray_dir[3];
@ -872,7 +866,7 @@ static Object *boid_find_ground(BoidBrainData *bbd,
hit.dist = col.original_ray_length = normalize_v3(ray_dir);
col.pce.inside = 0;
for (coll = static_cast<ColliderCache *>(bbd->sim->colliders->first); coll; coll = coll->next) {
LISTBASE_FOREACH (ColliderCache *, coll, bbd->sim->colliders) {
col.current = coll->ob;
col.md = coll->collmd;
col.fac1 = col.fac2 = 0.0f;
@ -905,7 +899,7 @@ static Object *boid_find_ground(BoidBrainData *bbd,
hit.index = -1;
hit.dist = col.original_ray_length = normalize_v3(ray_dir);
for (coll = static_cast<ColliderCache *>(bbd->sim->colliders->first); coll; coll = coll->next) {
LISTBASE_FOREACH (ColliderCache *, coll, bbd->sim->colliders) {
col.current = coll->ob;
col.md = coll->collmd;
@ -956,10 +950,8 @@ static bool boid_rule_applies(ParticleData *pa, BoidSettings * /*boids*/, BoidRu
}
void boids_precalc_rules(ParticleSettings *part, float cfra)
{
BoidState *state = static_cast<BoidState *>(part->boids->states.first);
BoidRule *rule;
for (; state; state = state->next) {
for (rule = static_cast<BoidRule *>(state->rules.first); rule; rule = rule->next) {
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
if (rule->type == eBoidRuleType_FollowLeader) {
BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
@ -1093,7 +1085,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
/* go through rules */
switch (state->ruleset_type) {
case eBoidRulesetType_Fuzzy: {
for (rule = static_cast<BoidRule *>(state->rules.first); rule; rule = rule->next) {
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
if (apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness)) {
break; /* only first nonzero rule that comes through fuzzy rule is applied */
}
@ -1112,7 +1104,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
case eBoidRulesetType_Average: {
float wanted_co[3] = {0.0f, 0.0f, 0.0f}, wanted_speed = 0.0f;
int n = 0;
for (rule = static_cast<BoidRule *>(state->rules.first); rule; rule = rule->next) {
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
if (apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {
add_v3_v3(wanted_co, bbd->wanted_co);
wanted_speed += bbd->wanted_speed;

View File

@ -438,9 +438,7 @@ bool BKE_cache_file_uses_render_procedural(const CacheFile *cache_file, Scene *s
CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepath[1024])
{
for (CacheFileLayer *layer = static_cast<CacheFileLayer *>(cache_file->layers.first); layer;
layer = layer->next)
{
LISTBASE_FOREACH (CacheFileLayer *, layer, &cache_file->layers) {
if (STREQ(layer->filepath, filepath)) {
return nullptr;
}

View File

@ -1976,9 +1976,7 @@ bool BKE_collection_validate(Collection *collection)
/* Check that children have each collection used/referenced only once. */
GSet *processed_collections = BLI_gset_ptr_new(__func__);
for (CollectionChild *child = static_cast<CollectionChild *>(collection->children.first); child;
child = child->next)
{
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
void **r_key;
if (BLI_gset_ensure_p_ex(processed_collections, child->collection, &r_key)) {
is_ok = false;
@ -1990,11 +1988,7 @@ bool BKE_collection_validate(Collection *collection)
/* Check that parents have each collection used/referenced only once. */
BLI_gset_clear(processed_collections, nullptr);
for (CollectionParent *parent =
static_cast<CollectionParent *>(collection->runtime.parents.first);
parent;
parent = parent->next)
{
LISTBASE_FOREACH (CollectionParent *, parent, &collection->runtime.parents) {
void **r_key;
if (BLI_gset_ensure_p_ex(processed_collections, parent->collection, &r_key)) {
is_ok = false;

View File

@ -6300,8 +6300,6 @@ void BKE_constraint_targets_for_solving_get(
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (cti && cti->get_constraint_targets) {
bConstraintTarget *ct;
/* get targets
* - constraints should use ct->matrix, not directly accessing values
* - ct->matrix members have not yet been calculated here!
@ -6317,12 +6315,12 @@ void BKE_constraint_targets_for_solving_get(
* - calculate if possible, otherwise just initialize as identity matrix
*/
if (cti->get_target_matrix) {
for (ct = static_cast<bConstraintTarget *>(targets->first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, targets) {
cti->get_target_matrix(depsgraph, con, cob, ct, ctime);
}
}
else {
for (ct = static_cast<bConstraintTarget *>(targets->first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, targets) {
unit_m4(ct->matrix);
}
}
@ -6355,7 +6353,6 @@ void BKE_constraints_solve(Depsgraph *depsgraph,
bConstraintOb *cob,
float ctime)
{
bConstraint *con;
float oldmat[4][4];
float enf;
@ -6365,7 +6362,7 @@ void BKE_constraints_solve(Depsgraph *depsgraph,
}
/* loop over available constraints, solving and blending them */
for (con = static_cast<bConstraint *>(conlist->first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, conlist) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {nullptr, nullptr};

View File

@ -1511,13 +1511,9 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
tolayers,
space_transform))
{
CustomDataTransferLayerMap *lay_mapit;
changed |= (lay_map.first != nullptr);
for (lay_mapit = static_cast<CustomDataTransferLayerMap *>(lay_map.first); lay_mapit;
lay_mapit = lay_mapit->next)
{
LISTBASE_FOREACH (CustomDataTransferLayerMap *, lay_mapit, &lay_map) {
CustomData_data_transfer(&geom_map[VDATA], lay_mapit);
}
@ -1600,13 +1596,9 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
tolayers,
space_transform))
{
CustomDataTransferLayerMap *lay_mapit;
changed |= (lay_map.first != nullptr);
for (lay_mapit = static_cast<CustomDataTransferLayerMap *>(lay_map.first); lay_mapit;
lay_mapit = lay_mapit->next)
{
LISTBASE_FOREACH (CustomDataTransferLayerMap *, lay_mapit, &lay_map) {
CustomData_data_transfer(&geom_map[EDATA], lay_mapit);
}
@ -1704,13 +1696,9 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
tolayers,
space_transform))
{
CustomDataTransferLayerMap *lay_mapit;
changed |= (lay_map.first != nullptr);
for (lay_mapit = static_cast<CustomDataTransferLayerMap *>(lay_map.first); lay_mapit;
lay_mapit = lay_mapit->next)
{
LISTBASE_FOREACH (CustomDataTransferLayerMap *, lay_mapit, &lay_map) {
CustomData_data_transfer(&geom_map[LDATA], lay_mapit);
}
@ -1793,13 +1781,9 @@ bool BKE_object_data_transfer_ex(Depsgraph *depsgraph,
tolayers,
space_transform))
{
CustomDataTransferLayerMap *lay_mapit;
changed |= (lay_map.first != nullptr);
for (lay_mapit = static_cast<CustomDataTransferLayerMap *>(lay_map.first); lay_mapit;
lay_mapit = lay_mapit->next)
{
LISTBASE_FOREACH (CustomDataTransferLayerMap *, lay_mapit, &lay_map) {
CustomData_data_transfer(&geom_map[PDATA], lay_mapit);
}

View File

@ -684,9 +684,8 @@ int BKE_object_defgroup_flip_index(const Object *ob, int index, const bool use_d
static bool defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *ob)
{
const ListBase *defbase = BKE_object_defgroup_list(ob);
bDeformGroup *curdef;
for (curdef = static_cast<bDeformGroup *>(defbase->first); curdef; curdef = curdef->next) {
LISTBASE_FOREACH (bDeformGroup *, curdef, defbase) {
if (dg != curdef) {
if (STREQ(curdef->name, name)) {
return true;

View File

@ -479,7 +479,6 @@ static float eff_calc_visibility(ListBase *colliders,
{
const int raycast_flag = BVH_RAYCAST_DEFAULT & ~BVH_RAYCAST_WATERTIGHT;
ListBase *colls = colliders;
ColliderCache *col;
float norm[3], len = 0.0;
float visibility = 1.0, absorption = 0.0;
@ -497,7 +496,7 @@ static float eff_calc_visibility(ListBase *colliders,
len = normalize_v3(norm);
/* check all collision objects */
for (col = static_cast<ColliderCache *>(colls->first); col; col = col->next) {
LISTBASE_FOREACH (ColliderCache *, col, colls) {
CollisionModifierData *collmd = col->collmd;
if (col->ob == eff->ob) {
@ -1152,7 +1151,6 @@ void BKE_effectors_apply(ListBase *effectors,
* (particles are guided along a curve bezier or old nurbs)
* (is independent of other effectors)
*/
EffectorCache *eff;
EffectorData efd;
int p = 0, tot = 1, step = 1;
@ -1160,7 +1158,7 @@ void BKE_effectors_apply(ListBase *effectors,
/* Check for min distance here? (yes would be cool to add that, ton) */
if (effectors) {
for (eff = static_cast<EffectorCache *>(effectors->first); eff; eff = eff->next) {
LISTBASE_FOREACH (EffectorCache *, eff, effectors) {
/* object effectors were fully checked to be OK to evaluate! */
get_effector_tot(eff, &efd, point, &tot, &p, &step);

View File

@ -1766,9 +1766,7 @@ void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool
bool found = false;
/* If there's another selected frame here, merge it */
for (tRetainedKeyframe *rk = static_cast<tRetainedKeyframe *>(retained_keys.last); rk;
rk = rk->prev)
{
LISTBASE_FOREACH_BACKWARD (tRetainedKeyframe *, rk, &retained_keys) {
if (IS_EQT(rk->frame, bezt->vec[1][0], BEZT_BINARYSEARCH_THRESH)) {
rk->val += bezt->vec[1][1];
rk->tot_count++;
@ -1819,9 +1817,7 @@ void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool
/* Is this keyframe a candidate for deletion? */
/* TODO: Replace loop with an O(1) lookup instead */
for (tRetainedKeyframe *rk = static_cast<tRetainedKeyframe *>(retained_keys.last); rk;
rk = rk->prev)
{
LISTBASE_FOREACH_BACKWARD (tRetainedKeyframe *, rk, &retained_keys) {
if (IS_EQT(bezt->vec[1][0], rk->frame, BEZT_BINARYSEARCH_THRESH)) {
/* Selected keys are treated with greater care than unselected ones... */
if (BEZT_ISSEL_ANY(bezt)) {

View File

@ -1264,7 +1264,7 @@ static void evaluate_driver_sum(const AnimationEvalContext *anim_eval_context,
int tot = 0;
/* Loop through targets, adding (hopefully we don't get any overflow!). */
for (dvar = static_cast<DriverVar *>(driver->variables.first); dvar; dvar = dvar->next) {
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
value += driver_get_variable_value(anim_eval_context, driver, dvar);
tot++;
}
@ -1281,11 +1281,10 @@ static void evaluate_driver_sum(const AnimationEvalContext *anim_eval_context,
static void evaluate_driver_min_max(const AnimationEvalContext *anim_eval_context,
ChannelDriver *driver)
{
DriverVar *dvar;
float value = 0.0f;
/* Loop through the variables, getting the values and comparing them to existing ones. */
for (dvar = static_cast<DriverVar *>(driver->variables.first); dvar; dvar = dvar->next) {
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
/* Get value. */
float tmp_val = driver_get_variable_value(anim_eval_context, driver, dvar);

View File

@ -1240,15 +1240,13 @@ void free_fmodifiers(ListBase *modifiers)
FModifier *find_active_fmodifier(ListBase *modifiers)
{
FModifier *fcm;
/* sanity checks */
if (ELEM(nullptr, modifiers, modifiers->first)) {
return nullptr;
}
/* loop over modifiers until 'active' one is found */
for (fcm = static_cast<FModifier *>(modifiers->first); fcm; fcm = fcm->next) {
LISTBASE_FOREACH (FModifier *, fcm, modifiers) {
if (fcm->flag & FMODIFIER_FLAG_ACTIVE) {
return fcm;
}
@ -1260,15 +1258,13 @@ FModifier *find_active_fmodifier(ListBase *modifiers)
void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
{
FModifier *fm;
/* sanity checks */
if (ELEM(nullptr, modifiers, modifiers->first)) {
return;
}
/* deactivate all, and set current one active */
for (fm = static_cast<FModifier *>(modifiers->first); fm; fm = fm->next) {
LISTBASE_FOREACH (FModifier *, fm, modifiers) {
fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
}
@ -1280,8 +1276,6 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
bool list_has_suitable_fmodifier(const ListBase *modifiers, int mtype, short acttype)
{
FModifier *fcm;
/* if there are no specific filtering criteria, just skip */
if ((mtype == 0) && (acttype == 0)) {
return (modifiers && modifiers->first);
@ -1293,7 +1287,7 @@ bool list_has_suitable_fmodifier(const ListBase *modifiers, int mtype, short act
}
/* Find the first modifier fitting these criteria. */
for (fcm = static_cast<FModifier *>(modifiers->first); fcm; fcm = fcm->next) {
LISTBASE_FOREACH (FModifier *, fcm, modifiers) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */

View File

@ -40,9 +40,7 @@ void BKE_freestyle_config_init(FreestyleConfig *config)
void BKE_freestyle_config_free(FreestyleConfig *config, const bool do_id_user)
{
FreestyleLineSet *lineset;
for (lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {
LISTBASE_FOREACH (FreestyleLineSet *, lineset, &config->linesets) {
if (lineset->group) {
if (do_id_user) {
id_us_min(&lineset->group->id);
@ -64,8 +62,8 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config,
const FreestyleConfig *config,
const int flag)
{
FreestyleLineSet *lineset, *new_lineset;
FreestyleModuleConfig *module, *new_module;
FreestyleLineSet *new_lineset;
FreestyleModuleConfig *new_module;
new_config->mode = config->mode;
new_config->flags = config->flags;
@ -74,14 +72,14 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config,
new_config->crease_angle = config->crease_angle;
BLI_listbase_clear(&new_config->linesets);
for (lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {
LISTBASE_FOREACH (FreestyleLineSet *, lineset, &config->linesets) {
new_lineset = alloc_lineset();
copy_lineset(new_lineset, lineset, flag);
BLI_addtail(&new_config->linesets, (void *)new_lineset);
}
BLI_listbase_clear(&new_config->modules);
for (module = (FreestyleModuleConfig *)config->modules.first; module; module = module->next) {
LISTBASE_FOREACH (FreestyleModuleConfig *, module, &config->modules) {
new_module = alloc_module();
copy_module(new_module, module);
BLI_addtail(&new_config->modules, (void *)new_module);
@ -211,9 +209,7 @@ bool BKE_freestyle_lineset_delete(FreestyleConfig *config, FreestyleLineSet *lin
FreestyleLineSet *BKE_freestyle_lineset_get_active(FreestyleConfig *config)
{
FreestyleLineSet *lineset;
for (lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {
LISTBASE_FOREACH (FreestyleLineSet *, lineset, &config->linesets) {
if (lineset->flags & FREESTYLE_LINESET_CURRENT) {
return lineset;
}

View File

@ -397,7 +397,7 @@ static void stroke_defvert_create_nr_list(MDeformVert *dv_list,
for (j = 0; j < dv->totweight; j++) {
bool found = false;
dw = &dv->dw[j];
for (ld = (LinkData *)result->first; ld; ld = ld->next) {
LISTBASE_FOREACH (LinkData *, ld, result) {
if (ld->data == POINTER_FROM_INT(dw->def_nr)) {
found = true;
break;
@ -418,7 +418,6 @@ static void stroke_defvert_create_nr_list(MDeformVert *dv_list,
static MDeformVert *stroke_defvert_new_count(int count, int totweight, ListBase *def_nr_list)
{
int i, j;
LinkData *ld;
MDeformVert *dst = (MDeformVert *)MEM_mallocN(count * sizeof(MDeformVert), "new_deformVert");
for (i = 0; i < count; i++) {
@ -427,7 +426,7 @@ static MDeformVert *stroke_defvert_new_count(int count, int totweight, ListBase
dst[i].totweight = totweight;
j = 0;
/* re-assign deform groups */
for (ld = (LinkData *)def_nr_list->first; ld; ld = ld->next) {
LISTBASE_FOREACH (LinkData *, ld, def_nr_list) {
dst[i].dw[j].def_nr = POINTER_AS_INT(ld->data);
j++;
}

View File

@ -1220,12 +1220,10 @@ bool BKE_gpencil_layer_is_editable(const bGPDlayer *gpl)
bGPDframe *BKE_gpencil_layer_frame_find(bGPDlayer *gpl, int cframe)
{
bGPDframe *gpf;
/* Search in reverse order, since this is often used for playback/adding,
* where it's less likely that we're interested in the earlier frames
*/
for (gpf = static_cast<bGPDframe *>(gpl->frames.last); gpf; gpf = gpf->prev) {
LISTBASE_FOREACH_BACKWARD (bGPDframe *, gpf, &gpl->frames) {
if (gpf->framenum == cframe) {
return gpf;
}
@ -1583,15 +1581,13 @@ bGPDlayer *BKE_gpencil_layer_active_get(bGPdata *gpd)
bGPDlayer *BKE_gpencil_layer_get_by_name(bGPdata *gpd, const char *name, int first_if_not_found)
{
bGPDlayer *gpl;
/* error checking */
if (ELEM(nullptr, gpd, gpd->layers.first)) {
return nullptr;
}
/* loop over layers until found (assume only one active) */
for (gpl = static_cast<bGPDlayer *>(gpd->layers.first); gpl; gpl = gpl->next) {
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
if (STREQ(name, gpl->info)) {
return gpl;
}

View File

@ -365,8 +365,7 @@ static void image_blend_write(BlendWriter *writer, ID *id, const void *id_addres
BLO_write_id_struct(writer, Image, id_address, &ima->id);
BKE_id_blend_write(writer, &ima->id);
for (imapf = static_cast<ImagePackedFile *>(ima->packedfiles.first); imapf; imapf = imapf->next)
{
LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
BLO_write_struct(writer, ImagePackedFile, imapf);
BKE_packedfile_blend_write(writer, imapf->packedfile);
}
@ -2685,8 +2684,7 @@ static void image_viewer_create_views(const RenderData *rd, Image *ima)
image_add_view(ima, "", "");
}
else {
for (SceneRenderView *srv = static_cast<SceneRenderView *>(rd->views.first); srv;
srv = srv->next) {
LISTBASE_FOREACH (SceneRenderView *, srv, &rd->views) {
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
}
@ -2711,11 +2709,8 @@ void BKE_image_ensure_viewer_views(const RenderData *rd, Image *ima, ImageUser *
/* multiview also needs to be sure all the views are synced */
if (is_multiview && !do_reset) {
SceneRenderView *srv;
ImageView *iv;
for (iv = static_cast<ImageView *>(ima->views.first); iv; iv = iv->next) {
srv = static_cast<SceneRenderView *>(
LISTBASE_FOREACH (ImageView *, iv, &ima->views) {
SceneRenderView *srv = static_cast<SceneRenderView *>(
BLI_findstring(&rd->views, iv->name, offsetof(SceneRenderView, name)));
if ((srv == nullptr) || (BKE_scene_multiview_is_render_view_active(rd, srv) == false)) {
do_reset = true;
@ -3151,9 +3146,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
BKE_image_packfiles(nullptr, ima, ID_BLEND_PATH(bmain, &ima->id));
}
else {
ImagePackedFile *imapf;
for (imapf = static_cast<ImagePackedFile *>(ima->packedfiles.first); imapf;
imapf = imapf->next) {
LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
PackedFile *pf;
pf = BKE_packedfile_new(nullptr, imapf->filepath, ID_BLEND_PATH(bmain, &ima->id));
if (pf) {
@ -4774,11 +4767,9 @@ void BKE_image_pool_free(ImagePool *pool)
BLI_INLINE ImBuf *image_pool_find_item(
ImagePool *pool, Image *image, int entry, int index, bool *found)
{
ImagePoolItem *item;
*found = false;
for (item = static_cast<ImagePoolItem *>(pool->image_buffers.first); item; item = item->next) {
LISTBASE_FOREACH (ImagePoolItem *, item, &pool->image_buffers) {
if (item->image == image && item->entry == entry && item->index == index) {
*found = true;
return item->ibuf;
@ -5365,7 +5356,6 @@ ImBuf *BKE_image_get_first_ibuf(Image *image)
static void image_update_views_format(Image *ima, ImageUser *iuser)
{
SceneRenderView *srv;
ImageView *iv;
Scene *scene = iuser->scene;
const bool is_multiview = ((scene->r.scemode & R_MULTIVIEW) != 0) &&
@ -5399,7 +5389,7 @@ static void image_update_views_format(Image *ima, ImageUser *iuser)
}
/* create all the image views */
for (srv = static_cast<SceneRenderView *>(scene->r.views.first); srv; srv = srv->next) {
LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) {
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
char filepath_view[FILE_MAX];
SNPRINTF(filepath_view, "%s%s%s", prefix, srv->suffix, ext);

View File

@ -1727,7 +1727,7 @@ static void ipo_to_animato(ID *id,
}
/* loop over IPO-Curves, freeing as we progress */
for (icu = static_cast<IpoCurve *>(ipo->curve.first); icu; icu = icu->next) {
LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
/* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves),
* we figure out the best place to put the channel,
* then tell the curve-converter to just dump there. */
@ -2107,8 +2107,6 @@ void do_versions_ipos_to_animato(Main *bmain)
/* objects */
for (id = static_cast<ID *>(bmain->objects.first); id; id = static_cast<ID *>(id->next)) {
Object *ob = (Object *)id;
bPoseChannel *pchan;
bConstraint *con;
bConstraintChannel *conchan, *conchann;
if (G.debug & G_DEBUG) {
@ -2166,9 +2164,8 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Verify if there's AnimData block */
BKE_animdata_ensure_id(id);
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
/* if constraint has own IPO, convert add these to Object
* (NOTE: they're most likely to be drivers too)
*/
@ -2185,7 +2182,7 @@ void do_versions_ipos_to_animato(Main *bmain)
}
/* check constraints for local IPO's */
for (con = static_cast<bConstraint *>(ob->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, &ob->constraints) {
/* if constraint has own IPO, convert add these to Object
* (NOTE: they're most likely to be drivers too)
*/

View File

@ -306,7 +306,6 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
void BKE_key_sort(Key *key)
{
KeyBlock *kb;
KeyBlock *kb2;
/* locate the key which is out of position */
for (kb = static_cast<KeyBlock *>(key->block.first); kb; kb = kb->next) {
@ -321,7 +320,7 @@ void BKE_key_sort(Key *key)
BLI_remlink(&key->block, kb);
/* find the right location and insert before */
for (kb2 = static_cast<KeyBlock *>(key->block.first); kb2; kb2 = kb2->next) {
LISTBASE_FOREACH (KeyBlock *, kb2, &key->block) {
if (kb2->pos > kb->pos) {
BLI_insertlinkafter(&key->block, kb2->prev, kb);
break;
@ -1879,8 +1878,7 @@ KeyBlock *BKE_keyblock_add_ctime(Key *key, const char *name, const bool do_force
* won't have to systematically use retiming func (and have ordering issues, too). See #39897.
*/
if (!do_force && (key->type != KEY_RELATIVE)) {
KeyBlock *it_kb;
for (it_kb = static_cast<KeyBlock *>(key->block.first); it_kb; it_kb = it_kb->next) {
LISTBASE_FOREACH (KeyBlock *, it_kb, &key->block) {
/* Use epsilon to avoid floating point precision issues.
* 1e-3 because the position is stored as frame * 1e-2. */
if (compare_ff(it_kb->pos, cpos, 1e-3f)) {
@ -2063,7 +2061,6 @@ int BKE_keyblock_curve_element_count(const ListBase *nurb)
void BKE_keyblock_update_from_curve(const Curve * /*cu*/, KeyBlock *kb, const ListBase *nurb)
{
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
float *fp;
@ -2078,7 +2075,7 @@ void BKE_keyblock_update_from_curve(const Curve * /*cu*/, KeyBlock *kb, const Li
}
fp = static_cast<float *>(kb->data);
for (nu = static_cast<Nurb *>(nurb->first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, nurb) {
if (nu->bezt) {
for (a = nu->pntsu, bezt = nu->bezt; a; a--, bezt++) {
for (int i = 0; i < 3; i++) {
@ -2107,7 +2104,7 @@ void BKE_keyblock_curve_data_transform(const ListBase *nurb,
{
const float *src = static_cast<const float *>(src_data);
float *dst = static_cast<float *>(dst_data);
for (Nurb *nu = static_cast<Nurb *>(nurb->first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, nurb) {
if (nu->bezt) {
for (int a = nu->pntsu; a; a--) {
for (int i = 0; i < 3; i++) {
@ -2348,11 +2345,10 @@ void BKE_keyblock_update_from_vertcos(const Object *ob, KeyBlock *kb, const floa
}
else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) {
const Curve *cu = (const Curve *)ob->data;
const Nurb *nu;
const BezTriple *bezt;
const BPoint *bp;
for (nu = static_cast<const Nurb *>(cu->nurb.first); nu; nu = nu->next) {
LISTBASE_FOREACH (const Nurb *, nu, &cu->nurb) {
if (nu->bezt) {
for (a = nu->pntsu, bezt = nu->bezt; a; a--, bezt++) {
for (int i = 0; i < 3; i++, co++) {
@ -2438,11 +2434,10 @@ float (*BKE_keyblock_convert_to_vertcos(const Object *ob, const KeyBlock *kb))[3
}
else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) {
const Curve *cu = (const Curve *)ob->data;
const Nurb *nu;
const BezTriple *bezt;
const BPoint *bp;
for (nu = static_cast<Nurb *>(cu->nurb.first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->bezt) {
for (a = nu->pntsu, bezt = nu->bezt; a; a--, bezt++) {
for (int i = 0; i < 3; i++, co++) {
@ -2475,11 +2470,10 @@ void BKE_keyblock_update_from_offset(const Object *ob, KeyBlock *kb, const float
}
else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) {
const Curve *cu = (const Curve *)ob->data;
const Nurb *nu;
const BezTriple *bezt;
const BPoint *bp;
for (nu = static_cast<const Nurb *>(cu->nurb.first); nu; nu = nu->next) {
LISTBASE_FOREACH (const Nurb *, nu, &cu->nurb) {
if (nu->bezt) {
for (a = nu->pntsu, bezt = nu->bezt; a; a--, bezt++) {
for (int i = 0; i < 3; i++, ofs++) {

View File

@ -705,9 +705,7 @@ void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
}
if (do_keys && lt->key) {
KeyBlock *kb;
for (kb = static_cast<KeyBlock *>(lt->key->block.first); kb; kb = kb->next) {
LISTBASE_FOREACH (KeyBlock *, kb, &lt->key->block) {
float *fp = static_cast<float *>(kb->data);
for (i = kb->totelem; i--; fp += 3) {
mul_m4_v3(mat, fp);
@ -735,9 +733,7 @@ void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
}
if (do_keys && lt->key) {
KeyBlock *kb;
for (kb = static_cast<KeyBlock *>(lt->key->block.first); kb; kb = kb->next) {
LISTBASE_FOREACH (KeyBlock *, kb, &lt->key->block) {
float *fp = static_cast<float *>(kb->data);
for (i = kb->totelem; i--; fp += 3) {
add_v3_v3(fp, offset);

View File

@ -566,10 +566,9 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
sizeof(view_layer->name));
if (scene->nodetree) {
bNode *node;
int index = BLI_findindex(&scene->view_layers, view_layer);
for (node = static_cast<bNode *>(scene->nodetree->nodes.first); node; node = node->next) {
LISTBASE_FOREACH (bNode *, node, &scene->nodetree->nodes) {
if (node->type == CMP_NODE_R_LAYERS && node->id == nullptr) {
if (node->custom1 == index) {
STRNCPY(node->name, view_layer->name);

View File

@ -76,36 +76,23 @@ static void linestyle_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const
linestyle_dst->nodetree->owner_id = &linestyle_dst->id;
}
LineStyleModifier *linestyle_modifier;
BLI_listbase_clear(&linestyle_dst->color_modifiers);
for (linestyle_modifier = (LineStyleModifier *)linestyle_src->color_modifiers.first;
linestyle_modifier;
linestyle_modifier = linestyle_modifier->next)
{
LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->color_modifiers) {
BKE_linestyle_color_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
}
BLI_listbase_clear(&linestyle_dst->alpha_modifiers);
for (linestyle_modifier = (LineStyleModifier *)linestyle_src->alpha_modifiers.first;
linestyle_modifier;
linestyle_modifier = linestyle_modifier->next)
{
LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->alpha_modifiers) {
BKE_linestyle_alpha_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
}
BLI_listbase_clear(&linestyle_dst->thickness_modifiers);
for (linestyle_modifier = (LineStyleModifier *)linestyle_src->thickness_modifiers.first;
linestyle_modifier;
linestyle_modifier = linestyle_modifier->next)
{
LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->thickness_modifiers) {
BKE_linestyle_thickness_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
}
BLI_listbase_clear(&linestyle_dst->geometry_modifiers);
for (linestyle_modifier = (LineStyleModifier *)linestyle_src->geometry_modifiers.first;
linestyle_modifier;
linestyle_modifier = linestyle_modifier->next)
{
LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->geometry_modifiers) {
BKE_linestyle_geometry_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
}
}
@ -187,9 +174,7 @@ static void linestyle_foreach_id(ID *id, LibraryForeachIDData *data)
static void write_linestyle_color_modifiers(BlendWriter *writer, ListBase *modifiers)
{
LineStyleModifier *m;
for (m = static_cast<LineStyleModifier *>(modifiers->first); m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
int struct_nr;
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
@ -221,7 +206,7 @@ static void write_linestyle_color_modifiers(BlendWriter *writer, ListBase *modif
}
BLO_write_struct_by_id(writer, struct_nr, m);
}
for (m = static_cast<LineStyleModifier *>(modifiers->first); m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
BLO_write_struct(writer, ColorBand, ((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
@ -256,9 +241,7 @@ static void write_linestyle_color_modifiers(BlendWriter *writer, ListBase *modif
static void write_linestyle_alpha_modifiers(BlendWriter *writer, ListBase *modifiers)
{
LineStyleModifier *m;
for (m = static_cast<LineStyleModifier *>(modifiers->first); m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
int struct_nr;
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
@ -290,7 +273,7 @@ static void write_linestyle_alpha_modifiers(BlendWriter *writer, ListBase *modif
}
BLO_write_struct_by_id(writer, struct_nr, m);
}
for (m = static_cast<LineStyleModifier *>(modifiers->first); m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
BKE_curvemapping_blend_write(writer, ((LineStyleAlphaModifier_AlongStroke *)m)->curve);
@ -324,9 +307,7 @@ static void write_linestyle_alpha_modifiers(BlendWriter *writer, ListBase *modif
static void write_linestyle_thickness_modifiers(BlendWriter *writer, ListBase *modifiers)
{
LineStyleModifier *m;
for (m = static_cast<LineStyleModifier *>(modifiers->first); m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
int struct_nr;
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
@ -361,7 +342,7 @@ static void write_linestyle_thickness_modifiers(BlendWriter *writer, ListBase *m
}
BLO_write_struct_by_id(writer, struct_nr, m);
}
for (m = static_cast<LineStyleModifier *>(modifiers->first); m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
BKE_curvemapping_blend_write(writer, ((LineStyleThicknessModifier_AlongStroke *)m)->curve);
@ -393,9 +374,7 @@ static void write_linestyle_thickness_modifiers(BlendWriter *writer, ListBase *m
static void write_linestyle_geometry_modifiers(BlendWriter *writer, ListBase *modifiers)
{
LineStyleModifier *m;
for (m = static_cast<LineStyleModifier *>(modifiers->first); m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
int struct_nr;
switch (m->type) {
case LS_MODIFIER_SAMPLING:
@ -1921,13 +1900,12 @@ bool BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle,
void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase)
{
LineStyleModifier *m;
ColorBand *color_ramp;
LinkData *link;
BLI_listbase_clear(listbase);
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->color_modifiers) {
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
color_ramp = ((LineStyleColorModifier_AlongStroke *)m)->color_ramp;
@ -1952,10 +1930,9 @@ void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, List
char *BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand *color_ramp)
{
LineStyleModifier *m;
bool found = false;
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->color_modifiers) {
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp) {
@ -2013,10 +1990,7 @@ bool BKE_linestyle_use_textures(FreestyleLineStyle *linestyle, const bool use_sh
{
if (use_shading_nodes) {
if (linestyle && linestyle->use_nodes && linestyle->nodetree) {
bNode *node;
for (node = static_cast<bNode *>(linestyle->nodetree->nodes.first); node; node = node->next)
{
LISTBASE_FOREACH (bNode *, node, &linestyle->nodetree->nodes) {
if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
return true;
}

View File

@ -1377,12 +1377,9 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
static bNode *nodetree_uv_node_recursive(bNode *node)
{
bNode *inode;
bNodeSocket *sock;
for (sock = static_cast<bNodeSocket *>(node->inputs.first); sock; sock = sock->next) {
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (sock->link) {
inode = sock->link->fromnode;
bNode *inode = sock->link->fromnode;
if (inode->typeinfo->nclass == NODE_CLASS_INPUT && inode->typeinfo->type == SH_NODE_UVMAP) {
return inode;
}

View File

@ -166,11 +166,7 @@ static void write_movieTracks(BlendWriter *writer, ListBase *tracks)
static void write_moviePlaneTracks(BlendWriter *writer, ListBase *plane_tracks_base)
{
MovieTrackingPlaneTrack *plane_track;
for (plane_track = static_cast<MovieTrackingPlaneTrack *>(plane_tracks_base->first); plane_track;
plane_track = plane_track->next)
{
LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
BLO_write_struct(writer, MovieTrackingPlaneTrack, plane_track);
BLO_write_pointer_array(writer, plane_track->point_tracksnr, plane_track->point_tracks);

View File

@ -138,7 +138,7 @@ NlaStrip *BKE_nlastrip_copy(Main *bmain,
const int flag)
{
NlaStrip *strip_d;
NlaStrip *cs, *cs_d;
NlaStrip *cs_d;
const bool do_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0;
@ -172,7 +172,7 @@ NlaStrip *BKE_nlastrip_copy(Main *bmain,
/* make a copy of all the child-strips, one at a time */
BLI_listbase_clear(&strip_d->strips);
for (cs = static_cast<NlaStrip *>(strip->strips.first); cs; cs = cs->next) {
LISTBASE_FOREACH (NlaStrip *, cs, &strip->strips) {
cs_d = BKE_nlastrip_copy(bmain, cs, use_same_action, flag);
BLI_addtail(&strip_d->strips, cs_d);
}
@ -186,7 +186,7 @@ NlaTrack *BKE_nlatrack_copy(Main *bmain,
const bool use_same_actions,
const int flag)
{
NlaStrip *strip, *strip_d;
NlaStrip *strip_d;
NlaTrack *nlt_d;
/* sanity check */
@ -201,7 +201,7 @@ NlaTrack *BKE_nlatrack_copy(Main *bmain,
/* make a copy of all the strips, one at a time */
BLI_listbase_clear(&nlt_d->strips);
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
strip_d = BKE_nlastrip_copy(bmain, strip, use_same_actions, flag);
BLI_addtail(&nlt_d->strips, strip_d);
}
@ -212,7 +212,7 @@ NlaTrack *BKE_nlatrack_copy(Main *bmain,
void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, const ListBase *src, const int flag)
{
NlaTrack *nlt, *nlt_d;
NlaTrack *nlt_d;
/* sanity checks */
if (ELEM(nullptr, dst, src)) {
@ -223,7 +223,7 @@ void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, const ListBase *src, const
BLI_listbase_clear(dst);
/* copy each NLA-track, one at a time */
for (nlt = static_cast<NlaTrack *>(src->first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, src) {
/* make a copy, and add the copy to the destination list */
/* XXX: we need to fix this sometime. */
nlt_d = BKE_nlatrack_copy(bmain, nlt, true, flag);
@ -759,8 +759,6 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
bool BKE_nlastrips_has_space(ListBase *strips, float start, float end)
{
NlaStrip *strip;
/* sanity checks */
if ((strips == nullptr) || IS_EQF(start, end)) {
return false;
@ -771,7 +769,7 @@ bool BKE_nlastrips_has_space(ListBase *strips, float start, float end)
}
/* loop over NLA strips checking for any overlaps with this area... */
for (strip = static_cast<NlaStrip *>(strips->first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* if start frame of strip is past the target end-frame, that means that
* we've gone past the window we need to check for, so things are fine
*/
@ -794,7 +792,7 @@ bool BKE_nlastrips_has_space(ListBase *strips, float start, float end)
void BKE_nlastrips_sort_strips(ListBase *strips)
{
ListBase tmp = {nullptr, nullptr};
NlaStrip *strip, *sstrip, *stripn;
NlaStrip *strip, *stripn;
/* sanity checks */
if (ELEM(nullptr, strips, strips->first)) {
@ -814,7 +812,7 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
*/
BLI_remlink(strips, strip);
for (sstrip = static_cast<NlaStrip *>(tmp.last); sstrip; sstrip = sstrip->prev) {
LISTBASE_FOREACH_BACKWARD (NlaStrip *, sstrip, &tmp) {
/* check if add after */
if (sstrip->start <= strip->start) {
BLI_insertlinkafter(&tmp, sstrip, strip);
@ -836,14 +834,13 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
void BKE_nlastrips_add_strip_unsafe(ListBase *strips, NlaStrip *strip)
{
NlaStrip *ns;
bool not_added = true;
/* sanity checks */
BLI_assert(!ELEM(nullptr, strips, strip));
/* find the right place to add the strip to the nominated track */
for (ns = static_cast<NlaStrip *>(strips->first); ns; ns = ns->next) {
LISTBASE_FOREACH (NlaStrip *, ns, strips) {
/* if current strip occurs after the new strip, add it before */
if (ns->start >= strip->start) {
BLI_insertlinkbefore(strips, ns, strip);
@ -1023,7 +1020,6 @@ bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
{
NlaStrip *strip;
float oStart, oEnd, offset;
float oLen, nLen;
short scaleChanged = 0;
@ -1061,7 +1057,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
}
/* for each child-strip, calculate new start/end points based on this new info */
for (strip = static_cast<NlaStrip *>(mstrip->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &mstrip->strips) {
if (scaleChanged) {
float p1, p2;
@ -1088,7 +1084,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
}
/* apply a second pass over child strips, to finish up unfinished business */
for (strip = static_cast<NlaStrip *>(mstrip->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &mstrip->strips) {
/* only if scale changed, need to perform RNA updates */
if (scaleChanged) {
PointerRNA ptr;
@ -1109,15 +1105,13 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
NlaTrack *BKE_nlatrack_find_active(ListBase *tracks)
{
NlaTrack *nlt;
/* sanity check */
if (ELEM(nullptr, tracks, tracks->first)) {
return nullptr;
}
/* try to find the first active track */
for (nlt = static_cast<NlaTrack *>(tracks->first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
if (nlt->flag & NLATRACK_ACTIVE) {
return nlt;
}
@ -1129,15 +1123,13 @@ NlaTrack *BKE_nlatrack_find_active(ListBase *tracks)
NlaTrack *BKE_nlatrack_find_tweaked(AnimData *adt)
{
NlaTrack *nlt;
/* sanity check */
if (adt == nullptr) {
return nullptr;
}
/* Since the track itself gets disabled, we want the first disabled... */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
if (nlt->flag & (NLATRACK_ACTIVE | NLATRACK_DISABLED)) {
/* For good measure, make sure that strip actually exists there */
if (BLI_findindex(&nlt->strips, adt->actstrip) != -1) {
@ -1160,15 +1152,13 @@ NlaTrack *BKE_nlatrack_find_tweaked(AnimData *adt)
void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
{
NlaTrack *nt;
/* sanity check */
if (ELEM(nullptr, adt, adt->nla_tracks.first)) {
return;
}
/* firstly, make sure 'solo' flag for all tracks is disabled */
for (nt = static_cast<NlaTrack *>(adt->nla_tracks.first); nt; nt = nt->next) {
LISTBASE_FOREACH (NlaTrack *, nt, &adt->nla_tracks) {
if (nt != nlt) {
nt->flag &= ~NLATRACK_SOLO;
}
@ -1194,15 +1184,13 @@ void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a)
{
NlaTrack *nlt;
/* sanity check */
if (ELEM(nullptr, tracks, tracks->first)) {
return;
}
/* deactivate all the rest */
for (nlt = static_cast<NlaTrack *>(tracks->first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
nlt->flag &= ~NLATRACK_ACTIVE;
}
@ -1411,17 +1399,14 @@ void BKE_nlastrip_remove_and_free(ListBase *strips, NlaStrip *strip, const bool
void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
{
NlaTrack *nlt;
NlaStrip *nls;
/* sanity checks */
if (adt == nullptr) {
return;
}
/* Loop over tracks, deactivating. */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
for (nls = static_cast<NlaStrip *>(nlt->strips.first); nls; nls = nls->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
LISTBASE_FOREACH (NlaStrip *, nls, &nlt->strips) {
if (nls != strip) {
nls->flag &= ~NLASTRIP_FLAG_ACTIVE;
}
@ -1646,15 +1631,13 @@ void BKE_nlastrip_recalculate_blend(NlaStrip *strip)
bool BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
{
NlaStrip *strip;
/* sanity checks */
if (ELEM(nullptr, nlt, nlt->strips.first)) {
return false;
}
/* check each strip for F-Curves only (don't care about whether the flags are set) */
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (strip->fcurves.first) {
return true;
}
@ -1666,15 +1649,13 @@ bool BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
bool BKE_nlatracks_have_animated_strips(ListBase *tracks)
{
NlaTrack *nlt;
/* sanity checks */
if (ELEM(nullptr, tracks, tracks->first)) {
return false;
}
/* check each track, stopping on the first hit */
for (nlt = static_cast<NlaTrack *>(tracks->first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
if (BKE_nlatrack_has_animated_strips(nlt)) {
return true;
}
@ -1790,8 +1771,6 @@ static bool nla_editbone_name_check(void *arg, const char *name)
void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
{
GHash *gh;
NlaStrip *tstrip;
NlaTrack *nlt;
/* sanity checks */
if (ELEM(nullptr, adt, strip)) {
@ -1822,8 +1801,8 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
*/
gh = BLI_ghash_str_new("nlastrip_validate_name gh");
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
for (tstrip = static_cast<NlaStrip *>(nlt->strips.first); tstrip; tstrip = tstrip->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
LISTBASE_FOREACH (NlaStrip *, tstrip, &nlt->strips) {
/* don't add the strip of interest */
if (tstrip == strip) {
continue;
@ -1862,13 +1841,11 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip,
float **start,
float **end)
{
NlaStrip *nls;
/* find strips that overlap over the start/end of the given strip,
* but which don't cover the entire length
*/
/* TODO: this scheme could get quite slow for doing this on many strips... */
for (nls = static_cast<NlaStrip *>(track->strips.first); nls; nls = nls->next) {
LISTBASE_FOREACH (NlaStrip *, nls, &track->strips) {
/* Check if strip overlaps (extends over or exactly on)
* the entire range of the strip we're validating. */
if ((nls->start <= strip->start) && (nls->end >= strip->end)) {
@ -1984,8 +1961,6 @@ static bool nlastrip_validate_transition_start_end(ListBase *strips, NlaStrip *s
void BKE_nla_validate_state(AnimData *adt)
{
NlaTrack *nlt;
/* sanity checks */
if (ELEM(nullptr, adt, adt->nla_tracks.first)) {
return;
@ -1993,7 +1968,7 @@ void BKE_nla_validate_state(AnimData *adt)
/* Adjust blending values for auto-blending,
* and also do an initial pass to find the earliest strip. */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
LISTBASE_FOREACH_MUTABLE (NlaStrip *, strip, &nlt->strips) {
if (!nlastrip_validate_transition_start_end(&nlt->strips, strip)) {
@ -2017,12 +1992,9 @@ void BKE_nla_validate_state(AnimData *adt)
bool BKE_nla_action_is_stashed(AnimData *adt, bAction *act)
{
NlaTrack *nlt;
NlaStrip *strip;
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
if (strstr(nlt->name, STASH_TRACK_NAME)) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (strip->act == act) {
return true;
}
@ -2162,13 +2134,13 @@ static void nla_tweakmode_find_active(const ListBase /* NlaTrack */ *nla_tracks,
NlaTrack **r_track_of_active_strip,
NlaStrip **r_active_strip)
{
NlaTrack *nlt, *activeTrack = nullptr;
NlaStrip *strip, *activeStrip = nullptr;
NlaTrack *activeTrack = nullptr;
NlaStrip *activeStrip = nullptr;
/* go over the tracks, finding the active one, and its active strip
* - if we cannot find both, then there's nothing to do
*/
for (nlt = static_cast<NlaTrack *>(nla_tracks->first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, nla_tracks) {
/* check if active */
if (nlt->flag & NLATRACK_ACTIVE) {
/* store reference to this active track */
@ -2188,7 +2160,7 @@ static void nla_tweakmode_find_active(const ListBase /* NlaTrack */ *nla_tracks,
*/
if (activeTrack == nullptr) {
/* try last selected track for active strip */
for (nlt = static_cast<NlaTrack *>(nla_tracks->last); nlt; nlt = nlt->prev) {
LISTBASE_FOREACH_BACKWARD (NlaTrack *, nlt, nla_tracks) {
if (nlt->flag & NLATRACK_SELECTED) {
/* assume this is the active track */
activeTrack = nlt;
@ -2202,7 +2174,7 @@ static void nla_tweakmode_find_active(const ListBase /* NlaTrack */ *nla_tracks,
if ((activeTrack) && (activeStrip == nullptr)) {
/* No active strip in active or last selected track;
* compromise for first selected (assuming only single). */
for (strip = static_cast<NlaStrip *>(activeTrack->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &activeTrack->strips) {
if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) {
activeStrip = strip;
break;
@ -2217,7 +2189,7 @@ static void nla_tweakmode_find_active(const ListBase /* NlaTrack */ *nla_tracks,
bool BKE_nla_tweakmode_enter(AnimData *adt)
{
NlaTrack *nlt, *activeTrack = nullptr;
NlaStrip *strip, *activeStrip = nullptr;
NlaStrip *activeStrip = nullptr;
/* verify that data is valid */
if (ELEM(nullptr, adt, adt->nla_tracks.first)) {
@ -2243,8 +2215,8 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
/* Go over all the tracks, tagging each strip that uses the same
* action as the active strip, but leaving everything else alone.
*/
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (strip->act == activeStrip->act) {
strip->flag |= NLASTRIP_FLAG_TWEAKUSER;
}
@ -2291,7 +2263,6 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
void BKE_nla_tweakmode_exit(AnimData *adt)
{
NlaStrip *strip;
NlaTrack *nlt;
/* verify that data is valid */
if (ELEM(nullptr, adt, adt->nla_tracks.first)) {
@ -2319,10 +2290,10 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
/* for all Tracks, clear the 'disabled' flag
* for all Strips, clear the 'tweak-user' flag
*/
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
nlt->flag &= ~NLATRACK_DISABLED;
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* sync strip extents if this strip uses the same action */
if ((adt->actstrip) && (adt->actstrip->act == strip->act) &&
(strip->flag & NLASTRIP_FLAG_SYNC_LENGTH))

View File

@ -5250,8 +5250,7 @@ static Object *obrel_armature_find(Object *ob)
ob_arm = ob->parent;
}
else {
ModifierData *mod;
for (mod = (ModifierData *)ob->modifiers.first; mod; mod = mod->next) {
LISTBASE_FOREACH (ModifierData *, mod, &ob->modifiers) {
if (mod->type == eModifierType_Armature) {
ob_arm = ((ArmatureModifierData *)mod)->object;
}

View File

@ -53,10 +53,6 @@ static Lattice *object_defgroup_lattice_get(ID *id)
void BKE_object_defgroup_remap_update_users(Object *ob, const int *map)
{
ModifierData *md;
ParticleSystem *psys;
int a;
/* these cases don't use names to refer to vertex groups, so when
* they get removed the numbers get out of sync, this corrects that */
@ -64,7 +60,7 @@ void BKE_object_defgroup_remap_update_users(Object *ob, const int *map)
ob->soft->vertgroup = map[ob->soft->vertgroup];
}
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Explode) {
ExplodeModifierData *emd = (ExplodeModifierData *)md;
emd->vgroup = map[emd->vgroup];
@ -81,8 +77,8 @@ void BKE_object_defgroup_remap_update_users(Object *ob, const int *map)
}
}
for (psys = static_cast<ParticleSystem *>(ob->particlesystem.first); psys; psys = psys->next) {
for (a = 0; a < PSYS_TOT_VG; a++) {
LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
for (int a = 0; a < PSYS_TOT_VG; a++) {
psys->vgroup[a] = map[psys->vgroup[a]];
}
}
@ -207,12 +203,11 @@ bool BKE_object_defgroup_clear(Object *ob, bDeformGroup *dg, const bool use_sele
bool BKE_object_defgroup_clear_all(Object *ob, const bool use_selection)
{
bDeformGroup *dg;
bool changed = false;
const ListBase *defbase = BKE_object_defgroup_list(ob);
for (dg = static_cast<bDeformGroup *>(defbase->first); dg; dg = dg->next) {
LISTBASE_FOREACH (bDeformGroup *, dg, defbase) {
if (BKE_object_defgroup_clear(ob, dg, use_selection)) {
changed = true;
}
@ -564,7 +559,7 @@ bool *BKE_object_defgroup_validmap_get(Object *ob, const int defbase_tot)
gh = BLI_ghash_str_new_ex(__func__, defbase_tot);
/* add all names to a hash table */
for (dg = static_cast<bDeformGroup *>(defbase->first); dg; dg = dg->next) {
LISTBASE_FOREACH (bDeformGroup *, dg, defbase) {
BLI_ghash_insert(gh, dg->name, nullptr);
}
@ -585,9 +580,8 @@ bool *BKE_object_defgroup_validmap_get(Object *ob, const int defbase_tot)
if (amd->object && amd->object->pose) {
bPose *pose = amd->object->pose;
bPoseChannel *chan;
for (chan = static_cast<bPoseChannel *>(pose->chanbase.first); chan; chan = chan->next) {
LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
void **val_p;
if (chan->bone->flag & BONE_NO_DEFORM) {
continue;

View File

@ -622,13 +622,11 @@ static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot,
static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *bufs)
{
LinkData *buf;
if (cache) {
MEM_freeN(cache);
}
for (buf = static_cast<LinkData *>(bufs->first); buf; buf = buf->next) {
LISTBASE_FOREACH (LinkData *, buf, bufs) {
MEM_freeN(buf->data);
}
BLI_freelistN(bufs);
@ -640,12 +638,11 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf
ParticleSystem *psys_get_current(Object *ob)
{
ParticleSystem *psys;
if (ob == nullptr) {
return nullptr;
}
for (psys = static_cast<ParticleSystem *>(ob->particlesystem.first); psys; psys = psys->next) {
LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
if (psys->flag & PSYS_CURRENT) {
return psys;
}
@ -915,7 +912,7 @@ void psys_check_group_weights(ParticleSettings *part)
/* Ensure there is an element marked as current. */
int current = 0;
for (dw = static_cast<ParticleDupliWeight *>(part->instance_weights.first); dw; dw = dw->next) {
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
if (dw->flag & PART_DUPLIW_CURRENT) {
current = 1;
break;
@ -1083,7 +1080,6 @@ void psys_free(Object *ob, ParticleSystem *psys)
{
if (psys) {
int nr = 0;
ParticleSystem *tpsys;
psys_free_path_cache(psys, nullptr);
@ -1116,8 +1112,7 @@ void psys_free(Object *ob, ParticleSystem *psys)
}
/* check if we are last non-visible particle system */
for (tpsys = static_cast<ParticleSystem *>(ob->particlesystem.first); tpsys;
tpsys = tpsys->next) {
LISTBASE_FOREACH (ParticleSystem *, tpsys, &ob->particlesystem) {
if (tpsys->part) {
if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
nr++;
@ -1355,10 +1350,9 @@ static int get_pointcache_times_for_particle(PointCache *cache,
float *r_start,
float *r_dietime)
{
PTCacheMem *pm;
int ret = 0;
for (pm = static_cast<PTCacheMem *>(cache->mem_cache.first); pm; pm = pm->next) {
LISTBASE_FOREACH (PTCacheMem *, pm, &cache->mem_cache) {
if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
*r_start = pm->frame;
ret++;
@ -1366,7 +1360,7 @@ static int get_pointcache_times_for_particle(PointCache *cache,
}
}
for (pm = static_cast<PTCacheMem *>(cache->mem_cache.last); pm; pm = pm->prev) {
LISTBASE_FOREACH_BACKWARD (PTCacheMem *, pm, &cache->mem_cache) {
if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
/* Die *after* the last available frame. */
*r_dietime = pm->frame + 1;
@ -1380,10 +1374,9 @@ static int get_pointcache_times_for_particle(PointCache *cache,
float psys_get_dietime_from_cache(PointCache *cache, int index)
{
PTCacheMem *pm;
int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */
for (pm = static_cast<PTCacheMem *>(cache->mem_cache.last); pm; pm = pm->prev) {
LISTBASE_FOREACH_BACKWARD (PTCacheMem *, pm, &cache->mem_cache) {
if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
/* Die *after* the last available frame. */
dietime = pm->frame + 1;
@ -2259,10 +2252,9 @@ float psys_particle_value_from_verts(Mesh *mesh, short from, ParticleData *pa, f
ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys)
{
ModifierData *md;
ParticleSystemModifierData *psmd;
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_ParticleSystem) {
psmd = (ParticleSystemModifierData *)md;
if (psmd->psys == psys) {
@ -2390,7 +2382,6 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
EffectedPoint point;
ParticleKey state;
EffectorData efd;
EffectorCache *eff;
ParticleSystem *psys = sim->psys;
EffectorWeights *weights = sim->psys->part->effector_weights;
GuideEffectorData *data;
@ -2419,7 +2410,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
pd_point_from_particle(sim, pa, &state, &point);
for (eff = static_cast<EffectorCache *>(effectors->first); eff; eff = eff->next) {
LISTBASE_FOREACH (EffectorCache *, eff, effectors) {
if (eff->pd->forcefield != PFIELD_GUIDE) {
continue;
}
@ -2452,7 +2443,6 @@ bool do_guides(Depsgraph *depsgraph,
nullptr;
CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve :
nullptr;
EffectorCache *eff;
PartDeflect *pd;
Curve *cu;
GuideEffectorData *data;
@ -2463,7 +2453,7 @@ bool do_guides(Depsgraph *depsgraph,
float vec_to_point[3];
if (effectors) {
for (eff = static_cast<EffectorCache *>(effectors->first); eff; eff = eff->next) {
LISTBASE_FOREACH (EffectorCache *, eff, effectors) {
pd = eff->pd;
if (pd->forcefield != PFIELD_GUIDE) {

View File

@ -2847,7 +2847,6 @@ static int collision_detect(ParticleData *pa,
ListBase *colliders)
{
const int raycast_flag = BVH_RAYCAST_DEFAULT & ~(BVH_RAYCAST_WATERTIGHT);
ColliderCache *coll;
float ray_dir[3];
if (BLI_listbase_is_empty(colliders)) {
@ -2865,7 +2864,7 @@ static int collision_detect(ParticleData *pa,
hit->dist = col->original_ray_length = 0.000001f;
}
for (coll = static_cast<ColliderCache *>(colliders->first); coll; coll = coll->next) {
LISTBASE_FOREACH (ColliderCache *, coll, colliders) {
/* for boids: don't check with current ground object; also skip if permeated */
bool skip = false;
@ -5035,7 +5034,6 @@ static void particlesystem_modifiersForeachIDLink(void *user_data,
void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func, void *userdata)
{
ParticleTarget *pt;
LibraryForeachIDData *foreachid_data = static_cast<LibraryForeachIDData *>(userdata);
const int foreachid_data_flags = BKE_lib_query_foreachid_process_flags_get(foreachid_data);
@ -5056,7 +5054,7 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func,
}
}
for (pt = static_cast<ParticleTarget *>(psys->targets.first); pt; pt = pt->next) {
LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
func(psys, (ID **)&pt->ob, userdata, IDWALK_CB_NOP);
}

View File

@ -2936,8 +2936,6 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
{
PTCacheID pid;
ParticleSystem *psys;
ModifierData *md;
int reset, skip;
reset = 0;
@ -2948,7 +2946,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
for (psys = static_cast<ParticleSystem *>(ob->particlesystem.first); psys; psys = psys->next) {
LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
/* children or just redo can be calculated without resetting anything */
if (psys->recalc & ID_RECALC_PSYS_REDO || psys->recalc & ID_RECALC_PSYS_CHILD) {
skip = 1;
@ -2973,7 +2971,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
}
}
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Cloth) {
BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData *)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
@ -3081,9 +3079,7 @@ static PointCache *ptcache_copy(PointCache *cache, const bool copy_data)
ncache->simframe = 0;
}
else {
PTCacheMem *pm;
for (pm = static_cast<PTCacheMem *>(cache->mem_cache.first); pm; pm = pm->next) {
LISTBASE_FOREACH (PTCacheMem *, pm, &cache->mem_cache) {
PTCacheMem *pmn = static_cast<PTCacheMem *>(MEM_dupallocN(pm));
int i;
@ -3200,10 +3196,9 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) {
/* get all pids from the object and search for smoke low res */
ListBase pidlist2;
PTCacheID *pid2;
BLI_assert(GS(pid->owner_id->name) == ID_OB);
BKE_ptcache_ids_from_object(&pidlist2, (Object *)pid->owner_id, scene, MAX_DUPLI_RECUR);
for (pid2 = static_cast<PTCacheID *>(pidlist2.first); pid2; pid2 = pid2->next) {
LISTBASE_FOREACH (PTCacheID *, pid2, &pidlist2) {
if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED) {
@ -3366,7 +3361,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
for (SETLOOPER_VIEW_LAYER(scene, view_layer, sce_iter, base)) {
BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
for (pid = static_cast<PTCacheID *>(pidlist.first); pid; pid = pid->next) {
LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) {
/* skip hair particles */
if (pid->type == PTCACHE_TYPE_PARTICLES &&
((ParticleSystem *)pid->calldata)->part->type == PART_HAIR)
@ -3677,7 +3672,6 @@ void BKE_ptcache_load_external(PTCacheID *pid)
void BKE_ptcache_update_info(PTCacheID *pid)
{
PointCache *cache = pid->cache;
PTCacheExtra *extra = nullptr;
int totframes = 0;
char mem_info[sizeof(PointCache::info) / sizeof(*PointCache::info)];
@ -3740,7 +3734,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
bytes += MEM_allocN_len(pm->data[i]);
}
for (extra = static_cast<PTCacheExtra *>(pm->extradata.first); extra; extra = extra->next) {
LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
bytes += MEM_allocN_len(extra->data);
bytes += sizeof(PTCacheExtra);
}

View File

@ -146,8 +146,7 @@ static void reports_prepend_impl(ReportList *reports, const char *prepend)
/* Caller must ensure. */
BLI_assert(reports && reports->list.first);
const size_t prefix_len = strlen(prepend);
for (Report *report = static_cast<Report *>(reports->list.first); report; report = report->next)
{
LISTBASE_FOREACH (Report *, report, &reports->list) {
char *message = BLI_string_joinN(prepend, report->message);
MEM_freeN((void *)report->message);
report->message = message;
@ -217,7 +216,6 @@ void BKE_report_store_level_set(ReportList *reports, eReportType level)
char *BKE_reports_string(ReportList *reports, eReportType level)
{
Report *report;
DynStr *ds;
char *cstring;
@ -226,7 +224,7 @@ char *BKE_reports_string(ReportList *reports, eReportType level)
}
ds = BLI_dynstr_new();
for (report = static_cast<Report *>(reports->list.first); report; report = report->next) {
LISTBASE_FOREACH (Report *, report, &reports->list) {
if (report->type >= level) {
BLI_dynstr_appendf(ds, "%s: %s\n", report->typestr, report->message);
}
@ -276,9 +274,7 @@ void BKE_reports_print(ReportList *reports, eReportType level)
Report *BKE_reports_last_displayable(ReportList *reports)
{
Report *report;
for (report = static_cast<Report *>(reports->list.last); report; report = report->prev) {
LISTBASE_FOREACH_BACKWARD (Report *, report, &reports->list) {
if (ELEM(report->type, RPT_ERROR, RPT_WARNING, RPT_INFO)) {
return report;
}
@ -289,9 +285,8 @@ Report *BKE_reports_last_displayable(ReportList *reports)
bool BKE_reports_contain(ReportList *reports, eReportType level)
{
Report *report;
if (reports != nullptr) {
for (report = static_cast<Report *>(reports->list.first); report; report = report->next) {
LISTBASE_FOREACH (Report *, report, &reports->list) {
if (report->type >= level) {
return true;
}
@ -302,13 +297,11 @@ bool BKE_reports_contain(ReportList *reports, eReportType level)
bool BKE_report_write_file_fp(FILE *fp, ReportList *reports, const char *header)
{
Report *report;
if (header) {
fputs(header, fp);
}
for (report = static_cast<Report *>(reports->list.first); report; report = report->next) {
LISTBASE_FOREACH (Report *, report, &reports->list) {
fprintf((FILE *)fp, "%s # %s\n", report->message, report->typestr);
}

View File

@ -45,8 +45,7 @@ static ShaderFxTypeInfo *shader_fx_types[NUM_SHADER_FX_TYPES] = {nullptr};
bool BKE_shaderfx_has_gpencil(const Object *ob)
{
const ShaderFxData *fx;
for (fx = static_cast<const ShaderFxData *>(ob->shader_fx.first); fx; fx = fx->next) {
LISTBASE_FOREACH (const ShaderFxData *, fx, &ob->shader_fx) {
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(ShaderFxType(fx->type));
if (fxi->type == eShaderFxType_GpencilType) {
return true;

View File

@ -1133,8 +1133,6 @@ void BKE_sound_read_waveform(Main *bmain, bSound *sound, bool *stop)
static void sound_update_base(Scene *scene, Object *object, void *new_set)
{
NlaTrack *track;
NlaStrip *strip;
Speaker *speaker;
float quat[4];
@ -1145,9 +1143,8 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set)
return;
}
for (track = static_cast<NlaTrack *>(object->adt->nla_tracks.first); track; track = track->next)
{
for (strip = static_cast<NlaStrip *>(track->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaTrack *, track, &object->adt->nla_tracks) {
LISTBASE_FOREACH (NlaStrip *, strip, &track->strips) {
if (strip->type != NLASTRIP_TYPE_SOUND) {
continue;
}

View File

@ -638,7 +638,7 @@ UndoStep *BKE_undosys_step_find_by_name_with_type(UndoStack *ustack,
const char *name,
const UndoType *ut)
{
for (UndoStep *us = static_cast<UndoStep *>(ustack->steps.last); us; us = us->prev) {
LISTBASE_FOREACH_BACKWARD (UndoStep *, us, &ustack->steps) {
if (us->type == ut) {
if (STREQ(name, us->name)) {
return us;
@ -655,7 +655,7 @@ UndoStep *BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name)
UndoStep *BKE_undosys_step_find_by_type(UndoStack *ustack, const UndoType *ut)
{
for (UndoStep *us = static_cast<UndoStep *>(ustack->steps.last); us; us = us->prev) {
LISTBASE_FOREACH_BACKWARD (UndoStep *, us, &ustack->steps) {
if (us->type == ut) {
return us;
}

View File

@ -522,10 +522,8 @@ int BLI_listbase_count_at_most(const ListBase *listbase, const int count_max)
int BLI_listbase_count(const ListBase *listbase)
{
Link *link;
int count = 0;
for (link = static_cast<Link *>(listbase->first); link; link = link->next) {
LISTBASE_FOREACH (Link *, link, listbase) {
count++;
}
@ -601,14 +599,13 @@ int BLI_findindex(const ListBase *listbase, const void *vlink)
void *BLI_findstring(const ListBase *listbase, const char *id, const int offset)
{
Link *link = nullptr;
const char *id_iter;
if (id == nullptr) {
return nullptr;
}
for (link = static_cast<Link *>(listbase->first); link; link = link->next) {
LISTBASE_FOREACH (Link *, link, listbase) {
id_iter = ((const char *)link) + offset;
if (id[0] == id_iter[0] && STREQ(id, id_iter)) {
@ -621,13 +618,8 @@ void *BLI_findstring(const ListBase *listbase, const char *id, const int offset)
void *BLI_rfindstring(const ListBase *listbase, const char *id, const int offset)
{
/* Same as #BLI_findstring but find reverse. */
Link *link = nullptr;
const char *id_iter;
for (link = static_cast<Link *>(listbase->last); link; link = link->prev) {
id_iter = ((const char *)link) + offset;
LISTBASE_FOREACH_BACKWARD (Link *, link, listbase) {
const char *id_iter = ((const char *)link) + offset;
if (id[0] == id_iter[0] && STREQ(id, id_iter)) {
return link;
}
@ -638,10 +630,9 @@ void *BLI_rfindstring(const ListBase *listbase, const char *id, const int offset
void *BLI_findstring_ptr(const ListBase *listbase, const char *id, const int offset)
{
Link *link = nullptr;
const char *id_iter;
for (link = static_cast<Link *>(listbase->first); link; link = link->next) {
LISTBASE_FOREACH (Link *, link, listbase) {
/* exact copy of BLI_findstring(), except for this line */
id_iter = *((const char **)(((const char *)link) + offset));
@ -656,13 +647,11 @@ void *BLI_rfindstring_ptr(const ListBase *listbase, const char *id, const int of
{
/* Same as #BLI_findstring_ptr but find reverse. */
Link *link = nullptr;
const char *id_iter;
for (link = static_cast<Link *>(listbase->last); link; link = link->prev) {
/* exact copy of BLI_rfindstring(), except for this line */
LISTBASE_FOREACH_BACKWARD (Link *, link, listbase) {
/* Exact copy of #BLI_rfindstring(), except for this line */
id_iter = *((const char **)(((const char *)link) + offset));
if (id[0] == id_iter[0] && STREQ(id, id_iter)) {
return link;
}
@ -673,36 +662,26 @@ void *BLI_rfindstring_ptr(const ListBase *listbase, const char *id, const int of
void *BLI_findptr(const ListBase *listbase, const void *ptr, const int offset)
{
Link *link = nullptr;
const void *ptr_iter;
for (link = static_cast<Link *>(listbase->first); link; link = link->next) {
/* exact copy of BLI_findstring(), except for this line */
ptr_iter = *((const void **)(((const char *)link) + offset));
LISTBASE_FOREACH (Link *, link, listbase) {
/* Exact copy of #BLI_findstring(), except for this line. */
const void *ptr_iter = *((const void **)(((const char *)link) + offset));
if (ptr == ptr_iter) {
return link;
}
}
return nullptr;
}
void *BLI_rfindptr(const ListBase *listbase, const void *ptr, const int offset)
{
/* Same as #BLI_findptr but find reverse. */
Link *link = nullptr;
const void *ptr_iter;
for (link = static_cast<Link *>(listbase->last); link; link = link->prev) {
/* exact copy of BLI_rfindstring(), except for this line */
ptr_iter = *((const void **)(((const char *)link) + offset));
LISTBASE_FOREACH_BACKWARD (Link *, link, listbase) {
/* Exact copy of #BLI_rfindstring(), except for this line. */
const void *ptr_iter = *((const void **)(((const char *)link) + offset));
if (ptr == ptr_iter) {
return link;
}
}
return nullptr;
}
@ -711,12 +690,8 @@ void *BLI_listbase_bytes_find(const ListBase *listbase,
const size_t bytes_size,
const int offset)
{
Link *link = nullptr;
const void *ptr_iter;
for (link = static_cast<Link *>(listbase->first); link; link = link->next) {
ptr_iter = (const void *)(((const char *)link) + offset);
LISTBASE_FOREACH (Link *, link, listbase) {
const void *ptr_iter = (const void *)(((const char *)link) + offset);
if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
return link;
}
@ -730,18 +705,12 @@ void *BLI_listbase_bytes_rfind(const ListBase *listbase,
const int offset)
{
/* Same as #BLI_listbase_bytes_find but find reverse. */
Link *link = nullptr;
const void *ptr_iter;
for (link = static_cast<Link *>(listbase->last); link; link = link->prev) {
ptr_iter = (const void *)(((const char *)link) + offset);
LISTBASE_FOREACH_BACKWARD (Link *, link, listbase) {
const void *ptr_iter = (const void *)(((const char *)link) + offset);
if (memcmp(bytes, ptr_iter, bytes_size) == 0) {
return link;
}
}
return nullptr;
}
@ -885,7 +854,7 @@ bool BLI_listbase_validate(ListBase *lb)
/* Walk the list in bot directions to ensure all next & prev pointers are valid and consistent.
*/
for (Link *lb_link = static_cast<Link *>(lb->first); lb_link; lb_link = lb_link->next) {
LISTBASE_FOREACH (Link *, lb_link, lb) {
if (lb_link == lb->first) {
if (lb_link->prev != nullptr) {
return false;
@ -897,7 +866,7 @@ bool BLI_listbase_validate(ListBase *lb)
}
}
}
for (Link *lb_link = static_cast<Link *>(lb->last); lb_link; lb_link = lb_link->prev) {
LISTBASE_FOREACH_BACKWARD (Link *, lb_link, lb) {
if (lb_link == lb->last) {
if (lb_link->next != nullptr) {
return false;

View File

@ -530,7 +530,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
// printf("blo_find_main: original in %s\n", filepath);
// printf("blo_find_main: converted to %s\n", filepath_abs);
for (m = static_cast<Main *>(mainlist->first); m; m = m->next) {
LISTBASE_FOREACH (Main *, m, mainlist) {
const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->filepath;
if (BLI_path_cmp(filepath_abs, libname) == 0) {
@ -2239,7 +2239,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
BLI_path_normalize(lib->filepath_abs);
/* check if the library was already read */
for (newmain = static_cast<Main *>(fd->mainlist->first); newmain; newmain = newmain->next) {
LISTBASE_FOREACH (Main *, newmain, fd->mainlist) {
if (newmain->curlib) {
if (BLI_path_cmp(newmain->curlib->filepath_abs, lib->filepath_abs) == 0) {
BLO_reportf_wrap(fd->reports,

View File

@ -108,7 +108,6 @@ static void vcol_to_fcol(Mesh *me)
static void do_version_bone_head_tail_237(Bone *bone)
{
Bone *child;
float vec[3];
/* head */
@ -119,16 +118,14 @@ static void do_version_bone_head_tail_237(Bone *bone)
mul_v3_fl(vec, bone->length);
add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
for (child = static_cast<Bone *>(bone->childbase.first); child; child = child->next) {
LISTBASE_FOREACH (Bone *, child, &bone->childbase) {
do_version_bone_head_tail_237(child);
}
}
static void bone_version_238(ListBase *lb)
{
Bone *bone;
for (bone = static_cast<Bone *>(lb->first); bone; bone = bone->next) {
LISTBASE_FOREACH (Bone *, bone, lb) {
if (bone->rad_tail == 0.0f && bone->rad_head == 0.0f) {
bone->rad_head = 0.25f * bone->length;
bone->rad_tail = 0.1f * bone->length;
@ -144,9 +141,7 @@ static void bone_version_238(ListBase *lb)
static void bone_version_239(ListBase *lb)
{
Bone *bone;
for (bone = static_cast<Bone *>(lb->first); bone; bone = bone->next) {
LISTBASE_FOREACH (Bone *, bone, lb) {
if (bone->layer == 0) {
bone->layer = 1;
}
@ -156,10 +151,8 @@ static void bone_version_239(ListBase *lb)
static void ntree_version_241(bNodeTree *ntree)
{
bNode *node;
if (ntree->type == NTREE_COMPOSIT) {
for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_BLUR) {
if (node->storage == nullptr) {
NodeBlurData *nbd = static_cast<NodeBlurData *>(
@ -186,10 +179,8 @@ static void ntree_version_241(bNodeTree *ntree)
static void ntree_version_242(bNodeTree *ntree)
{
bNode *node;
if (ntree->type == NTREE_COMPOSIT) {
for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_HUE_SAT) {
if (node->storage) {
NodeHueSat *nhs = static_cast<NodeHueSat *>(node->storage);
@ -204,14 +195,13 @@ static void ntree_version_242(bNodeTree *ntree)
static void ntree_version_245(FileData *fd, Library * /*lib*/, bNodeTree *ntree)
{
bNode *node;
NodeTwoFloats *ntf;
ID *nodeid;
Image *image;
ImageUser *iuser;
if (ntree->type == NTREE_COMPOSIT) {
for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_ALPHAOVER) {
if (!node->storage) {
ntf = static_cast<NodeTwoFloats *>(MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"));
@ -370,10 +360,8 @@ static void customdata_version_243(Mesh *me)
/* struct NodeImageAnim moved to ImageUser, and we make it default available */
static void do_version_ntree_242_2(bNodeTree *ntree)
{
bNode *node;
if (ntree->type == NTREE_COMPOSIT) {
for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
/* only image had storage */
if (node->storage) {
@ -421,10 +409,9 @@ static void do_version_free_effects_245(ListBase *lb)
static void do_version_constraints_245(ListBase *lb)
{
bConstraint *con;
bConstraintTarget *ct;
for (con = static_cast<bConstraint *>(lb->first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, lb) {
if (con->type == CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = (bPythonConstraint *)con->data;
if (data->tar) {
@ -888,12 +875,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_GRAPH) {
SpaceSeq *sseq = (SpaceSeq *)sl;
sseq->v2d.keeptot = 0;
@ -921,8 +904,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
*/
if (list) {
bConstraint *curcon;
for (curcon = static_cast<bConstraint *>(list->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, list) {
if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
bTrackToConstraint *data = static_cast<bTrackToConstraint *>(curcon->data);
data->reserved1 = ob->trackflag;
@ -933,12 +915,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (ob->type == OB_ARMATURE) {
if (ob->pose) {
bConstraint *curcon;
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
for (curcon = static_cast<bConstraint *>(pchan->constraints.first); curcon;
curcon = curcon->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
LISTBASE_FOREACH (bConstraint *, curcon, &pchan->constraints) {
if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
bTrackToConstraint *data = static_cast<bTrackToConstraint *>(curcon->data);
data->reserved1 = ob->trackflag;
@ -966,12 +944,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *sac = (SpaceAction *)sl;
sac->v2d.max[0] = 32000;
@ -1002,8 +976,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
* set their track and up flag correctly */
if (list) {
bConstraint *curcon;
for (curcon = static_cast<bConstraint *>(list->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, list) {
if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
bTrackToConstraint *data = static_cast<bTrackToConstraint *>(curcon->data);
data->reserved1 = ob->trackflag;
@ -1014,12 +987,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (ob->type == OB_ARMATURE) {
if (ob->pose) {
bConstraint *curcon;
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
for (curcon = static_cast<bConstraint *>(pchan->constraints.first); curcon;
curcon = curcon->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
LISTBASE_FOREACH (bConstraint *, curcon, &pchan->constraints) {
if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
bTrackToConstraint *data = static_cast<bTrackToConstraint *>(curcon->data);
data->reserved1 = ob->trackflag;
@ -1037,12 +1006,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_PROPERTIES) {
SpaceProperties *sbuts = (SpaceProperties *)sl;
@ -1108,12 +1073,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
/* added: 5x better zoom in for action */
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *sac = (SpaceAction *)sl;
@ -1194,10 +1155,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
/* added: 5x better zoom in for nla */
if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)sl;
@ -1214,10 +1173,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->flag |= V3D_SELECT_OUTLINE;
@ -1233,10 +1190,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_TEXT) {
SpaceText *st = (SpaceText *)sl;
if (st->tabnumber == 0) {
@ -1308,9 +1263,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile <= 237) {
bArmature *arm;
bConstraint *con;
Object *ob;
Bone *bone;
/* armature recode checks */
for (arm = static_cast<bArmature *>(bmain->armatures.first); arm;
@ -1318,7 +1271,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
{
BKE_armature_where_is(arm);
for (bone = static_cast<Bone *>(arm->bonebase.first); bone; bone = bone->next) {
LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
do_version_bone_head_tail_237(bone);
}
}
@ -1385,7 +1338,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
/* follow path constraint needs to set the 'path' option in curves... */
for (con = static_cast<bConstraint *>(ob->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, &ob->constraints) {
if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
bFollowPathConstraint *data = static_cast<bFollowPathConstraint *>(con->data);
Object *obc = static_cast<Object *>(
@ -1435,7 +1388,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ModifierData *md;
PartEff *paf;
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
@ -1463,17 +1416,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
if (ob->pose) {
bPoseChannel *pchan;
bConstraint *con;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
/* NOTE: pchan->bone is also lib-link stuff. */
if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) {
pchan->limitmin[0] = pchan->limitmin[1] = pchan->limitmin[2] = -180.0f;
pchan->limitmax[0] = pchan->limitmax[1] = pchan->limitmax[2] = 180.0f;
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next)
{
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = (bKinematicConstraint *)con->data;
data->weight = 1.0f;
@ -1524,10 +1473,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (key = static_cast<Key *>(bmain->shapekeys.first); key;
key = static_cast<Key *>(key->id.next)) {
KeyBlock *kb;
int index = 1;
for (kb = static_cast<KeyBlock *>(key->block.first); kb; kb = kb->next) {
LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
if (kb == key->refkey) {
if (kb->name[0] == 0) {
STRNCPY(kb->name, "Basis");
@ -1553,9 +1501,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* deformflag is local in modifier now */
for (ob = static_cast<Object *>(bmain->objects.first); ob;
ob = static_cast<Object *>(ob->id.next)) {
ModifierData *md;
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
if (amd->object && amd->deformflag == 0) {
@ -1626,11 +1572,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* We don't add default layer since blender2.8 because the layers
* are now in Scene->view_layers and a default layer is created in
* the doversion later on.
*/
SceneRenderLayer *srl;
* the doversion later on. */
/* new layer flag for sky, was default for solid */
for (srl = static_cast<SceneRenderLayer *>(sce->r.layers.first); srl; srl = srl->next) {
LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
if (srl->layflag & SCE_LAY_SOLID) {
srl->layflag |= SCE_LAY_SKY;
}
@ -1686,7 +1631,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Material *ma;
Mesh *me;
Collection *collection;
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
bNodeTree *ntree;
@ -1698,9 +1642,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ScrArea *area;
area = static_cast<ScrArea *>(screen->areabase.first);
while (area) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d->gridsubdiv == 0) {
@ -1743,7 +1685,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* add default radius values to old curve points */
for (cu = static_cast<Curve *>(bmain->curves.first); cu;
cu = static_cast<Curve *>(cu->id.next)) {
for (nu = static_cast<Nurb *>(cu->nurb.first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
if (!bezt->radius) {
@ -1763,7 +1705,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (ob = static_cast<Object *>(bmain->objects.first); ob;
ob = static_cast<Object *>(ob->id.next)) {
ModifierData *md;
ListBase *list;
list = &ob->constraints;
@ -1771,8 +1712,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
* and update the sticky flagging */
if (list) {
bConstraint *curcon;
for (curcon = static_cast<bConstraint *>(list->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, list) {
switch (curcon->type) {
case CONSTRAINT_TYPE_ROTLIKE: {
bRotateLikeConstraint *data = static_cast<bRotateLikeConstraint *>(curcon->data);
@ -1790,12 +1730,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (ob->type == OB_ARMATURE) {
if (ob->pose) {
bConstraint *curcon;
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
for (curcon = static_cast<bConstraint *>(pchan->constraints.first); curcon;
curcon = curcon->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
LISTBASE_FOREACH (bConstraint *, curcon, &pchan->constraints) {
switch (curcon->type) {
case CONSTRAINT_TYPE_KINEMATIC: {
bKinematicConstraint *data = static_cast<bKinematicConstraint *>(curcon->data);
@ -1821,7 +1757,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
/* copy old object level track settings to curve modifiers */
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Curve) {
CurveModifierData *cmd = (CurveModifierData *)md;
@ -1934,10 +1870,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Object *ob = static_cast<Object *>(bmain->objects.first);
for (; ob; ob = static_cast<Object *>(ob->id.next)) {
bDeformGroup *curdef;
for (curdef = static_cast<bDeformGroup *>(ob->defbase.first); curdef; curdef = curdef->next)
{
LISTBASE_FOREACH (bDeformGroup *, curdef, &ob->defbase) {
/* replace an empty-string name with unique name */
if (curdef->name[0] == '\0') {
BKE_object_defgroup_unique_name(curdef, ob);
@ -1945,10 +1878,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
if (bmain->versionfile < 243 || bmain->subversionfile < 1) {
ModifierData *md;
/* translate old mirror modifier axis values to new flags */
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Mirror) {
MirrorModifierData *mmd = (MirrorModifierData *)md;
@ -1991,9 +1922,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ScrArea *area;
area = static_cast<ScrArea *>(screen->areabase.first);
while (area) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
@ -2018,8 +1947,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ParticleSettings *part;
bNodeTree *ntree;
Tex *tex;
ModifierData *md;
ParticleSystem *psys;
/* unless the file was created 2.44.3 but not 2.45, update the constraints */
if (!(bmain->versionfile == 244 && bmain->subversionfile == 3) &&
@ -2032,8 +1959,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* fix up constraints due to constraint recode changes (originally at 2.44.3) */
if (list) {
bConstraint *curcon;
for (curcon = static_cast<bConstraint *>(list->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, list) {
/* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
if (curcon->flag & 0x20) {
curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
@ -2059,14 +1985,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (ob->type == OB_ARMATURE) {
if (ob->pose) {
bConstraint *curcon;
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
/* make sure constraints are all up to date */
for (curcon = static_cast<bConstraint *>(pchan->constraints.first); curcon;
curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, &pchan->constraints) {
/* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
if (curcon->flag & 0x20) {
curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
@ -2112,8 +2033,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches);
}
for (psys = static_cast<ParticleSystem *>(ob->particlesystem.first); psys; psys = psys->next)
{
LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
if (psys->pointcache) {
if (psys->pointcache->flag & PTCACHE_BAKED &&
(psys->pointcache->flag & PTCACHE_DISK_CACHE) == 0) {
@ -2126,7 +2046,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
if (!clmd->point_cache) {
@ -2210,7 +2130,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 245, 4)) {
bArmature *arm;
ModifierData *md;
Object *ob;
for (arm = static_cast<bArmature *>(bmain->armatures.first); arm;
@ -2221,7 +2140,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (ob = static_cast<Object *>(bmain->objects.first); ob;
ob = static_cast<Object *>(ob->id.next)) {
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Armature) {
((ArmatureModifierData *)md)->deformflag |= ARM_DEF_B_BONE_REST;
}
@ -2255,13 +2174,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 245, 7)) {
Object *ob;
bPoseChannel *pchan;
for (ob = static_cast<Object *>(bmain->objects.first); ob;
ob = static_cast<Object *>(ob->id.next)) {
if (ob->pose) {
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
do_version_constraints_245(&pchan->constraints);
}
}
@ -2465,12 +2382,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 245, 11)) {
Object *ob;
bActionStrip *strip;
/* NLA-strips - scale. */
for (ob = static_cast<Object *>(bmain->objects.first); ob;
ob = static_cast<Object *>(ob->id.next)) {
for (strip = static_cast<bActionStrip *>(ob->nlastrips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (bActionStrip *, strip, &ob->nlastrips) {
float length, actlength, repeat;
if (strip->flag & ACTSTRIP_USESTRIDE) {
@ -2576,11 +2492,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* set the curve radius interpolation to 2.47 default - easy */
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 247, 6)) {
Curve *cu;
Nurb *nu;
for (cu = static_cast<Curve *>(bmain->curves.first); cu;
cu = static_cast<Curve *>(cu->id.next)) {
for (nu = static_cast<Nurb *>(cu->nurb.first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
nu->radius_interp = 3;
/* resolu and resolv are now used differently for surfaces
@ -2614,12 +2529,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
switch (sl->spacetype) {
case SPACE_ACTION: {
SpaceAction *sact = (SpaceAction *)sl;

View File

@ -319,9 +319,7 @@ void blo_do_versions_userdef(UserDef *userdef)
}
if (!USER_VERSION_ATLEAST(250, 8)) {
wmKeyMap *km;
for (km = static_cast<wmKeyMap *>(userdef->user_keymaps.first); km; km = km->next) {
LISTBASE_FOREACH (wmKeyMap *, km, &userdef->user_keymaps) {
if (STREQ(km->idname, "Armature_Sketch")) {
STRNCPY(km->idname, "Armature Sketch");
}

View File

@ -607,7 +607,6 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
BMEdge *e, *e_new, **etable = nullptr;
BMFace *f, *f_new, **ftable = nullptr;
BMElem **eletable;
BMEditSelection *ese;
BMIter iter;
int i;
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_BM(bm_old);
@ -683,7 +682,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
BLI_assert(i == bm_old->totface);
/* copy over edit selection history */
for (ese = static_cast<BMEditSelection *>(bm_old->selected.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &bm_old->selected) {
BMElem *ele = nullptr;
switch (ese->htype) {

View File

@ -398,27 +398,21 @@ void BM_mesh_edgeloops_free(ListBase *eloops)
void BM_mesh_edgeloops_calc_center(BMesh *bm, ListBase *eloops)
{
BMEdgeLoopStore *el_store;
for (el_store = static_cast<BMEdgeLoopStore *>(eloops->first); el_store;
el_store = el_store->next) {
LISTBASE_FOREACH (BMEdgeLoopStore *, el_store, eloops) {
BM_edgeloop_calc_center(bm, el_store);
}
}
void BM_mesh_edgeloops_calc_normal(BMesh *bm, ListBase *eloops)
{
BMEdgeLoopStore *el_store;
for (el_store = static_cast<BMEdgeLoopStore *>(eloops->first); el_store;
el_store = el_store->next) {
LISTBASE_FOREACH (BMEdgeLoopStore *, el_store, eloops) {
BM_edgeloop_calc_normal(bm, el_store);
}
}
void BM_mesh_edgeloops_calc_normal_aligned(BMesh *bm, ListBase *eloops, const float no_align[3])
{
BMEdgeLoopStore *el_store;
for (el_store = static_cast<BMEdgeLoopStore *>(eloops->first); el_store;
el_store = el_store->next) {
LISTBASE_FOREACH (BMEdgeLoopStore *, el_store, eloops) {
BM_edgeloop_calc_normal_aligned(bm, el_store, no_align);
}
}
@ -442,8 +436,7 @@ void BM_mesh_edgeloops_calc_order(BMesh * /*bm*/, ListBase *eloops, const bool u
{
BMEdgeLoopStore *el_store_best = nullptr;
float len_best_sq = -1.0f;
for (el_store = static_cast<BMEdgeLoopStore *>(eloops->first); el_store;
el_store = el_store->next) {
LISTBASE_FOREACH (BMEdgeLoopStore *, el_store, eloops) {
const float len_sq = len_squared_v3v3(cent, el_store->co);
if (len_sq > len_best_sq) {
len_best_sq = len_sq;
@ -466,8 +459,7 @@ void BM_mesh_edgeloops_calc_order(BMesh * /*bm*/, ListBase *eloops, const bool u
BLI_ASSERT_UNIT_V3(no);
}
for (el_store = static_cast<BMEdgeLoopStore *>(eloops->first); el_store;
el_store = el_store->next) {
LISTBASE_FOREACH (BMEdgeLoopStore *, el_store, eloops) {
float len_sq;
if (use_normals) {
/* Scale the length by how close the loops are to pointing at each other. */
@ -776,23 +768,21 @@ void BM_edgeloop_expand(
bool BM_edgeloop_overlap_check(BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b)
{
LinkData *node;
/* A little more efficient if 'a' as smaller. */
if (el_store_a->len > el_store_b->len) {
SWAP(BMEdgeLoopStore *, el_store_a, el_store_b);
}
/* init */
for (node = static_cast<LinkData *>(el_store_a->verts.first); node; node = node->next) {
LISTBASE_FOREACH (LinkData *, node, &el_store_a->verts) {
BM_elem_flag_enable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
for (node = static_cast<LinkData *>(el_store_b->verts.first); node; node = node->next) {
LISTBASE_FOREACH (LinkData *, node, &el_store_b->verts) {
BM_elem_flag_disable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
/* Check 'a' (clear as we go). */
for (node = static_cast<LinkData *>(el_store_a->verts.first); node; node = node->next) {
LISTBASE_FOREACH (LinkData *, node, &el_store_a->verts) {
if (!BM_elem_flag_test((BMVert *)node->data, BM_ELEM_INTERNAL_TAG)) {
/* Finish clearing 'a', leave tag clean. */
while ((node = node->next)) {

View File

@ -1139,16 +1139,13 @@ bool BM_select_history_active_get(BMesh *bm, BMEditSelection *ese)
GHash *BM_select_history_map_create(BMesh *bm)
{
BMEditSelection *ese;
GHash *map;
if (BLI_listbase_is_empty(&bm->selected)) {
return nullptr;
}
map = BLI_ghash_ptr_new(__func__);
GHash *map = BLI_ghash_ptr_new(__func__);
for (ese = static_cast<BMEditSelection *>(bm->selected.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
BLI_ghash_insert(map, ese->ele, ese);
}

View File

@ -990,8 +990,7 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
/* Selection history */
{
BMEditSelection *ese;
for (ese = static_cast<BMEditSelection *>(bm->selected.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
switch (ese->htype) {
case BM_VERT:
if (vptr_map) {

View File

@ -1512,7 +1512,7 @@ bool BMO_error_get_at_level(BMesh *bm,
const char **r_msg,
BMOperator **r_op)
{
for (BMOpError *err = static_cast<BMOpError *>(bm->errorstack.first); err; err = err->next) {
LISTBASE_FOREACH (BMOpError *, err, &bm->errorstack) {
if (err->level >= level) {
if (r_msg) {
*r_msg = err->msg;

View File

@ -257,9 +257,7 @@ static void bridge_loop_pair(BMesh *bm,
int winding_votes[2] = {0, 0};
int winding_dir = 1;
for (i = 0; i < 2; i++, winding_dir = -winding_dir) {
LinkData *el;
for (el = static_cast<LinkData *>(BM_edgeloop_verts_get(estore_pair[i])->first); el;
el = el->next) {
LISTBASE_FOREACH (LinkData *, el, BM_edgeloop_verts_get(estore_pair[i])) {
LinkData *el_next = BM_EDGELINK_NEXT(estore_pair[i], el);
if (el_next) {
BMEdge *e = BM_edge_exists(static_cast<BMVert *>(el->data),
@ -510,9 +508,7 @@ static void bridge_loop_pair(BMesh *bm,
/* tag verts on each side so we can restrict rotation of edges to verts on the same side */
for (i = 0; i < 2; i++) {
LinkData *el;
for (el = static_cast<LinkData *>(BM_edgeloop_verts_get(estore_pair[i])->first); el;
el = el->next) {
LISTBASE_FOREACH (LinkData *, el, BM_edgeloop_verts_get(estore_pair[i])) {
BM_elem_flag_set((BMVert *)el->data, BM_ELEM_TAG, i);
}
}
@ -557,9 +553,7 @@ static void bridge_loop_pair(BMesh *bm,
BMEdgeLoopStore *estore_pair[2] = {el_store_a, el_store_b};
int i;
for (i = 0; i < 2; i++) {
LinkData *el;
for (el = static_cast<LinkData *>(BM_edgeloop_verts_get(estore_pair[i])->first); el;
el = el->next) {
LISTBASE_FOREACH (LinkData *, el, BM_edgeloop_verts_get(estore_pair[i])) {
LinkData *el_next = BM_EDGELINK_NEXT(estore_pair[i], el);
if (el_next) {
if (el->data != el_next->data) {
@ -580,7 +574,6 @@ static void bridge_loop_pair(BMesh *bm,
void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
{
ListBase eloops = {nullptr};
LinkData *el_store;
/* merge-bridge support */
const bool use_pairs = BMO_slot_bool_get(op->slots_in, "use_pairs");
@ -610,7 +603,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
if (use_merge) {
bool match = true;
const int eloop_len = BM_edgeloop_length_get(static_cast<BMEdgeLoopStore *>(eloops.first));
for (el_store = static_cast<LinkData *>(eloops.first); el_store; el_store = el_store->next) {
LISTBASE_FOREACH (LinkData *, el_store, &eloops) {
if (eloop_len != BM_edgeloop_length_get((BMEdgeLoopStore *)el_store)) {
match = false;
break;
@ -629,7 +622,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
BM_mesh_edgeloops_calc_order(bm, &eloops, use_pairs);
}
for (el_store = static_cast<LinkData *>(eloops.first); el_store; el_store = el_store->next) {
LISTBASE_FOREACH (LinkData *, el_store, &eloops) {
LinkData *el_store_next = el_store->next;
if (el_store_next == nullptr) {

View File

@ -222,11 +222,9 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
* if all history verts have ELE_NEW flagged and the total number of history verts == totv,
* then we know the history contains all verts here and we can continue...
*/
BMEditSelection *ese;
int tot_ese_v = 0;
for (ese = static_cast<BMEditSelection *>(bm->selected.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
if (ese->htype == BM_VERT) {
if (BMO_vert_flag_test(bm, (BMVert *)ese->ele, ELE_NEW)) {
tot_ese_v++;
@ -243,7 +241,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
BMVert *v_prev = nullptr;
/* yes, all select-history verts are accounted for, now make edges */
for (ese = static_cast<BMEditSelection *>(bm->selected.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
if (ese->htype == BM_VERT) {
BMVert *v = (BMVert *)ese->ele;
if (v_prev) {

View File

@ -160,7 +160,7 @@ static LinkData *final_edges_find_link(ListBase *adj, BMVert *v)
{
LinkData *link;
for (link = static_cast<LinkData *>(adj->first); link; link = link->next) {
LISTBASE_FOREACH (LinkData *, link, adj) {
if (link->data == v) {
return link;
}

View File

@ -155,15 +155,13 @@ static bool bm_edgeloop_check_overlap_all(BMesh *bm,
BMEdgeLoopStore *el_store_b)
{
bool has_overlap = true;
LinkData *node;
ListBase *lb_a = BM_edgeloop_verts_get(el_store_a);
ListBase *lb_b = BM_edgeloop_verts_get(el_store_b);
bm_edgeloop_vert_tag(el_store_a, false);
bm_edgeloop_vert_tag(el_store_b, true);
for (node = static_cast<LinkData *>(lb_a->first); node; node = node->next) {
LISTBASE_FOREACH (LinkData *, node, lb_a) {
if (bm_vert_is_tag_edge_connect(bm, static_cast<BMVert *>(node->data)) == false) {
has_overlap = false;
goto finally;
@ -173,7 +171,7 @@ static bool bm_edgeloop_check_overlap_all(BMesh *bm,
bm_edgeloop_vert_tag(el_store_a, true);
bm_edgeloop_vert_tag(el_store_b, false);
for (node = static_cast<LinkData *>(lb_b->first); node; node = node->next) {
LISTBASE_FOREACH (LinkData *, node, lb_b) {
if (bm_vert_is_tag_edge_connect(bm, static_cast<BMVert *>(node->data)) == false) {
has_overlap = false;
goto finally;
@ -994,7 +992,6 @@ static void bm_edgering_pair_subdiv(BMesh *bm,
STACK_DECLARE(edges_ring_arr);
STACK_DECLARE(faces_ring_arr);
BMEdgeLoopStore *el_store_ring;
LinkData *node;
BMEdge *e;
BMFace *f;
@ -1004,7 +1001,7 @@ static void bm_edgering_pair_subdiv(BMesh *bm,
bm_edgeloop_vert_tag(el_store_a, false);
bm_edgeloop_vert_tag(el_store_b, true);
for (node = static_cast<LinkData *>(lb_a->first); node; node = node->next) {
LISTBASE_FOREACH (LinkData *, node, lb_a) {
BMIter eiter;
BM_ITER_ELEM (e, &eiter, (BMVert *)node->data, BM_EDGES_OF_VERT) {

View File

@ -54,7 +54,6 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
BMEdge *e;
ScanFillContext sf_ctx;
/* ScanFillEdge *sf_edge; */ /* UNUSED */
ScanFillFace *sf_tri;
GHash *sf_vert_map;
float normal[3];
const int scanfill_flag = BLI_SCANFILL_CALC_HOLES | BLI_SCANFILL_CALC_POLYS |
@ -181,9 +180,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
/* if we have existing faces, base winding on those */
if (calc_winding) {
int winding_votes = 0;
for (sf_tri = static_cast<ScanFillFace *>(sf_ctx.fillfacebase.first); sf_tri;
sf_tri = sf_tri->next)
{
LISTBASE_FOREACH (ScanFillFace *, sf_tri, &sf_ctx.fillfacebase) {
BMVert *v_tri[3] = {static_cast<BMVert *>(sf_tri->v1->tmp.p),
static_cast<BMVert *>(sf_tri->v2->tmp.p),
static_cast<BMVert *>(sf_tri->v3->tmp.p)};
@ -198,17 +195,13 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
}
if (winding_votes < 0) {
for (sf_tri = static_cast<ScanFillFace *>(sf_ctx.fillfacebase.first); sf_tri;
sf_tri = sf_tri->next)
{
LISTBASE_FOREACH (ScanFillFace *, sf_tri, &sf_ctx.fillfacebase) {
SWAP(ScanFillVert *, sf_tri->v2, sf_tri->v3);
}
}
}
for (sf_tri = static_cast<ScanFillFace *>(sf_ctx.fillfacebase.first); sf_tri;
sf_tri = sf_tri->next)
{
LISTBASE_FOREACH (ScanFillFace *, sf_tri, &sf_ctx.fillfacebase) {
BMFace *f;
BMLoop *l;
BMIter liter;

View File

@ -28,10 +28,8 @@ void BM_mesh_edgesplit(BMesh *bm,
GHash *ese_gh = nullptr;
if (copy_select && bm->selected.first) {
BMEditSelection *ese;
ese_gh = BLI_ghash_ptr_new(__func__);
for (ese = static_cast<BMEditSelection *>(bm->selected.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
if (ese->htype != BM_FACE) {
BLI_ghash_insert(ese_gh, ese->ele, ese);
}

View File

@ -43,12 +43,9 @@ void MaskOperation::init_execution()
/* trick so we can get unkeyed edits to display */
{
MaskLayer *masklay;
MaskLayerShape *masklay_shape;
for (masklay = (MaskLayer *)mask_temp->masklayers.first; masklay; masklay = masklay->next)
{
masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame_number_);
LISTBASE_FOREACH (MaskLayer *, masklay, &mask_temp->masklayers) {
MaskLayerShape *masklay_shape = BKE_mask_layer_shape_verify_frame(masklay,
frame_number_);
BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
}
}

View File

@ -37,7 +37,6 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filepat
{
size_t width = this->get_width();
size_t height = this->get_height();
SceneRenderView *srv;
if (width != 0 && height != 0) {
void *exrhandle;
@ -50,7 +49,7 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filepat
IMB_exr_clear_channels(exrhandle);
for (srv = (SceneRenderView *)rd_->views.first; srv; srv = srv->next) {
LISTBASE_FOREACH (SceneRenderView *, srv, &rd_->views) {
if (BKE_scene_multiview_is_render_view_active(rd_, srv) == false) {
continue;
}
@ -139,12 +138,8 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filepath
uint height = this->get_height();
if (width != 0 && height != 0) {
void *exrhandle;
SceneRenderView *srv;
/* get a new global handle */
exrhandle = IMB_exr_get_handle_name(filepath);
/* Get a new global handle. */
void *exrhandle = IMB_exr_get_handle_name(filepath);
if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) {
return exrhandle;
@ -153,7 +148,7 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filepath
IMB_exr_clear_channels(exrhandle);
/* check renderdata for amount of views */
for (srv = (SceneRenderView *)rd_->views.first; srv; srv = srv->next) {
LISTBASE_FOREACH (SceneRenderView *, srv, &rd_->views) {
if (BKE_scene_multiview_is_render_view_active(rd_, srv) == false) {
continue;

View File

@ -107,10 +107,8 @@ void free_exr_channels(void *exrhandle,
const char *layer_name,
const DataType datatype)
{
SceneRenderView *srv;
/* check renderdata for amount of views */
for (srv = (SceneRenderView *)rd->views.first; srv; srv = srv->next) {
LISTBASE_FOREACH (SceneRenderView *, srv, &rd->views) {
float *rect = nullptr;
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {

View File

@ -48,7 +48,7 @@ void DepsgraphNodeBuilder::build_layer_collections(ListBase *lb)
const int visibility_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? COLLECTION_HIDE_VIEWPORT :
COLLECTION_HIDE_RENDER;
for (LayerCollection *lc = (LayerCollection *)lb->first; lc; lc = lc->next) {
LISTBASE_FOREACH (LayerCollection *, lc, lb) {
if (lc->collection->flag & visibility_flag) {
continue;
}

View File

@ -1339,7 +1339,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
OperationCode::BONE_CONSTRAINTS :
OperationCode::TRANSFORM_CONSTRAINTS);
/* Add dependencies for each constraint in turn. */
for (bConstraint *con = (bConstraint *)constraints->first; con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, constraints) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {nullptr, nullptr};
/* Invalid constraint type. */

View File

@ -1406,13 +1406,11 @@ static void draw_bone_update_disp_matrix_default(UnifiedBonePtr bone)
/* compute connected child pointer for B-Bone drawing */
static void edbo_compute_bbone_child(bArmature *arm)
{
EditBone *eBone;
for (eBone = static_cast<EditBone *>(arm->edbo->first); eBone; eBone = eBone->next) {
LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
eBone->bbone_child = nullptr;
}
for (eBone = static_cast<EditBone *>(arm->edbo->first); eBone; eBone = eBone->next) {
LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
if (eBone->parent && (eBone->flag & BONE_CONNECTED)) {
eBone->parent->bbone_child = eBone;
}
@ -1800,12 +1798,11 @@ static void pchan_draw_ik_lines(const ArmatureDrawContext *ctx,
const bPoseChannel *pchan,
const bool only_temp)
{
const bConstraint *con;
const bPoseChannel *parchan;
const float *line_start = nullptr, *line_end = nullptr;
const ePchan_ConstFlag constflag = ePchan_ConstFlag(pchan->constflag);
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
if (con->enforce == 0.0f) {
continue;
}

View File

@ -1286,7 +1286,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb,
}
/* Drawing the hook lines. */
for (ModifierData *md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData *)md;
float center[3];
@ -1297,11 +1297,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb,
OVERLAY_extra_point(cb, center, relation_color);
}
}
for (GpencilModifierData *md =
static_cast<GpencilModifierData *>(ob->greasepencil_modifiers.first);
md;
md = md->next)
{
LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) {
if (md->type == eGpencilModifierType_Hook) {
HookGpencilModifierData *hmd = (HookGpencilModifierData *)md;
float center[3];
@ -1328,13 +1324,11 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb,
/* Drawing the constraint lines */
if (!BLI_listbase_is_empty(&ob->constraints)) {
bConstraint *curcon;
bConstraintOb *cob;
ListBase *list = &ob->constraints;
bConstraintOb *cob = BKE_constraints_make_evalob(
depsgraph, scene, ob, nullptr, CONSTRAINT_OBTYPE_OBJECT);
cob = BKE_constraints_make_evalob(depsgraph, scene, ob, nullptr, CONSTRAINT_OBTYPE_OBJECT);
for (curcon = static_cast<bConstraint *>(list->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, list) {
if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) {
/* special case for object solver and follow track constraints because they don't fill
* constraint targets properly (design limitation -- scene is needed for their target
@ -1360,11 +1354,9 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb,
ListBase targets = {nullptr, nullptr};
if ((curcon->ui_expand_flag & (1 << 0)) && BKE_constraint_targets_get(curcon, &targets)) {
bConstraintTarget *ct;
BKE_constraint_custom_object_space_init(cob, curcon);
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
/* calculate target's matrix */
if (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE) {
copy_m4_m4(ct->matrix, cob->space_obj_world_matrix);

View File

@ -790,9 +790,7 @@ void **DRW_view_layer_engine_data_ensure_ex(ViewLayer *view_layer,
{
ViewLayerEngineData *sled;
for (sled = static_cast<ViewLayerEngineData *>(view_layer->drawdata.first); sled;
sled = sled->next)
{
LISTBASE_FOREACH (ViewLayerEngineData *, sled, &view_layer->drawdata) {
if (sled->engine_type == engine_type) {
return &sled->storage;
}
@ -974,7 +972,6 @@ static void drw_drawdata_unlink_dupli(ID *id)
void DRW_cache_free_old_batches(Main *bmain)
{
Scene *scene;
ViewLayer *view_layer;
static int lasttime = 0;
int ctime = int(PIL_check_seconds_timer());
@ -987,9 +984,7 @@ void DRW_cache_free_old_batches(Main *bmain)
for (scene = static_cast<Scene *>(bmain->scenes.first); scene;
scene = static_cast<Scene *>(scene->id.next))
{
for (view_layer = static_cast<ViewLayer *>(scene->view_layers.first); view_layer;
view_layer = view_layer->next)
{
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer);
if (depsgraph == nullptr) {
continue;

View File

@ -410,7 +410,7 @@ static ListBase /*bAnimListElem*/ anim_channels_for_selection(bAnimContext *ac)
static eAnimChannels_SetFlag anim_channels_selection_flag_for_toggle(const ListBase anim_data)
{
/* See if we should be selecting or deselecting. */
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
switch (ale->type) {
case ANIMTYPE_SCENE:
if (ale->flag & SCE_DS_SELECTED) {
@ -494,11 +494,10 @@ static void anim_channels_select_set(bAnimContext *ac,
const ListBase anim_data,
eAnimChannels_SetFlag sel)
{
bAnimListElem *ale;
/* Boolean to keep active channel status during range selection. */
const bool change_active = (sel != ACHANNEL_SETFLAG_EXTEND_RANGE);
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
switch (ale->type) {
case ANIMTYPE_SCENE: {
if (change_active) {
@ -751,7 +750,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
eAnimChannel_Settings setting,
eAnimChannels_SetFlag mode)
{
bAnimListElem *ale, *match = nullptr;
bAnimListElem *match = nullptr;
int matchLevel = 0;
/* sanity check */
@ -764,7 +763,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
}
/* find the channel that got changed */
for (ale = static_cast<bAnimListElem *>(anim_data->first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {
/* compare data, and type as main way of identifying the channel */
if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
/* We also have to check the ID, this is assigned to,
@ -1520,7 +1519,7 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
/* ensure that all of these get their group set to this temp group
* (so that visibility filtering works)
*/
for (fcu = static_cast<FCurve *>(tgrp->channels.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &tgrp->channels) {
fcu->grp = tgrp;
}
}
@ -1532,9 +1531,7 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
/* link lists of channels that groups have */
static void join_groups_action_temp(bAction *act)
{
bActionGroup *agrp;
for (agrp = static_cast<bActionGroup *>(act->groups.first); agrp; agrp = agrp->next) {
LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
/* add list of channels to action's channels */
const ListBase group_channels = agrp->channels;
BLI_movelisttolist(&act->curves, &agrp->channels);
@ -1592,12 +1589,10 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
BLI_freelistN(&anim_data_visible);
if (do_channels) {
bActionGroup *agrp;
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE);
for (agrp = static_cast<bActionGroup *>(act->groups.first); agrp; agrp = agrp->next) {
LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
/* only consider F-Curves if they're visible (group expanded) */
if (EXPANDED_AGRP(ac, agrp)) {
rearrange_animchannel_islands(
@ -1621,9 +1616,6 @@ static void rearrange_nla_control_channels(bAnimContext *ac,
{
ListBase anim_data_visible = {nullptr, nullptr};
NlaTrack *nlt;
NlaStrip *strip;
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
@ -1640,8 +1632,8 @@ static void rearrange_nla_control_channels(bAnimContext *ac,
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE);
/* we cannot rearrange between strips, but within each strip, we can rearrange those curves */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = strip->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
rearrange_animchannel_islands(
&strip->fcurves, rearrange_func, mode, ANIMTYPE_NLACURVE, &anim_data_visible);
}
@ -1656,7 +1648,6 @@ static void rearrange_nla_control_channels(bAnimContext *ac,
static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode mode)
{
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* get rearranging function */
@ -1672,7 +1663,7 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* only consider grease pencil container channels */
if (!ELEM(ale->type, ANIMTYPE_GPDATABLOCK, ANIMTYPE_DSGPENCIL)) {
continue;
@ -1736,7 +1727,6 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
}
else {
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) {
@ -1749,7 +1739,7 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
AnimData *adt = static_cast<AnimData *>(ale->data);
switch (ac.datatype) {
@ -1897,14 +1887,13 @@ static void animchannels_group_channels(bAnimContext *ac,
if (anim_data.first) {
bActionGroup *agrp;
bAnimListElem *ale;
/* create new group, which should now be part of the action */
agrp = action_groups_add_new(act, name);
BLI_assert(agrp != nullptr);
/* Transfer selected F-Curves across to new group. */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->data;
bActionGroup *grp = fcu->grp;
@ -1941,7 +1930,6 @@ static int animchannels_group_exec(bContext *C, wmOperator *op)
/* XXX: name for group should never be empty... */
if (name[0]) {
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* Handle each animdata block separately, so that the regrouping doesn't flow into blocks. */
@ -1950,7 +1938,7 @@ static int animchannels_group_exec(bContext *C, wmOperator *op)
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
animchannels_group_channels(&ac, ale, name);
}
@ -2001,7 +1989,6 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator * /*op*/)
bAnimContext ac;
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* get editor data */
@ -2015,7 +2002,7 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator * /*op*/)
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* find action for this F-Curve... */
if (ale->adt && ale->adt->action) {
FCurve *fcu = (FCurve *)ale->data;
@ -2091,7 +2078,6 @@ static int animchannels_delete_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* get editor data */
@ -2113,7 +2099,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator * /*op*/)
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* delete selected groups and their associated channels */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* only groups - don't check other types yet, since they may no-longer exist */
if (ale->type == ANIMTYPE_GROUP) {
bActionGroup *agrp = (bActionGroup *)ale->data;
@ -2157,7 +2143,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator * /*op*/)
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* delete selected data channels */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
switch (ale->type) {
case ANIMTYPE_FCURVE: {
/* F-Curves if we can identify its parent */
@ -2280,7 +2266,6 @@ static void setflag_anim_channels(bAnimContext *ac,
{
ListBase anim_data = {nullptr, nullptr};
ListBase all_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* filter data that we need if flush is on */
@ -2323,7 +2308,7 @@ static void setflag_anim_channels(bAnimContext *ac,
mode = ACHANNEL_SETFLAG_ADD;
/* see if we should turn off instead... */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* set the setting in the appropriate way (if available) */
if (ANIM_channel_setting_get(ac, ale, setting) > 0) {
mode = ACHANNEL_SETFLAG_CLEAR;
@ -2333,7 +2318,7 @@ static void setflag_anim_channels(bAnimContext *ac,
}
/* apply the setting */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* skip channel if setting is not available */
if (ANIM_channel_setting_get(ac, ale, setting) == -1) {
continue;
@ -2612,7 +2597,6 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator * /*op*/)
bAnimContext ac;
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* get editor data */
@ -2626,7 +2610,7 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator * /*op*/)
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
ID *id = ale->id;
AnimData *adt = static_cast<AnimData *>(ale->data);
@ -2653,10 +2637,8 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator * /*op*/)
nla_empty = true;
}
else {
NlaTrack *nlt;
/* empty tracks? */
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
if (nlt->strips.first) {
/* stop searching, as we found one that actually had stuff we don't want lost
* NOTE: nla_empty gets reset to false, as a previous track may have been empty
@ -2734,7 +2716,6 @@ static int animchannels_enable_exec(bContext *C, wmOperator * /*op*/)
bAnimContext ac;
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* get editor data */
@ -2748,7 +2729,7 @@ static int animchannels_enable_exec(bContext *C, wmOperator * /*op*/)
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* loop through filtered data and clean curves */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->data;
/* remove disabled flags from F-Curves */
@ -2932,7 +2913,6 @@ static void ANIM_OT_channels_select_all(wmOperatorType *ot)
static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectmode)
{
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
SpaceNla *snla = (SpaceNla *)ac->sl;
@ -2958,7 +2938,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
}
/* loop over data, doing box select */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
float ymin;
if (ale->type == ANIMTYPE_GPDATABLOCK) {
@ -3970,7 +3950,7 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e
filter = (ANIMFILTER_DATA_VISIBLE);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu_inner = (FCurve *)ale->key_data;
if (fcu_inner != nullptr && fcu_inner->bezt != nullptr) {
@ -4090,11 +4070,10 @@ static int graphkeys_view_selected_channels_exec(bContext *C, wmOperator *op)
bounds.ymin = FLT_MAX;
bounds.ymax = -FLT_MAX;
bAnimListElem *ale;
const bool include_handles = RNA_boolean_get(op->ptr, "include_handles");
bool valid_bounds = false;
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
rctf channel_bounds;
const bool found_bounds = get_channel_bounds(
&ac, ale, range, include_handles, &channel_bounds);

View File

@ -257,7 +257,6 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
{
bAnimContext ac;
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
bActionGroup *active_agrp = nullptr;
@ -278,7 +277,7 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* flush settings as appropriate depending on the types of the channels */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
switch (ale->type) {
case ANIMTYPE_GROUP:
animchan_sync_group(&ac, ale, &active_agrp);
@ -309,9 +308,7 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
{
bAnimListElem *ale;
for (ale = static_cast<bAnimListElem *>(anim_data->first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {
if (ale->type == ANIMTYPE_GPLAYER) {
bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);

View File

@ -105,7 +105,6 @@ ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
int ED_markers_post_apply_transform(
ListBase *markers, Scene *scene, int mode, float value, char side)
{
TimeMarker *marker;
float cfra = float(scene->r.cfra);
int changed_tot = 0;
@ -115,7 +114,7 @@ int ED_markers_post_apply_transform(
}
/* affect selected markers - it's unlikely that we will want to affect all in this way? */
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->flag & SELECT) {
switch (mode) {
case TFM_TIME_TRANSLATE:
@ -146,11 +145,11 @@ int ED_markers_post_apply_transform(
TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x)
{
TimeMarker *marker, *nearest = nullptr;
TimeMarker *nearest = nullptr;
float dist, min_dist = 1000000;
if (markers) {
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
dist = fabsf(float(marker->frame) - x);
if (dist < min_dist) {
@ -171,7 +170,6 @@ int ED_markers_find_nearest_marker_time(ListBase *markers, float x)
void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float *r_last)
{
TimeMarker *marker;
float min, max;
/* sanity check */
@ -184,7 +182,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float *
min = FLT_MAX;
max = -FLT_MAX;
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (!sel || (marker->flag & SELECT)) {
if (marker->frame < min) {
min = float(marker->frame);
@ -298,8 +296,6 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
{
TimeMarker *marker;
if (lb) {
/* Clear the list first, since callers have no way of knowing
* whether this terminated early otherwise. This may lead
@ -315,7 +311,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
return;
}
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
add_marker_to_cfra_elem(lb, marker, only_sel);
}
}
@ -346,10 +342,8 @@ void ED_markers_deselect_all(ListBase *markers, int action)
TimeMarker *ED_markers_get_first_selected(ListBase *markers)
{
TimeMarker *marker;
if (markers) {
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->flag & SELECT) {
return marker;
}
@ -365,9 +359,6 @@ void debug_markers_print_list(ListBase *markers)
{
/* NOTE: do NOT make static or use `ifdef`'s as "unused code".
* That's too much trouble when we need to use for quick debugging! */
TimeMarker *marker;
if (markers == nullptr) {
printf("No markers list to print debug for\n");
return;
@ -375,7 +366,7 @@ void debug_markers_print_list(ListBase *markers)
printf("List of markers follows: -----\n");
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
printf(
"\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag);
}
@ -737,14 +728,14 @@ static int ed_marker_add_exec(bContext *C, wmOperator * /*op*/)
/* prefer not having 2 markers at the same place,
* though the user can move them to overlap once added */
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->frame == frame) {
return OPERATOR_CANCELLED;
}
}
/* deselect all */
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
marker->flag &= ~SELECT;
}
@ -1165,8 +1156,6 @@ static void MARKER_OT_move(wmOperatorType *ot)
static void ed_marker_duplicate_apply(bContext *C)
{
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker, *newmarker;
if (markers == nullptr) {
return;
}
@ -1174,13 +1163,14 @@ static void ed_marker_duplicate_apply(bContext *C)
/* go through the list of markers, duplicate selected markers and add duplicated copies
* to the beginning of the list (unselect original markers)
*/
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->flag & SELECT) {
/* unselect selected marker */
marker->flag &= ~SELECT;
/* create and set up new marker */
newmarker = static_cast<TimeMarker *>(MEM_callocN(sizeof(TimeMarker), "TimeMarker"));
TimeMarker *newmarker = static_cast<TimeMarker *>(
MEM_callocN(sizeof(TimeMarker), "TimeMarker"));
newmarker->flag = SELECT;
newmarker->frame = marker->frame;
STRNCPY(newmarker->name, marker->name);
@ -1263,7 +1253,7 @@ static int select_timeline_marker_frame(ListBase *markers,
}
/* support for selection cycling */
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->frame == frame) {
if (marker->flag & SELECT) {
marker_cycle_selected = static_cast<TimeMarker *>(marker->next ? marker->next :
@ -1304,14 +1294,13 @@ static void select_marker_camera_switch(
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base;
TimeMarker *marker;
int sel = 0;
if (!extend) {
BKE_view_layer_base_deselect_all(scene, view_layer);
}
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->frame == cfra) {
sel = (marker->flag & SELECT);
break;
@ -1319,7 +1308,7 @@ static void select_marker_camera_switch(
}
BKE_view_layer_synced_ensure(scene, view_layer);
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->camera) {
if (marker->frame == cfra) {
base = BKE_view_layer_base_find(view_layer, marker->camera);
@ -1766,7 +1755,7 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
ListBase *markers = ED_context_get_markers(C);
Scene *scene_to = static_cast<Scene *>(
BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")));
TimeMarker *marker, *marker_new;
TimeMarker *marker_new;
if (scene_to == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Scene not found");
@ -1784,7 +1773,7 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
}
/* copy markers */
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->flag & SELECT) {
marker_new = static_cast<TimeMarker *>(MEM_dupallocN(marker));
marker_new->prev = marker_new->next = nullptr;

View File

@ -110,10 +110,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
/* bones */
if ((ob->pose) && (ob->pose->avs.recalc & ANIMVIZ_RECALC_PATHS)) {
bArmature *arm = static_cast<bArmature *>(ob->data);
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if ((pchan->bone) && ANIM_bonecoll_is_visible_pchan(arm, pchan) && (pchan->mpath)) {
/* new target for bone */
mpt = static_cast<MPathTarget *>(MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone"));
@ -132,10 +129,8 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
/* perform baking for the targets on the current frame */
static void motionpaths_calc_bake_targets(ListBase *targets, int cframe)
{
MPathTarget *mpt;
/* for each target, check if it can be baked on the current frame */
for (mpt = static_cast<MPathTarget *>(targets->first); mpt; mpt = mpt->next) {
LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
bMotionPath *mpath = mpt->mpath;
/* current frame must be within the range the cache works for

View File

@ -884,7 +884,7 @@ void ANIM_fmodifier_panels(const bContext *C,
if (!panels_match) {
UI_panels_free_instanced(C, region);
for (FModifier *fcm = static_cast<FModifier *>(fmodifiers->first); fcm; fcm = fcm->next) {
LISTBASE_FOREACH (FModifier *, fcm, fmodifiers) {
char panel_idname[MAX_NAME];
panel_id_fn(fcm, panel_idname);
@ -987,7 +987,6 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *curve)
{
FModifier *fcm;
bool ok = false;
/* sanity checks */
@ -1003,7 +1002,7 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
}
/* now copy over all the modifiers in the buffer to the end of the list */
for (fcm = static_cast<FModifier *>(fmodifier_copypaste_buf.first); fcm; fcm = fcm->next) {
LISTBASE_FOREACH (FModifier *, fcm, &fmodifier_copypaste_buf) {
/* make a copy of it */
FModifier *fcmN = copy_fmodifier(fcm);

View File

@ -1095,14 +1095,13 @@ void ANIM_fcurves_copybuf_free()
short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
{
bAnimListElem *ale;
Scene *scene = ac->scene;
/* clear buffer first */
ANIM_fcurves_copybuf_free();
/* assume that each of these is an F-Curve */
for (ale = static_cast<bAnimListElem *>(anim_data->first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
tAnimCopybufItem *aci;
BezTriple *bezt, *nbezt, *newbuf;
@ -1630,7 +1629,7 @@ eKeyPasteError paste_animedit_keys(bAnimContext *ac,
for (pass = 0; pass < 3; pass++) {
uint totmatch = 0;
for (ale = static_cast<bAnimListElem *>(anim_data->first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {
/* Find buffer item to paste from:
* - If names don't matter (i.e. only 1 channel in buffer), don't check id/group
* - If names do matter, only check if id-type is ok for now

View File

@ -2973,8 +2973,6 @@ bool fcurve_is_changed(PointerRNA ptr,
*/
static bool action_frame_has_keyframe(bAction *act, float frame)
{
FCurve *fcu;
/* can only find if there is data */
if (act == nullptr) {
return false;
@ -2987,7 +2985,7 @@ static bool action_frame_has_keyframe(bAction *act, float frame)
/* loop over F-Curves, using binary-search to try to find matches
* - this assumes that keyframes are only beztriples
*/
for (fcu = static_cast<FCurve *>(act->curves.first); fcu; fcu = fcu->next) {
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
/* only check if there are keyframes (currently only of type BezTriple) */
if (fcu->bezt && fcu->totvert) {
if (fcurve_frame_has_keyframe(fcu, frame)) {

View File

@ -724,7 +724,6 @@ static void anim_keyingset_visit_for_search_impl(const bContext *C,
}
Scene *scene = C ? CTX_data_scene(C) : nullptr;
KeyingSet *ks;
/* Active Keying Set. */
if (!use_poll || (scene && scene->active_keyingset)) {
@ -736,7 +735,7 @@ static void anim_keyingset_visit_for_search_impl(const bContext *C,
/* User-defined Keying Sets. */
if (scene && scene->keyingsets.first) {
for (ks = static_cast<KeyingSet *>(scene->keyingsets.first); ks; ks = ks->next) {
LISTBASE_FOREACH (KeyingSet *, ks, &scene->keyingsets) {
if (use_poll && !ANIM_keyingset_context_ok_poll((bContext *)C, ks)) {
continue;
}
@ -748,7 +747,7 @@ static void anim_keyingset_visit_for_search_impl(const bContext *C,
}
/* Builtin Keying Sets. */
for (ks = static_cast<KeyingSet *>(builtin_keyingsets.first); ks; ks = ks->next) {
LISTBASE_FOREACH (KeyingSet *, ks, &builtin_keyingsets) {
if (use_poll && !ANIM_keyingset_context_ok_poll((bContext *)C, ks)) {
continue;
}
@ -920,9 +919,7 @@ static void RKS_ITER_overrides_list(KeyingSetInfo *ksi,
KeyingSet *ks,
ListBase *dsources)
{
tRKS_DSource *ds;
for (ds = static_cast<tRKS_DSource *>(dsources->first); ds; ds = ds->next) {
LISTBASE_FOREACH (tRKS_DSource *, ds, dsources) {
/* run generate callback on this data */
ksi->generate(ksi, C, ks, &ds->ptr);
}
@ -1048,7 +1045,6 @@ int ANIM_apply_keyingset(
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ReportList *reports = CTX_wm_reports(C);
KS_Path *ksp;
ListBase nla_cache = {nullptr, nullptr};
const eInsertKeyFlags base_kflags = ANIM_get_keyframing_flags(scene, true);
const char *groupname = nullptr;
@ -1082,7 +1078,7 @@ int ANIM_apply_keyingset(
}
/* apply the paths as specified in the KeyingSet now */
for (ksp = static_cast<KS_Path *>(ks->paths.first); ksp; ksp = ksp->next) {
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
int arraylen, i;
eInsertKeyFlags kflag2;

View File

@ -273,10 +273,8 @@ EditBone *add_points_bone(Object *obedit, float head[3], float tail[3])
static EditBone *get_named_editbone(ListBase *edbo, const char *name)
{
EditBone *eBone;
if (name) {
for (eBone = static_cast<EditBone *>(edbo->first); eBone; eBone = eBone->next) {
LISTBASE_FOREACH (EditBone *, eBone, edbo) {
if (STREQ(name, eBone->name)) {
return eBone;
}
@ -376,20 +374,18 @@ static void updateDuplicateSubtarget(EditBone *dup_bone,
*/
EditBone *oldtarget, *newtarget;
bPoseChannel *pchan;
bConstraint *curcon;
ListBase *conlist;
if ((pchan = BKE_pose_channel_ensure(ob->pose, dup_bone->name))) {
if ((conlist = &pchan->constraints)) {
for (curcon = static_cast<bConstraint *>(conlist->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, conlist) {
/* does this constraint have a subtarget in
* this armature?
*/
ListBase targets = {nullptr, nullptr};
bConstraintTarget *ct;
if (BKE_constraint_targets_get(curcon, &targets)) {
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
if ((ct->tar == ob) && (ct->subtarget[0])) {
oldtarget = get_named_editbone(editbones, ct->subtarget);
if (oldtarget) {
@ -504,7 +500,7 @@ static void updateDuplicateActionConstraintSettings(
BKE_fcurves_filter(&ani_curves, &act->curves, "pose.bones[", orig_bone->name))
{
/* Create a copy and mirror the animation */
for (LinkData *ld = static_cast<LinkData *>(ani_curves.first); ld; ld = ld->next) {
LISTBASE_FOREACH (LinkData *, ld, &ani_curves) {
FCurve *old_curve = static_cast<FCurve *>(ld->data);
FCurve *new_curve = BKE_fcurve_copy(old_curve);
bActionGroup *agrp;
@ -829,7 +825,6 @@ static void updateDuplicateConstraintSettings(EditBone *dup_bone, EditBone *orig
* subtarget they point to has also been duplicated.
*/
bPoseChannel *pchan;
bConstraint *curcon;
ListBase *conlist;
if ((pchan = BKE_pose_channel_ensure(ob->pose, dup_bone->name)) == nullptr ||
@ -838,7 +833,7 @@ static void updateDuplicateConstraintSettings(EditBone *dup_bone, EditBone *orig
return;
}
for (curcon = static_cast<bConstraint *>(conlist->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, conlist) {
switch (curcon->type) {
case CONSTRAINT_TYPE_ACTION:
updateDuplicateActionConstraintSettings(dup_bone, orig_bone, ob, pchan, curcon);
@ -977,9 +972,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
for (ebone_iter = static_cast<EditBone *>(arm->edbo->first); ebone_iter;
ebone_iter = ebone_iter->next)
{
LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) {
EditBone *ebone;
@ -1162,9 +1155,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
* and unique selected bones with an unique flippable name.
*
* Storing temp pointers to mirrored unselected ebones. */
for (ebone_iter = static_cast<EditBone *>(arm->edbo->first); ebone_iter;
ebone_iter = ebone_iter->next)
{
LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (!(EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED))) {
/* Skipping invisible selected bones. */
continue;
@ -1430,7 +1421,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
ExtrudePoint do_extrude;
/* since we allow root extrude too, we have to make sure selection is OK */
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_ROOTSEL) {
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
@ -1694,7 +1685,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
static int armature_subdivide_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
EditBone *newbone, *tbone;
EditBone *newbone;
int cuts, i;
/* there may not be a number_cuts property defined (for 'simple' subdivide) */
@ -1739,7 +1730,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
ED_armature_ebone_unique_name(arm->edbo, newbone->name, nullptr);
/* correct parent bones */
for (tbone = static_cast<EditBone *>(arm->edbo->first); tbone; tbone = tbone->next) {
LISTBASE_FOREACH (EditBone *, tbone, arm->edbo) {
if (tbone->parent == ebone) {
tbone->parent = newbone;
}

View File

@ -55,14 +55,13 @@
void ED_armature_edit_transform(bArmature *arm, const float mat[4][4], const bool do_props)
{
EditBone *ebone;
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
float mat3[3][3];
copy_m3_m4(mat3, mat);
normalize_m3(mat3);
/* Do the rotations */
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
float tmat[3][3];
/* find the current bone's roll matrix */
@ -104,7 +103,6 @@ void ED_armature_origin_set(
Main *bmain, Object *ob, const float cursor[3], int centermode, int around)
{
const bool is_editmode = BKE_object_is_in_editmode(ob);
EditBone *ebone;
bArmature *arm = static_cast<bArmature *>(ob->data);
float cent[3];
@ -123,7 +121,7 @@ void ED_armature_origin_set(
if (around == V3D_AROUND_CENTER_BOUNDS) {
float min[3], max[3];
INIT_MINMAX(min, max);
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
minmax_v3v3_v3(min, max, ebone->head);
minmax_v3v3_v3(min, max, ebone->tail);
}
@ -132,7 +130,7 @@ void ED_armature_origin_set(
else { /* #V3D_AROUND_CENTER_MEDIAN. */
int total = 0;
zero_v3(cent);
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
total += 2;
add_v3_v3(cent, ebone->head);
add_v3_v3(cent, ebone->tail);
@ -144,7 +142,7 @@ void ED_armature_origin_set(
}
/* Do the adjustments */
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
sub_v3_v3(ebone->head, cent);
sub_v3_v3(ebone->tail, cent);
}
@ -297,7 +295,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
mul_m4_v3(ob->world_to_object, cursor_local);
/* cursor */
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
float cursor_rel[3];
sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
@ -312,7 +310,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
}
else if (ELEM(type, CALC_ROLL_TAN_POS_X, CALC_ROLL_TAN_POS_Z)) {
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->parent) {
bool is_edit = (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone));
bool is_edit_parent = (EBONE_VISIBLE(arm, ebone->parent) &&
@ -411,7 +409,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
negate_v3(vec);
}
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
/* roll func is a callback which assumes that all is well */
ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only);
@ -421,7 +419,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
if (arm->flag & ARM_MIRROR_EDIT) {
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
@ -558,15 +556,15 @@ struct EditBonePoint {
/* find chain-tips (i.e. bones without children) */
static void chains_find_tips(ListBase *edbo, ListBase *list)
{
EditBone *curBone, *ebo;
EditBone *ebo;
LinkData *ld;
/* NOTE: this is potentially very slow ... there's got to be a better way. */
for (curBone = static_cast<EditBone *>(edbo->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (EditBone *, curBone, edbo) {
short stop = 0;
/* is this bone contained within any existing chain? (skip if so) */
for (ld = static_cast<LinkData *>(list->first); ld; ld = ld->next) {
LISTBASE_FOREACH (LinkData *, ld, list) {
for (ebo = static_cast<EditBone *>(ld->data); ebo; ebo = ebo->parent) {
if (ebo == curBone) {
stop = 1;
@ -586,7 +584,7 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
/* is any existing chain part of the chain formed by this bone? */
stop = 0;
for (ebo = curBone->parent; ebo; ebo = ebo->parent) {
for (ld = static_cast<LinkData *>(list->first); ld; ld = ld->next) {
LISTBASE_FOREACH (LinkData *, ld, list) {
if (ld->data == ebo) {
ld->data = curBone;
stop = 1;
@ -629,7 +627,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
copy_v3_v3(vec, ebo->head);
}
for (ebp = static_cast<EditBonePoint *>(points->first); ebp; ebp = ebp->next) {
LISTBASE_FOREACH (EditBonePoint *, ebp, points) {
if (equals_v3v3(ebp->vec, vec)) {
if (eb_tail) {
if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) {
@ -884,9 +882,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot)
/* helper to clear BONE_TRANSFORM flags */
static void armature_clear_swap_done_flags(bArmature *arm)
{
EditBone *ebone;
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
ebone->flag &= ~BONE_TRANSFORM;
}
}
@ -904,7 +900,6 @@ static int armature_switch_direction_exec(bContext *C, wmOperator * /*op*/)
bArmature *arm = static_cast<bArmature *>(ob->data);
ListBase chains = {nullptr, nullptr};
LinkData *chain;
/* get chains of bones (ends on chains) */
chains_find_tips(arm->edbo, &chains);
@ -922,7 +917,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator * /*op*/)
armature_clear_swap_done_flags(arm);
/* loop over chains, only considering selected and visible bones */
for (chain = static_cast<LinkData *>(chains.first); chain; chain = chain->next) {
LISTBASE_FOREACH (LinkData *, chain, &chains) {
EditBone *ebo, *child = nullptr, *parent = nullptr;
/* loop over bones in chain */
@ -1036,9 +1031,7 @@ static void fix_connected_bone(EditBone *ebone)
/* helper to recursively find chains of connected bones starting at ebone and fix their position */
static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone)
{
EditBone *selbone;
for (selbone = static_cast<EditBone *>(edbo->first); selbone; selbone = selbone->next) {
LISTBASE_FOREACH (EditBone *, selbone, edbo) {
if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) {
fix_connected_bone(selbone);
fix_editbone_connected_children(edbo, selbone);
@ -1330,7 +1323,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
GHash *ebone_flag_orig = nullptr;
int ebone_num = 0;
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
ebone->temp.p = nullptr;
ebone->flag &= ~BONE_DONE;
ebone_num++;
@ -1340,7 +1333,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
GHashIterator gh_iter;
ebone_flag_orig = BLI_ghash_ptr_new_ex(__func__, ebone_num);
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
union {
int flag;
void *p;
@ -1361,7 +1354,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
}
}
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->parent && ebone->flag & BONE_CONNECTED) {
if (ebone->parent->temp.ebone == ebone->parent) {
/* ignore */
@ -1378,13 +1371,13 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
}
/* cleanup multiple used bones */
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->temp.ebone == ebone) {
ebone->temp.ebone = nullptr;
}
}
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
/* break connections for unseen bones */
if ((ANIM_bonecoll_is_visible_editbone(arm, ebone) &&
(ED_armature_ebone_selectflag_get(ebone) & (BONE_TIPSEL | BONE_SELECTED))) == 0)
@ -1401,7 +1394,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
}
}
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->parent && (ebone->parent->temp.ebone == ebone)) {
ebone->flag |= BONE_DONE;
@ -1424,14 +1417,14 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/)
}
if (changed) {
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->parent && ebone->parent->temp.ebone && (ebone->flag & BONE_CONNECTED)) {
ebone->rad_head = ebone->parent->rad_tail;
}
}
if (arm->flag & ARM_MIRROR_EDIT) {
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
union Value {
int flag;
void *p;

View File

@ -106,15 +106,12 @@ static void constraint_bone_name_fix(Object *ob,
const char *oldname,
const char *newname)
{
bConstraint *curcon;
bConstraintTarget *ct;
for (curcon = static_cast<bConstraint *>(conlist->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, conlist) {
ListBase targets = {nullptr, nullptr};
/* constraint targets */
if (BKE_constraint_targets_get(curcon, &targets)) {
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
if (ct->tar == ob) {
if (STREQ(ct->subtarget, oldname)) {
STRNCPY(ct->subtarget, newname);
@ -191,7 +188,6 @@ void ED_armature_bone_rename(Main *bmain,
/* do entire dbase - objects */
for (ob = static_cast<Object *>(bmain->objects.first); ob;
ob = static_cast<Object *>(ob->id.next)) {
ModifierData *md;
/* we have the object using the armature */
if (arm == ob->data) {
@ -227,9 +223,7 @@ void ED_armature_bone_rename(Main *bmain,
constraint_bone_name_fix(ob, &cob->constraints, oldname, newname);
}
if (cob->pose) {
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(cob->pose->chanbase.first); pchan;
pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &cob->pose->chanbase) {
constraint_bone_name_fix(ob, &pchan->constraints, oldname, newname);
}
}
@ -255,7 +249,7 @@ void ED_armature_bone_rename(Main *bmain,
}
/* fix modifiers that might be using this name */
for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
switch (md->type) {
case eModifierType_Hook: {
HookModifierData *hmd = (HookModifierData *)md;
@ -357,11 +351,9 @@ void ED_armature_bone_rename(Main *bmain,
for (screen = static_cast<bScreen *>(bmain->screens.first); screen;
screen = static_cast<bScreen *>(screen->id.next))
{
ScrArea *area;
/* add regions */
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
SpaceLink *sl;
for (sl = static_cast<SpaceLink *>(area->spacedata.first); sl; sl = sl->next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d->ob_center && v3d->ob_center->data == arm) {
@ -422,7 +414,7 @@ void ED_armature_bones_flip_names(Main *bmain,
* Note that if the other bone was not selected, its name was not flipped,
* so conflict remains and that second rename simply generates a new numbered alternative name.
*/
for (bfn = static_cast<BoneFlipNameData *>(bones_names_conflicts.first); bfn; bfn = bfn->next) {
LISTBASE_FOREACH (BoneFlipNameData *, bfn, &bones_names_conflicts) {
ED_armature_bone_rename(bmain, arm, bfn->name, bfn->name_flip);
}
}

View File

@ -65,16 +65,14 @@ static void joined_armature_fix_links_constraints(Main *bmain,
EditBone *curbone,
ListBase *lb)
{
bConstraint *con;
bool changed = false;
for (con = static_cast<bConstraint *>(lb->first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, lb) {
ListBase targets = {nullptr, nullptr};
bConstraintTarget *ct;
/* constraint targets */
if (BKE_constraint_targets_get(con, &targets)) {
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
if (ct->tar == srcArm) {
if (ct->subtarget[0] == '\0') {
ct->tar = tarArm;
@ -158,7 +156,6 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
/* Driver targets */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
/* Ensure that invalid drivers gets re-evaluated in case they become valid once the join
* operation is finished. */
@ -166,7 +163,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
driver->flag &= ~DRIVER_FLAG_INVALID;
/* Fix driver references to invalid ID's */
for (dvar = static_cast<DriverVar *>(driver->variables.first); dvar; dvar = dvar->next) {
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
/* only change the used targets, since the others will need fixing manually anyway */
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
/* change the ID's used... */
@ -218,7 +215,6 @@ static void joined_armature_fix_links(
{
Object *ob;
bPose *pose;
bPoseChannel *pchant;
/* let's go through all objects in database */
for (ob = static_cast<Object *>(bmain->objects.first); ob;
@ -226,8 +222,7 @@ static void joined_armature_fix_links(
/* do some object-type specific things */
if (ob->type == OB_ARMATURE) {
pose = ob->pose;
for (pchant = static_cast<bPoseChannel *>(pose->chanbase.first); pchant;
pchant = pchant->next) {
LISTBASE_FOREACH (bPoseChannel *, pchant, &pose->chanbase) {
joined_armature_fix_links_constraints(
bmain, ob, tarArm, srcArm, pchan, curbone, &pchant->constraints);
}
@ -449,8 +444,6 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op)
static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *newArm)
{
Object *ob;
bPoseChannel *pchan;
bConstraint *con;
ListBase *opchans, *npchans;
/* Get reference to list of bones in original and new armatures. */
@ -462,15 +455,13 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n
ob = static_cast<Object *>(ob->id.next)) {
/* do some object-type specific things */
if (ob->type == OB_ARMATURE) {
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
ListBase targets = {nullptr, nullptr};
bConstraintTarget *ct;
/* constraint targets */
if (BKE_constraint_targets_get(con, &targets)) {
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
/* Any targets which point to original armature
* are redirected to the new one only if:
* - The target isn't origArm/newArm itself.
@ -498,13 +489,12 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n
/* fix object-level constraints */
if (ob != origArm) {
for (con = static_cast<bConstraint *>(ob->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, &ob->constraints) {
ListBase targets = {nullptr, nullptr};
bConstraintTarget *ct;
/* constraint targets */
if (BKE_constraint_targets_get(con, &targets)) {
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
/* any targets which point to original armature are redirected to the new one only if:
* - the target isn't origArm/newArm itself
* - the target is one that can be found in newArm/origArm
@ -781,7 +771,7 @@ static void bone_connect_to_new_parent(ListBase *edbo,
add_v3_v3(selbone->tail, offset);
/* offset for all its children */
for (ebone = static_cast<EditBone *>(edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, edbo) {
EditBone *par;
for (par = ebone->parent; par; par = par->parent) {

View File

@ -1464,18 +1464,17 @@ static void armature_select_less(bArmature * /*arm*/, EditBone *ebone)
static void armature_select_more_less(Object *ob, bool more)
{
bArmature *arm = (bArmature *)ob->data;
EditBone *ebone;
/* XXX(@ideasman42): eventually we shouldn't need this. */
ED_armature_edit_sync_selection(arm->edbo);
/* count bones & store selection state */
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
EBONE_PREV_FLAG_SET(ebone, ED_armature_ebone_selectflag_get(ebone));
}
/* do selection */
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone)) {
if (more) {
armature_select_more(arm, ebone);
@ -1486,7 +1485,7 @@ static void armature_select_more_less(Object *ob, bool more)
}
}
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone)) {
if (more == false) {
if (ebone->flag & BONE_SELECTED) {
@ -2047,14 +2046,12 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
}
}
else { /* BONE_SELECT_CHILD */
EditBone *ebone_iter, *ebone_child = nullptr;
EditBone *ebone_child = nullptr;
int pass;
/* first pass, only connected bones (the logical direct child) */
for (pass = 0; pass < 2 && (ebone_child == nullptr); pass++) {
for (ebone_iter = static_cast<EditBone *>(arm->edbo->first); ebone_iter;
ebone_iter = ebone_iter->next)
{
LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
/* possible we have multiple children, some invisible */
if (EBONE_SELECTABLE(arm, ebone_iter)) {
if (ebone_iter->parent == ebone_active) {
@ -2141,14 +2138,14 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op)
Object *ob = objects[ob_index];
bArmature *arm = static_cast<bArmature *>(ob->data);
EditBone *ebone, *ebone_mirror_act = nullptr;
EditBone *ebone_mirror_act = nullptr;
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
const int flag = ED_armature_ebone_selectflag_get(ebone);
EBONE_PREV_FLAG_SET(ebone, flag);
}
for (ebone = static_cast<EditBone *>(arm->edbo->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
EditBone *ebone_mirror;
int flag_new = extend ? EBONE_PREV_FLAG_GET(ebone) : 0;

View File

@ -38,9 +38,7 @@
void ED_armature_edit_sync_selection(ListBase *edbo)
{
EditBone *ebo;
for (ebo = static_cast<EditBone *>(edbo->first); ebo; ebo = ebo->next) {
LISTBASE_FOREACH (EditBone *, ebo, edbo) {
/* if bone is not selectable, we shouldn't alter this setting... */
if ((ebo->flag & BONE_UNSELECTABLE) == 0) {
if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) {
@ -144,10 +142,8 @@ void bone_free(bArmature *arm, EditBone *bone)
void ED_armature_ebone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected)
{
EditBone *curBone;
/* Find any bones that refer to this bone */
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
if (curBone->parent == exBone) {
curBone->parent = exBone->parent;
if (clear_connected) {
@ -296,12 +292,10 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
BLI_assert((flag & ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) == 0);
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
EditBone *curBone, *ebone_mirr;
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (curBone->flag & flag) {
ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr) {
ebone_mirr->flag |= (curBone->flag & flag);
}
@ -318,16 +312,14 @@ void armature_select_mirrored(bArmature *arm)
void armature_tag_select_mirrored(bArmature *arm)
{
EditBone *curBone;
/* always untag */
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
curBone->flag &= ~BONE_DONE;
}
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
if (ANIM_bonecoll_is_visible_editbone(arm, curBone)) {
if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
@ -338,7 +330,7 @@ void armature_tag_select_mirrored(bArmature *arm)
}
}
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
if (curBone->flag & BONE_DONE) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
@ -349,9 +341,7 @@ void armature_tag_select_mirrored(bArmature *arm)
void armature_tag_unselect(bArmature *arm)
{
EditBone *curBone;
for (curBone = static_cast<EditBone *>(arm->edbo->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (EditBone *, curBone, arm->edbo) {
if (curBone->flag & BONE_DONE) {
curBone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL | BONE_DONE);
}
@ -391,9 +381,7 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo
eboflip->roll2 = -ebo->roll2;
/* Also move connected children, in case children's name aren't mirrored properly. */
EditBone *children;
for (children = static_cast<EditBone *>(arm->edbo->first); children;
children = children->next) {
LISTBASE_FOREACH (EditBone *, children, arm->edbo) {
if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
copy_v3_v3(children->head, eboflip->tail);
children->rad_head = ebo->rad_tail;
@ -460,9 +448,8 @@ static EditBone *make_boneList_recursive(ListBase *edbo,
EditBone *eBone;
EditBone *eBoneAct = nullptr;
EditBone *eBoneTest = nullptr;
Bone *curBone;
for (curBone = static_cast<Bone *>(bones->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (Bone *, curBone, bones) {
eBone = static_cast<EditBone *>(MEM_callocN(sizeof(EditBone), "make_editbone"));
eBone->temp.bone = curBone;
@ -595,10 +582,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, Bone *actBone)
*/
static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelist)
{
Bone *curBone;
EditBone *ebone;
for (curBone = static_cast<Bone *>(bonelist->first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (Bone *, curBone, bonelist) {
/* Set bone's local head/tail.
* Note that it's important to use final parent's rest-pose (arm_mat) here,
* instead of setting those values from edit-bone's matrix (see #46010). */
@ -624,7 +608,7 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis
BKE_armature_where_is_bone(curBone, curBone->parent, false);
/* Find the associated editbone */
for (ebone = static_cast<EditBone *>(editbonelist->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, editbonelist) {
if (ebone->temp.bone == curBone) {
float premat[3][3];
float postmat[3][3];
@ -678,10 +662,8 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
neBone = eBone->next;
/* TODO(sergey): How to ensure this is a `constexpr`? */
if (len_sq <= square_f(0.000001f)) { /* FLT_EPSILON is too large? */
EditBone *fBone;
/* Find any bones that refer to this bone */
for (fBone = static_cast<EditBone *>(arm->edbo->first); fBone; fBone = fBone->next) {
LISTBASE_FOREACH (EditBone *, fBone, arm->edbo) {
if (fBone->parent == eBone) {
fBone->parent = eBone->parent;
}
@ -694,7 +676,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
}
/* Copy the bones from the edit-data into the armature. */
for (eBone = static_cast<EditBone *>(arm->edbo->first); eBone; eBone = eBone->next) {
LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
newBone = static_cast<Bone *>(MEM_callocN(sizeof(Bone), "bone"));
eBone->temp.bone = newBone; /* Associate the real Bones with the EditBones */
@ -754,7 +736,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
* Do not set bone->head/tail here anymore,
* using EditBone data for that is not OK since our later fiddling with parent's arm_mat
* (for roll conversion) may have some small but visible impact on locations (#46010). */
for (eBone = static_cast<EditBone *>(arm->edbo->first); eBone; eBone = eBone->next) {
LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
newBone = eBone->temp.bone;
if (eBone->parent) {
newBone->parent = eBone->parent->temp.bone;
@ -793,12 +775,10 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
void ED_armature_edit_free(bArmature *arm)
{
EditBone *eBone;
/* Clear the edit-bones list. */
if (arm->edbo) {
if (arm->edbo->first) {
for (eBone = static_cast<EditBone *>(arm->edbo->first); eBone; eBone = eBone->next) {
LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
if (eBone->prop) {
IDP_FreeProperty(eBone->prop);
}
@ -844,14 +824,10 @@ void ED_armature_ebone_listbase_free(ListBase *lb, const bool do_id_user)
void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src, const bool do_id_user)
{
EditBone *ebone_src;
EditBone *ebone_dst;
BLI_assert(BLI_listbase_is_empty(lb_dst));
for (ebone_src = static_cast<EditBone *>(lb_src->first); ebone_src; ebone_src = ebone_src->next)
{
ebone_dst = static_cast<EditBone *>(MEM_dupallocN(ebone_src));
LISTBASE_FOREACH (EditBone *, ebone_src, lb_src) {
EditBone *ebone_dst = static_cast<EditBone *>(MEM_dupallocN(ebone_src));
if (ebone_dst->prop) {
ebone_dst->prop = IDP_CopyProperty_ex(ebone_dst->prop,
do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT);
@ -861,8 +837,7 @@ void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src, const b
}
/* set pointers */
for (ebone_dst = static_cast<EditBone *>(lb_dst->first); ebone_dst; ebone_dst = ebone_dst->next)
{
LISTBASE_FOREACH (EditBone *, ebone_dst, lb_dst) {
if (ebone_dst->parent) {
ebone_dst->parent = ebone_dst->parent->temp.ebone;
}
@ -877,9 +852,8 @@ void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src, const b
void ED_armature_ebone_listbase_temp_clear(ListBase *lb)
{
EditBone *ebone;
/* be sure they don't hang ever */
for (ebone = static_cast<EditBone *>(lb->first); ebone; ebone = ebone->next) {
LISTBASE_FOREACH (EditBone *, ebone, lb) {
ebone->temp.p = nullptr;
}
}

View File

@ -384,7 +384,6 @@ void POSE_OT_paths_update(wmOperatorType *ot)
/* for the object with pose/action: clear path curves for selected bones only */
static void ED_pose_clear_paths(Object *ob, bool only_selected)
{
bPoseChannel *pchan;
bool skipped = false;
if (ELEM(nullptr, ob, ob->pose)) {
@ -392,7 +391,7 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
}
/* free the motionpath blocks for all bones - This is easier for users to quickly clear all */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->mpath) {
if ((only_selected == false) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))) {
animviz_free_motionpath(pchan->mpath);

View File

@ -293,7 +293,6 @@ static int group_move_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : nullptr;
bPoseChannel *pchan;
bActionGroup *grp;
int dir = RNA_enum_get(op->ptr, "direction");
@ -317,8 +316,7 @@ static int group_move_exec(bContext *C, wmOperator *op)
pose->active_group += dir;
/* fix changed bone group indices in bones (swap grpIndexA with grpIndexB) */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->agrp_index == grpIndexB) {
pchan->agrp_index = grpIndexA;
}
@ -381,7 +379,6 @@ static int group_sort_exec(bContext *C, wmOperator * /*op*/)
{
Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : nullptr;
bPoseChannel *pchan;
tSortActionGroup *agrp_array;
bActionGroup *agrp;
@ -414,7 +411,7 @@ static int group_sort_exec(bContext *C, wmOperator * /*op*/)
}
/* Fix changed bone group indices in bones. */
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
for (i = 0; i < agrp_count; i++) {
if (pchan->agrp_index == agrp_array[i].index) {
pchan->agrp_index = i + 1;

View File

@ -327,7 +327,6 @@ void ED_armature_pose_select_in_wpaint_mode(const Scene *scene,
bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility)
{
bArmature *arm = static_cast<bArmature *>(ob->data);
bPoseChannel *pchan;
/* we call this from outliner too */
if (ob->pose == nullptr) {
@ -337,8 +336,7 @@ bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
/* Determine if we're selecting or deselecting */
if (select_mode == SEL_TOGGLE) {
select_mode = SEL_SELECT;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) {
if (pchan->bone->flag & BONE_SELECTED) {
select_mode = SEL_DESELECT;
@ -350,7 +348,7 @@ bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
/* Set the flags accordingly */
bool changed = false;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
/* ignore the pchan if it isn't visible or if its selection cannot be changed */
if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) {
int flag_prev = pchan->bone->flag;
@ -426,8 +424,6 @@ bool ED_pose_deselect_all_multi(bContext *C, int select_mode, const bool ignore_
static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
{
Bone *curBone;
/* stop when unconnected child is encountered, or when unselectable bone is encountered */
if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) {
return;
@ -440,7 +436,7 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
bone->flag |= BONE_SELECTED;
}
for (curBone = static_cast<Bone *>(bone->childbase.first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) {
selectconnected_posebonechildren(ob, curBone, extend);
}
}
@ -485,7 +481,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
}
/* Select children */
for (curBone = static_cast<Bone *>(bone->childbase.first); curBone; curBone = curBone->next) {
LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) {
selectconnected_posebonechildren(base->object, curBone, extend);
}
@ -556,8 +552,7 @@ static int pose_select_linked_exec(bContext *C, wmOperator * /*op*/)
}
/* Select children */
for (curBone = static_cast<Bone *>(pchan->bone->childbase.first); curBone;
curBone = curBone->next) {
LISTBASE_FOREACH (Bone *, curBone, &pchan->bone->childbase) {
selectconnected_posebonechildren(ob, curBone, false);
}
ED_pose_bone_select_tag_update(ob);
@ -689,17 +684,14 @@ void POSE_OT_select_parent(wmOperatorType *ot)
static int pose_select_constraint_target_exec(bContext *C, wmOperator * /*op*/)
{
bConstraint *con;
int found = 0;
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
if (pchan->bone->flag & BONE_SELECTED) {
for (con = static_cast<bConstraint *>(pchan->constraints.first); con; con = con->next) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
ListBase targets = {nullptr, nullptr};
bConstraintTarget *ct;
if (BKE_constraint_targets_get(con, &targets)) {
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
Object *ob = ct->tar;
/* Any armature that is also in pose mode should be selected. */
@ -781,15 +773,12 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
}
}
else { /* direction == BONE_SELECT_CHILD */
bPoseChannel *pchan_iter;
Bone *bone_child = nullptr;
int pass;
/* first pass, only connected bones (the logical direct child) */
for (pass = 0; pass < 2 && (bone_child == nullptr); pass++) {
for (pchan_iter = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan_iter;
pchan_iter = pchan_iter->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan_iter, &ob->pose->chanbase) {
/* possible we have multiple children, some invisible */
if (PBONE_SELECTABLE(arm, pchan_iter->bone)) {
if (pchan_iter->parent == pchan_act) {
@ -1059,7 +1048,6 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex
ViewLayer *view_layer = CTX_data_view_layer(C);
bool changed_multi = false;
KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
KS_Path *ksp;
/* sanity checks: validate Keying Set and object */
if (ks == nullptr) {
@ -1109,7 +1097,7 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex
/* iterate over elements in the Keying Set, setting selection depending on whether
* that bone is visible or not...
*/
for (ksp = static_cast<KS_Path *>(ks->paths.first); ksp; ksp = ksp->next) {
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
/* only items related to this object will be relevant */
if ((ksp->id == &ob->id) && (ksp->rna_path != nullptr)) {
bPoseChannel *pchan = nullptr;
@ -1236,16 +1224,14 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = static_cast<bArmature *>(ob->data);
bPoseChannel *pchan, *pchan_mirror_act = nullptr;
bPoseChannel *pchan_mirror_act = nullptr;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
const int flag = (pchan->bone->flag & BONE_SELECTED);
PBONE_PREV_FLAG_SET(pchan, flag);
}
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (PBONE_SELECTABLE(arm, pchan->bone)) {
bPoseChannel *pchan_mirror;
int flag_new = extend ? PBONE_PREV_FLAG_GET(pchan) : 0;

View File

@ -477,7 +477,6 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
const char prop_prefix[])
{
PointerRNA ptr = {nullptr};
LinkData *ld;
int len = strlen(pfl->pchan_path);
/* Setup pointer RNA for resolving paths. */
@ -488,7 +487,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
* - bbone properties are similar, but they always start with a prefix "bbone_*",
* so a similar method should work here for those too
*/
for (ld = static_cast<LinkData *>(pfl->fcurves.first); ld; ld = ld->next) {
LISTBASE_FOREACH (LinkData *, ld, &pfl->fcurves) {
FCurve *fcu = (FCurve *)ld->data;
const char *bPtr, *pPtr;
@ -760,10 +759,8 @@ static void pose_slide_rest_pose_apply_other_rot(tPoseSlideOp *pso, float vec[4]
*/
static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
/* For each link, handle each set of transforms. */
for (pfl = static_cast<tPChanFCurveLink *>(pso->pfLinks.first); pfl; pfl = pfl->next) {
LISTBASE_FOREACH (tPChanFCurveLink *, pfl, &pso->pfLinks) {
/* Valid transforms for each #bPoseChannel should have been noted already.
* - Sliding the pose should be a straightforward exercise for location+rotation,
* but rotations get more complicated since we may want to use quaternion blending
@ -819,8 +816,6 @@ static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso)
*/
static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
/* Sanitize the frame ranges. */
if (pso->prev_frame == pso->next_frame) {
/* Move out one step either side. */
@ -843,7 +838,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
}
/* For each link, handle each set of transforms. */
for (pfl = static_cast<tPChanFCurveLink *>(pso->pfLinks.first); pfl; pfl = pfl->next) {
LISTBASE_FOREACH (tPChanFCurveLink *, pfl, &pso->pfLinks) {
/* Valid transforms for each #bPoseChannel should have been noted already
* - sliding the pose should be a straightforward exercise for location+rotation,
* but rotations get more complicated since we may want to use quaternion blending
@ -1013,7 +1008,6 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso)
*/
static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent *event)
{
tPChanFCurveLink *pfl;
wmWindow *win = CTX_wm_window(C);
tPoseSlideOp *pso = static_cast<tPoseSlideOp *>(op->customdata);
@ -1021,11 +1015,9 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent *
ED_slider_init(pso->slider, event);
/* For each link, add all its keyframes to the search tree. */
for (pfl = static_cast<tPChanFCurveLink *>(pso->pfLinks.first); pfl; pfl = pfl->next) {
LinkData *ld;
LISTBASE_FOREACH (tPChanFCurveLink *, pfl, &pso->pfLinks) {
/* Do this for each F-Curve. */
for (ld = static_cast<LinkData *>(pfl->fcurves.first); ld; ld = ld->next) {
LISTBASE_FOREACH (LinkData *, ld, &pfl->fcurves) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(pfl->ob->adt, fcu, pso->keylist, 0);
}

View File

@ -368,9 +368,7 @@ static void applyarmature_reset_bone_constraints(const bPoseChannel *pchan)
* applied. */
static void applyarmature_reset_constraints(bPose *pose, const bool use_selected)
{
for (bPoseChannel *pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan;
pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
BLI_assert(pchan->bone != nullptr);
if (use_selected && (pchan->bone->flag & BONE_SELECTED) == 0) {
continue;
@ -390,7 +388,6 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bArmature *arm = BKE_armature_from_object(ob);
bPose *pose;
bPoseChannel *pchan;
ListBase selected_bones;
const bool use_selected = RNA_boolean_get(op->ptr, "selected");
@ -438,7 +435,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
BLI_freelistN(&selected_bones);
}
else {
for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
EditBone *curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
@ -602,10 +599,9 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot)
static void set_pose_keys(Object *ob)
{
bArmature *arm = static_cast<bArmature *>(ob->data);
bPoseChannel *chan;
if (ob->pose) {
for (chan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); chan; chan = chan->next) {
LISTBASE_FOREACH (bPoseChannel *, chan, &ob->pose->chanbase) {
Bone *bone = chan->bone;
if ((bone) && (bone->flag & BONE_SELECTED) && ANIM_bonecoll_is_visible(arm, bone)) {
chan->flag |= POSE_KEY;
@ -849,7 +845,6 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
bPoseChannel *chan;
const bool flip = RNA_boolean_get(op->ptr, "flipped");
bool selOnly = RNA_boolean_get(op->ptr, "selected_mask");
@ -900,7 +895,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
/* Safely merge all of the channels in the buffer pose into any
* existing pose.
*/
for (chan = static_cast<bPoseChannel *>(pose_from->chanbase.first); chan; chan = chan->next) {
LISTBASE_FOREACH (bPoseChannel *, chan, &pose_from->chanbase) {
if (chan->flag & POSE_KEY) {
/* Try to perform paste on this bone. */
bPoseChannel *pchan = pose_bone_do_paste(ob, chan, selOnly, flip);
@ -1378,7 +1373,6 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
*/
bPose *dummyPose = nullptr;
Object workob{};
bPoseChannel *pchan;
/* execute animation step for current frame using a dummy copy of the pose */
BKE_pose_copy_data(&dummyPose, ob->pose, false);
@ -1393,14 +1387,12 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
&workob.id, workob.adt, &anim_eval_context, ADT_RECALC_ANIM, false);
/* Copy back values, but on selected bones only. */
for (pchan = static_cast<bPoseChannel *>(dummyPose->chanbase.first); pchan;
pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &dummyPose->chanbase) {
pose_bone_do_paste(ob, pchan, only_select, false);
}
/* free temp data - free manually as was copied without constraints */
for (pchan = static_cast<bPoseChannel *>(dummyPose->chanbase.first); pchan;
pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &dummyPose->chanbase) {
if (pchan->prop) {
IDP_FreeProperty(pchan->prop);
}

View File

@ -214,10 +214,8 @@ void poseAnim_mapping_refresh(bContext *C, Scene * /*scene*/, Object *ob)
void poseAnim_mapping_reset(ListBase *pfLinks)
{
tPChanFCurveLink *pfl;
/* iterate over each pose-channel affected, restoring all channels to their original values */
for (pfl = static_cast<tPChanFCurveLink *>(pfLinks->first); pfl; pfl = pfl->next) {
LISTBASE_FOREACH (tPChanFCurveLink *, pfl, pfLinks) {
bPoseChannel *pchan = pfl->pchan;
/* just copy all the values over regardless of whether they changed or not */
@ -277,13 +275,12 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks,
/* Insert keyframes as necessary if auto-key-framing. */
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
ListBase dsources = {nullptr, nullptr};
tPChanFCurveLink *pfl;
/* iterate over each pose-channel affected, tagging bones to be keyed */
/* XXX: here we already have the information about what transforms exist, though
* it might be easier to just overwrite all using normal mechanisms
*/
for (pfl = static_cast<tPChanFCurveLink *>(pfLinks->first); pfl; pfl = pfl->next) {
LISTBASE_FOREACH (tPChanFCurveLink *, pfl, pfLinks) {
bPoseChannel *pchan = pfl->pchan;
if ((pfl->ob->id.tag & LIB_TAG_DOIT) == 0) {

View File

@ -4555,7 +4555,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
/* find both nurbs and points, nu1 will be put behind nu2 */
for (nu = static_cast<Nurb *>(nubase->first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, nubase) {
if (nu->pntsu == 1) {
nu->flagu &= ~CU_NURB_CYCLIC;
}

View File

@ -212,9 +212,8 @@ bool ED_curve_nurb_deselect_all(const Nurb *nu)
int ED_curve_select_count(const View3D *v3d, const EditNurb *editnurb)
{
int sel = 0;
Nurb *nu;
for (nu = static_cast<Nurb *>(editnurb->nurbs.first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
sel += ED_curve_nurb_select_count(v3d, nu);
}

View File

@ -64,7 +64,6 @@ static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short
{
ListBase *undobase = &ucu->nubase;
ListBase *editbase = BKE_curve_editNurbs_get(cu);
Nurb *nu, *newnu;
EditNurb *editnurb = cu->editnurb;
AnimData *ad = BKE_animdata_from_id(&cu->id);
@ -86,8 +85,8 @@ static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short
}
/* Copy. */
for (nu = static_cast<Nurb *>(undobase->first); nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
LISTBASE_FOREACH (Nurb *, nu, undobase) {
Nurb *newnu = BKE_nurb_duplicate(nu);
if (editnurb->keyindex) {
ED_curve_keyindex_update_nurb(editnurb, nu, newnu);
@ -108,7 +107,6 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
BLI_assert(BLI_array_is_zeroed(ucu, 1));
ListBase *nubase = BKE_curve_editNurbs_get(cu);
EditNurb *editnurb = cu->editnurb, tmpEditnurb;
Nurb *nu, *newnu;
AnimData *ad = BKE_animdata_from_id(&cu->id);
/* TODO: include size of fcurve & undoIndex */
@ -128,8 +126,8 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
}
/* Copy. */
for (nu = static_cast<Nurb *>(nubase->first); nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
LISTBASE_FOREACH (Nurb *, nu, nubase) {
Nurb *newnu = BKE_nurb_duplicate(nu);
if (ucu->undoIndex) {
ED_curve_keyindex_update_nurb(&tmpEditnurb, nu, newnu);

View File

@ -733,7 +733,6 @@ void ED_text_to_object(bContext *C, const Text *text, const bool split_lines)
{
Main *bmain = CTX_data_main(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
const TextLine *line;
float offset[3];
int linenum = 0;
@ -742,7 +741,7 @@ void ED_text_to_object(bContext *C, const Text *text, const bool split_lines)
}
if (split_lines) {
for (line = static_cast<const TextLine *>(text->lines.first); line; line = line->next) {
LISTBASE_FOREACH (const TextLine *, line, &text->lines) {
/* skip lines with no text, but still make space for them */
if (line->line[0] == '\0') {
linenum++;

View File

@ -318,7 +318,6 @@ void ED_gpencil_anim_copybuf_free()
bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
{
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
Scene *scene = ac->scene;
@ -331,7 +330,7 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* This function only deals with grease pencil layer frames.
* This check is needed in the case of a call from the main dopesheet. */
if (ale->type != ANIMTYPE_GPLAYER) {
@ -387,7 +386,6 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
{
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
Scene *scene = ac->scene;
@ -428,7 +426,7 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* from selected channels */
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* only deal with GPlayers (case of calls from general dopesheet) */
if (ale->type != ANIMTYPE_GPLAYER) {
continue;
@ -436,7 +434,7 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
bGPDlayer *gpld = (bGPDlayer *)ale->data;
bGPDlayer *gpls = nullptr;
bGPDframe *gpfs, *gpf;
bGPDframe *gpf;
/* find suitable layer from buffer to use to paste from */
for (gpls = static_cast<bGPDlayer *>(gpencil_anim_copybuf.first); gpls; gpls = gpls->next) {
@ -452,7 +450,7 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
}
/* add frames from buffer */
for (gpfs = static_cast<bGPDframe *>(gpls->frames.first); gpfs; gpfs = gpfs->next) {
LISTBASE_FOREACH (bGPDframe *, gpfs, &gpls->frames) {
/* temporarily apply offset to buffer-frame while copying */
gpfs->framenum += offset;
@ -462,8 +460,6 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
/* Ensure to use same keyframe type. */
gpf->key_type = gpfs->key_type;
bGPDstroke *gps, *gpsn;
/* This should be the right frame... as it may be a pre-existing frame,
* must make sure that only compatible stroke types get copied over
* - We cannot just add a duplicate frame, as that would cause errors
@ -471,9 +467,9 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
* don't have enough info to do so. Instead, we simply just paste,
* if it works, it will show up.
*/
for (gps = static_cast<bGPDstroke *>(gpfs->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpfs->strokes) {
/* make a copy of stroke, then of its points array */
gpsn = BKE_gpencil_stroke_duplicate(gps, true, true);
bGPDstroke *gpsn = BKE_gpencil_stroke_duplicate(gps, true, true);
/* append stroke to frame */
BLI_addtail(&gpf->strokes, gpsn);

View File

@ -1098,8 +1098,7 @@ static bool gpencil_reveal_poll(bContext *C)
static void gpencil_reveal_select_frame(bContext *C, bGPDframe *frame, bool select)
{
bGPDstroke *gps;
for (gps = static_cast<bGPDstroke *>(frame->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &frame->strokes) {
/* only deselect strokes that are valid in this view */
if (ED_gpencil_stroke_can_use(C, gps)) {
@ -1141,8 +1140,7 @@ static int gpencil_reveal_exec(bContext *C, wmOperator *op)
}
else {
/* deselect strokes on all frames (same as deselect all operator) */
bGPDframe *gpf;
for (gpf = static_cast<bGPDframe *>(gpl->frames.first); gpf; gpf = gpf->next) {
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
gpencil_reveal_select_frame(C, gpf, false);
}
}
@ -1621,7 +1619,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
continue;
}
/* verify if any selected stroke is in the extreme of the stack and select to move */
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* only if selected */
if (gps->flag & GP_STROKE_SELECT) {
/* skip strokes that are invalid for current view */
@ -1896,9 +1894,7 @@ static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator * /*op*/)
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* only editable and visible layers are considered */
if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != nullptr)) {
for (bGPDstroke *gps = static_cast<bGPDstroke *>(gpl->actframe->strokes.last); gps;
gps = gps->prev)
{
LISTBASE_FOREACH_BACKWARD (bGPDstroke *, gps, &gpl->actframe->strokes) {
/* only if selected */
if (gps->flag & GP_STROKE_SELECT) {
/* skip strokes that are invalid for current view */
@ -3115,9 +3111,7 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator * /*op*/)
if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != nullptr) &&
(gpl->flag & GP_LAYER_ACTIVE))
{
for (bGPDstroke *gps = static_cast<bGPDstroke *>(gpl->actframe->strokes.last); gps;
gps = gps->prev)
{
LISTBASE_FOREACH_BACKWARD (bGPDstroke *, gps, &gpl->actframe->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;

View File

@ -935,14 +935,13 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
ListBase new_strokes = {nullptr, nullptr};
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
if (gpf == nullptr) {
continue;
}
/* make copies of selected strokes, and deselect these once we're done */
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@ -1284,7 +1283,6 @@ static int gpencil_extrude_exec(bContext *C, wmOperator *op)
bGPdata *gpd = (bGPdata *)obact->data;
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
bGPDstroke *gps = nullptr;
if (gpd == nullptr) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
@ -1302,7 +1300,7 @@ static int gpencil_extrude_exec(bContext *C, wmOperator *op)
continue;
}
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@ -1520,8 +1518,7 @@ static int gpencil_strokes_copy_exec(bContext *C, wmOperator *op)
}
/* make copies of selected strokes, and deselect these once we're done */
for (bGPDstroke *gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps;
gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@ -1671,11 +1668,9 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op)
}
else {
/* Check that some of the strokes in the buffer can be used */
bGPDstroke *gps;
bool ok = false;
for (gps = static_cast<bGPDstroke *>(gpencil_strokes_copypastebuf.first); gps; gps = gps->next)
{
LISTBASE_FOREACH (bGPDstroke *, gps, &gpencil_strokes_copypastebuf) {
if (ED_gpencil_stroke_can_use(C, gps)) {
ok = true;
break;
@ -3279,7 +3274,6 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
const bool geometry = RNA_boolean_get(op->ptr, "geometry");
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
bGPDstroke *gps = nullptr;
/* sanity checks */
if (ELEM(nullptr, gpd)) {
@ -3298,7 +3292,7 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
continue;
}
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
/* skip strokes that are not selected or invalid for current view */
if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false)
@ -3448,8 +3442,7 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
continue;
}
for (bGPDstroke *gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next)
{
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
/* skip strokes that are not selected or invalid for current view */
@ -3965,8 +3958,7 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
if (gpf == nullptr) {
continue;
}
for (bGPDstroke *gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next)
{
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@ -4240,8 +4232,7 @@ static int gpencil_stroke_outline_exec(bContext *C, wmOperator *op)
continue;
}
for (bGPDstroke *gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next)
{
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
}

View File

@ -923,14 +923,13 @@ struct tGPSB_CloneBrushData {
static void gpencil_brush_clone_init(bContext *C, tGP_BrushEditData *gso)
{
tGPSB_CloneBrushData *data;
bGPDstroke *gps;
/* Initialize custom-data. */
gso->customdata = data = static_cast<tGPSB_CloneBrushData *>(
MEM_callocN(sizeof(tGPSB_CloneBrushData), "CloneBrushData"));
/* compute midpoint of strokes on clipboard */
for (gps = static_cast<bGPDstroke *>(gpencil_strokes_copypastebuf.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpencil_strokes_copypastebuf) {
if (ED_gpencil_stroke_can_use(C, gps)) {
const float dfac = 1.0f / float(gps->totpoints);
float mid[3] = {0.0f};
@ -996,7 +995,6 @@ static void gpencil_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
Object *ob = gso->object;
bGPdata *gpd = (bGPdata *)ob->data;
Scene *scene = gso->scene;
bGPDstroke *gps;
float delta[3];
size_t strokes_added = 0;
@ -1008,7 +1006,7 @@ static void gpencil_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
sub_v3_v3v3(delta, gso->dvec, data->buffer_midpoint);
/* Copy each stroke into the layer */
for (gps = static_cast<bGPDstroke *>(gpencil_strokes_copypastebuf.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpencil_strokes_copypastebuf) {
if (ED_gpencil_stroke_can_use(C, gps)) {
bGPDstroke *new_stroke;
bGPDspoint *pt;
@ -1241,12 +1239,10 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op)
char tool = gso->brush->gpencil_sculpt_tool;
switch (tool) {
case GPSCULPT_TOOL_CLONE: {
bGPDstroke *gps;
bool found = false;
/* check that there are some usable strokes in the buffer */
for (gps = static_cast<bGPDstroke *>(gpencil_strokes_copypastebuf.first); gps;
gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpencil_strokes_copypastebuf) {
if (ED_gpencil_stroke_can_use(C, gps)) {
found = true;
break;

View File

@ -765,7 +765,6 @@ static bool gpencil_select_same_layer(bContext *C)
bool changed = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, scene->r.cfra, GP_GETFRAME_USE_PREV);
bGPDstroke *gps;
bool found = false;
if (gpf == nullptr) {
@ -773,7 +772,7 @@ static bool gpencil_select_same_layer(bContext *C)
}
/* Search for a selected stroke */
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
if (ED_gpencil_stroke_can_use(C, gps)) {
if (gps->flag & GP_STROKE_SELECT) {
found = true;
@ -785,7 +784,7 @@ static bool gpencil_select_same_layer(bContext *C)
/* Select all if found */
if (found) {
if (is_curve_edit) {
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
if (gps->editcurve != nullptr && ED_gpencil_stroke_can_use(C, gps)) {
bGPDcurve *gpc = gps->editcurve;
for (int i = 0; i < gpc->tot_curve_points; i++) {
@ -802,7 +801,7 @@ static bool gpencil_select_same_layer(bContext *C)
}
}
else {
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
if (ED_gpencil_stroke_can_use(C, gps)) {
bGPDspoint *pt;
int i;

View File

@ -1465,15 +1465,13 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight)
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = static_cast<bGPDframe *>((is_multiedit) ? gpl->frames.first :
gpl->actframe);
bGPDstroke *gps = nullptr;
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
if (gpf == nullptr) {
continue;
}
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
@ -1519,7 +1517,6 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob)
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = static_cast<bGPDframe *>((is_multiedit) ? gpl->frames.first :
gpl->actframe);
bGPDstroke *gps = nullptr;
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
@ -1527,8 +1524,7 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob)
continue;
}
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@ -1572,16 +1568,13 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob)
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = static_cast<bGPDframe *>((is_multiedit) ? gpl->frames.first :
gpl->actframe);
bGPDstroke *gps = nullptr;
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
if (gpf == nullptr) {
continue;
}
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@ -1627,15 +1620,13 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = static_cast<bGPDframe *>((is_multiedit) ? gpl->frames.first :
gpl->actframe);
bGPDstroke *gps = nullptr;
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
if (gpf == nullptr) {
continue;
}
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
@ -2581,9 +2572,7 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
/* deselect all strokes on all frames */
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
bGPDstroke *gps;
for (gps = static_cast<bGPDstroke *>(gpf->strokes.first); gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
bGPDspoint *pt;
int i;

View File

@ -299,7 +299,7 @@ static bool *gpencil_vgroup_bone_deformed_map_get(Object *ob, const int defbase_
/* Add all vertex group names to a hash table. */
gh = BLI_ghash_str_new_ex(__func__, defbase_tot);
for (dg = static_cast<bDeformGroup *>(defbase->first); dg; dg = dg->next) {
LISTBASE_FOREACH (bDeformGroup *, dg, defbase) {
BLI_ghash_insert(gh, dg->name, nullptr);
}
BLI_assert(BLI_ghash_len(gh) == defbase_tot);
@ -314,9 +314,8 @@ static bool *gpencil_vgroup_bone_deformed_map_get(Object *ob, const int defbase_
if (amd->object && amd->object->pose) {
bPose *pose = amd->object->pose;
bPoseChannel *chan;
for (chan = static_cast<bPoseChannel *>(pose->chanbase.first); chan; chan = chan->next) {
LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
void **val_p;
if (chan->bone->flag & BONE_NO_DEFORM) {
continue;

View File

@ -6112,11 +6112,9 @@ static void ui_layout_introspect_button(DynStr *ds, uiButtonItem *bitem)
static void ui_layout_introspect_items(DynStr *ds, ListBase *lb)
{
uiItem *item;
BLI_dynstr_append(ds, "[");
for (item = static_cast<uiItem *>(lb->first); item; item = item->next) {
LISTBASE_FOREACH (uiItem *, item, lb) {
BLI_dynstr_append(ds, "{");

View File

@ -2307,7 +2307,7 @@ void uiTemplateModifiers(uiLayout * /*layout*/, bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
for (ModifierData *md = static_cast<ModifierData *>(modifiers->first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, modifiers) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
if (mti->panel_register == nullptr) {
continue;
@ -2556,9 +2556,7 @@ void uiTemplateGpencilModifiers(uiLayout * /*layout*/, bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
for (GpencilModifierData *md = static_cast<GpencilModifierData *>(modifiers->first); md;
md = md->next)
{
LISTBASE_FOREACH (GpencilModifierData *, md, modifiers) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(
GpencilModifierType(md->type));
if (mti->panel_register == nullptr) {
@ -2631,7 +2629,7 @@ void uiTemplateShaderFx(uiLayout * /*layout*/, bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
for (ShaderFxData *fx = static_cast<ShaderFxData *>(shaderfx->first); fx; fx = fx->next) {
LISTBASE_FOREACH (ShaderFxData *, fx, shaderfx) {
char panel_idname[MAX_NAME];
shaderfx_panel_id(fx, panel_idname);

View File

@ -40,12 +40,11 @@ static void edbm_extrude_edge_exclude_mirror(
Object *obedit, BMEditMesh *em, const char hflag, BMOperator *op, BMOpSlot *slot_edges_exclude)
{
BMesh *bm = em->bm;
ModifierData *md;
/* If a mirror modifier with clipping is on, we need to adjust some
* of the cases above to handle edges on the line of symmetry.
*/
for (md = static_cast<ModifierData *>(obedit->modifiers.first); md; md = md->next) {
LISTBASE_FOREACH (ModifierData *, md, &obedit->modifiers) {
if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) {
MirrorModifierData *mmd = (MirrorModifierData *)md;

View File

@ -686,7 +686,6 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd,
static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd)
{
Ref *ref;
KnifeVert *kfv;
KnifeVert *tempkfv;
KnifeEdge *kfe;
@ -700,7 +699,7 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd)
float *end;
kfe = static_cast<KnifeEdge *>(((Ref *)kfv->edges.first)->ref);
for (ref = static_cast<Ref *>(kfv->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kfv->edges) {
tempkfe = static_cast<KnifeEdge *>(ref->ref);
if (tempkfe->v1 != kfv) {
tempkfv = tempkfe->v1;
@ -783,7 +782,7 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd)
else {
/* Choose minimum angle edge. */
kfe = static_cast<KnifeEdge *>(((Ref *)kfv->edges.first)->ref);
for (ref = static_cast<Ref *>(kfv->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kfv->edges) {
tempkfe = static_cast<KnifeEdge *>(ref->ref);
if (tempkfe->v1 != kfv) {
tempkfv = tempkfe->v1;
@ -1586,8 +1585,7 @@ static BMElem *bm_elem_from_knife_vert(KnifeVert *kfv, KnifeEdge **r_kfe)
if (r_kfe || ele_test == nullptr) {
if (kfv->v == nullptr) {
Ref *ref;
for (ref = static_cast<Ref *>(kfv->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kfv->edges) {
kfe = static_cast<KnifeEdge *>(ref->ref);
if (kfe->e) {
if (r_kfe) {
@ -1655,9 +1653,7 @@ static void knife_append_list(KnifeTool_OpData *kcd, ListBase *lst, void *elem)
static Ref *find_ref(ListBase *lb, void *ref)
{
Ref *ref1;
for (ref1 = static_cast<Ref *>(lb->first); ref1; ref1 = ref1->next) {
LISTBASE_FOREACH (Ref *, ref1, lb) {
if (ref1->ref == ref) {
return ref1;
}
@ -1694,10 +1690,8 @@ static void knife_add_edge_faces_to_vert(KnifeTool_OpData *kcd, KnifeVert *kfv,
* If more than one, return the first; if none, return nullptr. */
static BMFace *knife_find_common_face(ListBase *faces1, ListBase *faces2)
{
Ref *ref1, *ref2;
for (ref1 = static_cast<Ref *>(faces1->first); ref1; ref1 = ref1->next) {
for (ref2 = static_cast<Ref *>(faces2->first); ref2; ref2 = ref2->next) {
LISTBASE_FOREACH (Ref *, ref1, faces1) {
LISTBASE_FOREACH (Ref *, ref2, faces2) {
if (ref1->ref == ref2->ref) {
return (BMFace *)(ref1->ref);
}
@ -1852,7 +1846,7 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
kfe->v1->is_splitting = true;
BLI_addtail(&kfe->v1->edges, ref);
for (ref = static_cast<Ref *>(kfe->faces.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kfe->faces) {
knife_edge_append_face(kcd, newkfe, static_cast<BMFace *>(ref->ref));
}
@ -2178,7 +2172,6 @@ static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits)
static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, ListBase *kfedges)
{
KnifeEdge *kfe;
Ref *ref;
int edge_array_len = BLI_listbase_count(kfedges);
int i;
@ -2190,7 +2183,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, Li
BLI_assert(BLI_gset_len(kcd->edgenet.edge_visit) == 0);
i = 0;
for (ref = static_cast<Ref *>(kfedges->first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, kfedges) {
bool is_new_edge = false;
kfe = static_cast<KnifeEdge *>(ref->ref);
@ -2320,7 +2313,6 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob)
BMFace *f;
BMEdge *e, *enew;
ListBase *list;
Ref *ref;
float pct;
SmallHashIter hiter;
BLI_mempool_iter iter;
@ -2366,7 +2358,7 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob)
if (kfv->v || kfv->is_invalid || kfv->ob != ob) {
continue; /* Already have a BMVert. */
}
for (ref = static_cast<Ref *>(kfv->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kfv->edges) {
kfe = static_cast<KnifeEdge *>(ref->ref);
e = kfe->e;
if (!e) {
@ -2390,7 +2382,7 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob)
{
BLI_listbase_sort_r(list, sort_verts_by_dist_cb, e->v1->co);
for (ref = static_cast<Ref *>(list->first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, list) {
kfv = static_cast<KnifeVert *>(ref->ref);
pct = line_point_factor_v3(kfv->co, e->v1->co, e->v2->co);
kfv->v = BM_edge_split(bm, e, e->v1, &enew, pct);
@ -2422,7 +2414,6 @@ static void knife_add_cut(KnifeTool_OpData *kcd)
int i;
GHash *facehits;
BMFace *f;
Ref *r;
GHashIterator giter;
ListBase *list;
@ -2462,12 +2453,12 @@ static void knife_add_cut(KnifeTool_OpData *kcd)
add_hit_to_facehits(kcd, facehits, lh->f, lh);
}
if (lh->v) {
for (r = static_cast<Ref *>(lh->v->faces.first); r; r = r->next) {
LISTBASE_FOREACH (Ref *, r, &lh->v->faces) {
add_hit_to_facehits(kcd, facehits, static_cast<BMFace *>(r->ref), lh);
}
}
if (lh->kfe) {
for (r = static_cast<Ref *>(lh->kfe->faces.first); r; r = r->next) {
LISTBASE_FOREACH (Ref *, r, &lh->kfe->faces) {
add_hit_to_facehits(kcd, facehits, static_cast<BMFace *>(r->ref), lh);
}
}
@ -2589,7 +2580,6 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
float d, lambda;
BMLoop **tri;
ListBase *list;
Ref *ref;
KnifeEdge *kfe;
sub_v3_v3v3(raydir, v2, v1);
@ -2626,7 +2616,7 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
interp_v3_v3v3v3_uv(hit_cageco, UNPACK3(tri_cos), ray_tri_uv);
/* Now check that far enough away from verts and edges. */
list = knife_get_face_kedges(kcd, ob, ob_index, f);
for (ref = static_cast<Ref *>(list->first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, list) {
kfe = static_cast<KnifeEdge *>(ref->ref);
if (kfe->is_invalid) {
continue;
@ -3287,7 +3277,6 @@ static int knife_sample_screen_density_from_closest_face(KnifeTool_OpData *kcd,
{
const float radius_sq = radius * radius;
ListBase *list;
Ref *ref;
float sco[2];
float dis_sq;
int c = 0;
@ -3295,7 +3284,7 @@ static int knife_sample_screen_density_from_closest_face(KnifeTool_OpData *kcd,
knife_project_v2(kcd, cageco, sco);
list = knife_get_face_kedges(kcd, ob, ob_index, f);
for (ref = static_cast<Ref *>(list->first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, list) {
KnifeEdge *kfe = static_cast<KnifeEdge *>(ref->ref);
int i;
@ -3422,14 +3411,13 @@ static KnifeEdge *knife_find_closest_edge_of_face(
KnifeEdge *cure = nullptr;
float cur_cagep[3];
ListBase *list;
Ref *ref;
float dis_sq, curdis_sq = maxdist_sq;
knife_project_v2(kcd, cagep, sco);
/* Look through all edges associated with this face. */
list = knife_get_face_kedges(kcd, ob, ob_index, f);
for (ref = static_cast<Ref *>(list->first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, list) {
KnifeEdge *kfe = static_cast<KnifeEdge *>(ref->ref);
float kfv1_sco[2], kfv2_sco[2], test_cagep[3];
float lambda;
@ -3637,7 +3625,6 @@ static float snap_v3_angle_plane(
/* Snap to required angle along the plane of the face nearest to kcd->prev. */
static bool knife_snap_angle_relative(KnifeTool_OpData *kcd)
{
Ref *ref;
KnifeEdge *kfe;
KnifeVert *kfv;
BMFace *f;
@ -3668,7 +3655,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd)
* If none exists then exit. */
if (kcd->prev.vert) {
int count = 0;
for (ref = static_cast<Ref *>(kcd->prev.vert->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kcd->prev.vert->edges) {
kfe = ((KnifeEdge *)(ref->ref));
if (kfe->is_invalid) {
continue;
@ -3701,7 +3688,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd)
/* Choose best face for plane. */
BMFace *fprev = nullptr;
if (kcd->prev.vert && kcd->prev.vert->v) {
for (ref = static_cast<Ref *>(kcd->prev.vert->faces.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kcd->prev.vert->faces) {
f = ((BMFace *)(ref->ref));
if (f == fcurr) {
fprev = f;
@ -3709,7 +3696,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd)
}
}
else if (kcd->prev.edge) {
for (ref = static_cast<Ref *>(kcd->prev.edge->faces.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kcd->prev.edge->faces) {
f = ((BMFace *)(ref->ref));
if (f == fcurr) {
fprev = f;
@ -3777,7 +3764,6 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd)
static int knife_calculate_snap_ref_edges(KnifeTool_OpData *kcd)
{
Ref *ref;
KnifeEdge *kfe;
/* Ray for kcd->curr. */
@ -3800,7 +3786,7 @@ static int knife_calculate_snap_ref_edges(KnifeTool_OpData *kcd)
}
if (kcd->prev.vert) {
for (ref = static_cast<Ref *>(kcd->prev.vert->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &kcd->prev.vert->edges) {
kfe = ((KnifeEdge *)(ref->ref));
if (kfe->is_invalid) {
continue;
@ -3956,7 +3942,6 @@ static bool knife_snap_update_from_mval(KnifeTool_OpData *kcd, const float mval[
*/
static void knifetool_undo(KnifeTool_OpData *kcd)
{
Ref *ref;
KnifeEdge *kfe, *newkfe;
KnifeEdge *lastkfe = nullptr;
KnifeVert *v1, *v2;
@ -3995,7 +3980,7 @@ static void knifetool_undo(KnifeTool_OpData *kcd)
if (!v1->is_invalid && !v1->is_splitting) {
v1->is_invalid = true;
/* If the first vertex is touching any other cut edges don't remove it. */
for (ref = static_cast<Ref *>(v1->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &v1->edges) {
kfe = static_cast<KnifeEdge *>(ref->ref);
if (kfe->is_cut && !kfe->is_invalid) {
v1->is_invalid = false;
@ -4008,7 +3993,7 @@ static void knifetool_undo(KnifeTool_OpData *kcd)
if (!v2->is_invalid && !v2->is_splitting) {
v2->is_invalid = true;
/* If the second vertex is touching any other cut edges don't remove it. */
for (ref = static_cast<Ref *>(v2->edges.first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, &v2->edges) {
kfe = static_cast<KnifeEdge *>(ref->ref);
if (kfe->is_cut && !kfe->is_invalid) {
v2->is_invalid = false;

View File

@ -1508,12 +1508,11 @@ static bool bm_vert_connect_select_history(BMesh *bm)
static bool bm_vert_connect_select_history_edge_to_vert_path(BMesh *bm, ListBase *r_selected)
{
ListBase selected_orig = {nullptr, nullptr};
BMEditSelection *ese;
int edges_len = 0;
bool side = false;
/* first check all edges are OK */
for (ese = static_cast<BMEditSelection *>(bm->selected.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
if (ese->htype == BM_EDGE) {
edges_len += 1;
}
@ -1529,7 +1528,7 @@ static bool bm_vert_connect_select_history_edge_to_vert_path(BMesh *bm, ListBase
SWAP(ListBase, bm->selected, selected_orig);
/* convert edge selection into 2 ordered loops (where the first edge ends up in the middle) */
for (ese = static_cast<BMEditSelection *>(selected_orig.first); ese; ese = ese->next) {
LISTBASE_FOREACH (BMEditSelection *, ese, &selected_orig) {
BMEdge *e_curr = (BMEdge *)ese->ele;
BMEdge *e_prev = ese->prev ? (BMEdge *)ese->prev->ele : nullptr;
BMLoop *l_curr;
@ -5068,9 +5067,9 @@ static bool edbm_fill_grid_prepare(BMesh *bm, int offset, int *span_p, const boo
}
else {
/* find the vertex with the best angle (a corner vertex) */
LinkData *v_link, *v_link_best = nullptr;
LinkData *v_link_best = nullptr;
float angle_best = -1.0f;
for (v_link = static_cast<LinkData *>(verts->first); v_link; v_link = v_link->next) {
LISTBASE_FOREACH (LinkData *, v_link, verts) {
const float angle = edbm_fill_grid_vert_tag_angle(static_cast<BMVert *>(v_link->data));
if ((angle > angle_best) || (v_link_best == nullptr)) {
angle_best = angle;

View File

@ -220,9 +220,8 @@ static void mball_select_similar_type_get(
Object *obedit, MetaBall *mb, int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
{
float tree_entry[3] = {0.0f, 0.0f, 0.0f};
MetaElem *ml;
int tree_index = 0;
for (ml = static_cast<MetaElem *>(mb->editelems->first); ml; ml = ml->next) {
LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (ml->flag & SELECT) {
switch (type) {
case SIMMBALL_RADIUS: {
@ -267,9 +266,8 @@ static bool mball_select_similar_type(Object *obedit,
const KDTree_3d *tree_3d,
const float thresh)
{
MetaElem *ml;
bool changed = false;
for (ml = static_cast<MetaElem *>(mb->editelems->first); ml; ml = ml->next) {
LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
bool select = false;
switch (type) {
case SIMMBALL_RADIUS: {
@ -359,8 +357,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
switch (type) {
case SIMMBALL_TYPE: {
MetaElem *ml;
for (ml = static_cast<MetaElem *>(mb->editelems->first); ml; ml = ml->next) {
LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (ml->flag & SELECT) {
short mball_type = 1 << (ml->type + 1);
type_ref |= mball_type;
@ -395,8 +392,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
switch (type) {
case SIMMBALL_TYPE: {
MetaElem *ml;
for (ml = static_cast<MetaElem *>(mb->editelems->first); ml; ml = ml->next) {
LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
short mball_type = 1 << (ml->type + 1);
if (mball_type & type_ref) {
ml->flag |= SELECT;

View File

@ -466,14 +466,13 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
static void multiresbake_startjob(void *bkv, bool *stop, bool *do_update, float *progress)
{
MultiresBakerJobData *data;
MultiresBakeJob *bkj = static_cast<MultiresBakeJob *>(bkv);
int baked_objects = 0, tot_obj;
tot_obj = BLI_listbase_count(&bkj->data);
if (bkj->bake_clear) { /* clear images */
for (data = static_cast<MultiresBakerJobData *>(bkj->data.first); data; data = data->next) {
LISTBASE_FOREACH (MultiresBakerJobData *, data, &bkj->data) {
ClearFlag clear_flag = ClearFlag(0);
if (bkj->mode == RE_BAKE_NORMALS) {
@ -487,7 +486,7 @@ static void multiresbake_startjob(void *bkv, bool *stop, bool *do_update, float
}
}
for (data = static_cast<MultiresBakerJobData *>(bkj->data.first); data; data = data->next) {
LISTBASE_FOREACH (MultiresBakerJobData *, data, &bkj->data) {
MultiresBakeRender bkr = {nullptr};
/* copy data stored in job descriptor */
@ -531,7 +530,6 @@ static void multiresbake_freejob(void *bkv)
{
MultiresBakeJob *bkj = static_cast<MultiresBakeJob *>(bkv);
MultiresBakerJobData *data, *next;
LinkData *link;
data = static_cast<MultiresBakerJobData *>(bkj->data.first);
while (data) {
@ -540,7 +538,7 @@ static void multiresbake_freejob(void *bkv)
data->hires_dm->release(data->hires_dm);
/* delete here, since this delete will be called from main thread */
for (link = static_cast<LinkData *>(data->images.first); link; link = link->next) {
LISTBASE_FOREACH (LinkData *, link, &data->images) {
Image *ima = (Image *)link->data;
BKE_image_partial_update_mark_full_update(ima);
}

View File

@ -645,8 +645,6 @@ static bool bake_objects_check(Main *bmain,
const bool is_selected_to_active,
const eBakeTarget target)
{
CollectionPointerLink *link;
/* error handling and tag (in case multiple materials share the same image) */
BKE_main_id_tag_idcode(bmain, ID_IM, LIB_TAG_DOIT, false);
@ -657,8 +655,7 @@ static bool bake_objects_check(Main *bmain,
return false;
}
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
link = link->next) {
LISTBASE_FOREACH (CollectionPointerLink *, link, selected_objects) {
Object *ob_iter = (Object *)link->ptr.data;
if (ob_iter == ob) {
@ -687,8 +684,7 @@ static bool bake_objects_check(Main *bmain,
return false;
}
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
link = link->next) {
LISTBASE_FOREACH (CollectionPointerLink *, link, selected_objects) {
if (!bake_object_check(
scene, view_layer, static_cast<Object *>(link->ptr.data), target, reports)) {
return false;
@ -1448,11 +1444,9 @@ static int bake(const BakeAPIRender *bkr,
}
if (bkr->is_selected_to_active) {
CollectionPointerLink *link;
tot_highpoly = 0;
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
link = link->next) {
LISTBASE_FOREACH (CollectionPointerLink *, link, selected_objects) {
Object *ob_iter = static_cast<Object *>(link->ptr.data);
if (ob_iter == ob_low) {
@ -1908,11 +1902,8 @@ static int bake_exec(bContext *C, wmOperator *op)
result = bake(&bkr, bkr.ob, &bkr.selected_objects, bkr.reports);
}
else {
CollectionPointerLink *link;
bkr.is_clear = bkr.is_clear && BLI_listbase_is_single(&bkr.selected_objects);
for (link = static_cast<CollectionPointerLink *>(bkr.selected_objects.first); link;
link = link->next)
{
LISTBASE_FOREACH (CollectionPointerLink *, link, &bkr.selected_objects) {
Object *ob_iter = static_cast<Object *>(link->ptr.data);
result = bake(&bkr, ob_iter, nullptr, bkr.reports);
}
@ -1964,11 +1955,8 @@ static void bake_startjob(void *bkv, bool * /*stop*/, bool *do_update, float *pr
bkr->result = bake(bkr, bkr->ob, &bkr->selected_objects, bkr->reports);
}
else {
CollectionPointerLink *link;
bkr->is_clear = bkr->is_clear && BLI_listbase_is_single(&bkr->selected_objects);
for (link = static_cast<CollectionPointerLink *>(bkr->selected_objects.first); link;
link = link->next)
{
LISTBASE_FOREACH (CollectionPointerLink *, link, &bkr->selected_objects) {
Object *ob_iter = static_cast<Object *>(link->ptr.data);
bkr->result = bake(bkr, ob_iter, nullptr, bkr->reports);

View File

@ -121,13 +121,10 @@ ListBase *ED_object_constraint_list_from_constraint(Object *ob,
/* if armature, try pose bones too */
if (ob->pose) {
bPoseChannel *pchan;
/* try each bone in order
* NOTE: it's not possible to directly look up the active bone yet, so this will have to do
*/
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (BLI_findindex(&pchan->constraints, con) != -1) {
if (r_pchan) {
@ -294,7 +291,6 @@ static void test_constraint(
Main *bmain, Object *owner, bPoseChannel *pchan, bConstraint *con, int type)
{
ListBase targets = {nullptr, nullptr};
bConstraintTarget *ct;
bool check_targets = true;
/* clear disabled-flag first */
@ -469,7 +465,7 @@ static void test_constraint(
/* Check targets for constraints */
if (check_targets && BKE_constraint_targets_get(con, &targets)) {
/* disable and clear constraints targets that are incorrect */
for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) {
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
/* general validity checks (for those constraints that need this) */
if (BKE_object_exists_check(bmain, ct->tar) == 0) {
/* object doesn't exist, but constraint requires target */
@ -573,7 +569,6 @@ static int constraint_type_get(Object *owner, bPoseChannel *pchan)
*/
static void test_constraints(Main *bmain, Object *ob, bPoseChannel *pchan)
{
bConstraint *curcon;
ListBase *conlist = nullptr;
int type;
@ -595,7 +590,7 @@ static void test_constraints(Main *bmain, Object *ob, bPoseChannel *pchan)
/* Check all constraints - is constraint valid? */
if (conlist) {
for (curcon = static_cast<bConstraint *>(conlist->first); curcon; curcon = curcon->next) {
LISTBASE_FOREACH (bConstraint *, curcon, conlist) {
test_constraint(bmain, ob, pchan, curcon, type);
}
}
@ -608,10 +603,7 @@ void object_test_constraints(Main *bmain, Object *ob)
}
if (ob->type == OB_ARMATURE && ob->pose) {
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan->next)
{
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->constraints.first) {
test_constraints(bmain, ob, pchan);
}
@ -626,9 +618,7 @@ static void object_test_constraint(Main *bmain, Object *ob, bConstraint *con)
test_constraint(bmain, ob, nullptr, con, CONSTRAINT_OBTYPE_OBJECT);
}
else {
bPoseChannel *pchan;
for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan;
pchan = pchan->next) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (BLI_findindex(&pchan->constraints, con) != -1) {
test_constraint(bmain, ob, pchan, con, CONSTRAINT_OBTYPE_BONE);
break;

Some files were not shown because too many files have changed in this diff Show More