diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2019-02-20 23:25:39 +0100 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2019-02-21 00:34:57 +0100 |
commit | edcfe41bd568efb22aaab3f45f38aed2b0f94cab (patch) | |
tree | cbb0035fb8deac018702cbcf8b9ba037d567808a | |
parent | 132e2f458df7a3551a251d68afeccd0362ca6be2 (diff) |
Area2d rectangle collision check doesn't ignore the first pixel row and column (fix #25462)
-rw-r--r-- | servers/physics_2d/shape_2d_sw.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index b622550ec9..4d288f575a 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -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 { |