Warn when using an AABB or Rect2 with a negative size
This commit is contained in:
@@ -35,6 +35,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;
|
||||
@@ -95,6 +100,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] = {
|
||||
|
||||
Reference in New Issue
Block a user