diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 02:39:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 12:48:17 +0300 |
commit | 735515a3f9e4c41738bf714d682b13db64adb638 (patch) | |
tree | 04b551336131bc84ecc664a77ae0cefdded78d0b /source/blender/blenkernel/intern/nla.c | |
parent | 14a49950ff11f43b7a5a73da545339b969de97f0 (diff) |
Cleanup: style, use braces for blenkernel
Diffstat (limited to 'source/blender/blenkernel/intern/nla.c')
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 351 |
1 files changed, 234 insertions, 117 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 3b33af62073..6953339f287 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -74,8 +74,9 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user) NlaStrip *cs, *csn; /* sanity checks */ - if (strip == NULL) + if (strip == NULL) { return; + } /* free child-strips */ for (cs = strip->strips.first; cs; cs = csn) { @@ -99,10 +100,12 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user) free_fmodifiers(&strip->modifiers); /* free the strip itself */ - if (strips) + if (strips) { BLI_freelinkN(strips, strip); - else + } + else { MEM_freeN(strip); + } } /* Remove the given NLA track from the set of NLA tracks, free the track's data, @@ -113,8 +116,9 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user) NlaStrip *strip, *stripn; /* sanity checks */ - if (nlt == NULL) + if (nlt == NULL) { return; + } /* free strips */ for (strip = nlt->strips.first; strip; strip = stripn) { @@ -123,10 +127,12 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user) } /* free NLA track itself now */ - if (tracks) + if (tracks) { BLI_freelinkN(tracks, nlt); - else + } + else { MEM_freeN(nlt); + } } /* Free the elements of type NLA Tracks provided in the given list, but do not free @@ -137,8 +143,9 @@ void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user) NlaTrack *nlt, *nltn; /* sanity checks */ - if (ELEM(NULL, tracks, tracks->first)) + if (ELEM(NULL, tracks, tracks->first)) { return; + } /* free tracks one by one */ for (nlt = tracks->first; nlt; nlt = nltn) { @@ -169,8 +176,9 @@ NlaStrip *BKE_nlastrip_copy(Main *bmain, const bool do_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0; /* sanity check */ - if (strip == NULL) + if (strip == NULL) { return NULL; + } /* make a copy */ strip_d = MEM_dupallocN(strip); @@ -219,8 +227,9 @@ NlaTrack *BKE_nlatrack_copy(Main *bmain, NlaTrack *nlt_d; /* sanity check */ - if (nlt == NULL) + if (nlt == NULL) { return NULL; + } /* make a copy */ nlt_d = MEM_dupallocN(nlt); @@ -247,8 +256,9 @@ void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, ListBase *src, const int fl NlaTrack *nlt, *nlt_d; /* sanity checks */ - if (ELEM(NULL, dst, src)) + if (ELEM(NULL, dst, src)) { return; + } /* clear out the destination list first for precautions... */ BLI_listbase_clear(dst); @@ -272,8 +282,9 @@ NlaTrack *BKE_nlatrack_add(AnimData *adt, NlaTrack *prev) NlaTrack *nlt; /* sanity checks */ - if (adt == NULL) + if (adt == NULL) { return NULL; + } /* allocate new track */ nlt = MEM_callocN(sizeof(NlaTrack), "NlaTrack"); @@ -283,10 +294,12 @@ NlaTrack *BKE_nlatrack_add(AnimData *adt, NlaTrack *prev) nlt->index = BLI_listbase_count(&adt->nla_tracks); /* add track to stack, and make it the active one */ - if (prev) + if (prev) { BLI_insertlinkafter(&adt->nla_tracks, prev, nlt); - else + } + else { BLI_addtail(&adt->nla_tracks, nlt); + } BKE_nlatrack_set_active(&adt->nla_tracks, nlt); /* must have unique name, but we need to seed this */ @@ -304,8 +317,9 @@ NlaStrip *BKE_nlastrip_new(bAction *act) NlaStrip *strip; /* sanity checks */ - if (act == NULL) + if (act == NULL) { return NULL; + } /* allocate new strip */ strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip"); @@ -347,13 +361,15 @@ NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act) NlaTrack *nlt; /* sanity checks */ - if (ELEM(NULL, adt, act)) + if (ELEM(NULL, adt, act)) { return NULL; + } /* create a new NLA strip */ strip = BKE_nlastrip_new(act); - if (strip == NULL) + if (strip == NULL) { return NULL; + } /* firstly try adding strip to last track, but if that fails, add to a new track */ if (BKE_nlatrack_add_strip(adt->nla_tracks.last, strip) == 0) { @@ -422,20 +438,23 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short // float repeat; // UNUSED /* get number of repeats */ - if (IS_EQF(strip->repeat, 0.0f)) + if (IS_EQF(strip->repeat, 0.0f)) { strip->repeat = 1.0f; + } // repeat = strip->repeat; // UNUSED /* scaling */ - if (IS_EQF(strip->scale, 0.0f)) + if (IS_EQF(strip->scale, 0.0f)) { strip->scale = 1.0f; + } scale = fabsf( strip->scale); /* scale must be positive - we've got a special flag for reversing */ /* length of referenced action */ actlength = strip->actend - strip->actstart; - if (IS_EQF(actlength, 0.0f)) + if (IS_EQF(actlength, 0.0f)) { actlength = 1.0f; + } /* reversed = play strip backwards */ if (strip->flag & NLASTRIP_FLAG_REVERSE) { @@ -499,16 +518,20 @@ static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short /* reversed = play strip backwards */ if (strip->flag & NLASTRIP_FLAG_REVERSE) { - if (mode == NLATIME_CONVERT_MAP) + if (mode == NLATIME_CONVERT_MAP) { return strip->end - (length * cframe); - else + } + else { return (strip->end - cframe) / length; + } } else { - if (mode == NLATIME_CONVERT_MAP) + if (mode == NLATIME_CONVERT_MAP) { return (length * cframe) + strip->start; - else + } + else { return (cframe - strip->start) / length; + } } } @@ -546,17 +569,20 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode) * - when not in tweakmode, the active Action does not have any scaling applied :) * - when in tweakmode, if the no-mapping flag is set, do not map */ - if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON) == 0 || (adt->flag & ADT_NLA_EDIT_NOMAP)) + if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON) == 0 || (adt->flag & ADT_NLA_EDIT_NOMAP)) { return cframe; + } /* if the active-strip info has been stored already, access this, otherwise look this up * and store for (very probable) future usage */ if (adt->act_track == NULL) { - if (adt->actstrip) + if (adt->actstrip) { adt->act_track = BKE_nlatrack_find_tweaked(adt); - else + } + else { adt->act_track = BKE_nlatrack_find_active(&adt->nla_tracks); + } } if (adt->actstrip == NULL) { adt->actstrip = BKE_nlastrip_find_active(adt->act_track); @@ -568,8 +594,9 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode) * - for now, if the user has defined a curve to control the time, this correction cannot be performed * reliably... */ - if ((strip == NULL) || (strip->flag & NLASTRIP_FLAG_USR_TIME)) + if ((strip == NULL) || (strip->flag & NLASTRIP_FLAG_USR_TIME)) { return cframe; + } /* perform the correction now... */ return nlastrip_get_frame(strip, cframe, mode); @@ -587,8 +614,9 @@ bool BKE_nlastrips_has_space(ListBase *strips, float start, float end) NlaStrip *strip; /* sanity checks */ - if ((strips == NULL) || IS_EQF(start, end)) + if ((strips == NULL) || IS_EQF(start, end)) { return false; + } if (start > end) { puts("BKE_nlastrips_has_space() error... start and end arguments swapped"); SWAP(float, start, end); @@ -599,14 +627,16 @@ bool BKE_nlastrips_has_space(ListBase *strips, float start, float end) /* 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 */ - if (strip->start >= end) + if (strip->start >= end) { return true; + } /* if the end of the strip is greater than either of the boundaries, the range * must fall within the extents of the strip */ - if ((strip->end > start) || (strip->end > end)) + if ((strip->end > start) || (strip->end > end)) { return false; + } } /* if we are still here, we haven't encountered any overlapping strips */ @@ -622,8 +652,9 @@ void BKE_nlastrips_sort_strips(ListBase *strips) NlaStrip *strip, *sstrip, *stripn; /* sanity checks */ - if (ELEM(NULL, strips, strips->first)) + if (ELEM(NULL, strips, strips->first)) { return; + } /* we simply perform insertion sort on this list, since it is assumed that per track, * there are only likely to be at most 5-10 strips @@ -648,8 +679,9 @@ void BKE_nlastrips_sort_strips(ListBase *strips) } /* add before first? */ - if (not_added) + if (not_added) { BLI_addhead(&tmp, strip); + } } /* reassign the start and end points of the strips */ @@ -666,12 +698,14 @@ bool BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip) bool not_added = true; /* sanity checks */ - if (ELEM(NULL, strips, strip)) + if (ELEM(NULL, strips, strip)) { return false; + } /* check if any space to add */ - if (BKE_nlastrips_has_space(strips, strip->start, strip->end) == 0) + if (BKE_nlastrips_has_space(strips, strip->start, strip->end) == 0) { return false; + } /* find the right place to add the strip to the nominated track */ for (ns = strips->first; ns; ns = ns->next) { @@ -703,8 +737,9 @@ void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp) NlaStrip *strip, *stripn; /* sanity checks */ - if (ELEM(NULL, strips, strips->first)) + if (ELEM(NULL, strips, strips->first)) { return; + } /* group all continuous chains of selected strips into meta-strips */ for (strip = strips->first; strip; strip = stripn) { @@ -722,8 +757,9 @@ void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp) mstrip->flag = NLASTRIP_FLAG_SELECT; /* set temp flag if appropriate (i.e. for transform-type editing) */ - if (is_temp) + if (is_temp) { mstrip->flag |= NLASTRIP_FLAG_TEMP_META; + } /* set default repeat/scale values to prevent warnings */ mstrip->repeat = mstrip->scale = 1.0f; @@ -754,8 +790,9 @@ void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip) NlaStrip *cs, *csn; /* sanity check */ - if (ELEM(NULL, strips, strip)) + if (ELEM(NULL, strips, strip)) { return; + } /* move each one of the meta-strip's children before the meta-strip * in the list of strips after unlinking them from the meta-strip @@ -779,8 +816,9 @@ void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp) NlaStrip *strip, *stripn; /* sanity checks */ - if (ELEM(NULL, strips, strips->first)) + if (ELEM(NULL, strips, strips->first)) { return; + } /* remove meta-strips fitting the criteria of the arguments */ for (strip = strips->first; strip; strip = stripn) { @@ -804,12 +842,14 @@ void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp) bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip) { /* sanity checks */ - if (ELEM(NULL, mstrip, strip)) + if (ELEM(NULL, mstrip, strip)) { return false; + } /* firstly, check if the meta-strip has space for this */ - if (BKE_nlastrips_has_space(&mstrip->strips, strip->start, strip->end) == 0) + if (BKE_nlastrips_has_space(&mstrip->strips, strip->start, strip->end) == 0) { return false; + } /* check if this would need to be added to the ends of the meta, * and subsequently, if the neighboring strips allow us enough room @@ -825,8 +865,9 @@ bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip) return true; } - else /* failed... no room before */ + else { /* failed... no room before */ return false; + } } else if (strip->end > mstrip->end) { /* check if strip to the right (if it exists) starts before the @@ -839,8 +880,9 @@ bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip) return true; } - else /* failed... no room after */ + else { /* failed... no room after */ return false; + } } else { /* just try to add to the meta-strip (no dimension changes needed) */ @@ -862,10 +904,12 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip) * - strip must exist * - strip must be a meta-strip with some contents */ - if (ELEM(NULL, mstrip, mstrip->strips.first)) + if (ELEM(NULL, mstrip, mstrip->strips.first)) { return; - if (mstrip->type != NLASTRIP_TYPE_META) + } + if (mstrip->type != NLASTRIP_TYPE_META) { return; + } /* get the original start/end points, and calculate the start-frame offset * - these are simply the start/end frames of the child strips, @@ -879,14 +923,16 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip) * don't flush if nothing changed yet * TODO: maybe we need a flag to say always flush? */ - if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end)) + if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end)) { return; + } /* check if scale changed */ oLen = oEnd - oStart; nLen = mstrip->end - mstrip->start; - if (IS_EQF(nLen, oLen) == 0) + if (IS_EQF(nLen, oLen) == 0) { scaleChanged = 1; + } /* for each child-strip, calculate new start/end points based on this new info */ for (strip = mstrip->strips.first; strip; strip = strip->next) { @@ -934,13 +980,15 @@ NlaTrack *BKE_nlatrack_find_active(ListBase *tracks) NlaTrack *nlt; /* sanity check */ - if (ELEM(NULL, tracks, tracks->first)) + if (ELEM(NULL, tracks, tracks->first)) { return NULL; + } /* try to find the first active track */ for (nlt = tracks->first; nlt; nlt = nlt->next) { - if (nlt->flag & NLATRACK_ACTIVE) + if (nlt->flag & NLATRACK_ACTIVE) { return nlt; + } } /* none found */ @@ -957,8 +1005,9 @@ NlaTrack *BKE_nlatrack_find_tweaked(AnimData *adt) NlaTrack *nlt; /* sanity check */ - if (adt == NULL) + if (adt == NULL) { return NULL; + } /* Since the track itself gets disabled, we want the first disabled... */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { @@ -990,13 +1039,15 @@ void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt) NlaTrack *nt; /* sanity check */ - if (ELEM(NULL, adt, adt->nla_tracks.first)) + if (ELEM(NULL, adt, adt->nla_tracks.first)) { return; + } /* firstly, make sure 'solo' flag for all tracks is disabled */ for (nt = adt->nla_tracks.first; nt; nt = nt->next) { - if (nt != nlt) + if (nt != nlt) { nt->flag &= ~NLATRACK_SOLO; + } } /* now, enable 'solo' for the given track if appropriate */ @@ -1005,13 +1056,16 @@ void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt) nlt->flag ^= NLATRACK_SOLO; /* set or clear solo-status on AnimData */ - if (nlt->flag & NLATRACK_SOLO) + if (nlt->flag & NLATRACK_SOLO) { adt->flag |= ADT_NLA_SOLO_TRACK; - else + } + else { adt->flag &= ~ADT_NLA_SOLO_TRACK; + } } - else + else { adt->flag &= ~ADT_NLA_SOLO_TRACK; + } } /* Make the given NLA-track the active one for the given stack. If no track is provided, @@ -1022,16 +1076,19 @@ void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a) NlaTrack *nlt; /* sanity check */ - if (ELEM(NULL, tracks, tracks->first)) + if (ELEM(NULL, tracks, tracks->first)) { return; + } /* deactivate all the rest */ - for (nlt = tracks->first; nlt; nlt = nlt->next) + for (nlt = tracks->first; nlt; nlt = nlt->next) { nlt->flag &= ~NLATRACK_ACTIVE; + } /* set the given one as the active one */ - if (nlt_a) + if (nlt_a) { nlt_a->flag |= NLATRACK_ACTIVE; + } } /* Check if there is any space in the given track to add a strip of the given length */ @@ -1042,8 +1099,9 @@ bool BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end) * - track must be editable * - bounds cannot be equal (0-length is nasty) */ - if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end)) + if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end)) { return false; + } if (start > end) { puts("BKE_nlatrack_has_space() error... start and end arguments swapped"); @@ -1060,8 +1118,9 @@ bool BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end) void BKE_nlatrack_sort_strips(NlaTrack *nlt) { /* sanity checks */ - if (ELEM(NULL, nlt, nlt->strips.first)) + if (ELEM(NULL, nlt, nlt->strips.first)) { return; + } /* sort the strips with a more generic function */ BKE_nlastrips_sort_strips(&nlt->strips); @@ -1073,12 +1132,14 @@ void BKE_nlatrack_sort_strips(NlaTrack *nlt) bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip) { /* sanity checks */ - if (ELEM(NULL, nlt, strip)) + if (ELEM(NULL, nlt, strip)) { return false; + } /* do not allow adding strips if this track is locked */ - if (nlt->flag & NLATRACK_PROTECTED) + if (nlt->flag & NLATRACK_PROTECTED) { return false; + } /* try to add the strip to the track using a more generic function */ return BKE_nlastrips_add_strip(&nlt->strips, strip); @@ -1092,14 +1153,17 @@ bool BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2]) NlaStrip *strip; /* initialize bounds */ - if (bounds) + if (bounds) { bounds[0] = bounds[1] = 0.0f; - else + } + else { return false; + } /* sanity checks */ - if (ELEM(NULL, nlt, nlt->strips.first)) + if (ELEM(NULL, nlt, nlt->strips.first)) { return false; + } /* lower bound is first strip's start frame */ strip = nlt->strips.first; @@ -1121,13 +1185,15 @@ NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt) NlaStrip *strip; /* sanity check */ - if (ELEM(NULL, nlt, nlt->strips.first)) + if (ELEM(NULL, nlt, nlt->strips.first)) { return NULL; + } /* try to find the first active strip */ for (strip = nlt->strips.first; strip; strip = strip->next) { - if (strip->flag & NLASTRIP_FLAG_ACTIVE) + if (strip->flag & NLASTRIP_FLAG_ACTIVE) { return strip; + } } /* none found */ @@ -1141,16 +1207,19 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip) NlaStrip *nls; /* sanity checks */ - if (adt == NULL) + if (adt == NULL) { return; + } /* loop over tracks, deactivating*/ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { for (nls = nlt->strips.first; nls; nls = nls->next) { - if (nls != strip) + if (nls != strip) { nls->flag &= ~NLASTRIP_FLAG_ACTIVE; - else + } + else { nls->flag |= NLASTRIP_FLAG_ACTIVE; + } } } } @@ -1162,8 +1231,9 @@ bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max) const float boundsLen = fabsf(max - min); /* sanity checks */ - if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f)) + if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f)) { return false; + } /* only ok if at least part of the strip is within the bounding window * - first 2 cases cover when the strip length is less than the bounding area @@ -1294,19 +1364,22 @@ void BKE_nlastrip_recalculate_bounds(NlaStrip *strip) * - must have a strip * - can only be done for action clips */ - if ((strip == NULL) || (strip->type != NLASTRIP_TYPE_CLIP)) + if ((strip == NULL) || (strip->type != NLASTRIP_TYPE_CLIP)) { return; + } /* calculate new length factors */ actlen = strip->actend - strip->actstart; - if (IS_EQF(actlen, 0.0f)) + if (IS_EQF(actlen, 0.0f)) { actlen = 1.0f; + } mapping = strip->scale * strip->repeat; /* adjust endpoint of strip in response to this */ - if (IS_EQF(mapping, 0.0f) == 0) + if (IS_EQF(mapping, 0.0f) == 0) { strip->end = (actlen * mapping) + strip->start; + } /* make sure we don't overlap our neighbors */ nlastrip_fix_resize_overlaps(strip); @@ -1320,12 +1393,14 @@ static bool nlastrip_is_first(AnimData *adt, NlaStrip *strip) NlaStrip *ns; /* sanity checks */ - if (ELEM(NULL, adt, strip)) + if (ELEM(NULL, adt, strip)) { return false; + } /* check if strip has any strips before it */ - if (strip->prev) + if (strip->prev) { return false; + } /* check other tracks to see if they have a strip that's earlier */ /* TODO: or should we check that the strip's track is also the first? */ @@ -1333,8 +1408,9 @@ static bool nlastrip_is_first(AnimData *adt, NlaStrip *strip) /* only check the first strip, assuming that they're all in order */ ns = nlt->strips.first; if (ns) { - if (ns->start < strip->start) + if (ns->start < strip->start) { return false; + } } } @@ -1350,13 +1426,15 @@ bool BKE_nlatrack_has_animated_strips(NlaTrack *nlt) NlaStrip *strip; /* sanity checks */ - if (ELEM(NULL, nlt, nlt->strips.first)) + if (ELEM(NULL, nlt, nlt->strips.first)) { return false; + } /* check each strip for F-Curves only (don't care about whether the flags are set) */ for (strip = nlt->strips.first; strip; strip = strip->next) { - if (strip->fcurves.first) + if (strip->fcurves.first) { return true; + } } /* none found */ @@ -1369,13 +1447,15 @@ bool BKE_nlatracks_have_animated_strips(ListBase *tracks) NlaTrack *nlt; /* sanity checks */ - if (ELEM(NULL, tracks, tracks->first)) + if (ELEM(NULL, tracks, tracks->first)) { return false; + } /* check each track, stopping on the first hit */ for (nlt = tracks->first; nlt; nlt = nlt->next) { - if (BKE_nlatrack_has_animated_strips(nlt)) + if (BKE_nlatrack_has_animated_strips(nlt)) { return true; + } } /* none found */ @@ -1388,8 +1468,9 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) FCurve *fcu; /* sanity checks */ - if (strip == NULL) + if (strip == NULL) { return; + } /* if controlling influence... */ if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) { @@ -1447,8 +1528,9 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) bool BKE_nlastrip_has_curves_for_property(const PointerRNA *ptr, const PropertyRNA *prop) { /* sanity checks */ - if (ELEM(NULL, ptr, prop)) + if (ELEM(NULL, ptr, prop)) { return false; + } /* 1) Must be NLA strip */ if (ptr->type == &RNA_NlaStrip) { @@ -1494,8 +1576,9 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip) NlaTrack *nlt; /* sanity checks */ - if (ELEM(NULL, adt, strip)) + if (ELEM(NULL, adt, strip)) { return; + } /* give strip a default name if none already */ if (strip->name[0] == 0) { @@ -1526,8 +1609,9 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip) for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { for (tstrip = nlt->strips.first; tstrip; tstrip = tstrip->next) { /* don't add the strip of interest */ - if (tstrip == strip) + if (tstrip == strip) { continue; + } /* use the name of the strip as the key, and the strip as the value, since we're mostly interested in the keys */ BLI_ghash_insert(gh, tstrip->name, tstrip); @@ -1575,21 +1659,25 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip, } /* check if strip doesn't even occur anywhere near... */ - if (nls->end < strip->start) + if (nls->end < strip->start) { continue; /* skip checking this strip... not worthy of mention */ - if (nls->start > strip->end) + } + if (nls->start > strip->end) { return; /* the range we're after has already passed */ + } /* if this strip is not part of an island of continuous strips, it can be used * - this check needs to be done for each end of the strip we try and use... */ if ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0) { - if ((nls->end > strip->start) && (nls->end < strip->end)) + if ((nls->end > strip->start) && (nls->end < strip->end)) { *start = &nls->end; + } } if ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0) { - if ((nls->start < strip->end) && (nls->start > strip->start)) + if ((nls->start < strip->end) && (nls->start > strip->start)) { *end = &nls->start; + } } } } @@ -1601,18 +1689,23 @@ static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls) float *ns = NULL, *ne = NULL; /* sanity checks */ - if (ELEM(NULL, nls, nlt)) + if (ELEM(NULL, nls, nlt)) { return; - if ((nlt->prev == NULL) && (nlt->next == NULL)) + } + if ((nlt->prev == NULL) && (nlt->next == NULL)) { return; - if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS) == 0) + } + if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS) == 0) { return; + } /* get test ranges */ - if (nlt->prev) + if (nlt->prev) { nlastrip_get_endpoint_overlaps(nls, nlt->prev, &ps, &pe); - if (nlt->next) + } + if (nlt->next) { nlastrip_get_endpoint_overlaps(nls, nlt->next, &ns, &ne); + } /* set overlaps for this strip * - don't use the values obtained though if the end in question @@ -1621,23 +1714,29 @@ static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls) */ if ((ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0)) { /* start overlaps - pick the largest overlap */ - if (((ps && ns) && (*ps > *ns)) || (ps)) + if (((ps && ns) && (*ps > *ns)) || (ps)) { nls->blendin = *ps - nls->start; - else + } + else { nls->blendin = *ns - nls->start; + } } - else /* no overlap allowed/needed */ + else { /* no overlap allowed/needed */ nls->blendin = 0.0f; + } if ((pe || ne) && ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0)) { /* end overlaps - pick the largest overlap */ - if (((pe && ne) && (*pe > *ne)) || (pe)) + if (((pe && ne) && (*pe > *ne)) || (pe)) { nls->blendout = nls->end - *pe; - else + } + else { nls->blendout = nls->end - *ne; + } } - else /* no overlap allowed/needed */ + else { /* no overlap allowed/needed */ nls->blendout = 0.0f; + } } /* Ensure that auto-blending and other settings are set correctly */ @@ -1647,8 +1746,9 @@ void BKE_nla_validate_state(AnimData *adt) NlaTrack *nlt; /* sanity checks */ - if (ELEM(NULL, adt, adt->nla_tracks.first)) + if (ELEM(NULL, adt, adt->nla_tracks.first)) { return; + } /* adjust blending values for auto-blending, and also do an initial pass to find the earliest strip */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { @@ -1657,8 +1757,9 @@ void BKE_nla_validate_state(AnimData *adt) BKE_nlastrip_validate_autoblends(nlt, strip); /* extend mode - find first strip */ - if ((fstrip == NULL) || (strip->start < fstrip->start)) + if ((fstrip == NULL) || (strip->start < fstrip->start)) { fstrip = strip; + } } } @@ -1678,10 +1779,12 @@ void BKE_nla_validate_state(AnimData *adt) * * Should fix problems such as [#29869] */ - if (strip == fstrip) + if (strip == fstrip) { strip->extendmode = NLASTRIP_EXTEND_HOLD; - else if (strip->blendmode == NLASTRIP_MODE_REPLACE) + } + else if (strip->blendmode == NLASTRIP_MODE_REPLACE) { strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; + } } } } @@ -1706,8 +1809,9 @@ bool BKE_nla_action_is_stashed(AnimData *adt, bAction *act) for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { if (strstr(nlt->name, STASH_TRACK_NAME)) { for (strip = nlt->strips.first; strip; strip = strip->next) { - if (strip->act == act) + if (strip->act == act) { return true; + } } } } @@ -1731,8 +1835,9 @@ bool BKE_nla_action_stash(AnimData *adt) } /* do not add if it is already stashed */ - if (BKE_nla_action_is_stashed(adt, adt->action)) + if (BKE_nla_action_is_stashed(adt, adt->action)) { return false; + } /* create a new track, and add this immediately above the previous stashing track */ for (prev_track = adt->nla_tracks.last; prev_track; prev_track = prev_track->prev) { @@ -1797,8 +1902,9 @@ void BKE_nla_action_pushdown(AnimData *adt) /* sanity checks */ /* TODO: need to report the error for this */ - if (ELEM(NULL, adt, adt->action)) + if (ELEM(NULL, adt, adt->action)) { return; + } /* if the action is empty, we also shouldn't try to add to stack, * as that will cause us grief down the track @@ -1853,8 +1959,9 @@ void BKE_nla_action_pushdown(AnimData *adt) * so that it doesn't override strips in previous tracks */ /* FIXME: this needs to be more automated, since user can rearrange strips */ - if (strip->extendmode == NLASTRIP_EXTEND_HOLD) + if (strip->extendmode == NLASTRIP_EXTEND_HOLD) { strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; + } } /* make strip the active one... */ @@ -1871,14 +1978,16 @@ bool BKE_nla_tweakmode_enter(AnimData *adt) NlaStrip *strip, *activeStrip = NULL; /* verify that data is valid */ - if (ELEM(NULL, adt, adt->nla_tracks.first)) + if (ELEM(NULL, adt, adt->nla_tracks.first)) { return false; + } /* if block is already in tweakmode, just leave, but we should report * that this block is in tweakmode (as our returncode) */ - if (adt->flag & ADT_NLA_EDIT_ON) + if (adt->flag & ADT_NLA_EDIT_ON) { return true; + } /* go over the tracks, finding the active one, and its active strip * - if we cannot find both, then there's nothing to do @@ -1935,26 +2044,31 @@ bool BKE_nla_tweakmode_enter(AnimData *adt) */ for (nlt = activeTrack->prev; nlt; nlt = nlt->prev) { for (strip = nlt->strips.first; strip; strip = strip->next) { - if (strip->act == activeStrip->act) + if (strip->act == activeStrip->act) { strip->flag |= NLASTRIP_FLAG_TWEAKUSER; - else + } + else { strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER; + } } } /* tag all other strips in active track that uses the same action as the active strip */ for (strip = activeTrack->strips.first; strip; strip = strip->next) { - if ((strip->act == activeStrip->act) && (strip != activeStrip)) + if ((strip->act == activeStrip->act) && (strip != activeStrip)) { strip->flag |= NLASTRIP_FLAG_TWEAKUSER; - else + } + else { strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER; + } } /* go over all the tracks after AND INCLUDING the active one, tagging them as being disabled * - the active track needs to also be tagged, otherwise, it'll overlap with the tweaks going on */ - for (nlt = activeTrack; nlt; nlt = nlt->next) + for (nlt = activeTrack; nlt; nlt = nlt->next) { nlt->flag |= NLATRACK_DISABLED; + } /* handle AnimData level changes: * - 'real' active action to temp storage (no need to change user-counts) @@ -1980,12 +2094,14 @@ void BKE_nla_tweakmode_exit(AnimData *adt) NlaTrack *nlt; /* verify that data is valid */ - if (ELEM(NULL, adt, adt->nla_tracks.first)) + if (ELEM(NULL, adt, adt->nla_tracks.first)) { return; + } /* hopefully the flag is correct - skip if not on */ - if ((adt->flag & ADT_NLA_EDIT_ON) == 0) + if ((adt->flag & ADT_NLA_EDIT_ON) == 0) { return; + } /* sync the length of the user-strip with the new state of the action * but only if the user has explicitly asked for this to happen @@ -2033,8 +2149,9 @@ void BKE_nla_tweakmode_exit(AnimData *adt) * - editing-flag for this AnimData block should also get turned off * - clear pointer to active strip */ - if (adt->action) + if (adt->action) { id_us_min(&adt->action->id); + } adt->action = adt->tmpact; adt->tmpact = NULL; adt->act_track = NULL; |