diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-09 09:20:04 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-09 09:20:04 +0400 |
commit | fa24ad1fd50cdd6a6af2b76736fe8e1430ee3cd7 (patch) | |
tree | f349f3b4696451a074cca74455d378f63277eee1 /source/blender/editors/animation/keyframes_edit.c | |
parent | 6a4567b9ab957ef912129f24aa4d3f60c3363c4f (diff) |
Graph Editor: add lasso select for fcurves
Diffstat (limited to 'source/blender/editors/animation/keyframes_edit.c')
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 6010a64bd06..6b294c93b42 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_lasso.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -523,6 +524,45 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) return 0; } +/** + * only called from #ok_bezier_region_lasso + */ +static bool bezier_region_lasso_test( + const struct KeyframeEdit_LassoData *data_lasso, + const float xy[2]) +{ + if (BLI_rctf_isect_pt_v(data_lasso->rectf_scaled, xy)) { + float xy_view[2]; + + BLI_rctf_transform_pt_v(data_lasso->rectf_view, data_lasso->rectf_scaled, xy_view, xy); + + if (BLI_lasso_is_point_inside(data_lasso->mcords, data_lasso->mcords_tot, xy_view[0], xy_view[1], INT_MAX)) { + return true; + } + } + + return false; +} + +static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt) +{ + /* rect is stored in data property (it's of type rectf, but may not be set) */ + if (ked->data) { + short ok = 0; + +#define KEY_CHECK_OK(_index) bezier_region_lasso_test(ked->data, bezt->vec[_index]) + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); +#undef KEY_CHECK_OK + + /* check for lasso */ + + /* return ok flags */ + return ok; + } + else + return 0; +} + KeyframeEditFunc ANIM_editkeyframes_ok(short mode) { @@ -540,6 +580,8 @@ KeyframeEditFunc ANIM_editkeyframes_ok(short mode) return ok_bezier_valuerange; case BEZT_OK_REGION: /* only if bezier falls within the specified rect (data -> rectf) */ return ok_bezier_region; + case BEZT_OK_REGION_LASSO: /* only if the point falls within KeyframeEdit_LassoData defined data */ + return ok_bezier_region_lasso; default: /* nothing was ok */ return NULL; } |