Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/rct.c')
-rw-r--r--source/blender/blenlib/intern/rct.c26
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;