diff options
| author | Dan Bechard <[email protected]> | 2023-04-22 04:15:19 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-22 10:15:19 +0200 |
| commit | 2d04dd8b88959bf28f070ba5d8631088e1273b56 (patch) | |
| tree | 21826f64af61a61afcdd46c8953da62657c44934 /src | |
| parent | 7b7c0c83ef3d52695b7c939ad181e7ca3faddbf6 (diff) | |
| download | raylib-2d04dd8b88959bf28f070ba5d8631088e1273b56.tar.gz raylib-2d04dd8b88959bf28f070ba5d8631088e1273b56.zip | |
Fix off-by-one error in CheckCollisionPointRec (#3022)
Checking `<= x + w` causes off-by-one error where `CheckCollisionPointRec` will return true at the same time for two rectangles rendered right next to each, but which don't overlap (e.g. when making a 2D tile editor). This is clearly not what was intended.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rshapes.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rshapes.c b/src/rshapes.c index 52c5648d..5d7eae0a 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1601,7 +1601,7 @@ bool CheckCollisionPointRec(Vector2 point, Rectangle rec) { bool collision = false; - if ((point.x >= rec.x) && (point.x <= (rec.x + rec.width)) && (point.y >= rec.y) && (point.y <= (rec.y + rec.height))) collision = true; + if ((point.x >= rec.x) && (point.x < (rec.x + rec.width)) && (point.y >= rec.y) && (point.y < (rec.y + rec.height))) collision = true; return collision; } |
