Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::UniformGrid< T > Class Template Reference

Models a uniform grid in 3D space, with the ability to insert and inspect certain cells in the grid. These cells contains a collection of objects. More...

#include <uniformGrid.h>

Public Member Functions

void insert (int x, int y, int z, T item)
 Insert an item into the grid.
 
void remove (int x, int y, int z, T item)
 Remove an item from a grid cell.
 
std::optional< GridCell > getCell (int x, int y, int z)
 Get the grid cell at a certain coordinate.
 

Detailed Description

template<class T>
class Saga::UniformGrid< T >

Models a uniform grid in 3D space, with the ability to insert and inspect certain cells in the grid. These cells contains a collection of objects.

Template Parameters
Tthe type of objects stored in each of the grid's cells.
Note
useful for optimizing collisions of dynamic entities.

Member Function Documentation

◆ getCell()

template<class T >
std::optional< std::list< T > > Saga::UniformGrid< T >::getCell ( int  x,
int  y,
int  z 
)

Get the grid cell at a certain coordinate.

Parameters
xthe x coordinate of the cell.
ythe y coordinate of the cell.
zthe z coordinate of the cell.
Returns
{} if the grid cell at position at (x,y,z) has always been empty.
GridCell the list of objects at that cell position otherwise.

◆ insert()

template<class T >
void Saga::UniformGrid< T >::insert ( int  x,
int  y,
int  z,
item 
)

Insert an item into the grid.

Parameters
xthe x coordinate of the cell.
ythe y coordinate of the cell.
zthe z coordinate of the cell.
itemthe item to insert into the grid at (x,y,z).

◆ remove()

template<class T >
void Saga::UniformGrid< T >::remove ( int  x,
int  y,
int  z,
item 
)

Remove an item from a grid cell.

Parameters
xthe x coordinate of the cell.
ythe y coordinate of the cell.
zthe z coordinate of the cell.
itemthe item to remove from the grid cell at (x,y,z).

The documentation for this class was generated from the following files: