Cleanup: use const result in `ED_keyframes_find_*` functions.

This commit is contained in:
Jeroen Bakker 2021-08-06 09:54:56 +02:00
parent 1ab75c1d49
commit 6188c29603
5 changed files with 19 additions and 17 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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);
}