Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 336 vs 337 for /trunk/Source Code/Libs/src/ReCast/Detour/Include/DetourNode.h

Diff revisions: vs.
  @@ -23,9 +23,9 @@
23 23
24 24 enum dtNodeFlags
25 25 {
26 - DT_NODE_OPEN = 0x01,
27 - DT_NODE_CLOSED = 0x02,
28 - DT_NODE_PARENT_DETACHED = 0x04, // parent of the node is not adjacent. Found using raycast.
26 + DT_NODE_OPEN = 0x01,
27 + DT_NODE_CLOSED = 0x02,
28 + DT_NODE_PARENT_DETACHED = 0x04, // parent of the node is not adjacent. Found using raycast.
29 29 };
30 30
31 31 typedef unsigned short dtNodeIndex;
  @@ -33,138 +33,138 @@
33 33
34 34 struct dtNode
35 35 {
36 - float pos[3]; ///< Position of the node.
37 - float cost; ///< Cost from previous node to current node.
38 - float total; ///< Cost up to the node.
39 - unsigned int pidx : 24; ///< Index to parent node.
40 - unsigned int state : 2; ///< extra state information. A polyRef can have multiple nodes with different extra info. see DT_MAX_STATES_PER_NODE
41 - unsigned int flags : 3; ///< Node flags. A combination of dtNodeFlags.
42 - dtPolyRef id; ///< Polygon ref the node corresponds to.
36 + float pos[3]; ///< Position of the node.
37 + float cost; ///< Cost from previous node to current node.
38 + float total; ///< Cost up to the node.
39 + unsigned int pidx : 24; ///< Index to parent node.
40 + unsigned int state : 2; ///< extra state information. A polyRef can have multiple nodes with different extra info. see DT_MAX_STATES_PER_NODE
41 + unsigned int flags : 3; ///< Node flags. A combination of dtNodeFlags.
42 + dtPolyRef id; ///< Polygon ref the node corresponds to.
43 43 };
44 44
45 45
46 - static const int DT_MAX_STATES_PER_NODE = 4; // number of extra states per node. See dtNode::state
46 + static const int DT_MAX_STATES_PER_NODE = 4; // number of extra states per node. See dtNode::state
47 47
48 48
49 49
50 50 class dtNodePool
51 51 {
52 52 public:
53 - dtNodePool(int maxNodes, int hashSize);
54 - ~dtNodePool();
55 - inline void operator=(const dtNodePool&) {}
56 - void clear();
57 -
58 - // Get a dtNode by ref and extra state information. If there is none then - allocate
59 - // There can be more than one node for the same polyRef but with different extra state information
60 - dtNode* getNode(dtPolyRef id, unsigned char state=0);
61 - dtNode* findNode(dtPolyRef id, unsigned char state);
62 - unsigned int findNodes(dtPolyRef id, dtNode** nodes, const int maxNodes);
63 -
64 - inline unsigned int getNodeIdx(const dtNode* node) const
65 - {
66 - if (!node) return 0;
67 - return (unsigned int)(node - m_nodes)+1;
68 - }
69 -
70 - inline dtNode* getNodeAtIdx(unsigned int idx)
71 - {
72 - if (!idx) return 0;
73 - return &m_nodes[idx-1];
74 - }
75 -
76 - inline const dtNode* getNodeAtIdx(unsigned int idx) const
77 - {
78 - if (!idx) return 0;
79 - return &m_nodes[idx-1];
80 - }
81 -
82 - inline int getMemUsed() const
83 - {
84 - return sizeof(*this) +
85 - sizeof(dtNode)*m_maxNodes +
86 - sizeof(dtNodeIndex)*m_maxNodes +
87 - sizeof(dtNodeIndex)*m_hashSize;
88 - }
89 -
90 - inline int getMaxNodes() const { return m_maxNodes; }
91 -
92 - inline int getHashSize() const { return m_hashSize; }
93 - inline dtNodeIndex getFirst(int bucket) const { return m_first[bucket]; }
94 - inline dtNodeIndex getNext(int i) const { return m_next[i]; }
95 - inline int getNodeCount() const { return m_nodeCount; }
96 -
53 + dtNodePool(int maxNodes, int hashSize);
54 + ~dtNodePool();
55 + inline void operator=(const dtNodePool&) {}
56 + void clear();
57 +
58 + // Get a dtNode by ref and extra state information. If there is none then - allocate
59 + // There can be more than one node for the same polyRef but with different extra state information
60 + dtNode* getNode(dtPolyRef id, unsigned char state=0);
61 + dtNode* findNode(dtPolyRef id, unsigned char state);
62 + unsigned int findNodes(dtPolyRef id, dtNode** nodes, const int maxNodes);
63 +
64 + inline unsigned int getNodeIdx(const dtNode* node) const
65 + {
66 + if (!node) return 0;
67 + return (unsigned int)(node - m_nodes)+1;
68 + }
69 +
70 + inline dtNode* getNodeAtIdx(unsigned int idx)
71 + {
72 + if (!idx) return 0;
73 + return &m_nodes[idx-1];
74 + }
75 +
76 + inline const dtNode* getNodeAtIdx(unsigned int idx) const
77 + {
78 + if (!idx) return 0;
79 + return &m_nodes[idx-1];
80 + }
81 +
82 + inline int getMemUsed() const
83 + {
84 + return sizeof(*this) +
85 + sizeof(dtNode)*m_maxNodes +
86 + sizeof(dtNodeIndex)*m_maxNodes +
87 + sizeof(dtNodeIndex)*m_hashSize;
88 + }
89 +
90 + inline int getMaxNodes() const { return m_maxNodes; }
91 +
92 + inline int getHashSize() const { return m_hashSize; }
93 + inline dtNodeIndex getFirst(int bucket) const { return m_first[bucket]; }
94 + inline dtNodeIndex getNext(int i) const { return m_next[i]; }
95 + inline int getNodeCount() const { return m_nodeCount; }
96 +
97 97 private:
98 -
99 - dtNode* m_nodes;
100 - dtNodeIndex* m_first;
101 - dtNodeIndex* m_next;
102 - const int m_maxNodes;
103 - const int m_hashSize;
104 - int m_nodeCount;
98 +
99 + dtNode* m_nodes;
100 + dtNodeIndex* m_first;
101 + dtNodeIndex* m_next;
102 + const int m_maxNodes;
103 + const int m_hashSize;
104 + int m_nodeCount;
105 105 };
106 106
107 107 class dtNodeQueue
108 108 {
109 109 public:
110 - dtNodeQueue(int n);
111 - ~dtNodeQueue();
112 - inline void operator=(dtNodeQueue&) {}
113 -
114 - inline void clear()
115 - {
116 - m_size = 0;
117 - }
118 -
119 - inline dtNode* top()
120 - {
121 - return m_heap[0];
122 - }
123 -
124 - inline dtNode* pop()
125 - {
126 - dtNode* result = m_heap[0];
127 - m_size--;
128 - trickleDown(0, m_heap[m_size]);
129 - return result;
130 - }
131 -
132 - inline void push(dtNode* node)
133 - {
134 - m_size++;
135 - bubbleUp(m_size-1, node);
136 - }
137 -
138 - inline void modify(dtNode* node)
139 - {
140 - for (int i = 0; i < m_size; ++i)
141 - {
142 - if (m_heap[i] == node)
143 - {
144 - bubbleUp(i, node);
145 - return;
146 - }
147 - }
148 - }
149 -
150 - inline bool empty() const { return m_size == 0; }
151 -
152 - inline int getMemUsed() const
153 - {
154 - return sizeof(*this) +
155 - sizeof(dtNode*)*(m_capacity+1);
156 - }
157 -
158 - inline int getCapacity() const { return m_capacity; }
159 -
110 + dtNodeQueue(int n);
111 + ~dtNodeQueue();
112 + inline void operator=(dtNodeQueue&) {}
113 +
114 + inline void clear()
115 + {
116 + m_size = 0;
117 + }
118 +
119 + inline dtNode* top()
120 + {
121 + return m_heap[0];
122 + }
123 +
124 + inline dtNode* pop()
125 + {
126 + dtNode* result = m_heap[0];
127 + m_size--;
128 + trickleDown(0, m_heap[m_size]);
129 + return result;
130 + }
131 +
132 + inline void push(dtNode* node)
133 + {
134 + m_size++;
135 + bubbleUp(m_size-1, node);
136 + }
137 +
138 + inline void modify(dtNode* node)
139 + {
140 + for (int i = 0; i < m_size; ++i)
141 + {
142 + if (m_heap[i] == node)
143 + {
144 + bubbleUp(i, node);
145 + return;
146 + }
147 + }
148 + }
149 +
150 + inline bool empty() const { return m_size == 0; }
151 +
152 + inline int getMemUsed() const
153 + {
154 + return sizeof(*this) +
155 + sizeof(dtNode*)*(m_capacity+1);
156 + }
157 +
158 + inline int getCapacity() const { return m_capacity; }
159 +
160 160 private:
161 - void bubbleUp(int i, dtNode* node);
162 - void trickleDown(int i, dtNode* node);
163 -
164 - dtNode** m_heap;
165 - const int m_capacity;
166 - int m_size;
167 - };
161 + void bubbleUp(int i, dtNode* node);
162 + void trickleDown(int i, dtNode* node);
163 +
164 + dtNode** m_heap;
165 + const int m_capacity;
166 + int m_size;
167 + };
168 168
169 169
170 170 #endif // DETOURNODE_H