Merge pull request #26103 from nekomatata/area2d-rectangle-collision-fix

Fixed Area2d input events ignoring the top and left edge of rectangle shape
This commit is contained in:
Rémi Verschelde 2019-02-21 14:39:26 +01:00 committed by GitHub
commit cac1a93d1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -369,8 +369,11 @@ void RectangleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_suppor
}
bool RectangleShape2DSW::contains_point(const Vector2 &p_point) const {
return Math::abs(p_point.x) < half_extents.x && Math::abs(p_point.y) < half_extents.y;
float x = p_point.x;
float y = p_point.y;
float edge_x = half_extents.x;
float edge_y = half_extents.y;
return (x >= -edge_x) && (x < edge_x) && (y >= -edge_y) && (y < edge_y);
}
bool RectangleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {