Line.intersectsRectangle should not reject horizontal/vertical lines

Fixes #2942

Rule 1 also implied that zero-length lines should pass when inside the
rectangle.
This commit is contained in:
samme 2017-01-03 12:45:53 -08:00
parent 1dc1dacb35
commit 9954130b40
2 changed files with 7 additions and 5 deletions

View file

@ -15,6 +15,7 @@
### Bug Fixes
* Phaser.Line.intersectsRectangle() now works correctly for horizontal and vertical lines ([#2942](https://github.com/photonstorm/phaser/issues/2942)).
* removeTextureAtlas now deletes the correct cache object.
## Version 2.7.1 - 28th November 2016

View file

@ -633,10 +633,11 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
*
* An intersection is considered valid if:
*
* The line starts within, or ends within, the Rectangle.
* The line segment intersects one of the 4 rectangle edges.
* The line starts within or ends within the rectangle (even for lines of length 0); or
* The line segment intersects one of the 4 rectangle edges; and
* The rectangle is not empty.
*
* The for the purposes of this function rectangles are considered 'solid'.
* For the purposes of this function rectangles are considered 'solid'.
*
* @method Phaser.Line.intersectsRectangle
* @param {Phaser.Line} line - The line to check for intersection with.
@ -645,8 +646,8 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
*/
Phaser.Line.intersectsRectangle = function (line, rect) {
// Quick bail out of the Line and Rect bounds don't intersect
if (!Phaser.Rectangle.intersects(line, rect))
// Quick bail out
if (rect.empty)
{
return false;
}