| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef DETOURPROXIMITYGRID_H |
| 20 |
#define DETOURPROXIMITYGRID_H |
| 21 |
|
| 22 |
class dtProximityGrid |
| 23 |
{ |
| 24 |
float m_cellSize; |
| 25 |
float m_invCellSize; |
| 26 |
|
| 27 |
struct Item |
| 28 |
{ |
| 29 |
unsigned short id; |
| 30 |
short x,y; |
| 31 |
unsigned short next; |
| 32 |
}; |
| 33 |
Item* m_pool; |
| 34 |
int m_poolHead; |
| 35 |
int m_poolSize; |
| 36 |
|
| 37 |
unsigned short* m_buckets; |
| 38 |
int m_bucketsSize; |
| 39 |
|
| 40 |
int m_bounds[4]; |
| 41 |
|
| 42 |
public: |
| 43 |
dtProximityGrid(); |
| 44 |
~dtProximityGrid(); |
| 45 |
|
| 46 |
bool init(const int poolSize, const float cellSize); |
| 47 |
|
| 48 |
void clear(); |
| 49 |
|
| 50 |
void addItem(const unsigned short id, |
| 51 |
const float minx, const float miny, |
| 52 |
const float maxx, const float maxy); |
| 53 |
|
| 54 |
int queryItems(const float minx, const float miny, |
| 55 |
const float maxx, const float maxy, |
| 56 |
unsigned short* ids, const int maxIds) const; |
| 57 |
|
| 58 |
int getItemCountAt(const int x, const int y) const; |
| 59 |
|
| 60 |
inline const int* getBounds() const { return m_bounds; } |
| 61 |
inline float getCellSize() const { return m_cellSize; } |
| 62 |
|
| 63 |
private: |
| 64 |
|
| 65 |
dtProximityGrid(const dtProximityGrid&); |
| 66 |
dtProximityGrid& operator=(const dtProximityGrid&); |
| 67 |
}; |
| 68 |
|
| 69 |
dtProximityGrid* dtAllocProximityGrid(); |
| 70 |
void dtFreeProximityGrid(dtProximityGrid* ptr); |
| 71 |
|
| 72 |
|
| 73 |
#endif |
| 74 |
|