[Bf-blender-cvs] [72d950b] master: Rectangle API: add single axis intersection check

Campbell Barton noreply at git.blender.org
Fri Dec 6 08:49:56 CET 2013


Commit: 72d950ba497058eb4e75e3898d626938b6a7940a
Author: Campbell Barton
Date:   Fri Dec 6 18:48:55 2013 +1100
http://developer.blender.org/rB72d950ba497058eb4e75e3898d626938b6a7940a

Rectangle API: add single axis intersection check

===================================================================

M	source/blender/blenlib/BLI_rect.h
M	source/blender/blenlib/intern/rct.c

===================================================================

diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index 0fee926..dddfb8c 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -68,8 +68,12 @@ bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, cons
 bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b);
 bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest);
 bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest);
+bool BLI_rcti_isect_x(const rcti *rect, const int x);
+bool BLI_rcti_isect_y(const rcti *rect, const int y);
 bool BLI_rcti_isect_pt(const struct rcti *rect, const int x, const int y);
 bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]);
+bool BLI_rctf_isect_x(const rctf *rect, const float x);
+bool BLI_rctf_isect_y(const rctf *rect, const float y);
 bool BLI_rctf_isect_pt(const struct rctf *rect, const float x, const float y);
 bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]);
 bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]);
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index aa36433..c59a019 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -58,6 +58,20 @@ bool BLI_rctf_is_empty(const rctf *rect)
 	return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
 }
 
+bool BLI_rcti_isect_x(const rcti *rect, const int x)
+{
+	if (x < rect->xmin) return false;
+	if (x > rect->xmax) return false;
+	return true;
+}
+
+bool BLI_rcti_isect_y(const rcti *rect, const int y)
+{
+	if (y < rect->ymin) return false;
+	if (y > rect->ymax) return false;
+	return true;
+}
+
 bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
 {
 	if (x < rect->xmin) return false;
@@ -67,13 +81,6 @@ bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
 	return true;
 }
 
-/**
- * Determine if a rect is empty. An empty
- * rect is one with a zero (or negative)
- * width or height.
- *
- * \return True if \a rect is empty.
- */
 bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
 {
 	if (xy[0] < rect->xmin) return false;
@@ -83,6 +90,20 @@ bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
 	return true;
 }
 
+bool BLI_rctf_isect_x(const rctf *rect, const float x)
+{
+	if (x < rect->xmin) return false;
+	if (x > rect->xmax) return false;
+	return true;
+}
+
+bool BLI_rctf_isect_y(const rctf *rect, const float y)
+{
+	if (y < rect->ymin) return false;
+	if (y > rect->ymax) return false;
+	return true;
+}
+
 bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
 {
 	if (x < rect->xmin) return false;




More information about the Bf-blender-cvs mailing list