(line, rect, out)
| 23 | * @return {Phaser.Math.Vector2[]} An array with the points of intersection if objects intersect, otherwise an empty array. |
| 24 | */ |
| 25 | var GetLineToRectangle = function (line, rect, out) |
| 26 | { |
| 27 | if (out === undefined) { out = []; } |
| 28 | |
| 29 | if (LineToRectangle(line, rect)) |
| 30 | { |
| 31 | var lineA = rect.getLineA(); |
| 32 | var lineB = rect.getLineB(); |
| 33 | var lineC = rect.getLineC(); |
| 34 | var lineD = rect.getLineD(); |
| 35 | |
| 36 | var output = [ new Vector2(), new Vector2(), new Vector2(), new Vector2() ]; |
| 37 | |
| 38 | var result = [ |
| 39 | LineToLine(lineA, line, output[0]), |
| 40 | LineToLine(lineB, line, output[1]), |
| 41 | LineToLine(lineC, line, output[2]), |
| 42 | LineToLine(lineD, line, output[3]) |
| 43 | ]; |
| 44 | |
| 45 | for (var i = 0; i < 4; i++) |
| 46 | { |
| 47 | if (result[i]) |
| 48 | { |
| 49 | out.push(output[i]); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return out; |
| 55 | }; |
| 56 | |
| 57 | module.exports = GetLineToRectangle; |
no test coverage detected
searching dependent graphs…