diff options
author | Thibault de Villèle <thibaulltt> | 2022-10-10 18:19:26 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-10-10 18:28:35 +0300 |
commit | 962b64769018414616d50d28914a4ce4b65b490b (patch) | |
tree | 71206c3499e9e0ea0e62582ab84a202723db46ec /source/blender/blenkernel | |
parent | 82a5790d2adf17fd30730166dbde60eabaedaab5 (diff) |
Cleanup: NLA transforms, simplify `recalcData_nla()`
Refactor the `recalcData_nla()` function, which takes data from the
transform system and updates NLA strips, such that the actual logic to
change the strip is moved into its own function.
This also moves some generic code (find prev/next strip) from that
function to BKE.
This is to make the code easier to adjust when different transform
operations need to perform different modifications of the strip (i.e. to
fix T101130).
Manifest Task: T101130
Reviewed By: sybren
Differential Revision: https://developer.blender.org/D16181
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_nla.h | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 28 |
2 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 9d3000759ab..efadd5c11d6 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -246,6 +246,24 @@ float BKE_nlastrip_compute_frame_from_previous_strip(struct NlaStrip *strip); */ float BKE_nlastrip_compute_frame_to_next_strip(struct NlaStrip *strip); +/** + * Returns the next strip in this strip's NLA track, or a null pointer. + * + * \param strip The strip to find the next trip from. + * \param check_transitions Whether or not to skip transitions. + * \return The next strip in the track, or NULL if none are present. + */ +struct NlaStrip *BKE_nlastrip_next_in_track(struct NlaStrip *strip, bool skip_transitions); + +/** + * Returns the previous strip in this strip's NLA track, or a null pointer. + * + * \param strip The strip to find the previous trip from. + * \param check_transitions Whether or not to skip transitions. + * \return The previous strip in the track, or NULL if none are present. + */ +struct NlaStrip *BKE_nlastrip_prev_in_track(struct NlaStrip *strip, bool skip_transitions); + /* ............ */ /** diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index fd3580a7e88..ba63cdff917 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1272,6 +1272,34 @@ float BKE_nlastrip_compute_frame_to_next_strip(NlaStrip *strip) return limit_next; } +NlaStrip *BKE_nlastrip_next_in_track(struct NlaStrip *strip, bool skip_transitions) +{ + NlaStrip *next = strip->next; + while (next != NULL) { + if (skip_transitions && (next->type & NLASTRIP_TYPE_TRANSITION)) { + next = next->next; + } + else { + return next; + } + } + return NULL; +} + +NlaStrip *BKE_nlastrip_prev_in_track(struct NlaStrip *strip, bool skip_transitions) +{ + NlaStrip *prev = strip->prev; + while (prev != NULL) { + if (skip_transitions && (prev->type & NLASTRIP_TYPE_TRANSITION)) { + prev = prev->prev; + } + else { + return prev; + } + } + return NULL; +} + NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt) { if (nlt == NULL) { |