Planeshift
DetourProximityGrid.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 // Permission is granted to anyone to use this software for any purpose,
8 // including commercial applications, and to alter it and redistribute it
9 // freely, subject to the following restrictions:
10 // 1. The origin of this software must not be misrepresented; you must not
11 // claim that you wrote the original software. If you use this software
12 // in a product, an acknowledgment in the product documentation would be
13 // appreciated but is not required.
14 // 2. Altered source versions must be plainly marked as such, and must not be
15 // misrepresented as being the original software.
16 // 3. This notice may not be removed or altered from any source distribution.
17 //
18 
19 #ifndef DETOURPROXIMITYGRID_H
20 #define DETOURPROXIMITYGRID_H
21 
23 {
24  int m_maxItems;
25  float m_cellSize;
26  float m_invCellSize;
27 
28  struct Item
29  {
30  unsigned short id;
31  short x,y;
32  unsigned short next;
33  };
34  Item* m_pool;
35  int m_poolHead;
36  int m_poolSize;
37 
38  unsigned short* m_buckets;
39  int m_bucketsSize;
40 
41  int m_bounds[4];
42 
43 public:
46 
47  bool init(const int maxItems, const float cellSize);
48 
49  void clear();
50 
51  void addItem(const unsigned short id,
52  const float minx, const float miny,
53  const float maxx, const float maxy);
54 
55  int queryItems(const float minx, const float miny,
56  const float maxx, const float maxy,
57  unsigned short* ids, const int maxIds) const;
58 
59  int getItemCountAt(const int x, const int y) const;
60 
61  inline const int* getBounds() const { return m_bounds; }
62  inline const float getCellSize() const { return m_cellSize; }
63 };
64 
67 
68 
69 #endif // DETOURPROXIMITYGRID_H
70 
int getItemCountAt(const int x, const int y) const
int queryItems(const float minx, const float miny, const float maxx, const float maxy, unsigned short *ids, const int maxIds) const
bool init(const int maxItems, const float cellSize)
void dtFreeProximityGrid(dtProximityGrid *ptr)
dtProximityGrid * dtAllocProximityGrid()
void addItem(const unsigned short id, const float minx, const float miny, const float maxx, const float maxy)
const float getCellSize() const
const int * getBounds() const