12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #include "Area.h"
- Framework::Vec3<int> getDirection(Directions dir)
- {
- Framework::Vec3<int> result(0, 0, 0);
- if ((dir | NORTH) == dir)
- --result.y;
- if ((dir | EAST) == dir)
- ++result.x;
- if ((dir | SOUTH) == dir)
- ++result.y;
- if ((dir | WEST) == dir)
- --result.x;
- if ((dir | TOP) == dir)
- ++result.z;
- if ((dir | BOTTOM) == dir)
- --result.z;
- return result;
- }
- int getDirectionIndex(Direction dir)
- {
- if (dir == NORTH)
- return 0;
- if (dir == EAST)
- return 1;
- if (dir == SOUTH)
- return 2;
- if (dir == WEST)
- return 3;
- if (dir == TOP)
- return 4;
- if (dir == BOTTOM)
- return 5;
- assert(false);
- return -1;
- }
- Direction getOppositeDirection(Direction dir)
- {
- if (dir == NORTH)
- return SOUTH;
- if (dir == EAST)
- return WEST;
- if (dir == SOUTH)
- return NORTH;
- if (dir == WEST)
- return EAST;
- if (dir == TOP)
- return BOTTOM;
- if (dir == BOTTOM)
- return TOP;
- assert(false);
- return NO_DIRECTION;
- }
- Direction getDirectionFromIndex(int index)
- {
- return (Direction)(1 << index);
- }
- Directions getDirectionsFromVector(Framework::Vec3<float> dir)
- {
- Directions dirs = NO_DIRECTION;
- if (dir.y < 0)
- dirs |= NORTH;
- else if (dir.y > 0)
- dirs |= SOUTH;
- if (dir.x < 0)
- dirs |= WEST;
- else if (dir.x > 0)
- dirs |= EAST;
- if (dir.z < 0)
- dirs |= BOTTOM;
- else if (dir.z > 0)
- dirs |= TOP;
- return dirs;
- }
|