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:
authorCampbell Barton <ideasman42@gmail.com>2012-09-22 16:23:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-22 16:23:17 +0400
commit3ff23b753e405bf3b434f834815e08c49fde8a2b (patch)
treec01fbbaa93512aaf611dcab575c2f82067029069 /source/blender/blenlib/intern/rct.c
parent76850d80b148bf681ecef9a839596e0d1b2047cb (diff)
rect/point clamping function: BLI_rct*_clamp_pt_v
Diffstat (limited to 'source/blender/blenlib/intern/rct.c')
-rw-r--r--source/blender/blenlib/intern/rct.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index fd0dac5bc3d..cab383b60f3 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -281,6 +281,27 @@ void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const f
/* BLI_rcti_interp() not needed yet */
+
+int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2])
+{
+ int change = 0;
+ if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; }
+ if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; }
+ if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; }
+ if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; }
+ return change;
+}
+
+int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2])
+{
+ int change = 0;
+ if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; }
+ if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; }
+ if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; }
+ if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; }
+ return change;
+}
+
int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit)
{
if (fabsf(rect_a->xmin - rect_b->xmin) < limit)