Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- glm::ivec2 squareRotXY(glm::ivec2 pos, int mod, ROT angle) {
- switch (angle) {
- case ROT_90:
- return glm::ivec2(mod - 1 - pos.y, pos.x);
- case ROT_180:
- return glm::ivec2(mod - 1 - pos.x, mod - 1 - pos.y);
- case ROT_270:
- return glm::ivec2(pos.y, mod - 1 - pos.x);
- }
- return pos;
- }
- void CuboidCoordsI::Bind(int mod) {
- FaceTranny ft;
- while (true) {
- if (x >= mod) {
- ft = faceLUT[face].Left;
- x -= mod;
- }
- else if (z >= mod) {
- ft = faceLUT[face].Up;
- z -= mod;
- }
- else if (x < 0) {
- ft = faceLUT[face].Right;
- x += mod;
- }
- else if (z < 0) {
- ft = faceLUT[face].Down;
- z += mod;
- }
- else { return; }
- if (ft.face != -1) {
- glm::ivec2 pos = squareRotXY(glm::ivec2(x, z), mod, ft.rot);
- x = pos.x;
- z = pos.y;
- face = ft.face;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement