diff options
Diffstat (limited to 'src/variant/rect2.cpp')
-rw-r--r-- | src/variant/rect2.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/variant/rect2.cpp b/src/variant/rect2.cpp index 53f06c6..1d15da7 100644 --- a/src/variant/rect2.cpp +++ b/src/variant/rect2.cpp @@ -41,6 +41,11 @@ bool Rect2::is_equal_approx(const Rect2 &p_rect) const { } bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos, Point2 *r_normal) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif real_t min = 0, max = 1; int axis = 0; real_t sign = 0; @@ -101,6 +106,11 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 } bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif //SAT intersection between local and transformed rect2 Vector2 xf_points[4] = { @@ -271,7 +281,7 @@ next4: } Rect2::operator String() const { - return String(position) + ", " + String(size); + return "[P: " + position.operator String() + ", S: " + size + "]"; } Rect2::operator Rect2i() const { |