Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. glm::ivec2 squareRotXY(glm::ivec2 pos, int mod, ROT angle) {
  2.     switch (angle) {
  3.     case ROT_90:
  4.         return glm::ivec2(mod - 1 - pos.y, pos.x);
  5.     case ROT_180:
  6.         return glm::ivec2(mod - 1 - pos.x, mod - 1 - pos.y);
  7.     case ROT_270:
  8.         return glm::ivec2(pos.y, mod - 1 - pos.x);
  9.     }
  10.     return pos;
  11. }
  12.  
  13. void CuboidCoordsI::Bind(int mod) {
  14.     FaceTranny ft;
  15.     while (true) {
  16.         if (x >= mod) {
  17.             ft = faceLUT[face].Left;
  18.             x -= mod;
  19.         }
  20.         else    if (z >= mod) {
  21.             ft = faceLUT[face].Up;
  22.             z -= mod;
  23.         }
  24.         else    if (x < 0) {
  25.             ft = faceLUT[face].Right;
  26.             x += mod;
  27.         }
  28.         else    if (z < 0) {
  29.             ft = faceLUT[face].Down;
  30.             z += mod;
  31.         }
  32.         else { return; }
  33.         if (ft.face != -1) {
  34.             glm::ivec2 pos = squareRotXY(glm::ivec2(x, z), mod, ft.rot);
  35.             x = pos.x;
  36.             z = pos.y;
  37.             face = ft.face;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement