| 63 | // them fast. Templates will inline completely for max speed. |
| 64 | template <typename XYVisitor> |
| 65 | void draw(const XYMap &xymap, XYVisitor &visitor) const { |
| 66 | for (u16 x = 0; x < 2; ++x) { |
| 67 | for (u16 y = 0; y < 2; ++y) { |
| 68 | u8 value = at(x, y); |
| 69 | if (value > 0) { |
| 70 | int xx = mOrigin.x + x; |
| 71 | int yy = mOrigin.y + y; |
| 72 | if (xymap.has(xx, yy)) { |
| 73 | // we know index cannot be -1 because we checked has(xx, yy) above. |
| 74 | u16 ux = static_cast<u16>(xx); |
| 75 | u16 uy = static_cast<u16>(yy); |
| 76 | int index = xymap.mapToIndex(ux, uy); |
| 77 | if (index >= 0) { |
| 78 | u32 uindex = static_cast<u32>(index); |
| 79 | vec2<u16> pt(ux, uy); |
| 80 | visitor.draw(pt, uindex, value); |
| 81 | } else { |
| 82 | // Unexpected because has(xx, yy) is true above therefore |
| 83 | // index cannot be < 0. TODO: low level log this. |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | private: |
| 92 | u8 mTile[2][2] = {}; |
nothing calls this directly
no test coverage detected