Skip to content

Commit cc102a1

Browse files
author
Wouter Commandeur
committed
Fix Phaser.Line.intersectsPoints by properly checking the boundaries
1 parent a01b8f2 commit cc102a1

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

src/geom/Line.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -380,23 +380,10 @@ Phaser.Line.intersectsPoints = function (a, b, e, f, asSegment, result) {
380380

381381
if (asSegment)
382382
{
383-
if (Math.pow((result.x - b.x) + (result.y - b.y), 2) > Math.pow((a.x - b.x) + (a.y - b.y), 2))
384-
{
385-
return null;
386-
}
387-
388-
if (Math.pow((result.x - a.x) + (result.y - a.y), 2) > Math.pow((a.x - b.x) + (a.y - b.y), 2))
389-
{
390-
return null;
391-
}
392-
393-
if (Math.pow((result.x - f.x) + (result.y - f.y), 2) > Math.pow((e.x - f.x) + (e.y - f.y), 2))
394-
{
395-
return null;
396-
}
397-
398-
if (Math.pow((result.x - e.x) + (result.y - e.y), 2) > Math.pow((e.x - f.x) + (e.y - f.y), 2))
399-
{
383+
if ( result.x < Math.min(a.x, b.x) || result.x > Math.max(a.x, b.x) ||
384+
result.y < Math.min(a.y, b.y) || result.y > Math.max(a.y, b.y) ||
385+
result.x < Math.min(e.x, f.x) || result.x > Math.max(e.x, f.x) ||
386+
result.y < Math.min(e.y, f.y) || result.y > Math.max(e.y, f.y) ) {
400387
return null;
401388
}
402389
}

0 commit comments

Comments
 (0)