mirror of
https://github.com/photonstorm/phaser
synced 2024-11-30 08:31:01 +00:00
Merge pull request #2945 from samme/fix-issue-2942
Don't reject horizontal and vertical lines in Line.intersectsRectangle()
This commit is contained in:
commit
05aff94195
2 changed files with 8 additions and 5 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
### Bug Fixes
|
### 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.
|
* removeTextureAtlas now deletes the correct cache object.
|
||||||
|
|
||||||
## Version 2.7.1 - 28th November 2016
|
## Version 2.7.1 - 28th November 2016
|
||||||
|
|
|
@ -633,10 +633,12 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
|
||||||
*
|
*
|
||||||
* An intersection is considered valid if:
|
* An intersection is considered valid if:
|
||||||
*
|
*
|
||||||
* The line starts within, or ends within, the Rectangle.
|
* The line starts within or ends within the rectangle; or
|
||||||
* The line segment intersects one of the 4 rectangle edges.
|
* 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
|
* @method Phaser.Line.intersectsRectangle
|
||||||
* @param {Phaser.Line} line - The line to check for intersection with.
|
* @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) {
|
Phaser.Line.intersectsRectangle = function (line, rect) {
|
||||||
|
|
||||||
// Quick bail out of the Line and Rect bounds don't intersect
|
// Quick bail out
|
||||||
if (!Phaser.Rectangle.intersects(line, rect))
|
if (line.length === 0 || rect.empty)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue