| 96 | } |
| 97 | |
| 98 | StaticList<Line2F, 2> WorldGeometry::splitLine(Line2F line, bool preserveDirection) const { |
| 99 | if (m_size[0] == 0) |
| 100 | return {line}; |
| 101 | |
| 102 | bool swapDirection = line.makePositive() && preserveDirection; |
| 103 | Vec2F minWrap = xwrap(line.min()); |
| 104 | |
| 105 | // diff is safe because we're looking for the line gnostic diff |
| 106 | Line2F lineWrap = Line2F(minWrap, minWrap + line.diff()); |
| 107 | |
| 108 | // Since min is wrapped, we're only checking to see if max is on the other |
| 109 | // side of the wrap point |
| 110 | if (lineWrap.max()[0] > m_size[0]) { |
| 111 | Vec2F intersection = lineWrap.intersection(Line2F(Vec2F(m_size[0], 0), Vec2F(m_size)), true).point; |
| 112 | if (swapDirection) |
| 113 | return {Line2F(lineWrap.max() - Vec2F(m_size[0], 0), Vec2F(0, intersection[1])), |
| 114 | Line2F(Vec2F(m_size[0], intersection[1]), lineWrap.min())}; |
| 115 | else |
| 116 | return {Line2F(lineWrap.min(), Vec2F(m_size[0], intersection[1])), |
| 117 | Line2F(Vec2F(0, intersection[1]), lineWrap.max() - Vec2F(m_size[0], 0))}; |
| 118 | } else { |
| 119 | if (swapDirection) |
| 120 | lineWrap.reverse(); |
| 121 | return {lineWrap}; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | StaticList<Line2F, 2> WorldGeometry::splitLine(Line2F line, Vec2F const& position, bool preserveDirection) const { |
| 126 | line.translate(position); |
no test coverage detected