#include <grid.hpp>
|
| | Grid () |
| |
| | Grid (int rows, int columns) |
| | Initializes this Grid with the specified number of rows and columns. More...
|
| |
| | ~Grid () |
| |
| void | addCell (int x, int y, CellType type) |
| | Adds a GridCell of the specified type at the given location. If the type is CellType::Spawn, then a pointer to the newly allocated GridCell will be added to the spawnCells vector. Note: If a GridCell already exists at the given location, the GridCell will not be added. (This function asserts that the given location is empty). Note: A GridCell will not be added if its x and y coordinates are outside of the integer range [0, columns - 1] and [0, rows - 1]. (This function asserts that the given x and y coordinates are within this range). More...
|
| |
| GridCell * | getCell (int x, int y) |
| | Attempts to retrieve a GridCell at the specified location. Note: This function asserts if the coordinates are outside of the grid's dimensions. Note: This function assumes that all GridCells inside the grid's dimensions are initialized. More...
|
| |
| int | getRows () const |
| | Returns the number of rows in this Grid. More...
|
| |
| int | getColumns () const |
| | Returns the number of columns in this Grid. More...
|
| |
| std::vector< std::vector< GridCell * > > | getGrid () |
| | Returns the 2-D GridCell vector maintained by this Grid. More...
|
| |
| std::vector< GridCell * > | getSpawnPoints () |
| | Returns the vector of spawn point GridCells in this grid. More...
|
| |
| glm::vec3 | getRandomSpawnPoint () |
| | randomly selects a spawn point More...
|
| |
| glm::vec3 | gridCellCenterPosition (GridCell *cell) |
| | Returns the center position (as an Object position vector) of the given GridCell's center. More...
|
| |
| void | writeToFile (std::string path) |
| |
|
| static glm::ivec2 | getGridCellFromPosition (glm::vec3 position) |
| | Returns the position of the GridCell that would contain the given position. More...
|
| |
| static std::vector< glm::ivec2 > | getCellsFromPositionRange (glm::vec3 p1, glm::vec3 p2) |
| | Returns a vector of positions of GridCells that contain the rectangle that extends from p1 to p2 (assumes p1.x <= p2.x and p1.z <= p2.z) More...
|
| |
◆ Grid() [1/2]
◆ Grid() [2/2]
| Grid::Grid |
( |
int |
rows, |
|
|
int |
columns |
|
) |
| |
Initializes this Grid with the specified number of rows and columns.
- Parameters
-
| rows | Number of rows in the grid. |
| columns | Number of columns in the grid. |
◆ ~Grid()
◆ addCell()
Adds a GridCell of the specified type at the given location. If the type is CellType::Spawn, then a pointer to the newly allocated GridCell will be added to the spawnCells vector. Note: If a GridCell already exists at the given location, the GridCell will not be added. (This function asserts that the given location is empty). Note: A GridCell will not be added if its x and y coordinates are outside of the integer range [0, columns - 1] and [0, rows - 1]. (This function asserts that the given x and y coordinates are within this range).
- Parameters
-
◆ getCell()
| GridCell * Grid::getCell |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Attempts to retrieve a GridCell at the specified location. Note: This function asserts if the coordinates are outside of the grid's dimensions. Note: This function assumes that all GridCells inside the grid's dimensions are initialized.
- Parameters
-
| x | x coordinate of the GridCell to retrieve. |
| y | y coordinate of the GridCell to retrieve. |
- Returns
- Pointer to the GridCell at the specified coordinates.
◆ getCellsFromPositionRange()
| std::vector< glm::ivec2 > Grid::getCellsFromPositionRange |
( |
glm::vec3 |
p1, |
|
|
glm::vec3 |
p2 |
|
) |
| |
|
static |
Returns a vector of positions of GridCells that contain the rectangle that extends from p1 to p2 (assumes p1.x <= p2.x and p1.z <= p2.z)
- Parameters
-
| p1 | 3-D game world point from which rectangle extands |
| p2 | 3-D game world point to which rectangle extends |
- Returns
- vector of positions of GridCells that contain the rectangle that extends from p1 to p2. If p1.x > p2.x or p1.z > p2.z, returns an empty vector.
◆ getColumns()
| int Grid::getColumns |
( |
| ) |
const |
Returns the number of columns in this Grid.
- Returns
- Integer number of columns in this Grid.
◆ getGrid()
| std::vector< std::vector< GridCell * > > Grid::getGrid |
( |
| ) |
|
◆ getGridCellFromPosition()
| glm::ivec2 Grid::getGridCellFromPosition |
( |
glm::vec3 |
position | ) |
|
|
static |
Returns the position of the GridCell that would contain the given position.
- Parameters
-
| position | 3-D Game world position |
- Returns
- 2-D Grid position of the GridCell that would contain the given position.
- Note
- It's possible that there may be no GridCell in a particularly used Grid that has the returned coordinates (meaning the input position is out of bounds of a given maze).
◆ getRandomSpawnPoint()
| glm::vec3 Grid::getRandomSpawnPoint |
( |
| ) |
|
randomly selects a spawn point
- Returns
- corner coordinate of a randomly selected spawn point
◆ getRows()
| int Grid::getRows |
( |
| ) |
const |
Returns the number of rows in this Grid.
- Returns
- Integer number of rows in this Grid.
◆ getSpawnPoints()
| std::vector< GridCell * > Grid::getSpawnPoints |
( |
| ) |
|
Returns the vector of spawn point GridCells in this grid.
- Returns
- Vector of spawn point GridCells in this grid.
◆ gridCellCenterPosition()
| glm::vec3 Grid::gridCellCenterPosition |
( |
GridCell * |
cell | ) |
|
Returns the center position (as an Object position vector) of the given GridCell's center.
- Parameters
-
| cell | GridCell whose center position will be returned as an Object position vector. |
- Returns
- Center position of the given grid cell as an Object Physics position vector, or (0,0,0) if the given cell pointer is nullptr
◆ writeToFile()
| void Grid::writeToFile |
( |
std::string |
path | ) |
|
◆ grid_cell_width
The width, in meters, of each GridCell in this grid.
The documentation for this class was generated from the following files: