Recast Navigation
Navigation-mesh Toolset for Games
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  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:
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  // Explicitly disabled copy constructor and copy assignment operator.
66  dtProximityGrid& operator=(const dtProximityGrid&);
67 };
68 
71 
72 
73 #endif // DETOURPROXIMITYGRID_H
74 
void dtFreeProximityGrid(dtProximityGrid *ptr)
Definition: DetourProximityGrid.cpp:35
dtProximityGrid * dtAllocProximityGrid()
Definition: DetourProximityGrid.cpp:28
int next(int i, int n)
Definition: DetourTileCacheBuilder.cpp:1080
Definition: DetourProximityGrid.h:23
int queryItems(const float minx, const float miny, const float maxx, const float maxy, unsigned short *ids, const int maxIds) const
Definition: DetourProximityGrid.cpp:136
~dtProximityGrid()
Definition: DetourProximityGrid.cpp:60
const int * getBounds() const
Definition: DetourProximityGrid.h:60
void clear()
Definition: DetourProximityGrid.cpp:92
int getItemCountAt(const int x, const int y) const
Definition: DetourProximityGrid.cpp:179
float getCellSize() const
Definition: DetourProximityGrid.h:61
void addItem(const unsigned short id, const float minx, const float miny, const float maxx, const float maxy)
Definition: DetourProximityGrid.cpp:102
bool init(const int poolSize, const float cellSize)
Definition: DetourProximityGrid.cpp:66
dtProximityGrid()
Definition: DetourProximityGrid.cpp:49