diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-08-06 10:54:56 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-08-06 10:54:56 +0300 |
commit | 6188c29603da211b8305d8fe7c082dcae61688ab (patch) | |
tree | 118c45f812d39295d8eeb32af7d18bd720a93857 | |
parent | 1ab75c1d494422270fa88bbf23cc42f7b203ed4b (diff) |
Cleanup: use const result in `ED_keyframes_find_*` functions.
-rw-r--r-- | source/blender/editors/animation/anim_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_keylist.c | 18 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_slide.c | 4 | ||||
-rw-r--r-- | source/blender/editors/include/ED_keyframes_keylist.h | 10 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 2 |
5 files changed, 19 insertions, 17 deletions
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 735f3b86924..6d272bfc180 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -495,7 +495,7 @@ static bool find_prev_next_keyframes(struct bContext *C, int *r_nextfra, int *r_ Mask *mask = CTX_data_edit_mask(C); bDopeSheet ads = {NULL}; struct AnimKeylist *keylist = ED_keylist_create(); - ActKeyColumn *aknext, *akprev; + const ActKeyColumn *aknext, *akprev; float cfranext, cfraprev; bool donenext = false, doneprev = false; int nextcount = 0, prevcount = 0; diff --git a/source/blender/editors/animation/keyframes_keylist.c b/source/blender/editors/animation/keyframes_keylist.c index a869d8d6388..98aedb9cd0c 100644 --- a/source/blender/editors/animation/keyframes_keylist.c +++ b/source/blender/editors/animation/keyframes_keylist.c @@ -72,26 +72,28 @@ void ED_keylist_free(AnimKeylist *keylist) MEM_freeN(keylist); } -ActKeyColumn *ED_keylist_find_exact(const AnimKeylist *keylist, float cfra) +const ActKeyColumn *ED_keylist_find_exact(const AnimKeylist *keylist, float cfra) { - return (ActKeyColumn *)BLI_dlrbTree_search_exact(&keylist->keys, compare_ak_cfraPtr, &cfra); + return (const ActKeyColumn *)BLI_dlrbTree_search_exact( + &keylist->keys, compare_ak_cfraPtr, &cfra); } -ActKeyColumn *ED_keylist_find_next(const AnimKeylist *keylist, float cfra) +const ActKeyColumn *ED_keylist_find_next(const AnimKeylist *keylist, float cfra) { - return (ActKeyColumn *)BLI_dlrbTree_search_next(&keylist->keys, compare_ak_cfraPtr, &cfra); + return (const ActKeyColumn *)BLI_dlrbTree_search_next(&keylist->keys, compare_ak_cfraPtr, &cfra); } -ActKeyColumn *ED_keylist_find_prev(const AnimKeylist *keylist, float cfra) +const ActKeyColumn *ED_keylist_find_prev(const AnimKeylist *keylist, float cfra) { - return (ActKeyColumn *)BLI_dlrbTree_search_prev(&keylist->keys, compare_ak_cfraPtr, &cfra); + return (const ActKeyColumn *)BLI_dlrbTree_search_prev(&keylist->keys, compare_ak_cfraPtr, &cfra); } /* TODO(jbakker): Should we change this to use `ED_keylist_find_next(keys, min_fra)` and only check * boundary of `max_fra`. */ -ActKeyColumn *ED_keylist_find_any_between(const AnimKeylist *keylist, const Range2f frame_range) +const ActKeyColumn *ED_keylist_find_any_between(const AnimKeylist *keylist, + const Range2f frame_range) { - for (ActKeyColumn *ak = keylist->keys.root; ak; + for (const ActKeyColumn *ak = keylist->keys.root; ak; ak = (ak->cfra < frame_range.min) ? ak->right : ak->left) { if (range2f_in_range(&frame_range, ak->cfra)) { return ak; diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 238799650a0..bc5cbd92deb 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1716,7 +1716,7 @@ static float pose_propagate_get_boneHoldEndFrame(tPChanFCurveLink *pfl, float st /* Find the long keyframe (i.e. hold), and hence obtain the endFrame value * - the best case would be one that starts on the frame itself */ - ActKeyColumn *ab = ED_keylist_find_exact(keylist, startFrame); + const ActKeyColumn *ab = ED_keylist_find_exact(keylist, startFrame); /* There are only two cases for no-exact match: * 1) the current frame is just before another key but not on a key itself @@ -1746,7 +1746,7 @@ static float pose_propagate_get_boneHoldEndFrame(tPChanFCurveLink *pfl, float st if (ab) { /* Go to next if it is also valid and meets "extension" criteria. */ while (ab->next) { - ActKeyColumn *abn = ab->next; + const ActKeyColumn *abn = ab->next; /* Must be valid. */ if ((actkeyblock_get_valid_hold(abn) & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) { diff --git a/source/blender/editors/include/ED_keyframes_keylist.h b/source/blender/editors/include/ED_keyframes_keylist.h index 86741b67698..3a9750c1206 100644 --- a/source/blender/editors/include/ED_keyframes_keylist.h +++ b/source/blender/editors/include/ED_keyframes_keylist.h @@ -139,11 +139,11 @@ typedef enum eKeyframeExtremeDrawOpts { struct AnimKeylist *ED_keylist_create(void); void ED_keylist_free(struct AnimKeylist *keylist); -struct ActKeyColumn *ED_keylist_find_exact(const struct AnimKeylist *keylist, float cfra); -struct ActKeyColumn *ED_keylist_find_next(const struct AnimKeylist *keylist, float cfra); -struct ActKeyColumn *ED_keylist_find_prev(const struct AnimKeylist *keylist, float cfra); -struct ActKeyColumn *ED_keylist_find_any_between(const struct AnimKeylist *keylist, - const Range2f frame_range); +const struct ActKeyColumn *ED_keylist_find_exact(const struct AnimKeylist *keylist, float cfra); +const struct ActKeyColumn *ED_keylist_find_next(const struct AnimKeylist *keylist, float cfra); +const struct ActKeyColumn *ED_keylist_find_prev(const struct AnimKeylist *keylist, float cfra); +const struct ActKeyColumn *ED_keylist_find_any_between(const struct AnimKeylist *keylist, + const Range2f frame_range); bool ED_keylist_is_empty(const struct AnimKeylist *keylist); const struct ListBase /* ActKeyColumn */ *ED_keylist_listbase(const struct AnimKeylist *keylist); bool ED_keylist_frame_range(const struct AnimKeylist *keylist, Range2f *r_frame_range); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e150d7774f9..6af18104336 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3077,7 +3077,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) } /* find matching keyframe in the right direction */ - ActKeyColumn *ak; + const ActKeyColumn *ak; if (next) { ak = ED_keylist_find_next(keylist, cfra); } |