Clean up grid system: allow directly creating Cell from x, y.

This commit is contained in:
megamage
2011-10-18 11:18:49 -04:00
parent e0d933fed8
commit e27ef59548
3 changed files with 20 additions and 18 deletions
+1
View File
@@ -68,6 +68,7 @@ struct Cell
Cell() { data.All = 0; }
Cell(const Cell &cell) { data.All = cell.data.All; }
explicit Cell(CellCoord const& p);
explicit Cell(float x, float y);
void operator|=(Cell &cell)
{
+11
View File
@@ -35,6 +35,17 @@ inline Cell::Cell(CellCoord const& p)
data.Part.reserved = 0;
}
inline Cell::Cell(float x, float y)
{
CellCoord p = Trinity::ComputeCellCoord(x, y);
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
data.Part.nocreate = 0;
data.Part.reserved = 0;
}
template<class T, class CONTAINER>
inline void
Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const