10 throw std::runtime_error(
11 std::format(
"{}: Grids must have atleast 2 columns!", __func__)
15 throw std::runtime_error(
16 std::format(
"{}: Grids must have atleast 2 rows!", __func__)
20 std::vector<glm::ivec2> path = {{0, 0}, {1, 0}, {0, 1}};
23 glm::ivec2 prevDir =
SW;
24 const glm::ivec2 start(0, 0);
25 const glm::ivec2 end(numCols - 1, numRows - 1);
26 const glm::ivec2 bottomLeft(start.x, end.y);
27 const glm::ivec2 topRight(end.x, start.y);
28 bool atPathEnd =
false;
34 if (pos == bottomLeft) {
35 dir = prevDir ==
SW ?
E :
NE;
41 if (pos == topRight) {
42 dir = prevDir ==
NE ?
S :
SW;
48 glm::ivec2 nextPos = pos + dir;
49 bool outOfBounds = nextPos.x < 0 || nextPos.x >= numCols || nextPos.y < 0 ||
52 dir = prevDir ==
SW ?
S : pos.y == 0 ?
E :
S;
59 }
else if (prevDir ==
NE) {
73 dir = pos.x == 0 ?
NE :
SW;
80 dir = pos.y == 0 ?
SW :
NE;