A grid divides world space into fixed grid of rectangular sectors. World is divided on XY plane, so each sector represents a whole vertical "column" of the world.
Needed sector interface:
| SECTOR | Sector class. |
| SECS_X | Number of sectors along world X axis. Should be a power of 2. |
| SECS_Y | Number of sectors along world Y axis. Should be a power of 2. |
Public Types | |
| typedef SECTOR | TSector |
| Sector type (from template argument). | |
Public Methods | |
| CGrid (SECTOR const &t=SECTOR()) | |
| Constructor. | |
| ~CGrid () | |
| Destructor. | |
| int | getSecsX () const |
| Returns number of sectors along X axis. | |
| int | getSecsY () const |
| Returns number of sectors along Y axis. | |
| int | getSecsCount () const |
| Returns total number of sectors. | |
| float | getStepX () const |
| Returns sector size along X axis. | |
| float | getStepY () const |
| Returns sector size along Y axis. | |
| float | getInvStepX () const |
| Returns inverse sector size along X axis. | |
| float | getInvStepY () const |
| Returns inverse sector size along Y axis. | |
| const SECTOR & | getSectorByPosition (float x, float y) const |
| Returns read-only sector by world space position XY. | |
| SECTOR & | getSectorByPosition (float x, float y) |
| Returns sector by world space position XY. | |
| const SECTOR & | getSectorByIndex (int ix, int iy) const |
| Returns read-only sector by it's XY index. | |
| SECTOR & | getSectorByIndex (int ix, int iy) |
| Returns sector by it's XY index. | |
| const SECTOR & | getSectorByIndex (int i) const |
| Returns read-only sector by it's absolute index. | |
| SECTOR & | getSectorByIndex (int i) |
| Returns sector by it's absolute index. | |
| int | position2Index (float x, float y) const |
| Returns sector's absolute index from world XY position. | |
| void | position2Index (float x, float y, int &ix, int &iy) const |
| Returns sector's XY index from world XY position. | |
|
||||||||||
|
Constructor.
|
1.2.17