diff options
author | Colin Basnett <cmbasnett@gmail.com> | 2022-11-09 06:19:59 +0300 |
---|---|---|
committer | Colin Basnett <cmbasnett@gmail.com> | 2022-11-09 08:04:47 +0300 |
commit | 3836b6ff8cba135d185e147dbffca7847870e6cd (patch) | |
tree | 9b7f9df86235cfd252843b68b577a97d7888332c /source/blender/blenkernel/intern/fcurve.c | |
parent | 800b025518e497d5298e6d44c769613481034bca (diff) |
Cancel Equalize Handles & Snap Keys when no control points are selected
The Equalize Handles and Snap Keys operators would allow the user to
invoke them successfully even when they would have no effect due to
there not being any selected control points.
This patch makes it so that an error is displayed when these operators
are invoked with no control points are selected.
The reason this is in the `invoke` function is because it would be too
expensive to run this check in the `poll` function since it requires a
linear search through all the keys of all the visible F-Curves.
Reviewed By: sybren
Differential Revision: https://developer.blender.org/D16390
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index beea3217126..d248faaab00 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -965,6 +965,18 @@ bool BKE_fcurve_is_protected(FCurve *fcu) return ((fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED))); } +bool BKE_fcurve_has_selected_control_points(const FCurve *fcu) +{ + int i; + BezTriple *bezt; + for (bezt = fcu->bezt, i = 0; i < fcu->totvert; ++i, ++bezt) { + if ((bezt->f2 & SELECT) != 0) { + return true; + } + } + return false; +} + bool BKE_fcurve_is_keyframable(FCurve *fcu) { /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */ |