diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-11-06 23:21:42 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-11-06 23:21:42 +0400 |
commit | 61c411068b4b6c593a3bb05b073b26e0d0227995 (patch) | |
tree | 82f1f5832ff68103b0a121dde208826901263de7 /source/blender/blenlib/intern/rct.c | |
parent | 549ed3d37873e242f12eb6d38ba481f4ed99e115 (diff) |
Patch #37274: Circle select for node editor, by Henrik Aarnio (hjaarnio).
Circle select was missing from node editor, and C key was assigned to now defunct "show cyclic dependencies". This patch remaps the key and adds circle select operator.
Functions to check intersection between rctf/rcti and a circle were also added to rct.c for code cleanliness and consistency.
Diffstat (limited to 'source/blender/blenlib/intern/rct.c')
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 02525e25dda..d36cd3cb394 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -216,6 +216,32 @@ bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[ } } +bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius) +{ + float dx, dy; + + if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0; + else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax); + + if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0; + else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax); + + return dx * dx + dy * dy <= radius * radius; +} + +bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius) +{ + float dx, dy; + + if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0; + else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax); + + if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0; + else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax); + + return dx * dx + dy * dy <= radius * radius; +} + void BLI_rctf_union(rctf *rct1, const rctf *rct2) { if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin; |