Skip to content

Commit d54478d

Browse files
author
samme
committed
Reject zero-length lines in Line.intersectsRectangle
Because it worked that way before.
1 parent 9954130 commit d54478d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

v2-community/src/geom/Line.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,9 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
633633
*
634634
* An intersection is considered valid if:
635635
*
636-
* The line starts within or ends within the rectangle (even for lines of length 0); or
636+
* The line starts within or ends within the rectangle; or
637637
* The line segment intersects one of the 4 rectangle edges; and
638+
* The line has a non-zero length; and
638639
* The rectangle is not empty.
639640
*
640641
* For the purposes of this function rectangles are considered 'solid'.
@@ -647,7 +648,7 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
647648
Phaser.Line.intersectsRectangle = function (line, rect) {
648649

649650
// Quick bail out
650-
if (rect.empty)
651+
if (line.length === 0 || rect.empty)
651652
{
652653
return false;
653654
}

0 commit comments

Comments
 (0)