Debian Codegraph @

DetourCrowd/Include/DetourProximityGrid.h

raw symbols SCIP
1 //
2 // Copyright (c) 2009-2010 Mikko Mononen [email protected]
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
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 // Explicitly disabled copy constructor and copy assignment operator.
65 dtProximityGrid(const dtProximityGrid&);
66 dtProximityGrid& operator=(const dtProximityGrid&);
67 };
68
69 dtProximityGrid* dtAllocProximityGrid();
70 void dtFreeProximityGrid(dtProximityGrid* ptr);
71
72
73 #endif // DETOURPROXIMITYGRID_H
74