Merge pull request #2945 from samme/fix-issue-2942

Don't reject horizontal and vertical lines in Line.intersectsRectangle()
This commit is contained in:
Richard Davey 2017-01-05 15:47:49 +00:00 committed by GitHub
commit 05aff94195
2 changed files with 8 additions and 5 deletions

View file

@ -16,6 +16,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,12 @@ 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; or
* The line segment intersects one of the 4 rectangle edges; and
* The line has a non-zero length; 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 +647,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 (line.length === 0 || rect.empty)
{
return false;
}