diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/keyframes_keylist.c | 9 | ||||
-rw-r--r-- | source/blender/editors/include/ED_keyframes_keylist.h | 8 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_select.c | 7 |
3 files changed, 10 insertions, 14 deletions
diff --git a/source/blender/editors/animation/keyframes_keylist.c b/source/blender/editors/animation/keyframes_keylist.c index 722edba0473..a869d8d6388 100644 --- a/source/blender/editors/animation/keyframes_keylist.c +++ b/source/blender/editors/animation/keyframes_keylist.c @@ -89,14 +89,11 @@ ActKeyColumn *ED_keylist_find_prev(const AnimKeylist *keylist, float cfra) /* TODO(jbakker): Should we change this to use `ED_keylist_find_next(keys, min_fra)` and only check * boundary of `max_fra`. */ -/* TODO(jbakker): Use const Range2f. */ -ActKeyColumn *ED_keylist_find_any_between(const AnimKeylist *keylist, - const float min_fra, - const float max_fra) +ActKeyColumn *ED_keylist_find_any_between(const AnimKeylist *keylist, const Range2f frame_range) { for (ActKeyColumn *ak = keylist->keys.root; ak; - ak = (ak->cfra < min_fra) ? ak->right : ak->left) { - if (IN_RANGE(ak->cfra, min_fra, max_fra)) { + 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/include/ED_keyframes_keylist.h b/source/blender/editors/include/ED_keyframes_keylist.h index 8ab2dff36e5..86741b67698 100644 --- a/source/blender/editors/include/ED_keyframes_keylist.h +++ b/source/blender/editors/include/ED_keyframes_keylist.h @@ -23,6 +23,8 @@ #pragma once +#include "BLI_range.h" + #ifdef __cplusplus extern "C" { #endif @@ -37,7 +39,6 @@ struct Scene; struct bAnimContext; struct bDopeSheet; struct bGPDlayer; -struct Range2f; /* ****************************** Base Structs ****************************** */ @@ -142,11 +143,10 @@ struct ActKeyColumn *ED_keylist_find_exact(const struct AnimKeylist *keylist, fl 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, - float min_fra, - float max_fra); + 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, struct Range2f *r_frame_range); +bool ED_keylist_frame_range(const struct AnimKeylist *keylist, Range2f *r_frame_range); /* Key-data Generation --------------- */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 64ccca2c907..9dcfc626a50 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -170,10 +170,9 @@ static void actkeys_find_key_in_list_element(bAnimContext *ac, /* half-size (for either side), but rounded up to nearest int (for easier targeting) */ key_hsize = roundf(key_hsize / 2.0f); - float xmin = UI_view2d_region_to_view_x(v2d, region_x - (int)key_hsize); - float xmax = UI_view2d_region_to_view_x(v2d, region_x + (int)key_hsize); - - const ActKeyColumn *ak = ED_keylist_find_any_between(keylist, xmin, xmax); + const Range2f range = {UI_view2d_region_to_view_x(v2d, region_x - (int)key_hsize), + UI_view2d_region_to_view_x(v2d, region_x + (int)key_hsize)}; + const ActKeyColumn *ak = ED_keylist_find_any_between(keylist, range); if (ak) { /* set the frame to use, and apply inverse-correction for NLA-mapping |