22#include "DetourNavMesh.h"
27 DT_NODE_CLOSED = 0x02,
28 DT_NODE_PARENT_DETACHED = 0x04,
31typedef unsigned short dtNodeIndex;
32static const dtNodeIndex DT_NULL_IDX = (dtNodeIndex)~0;
34static const int DT_NODE_PARENT_BITS = 24;
35static const int DT_NODE_STATE_BITS = 2;
41 unsigned int pidx : DT_NODE_PARENT_BITS;
42 unsigned int state : DT_NODE_STATE_BITS;
47static const int DT_MAX_STATES_PER_NODE = 1 << DT_NODE_STATE_BITS;
60 unsigned int findNodes(
dtPolyRef id,
dtNode** nodes,
const int maxNodes);
62 inline unsigned int getNodeIdx(
const dtNode* node)
const
65 return (
unsigned int)(node - m_nodes) + 1;
68 inline dtNode* getNodeAtIdx(
unsigned int idx)
71 return &m_nodes[idx - 1];
74 inline const dtNode* getNodeAtIdx(
unsigned int idx)
const
77 return &m_nodes[idx - 1];
80 inline int getMemUsed()
const
82 return sizeof(*this) +
83 sizeof(
dtNode)*m_maxNodes +
84 sizeof(dtNodeIndex)*m_maxNodes +
85 sizeof(dtNodeIndex)*m_hashSize;
88 inline int getMaxNodes()
const {
return m_maxNodes; }
90 inline int getHashSize()
const {
return m_hashSize; }
91 inline dtNodeIndex getFirst(
int bucket)
const {
return m_first[bucket]; }
92 inline dtNodeIndex getNext(
int i)
const {
return m_next[i]; }
93 inline int getNodeCount()
const {
return m_nodeCount; }
101 dtNodeIndex* m_first;
103 const int m_maxNodes;
104 const int m_hashSize;
114 inline void clear() { m_size = 0; }
116 inline dtNode* top() {
return m_heap[0]; }
120 dtNode* result = m_heap[0];
122 trickleDown(0, m_heap[m_size]);
126 inline void push(
dtNode* node)
129 bubbleUp(m_size-1, node);
132 inline void modify(
dtNode* node)
134 for (
int i = 0; i < m_size; ++i)
136 if (m_heap[i] == node)
144 inline bool empty()
const {
return m_size == 0; }
146 inline int getMemUsed()
const
148 return sizeof(*this) +
149 sizeof(
dtNode*) * (m_capacity + 1);
152 inline int getCapacity()
const {
return m_capacity; }
159 void bubbleUp(
int i,
dtNode* node);
160 void trickleDown(
int i,
dtNode* node);
163 const int m_capacity;
Definition DetourNode.h:50
Definition DetourNode.h:109
unsigned int dtPolyRef
Definition DetourNavMesh.h:48
Definition DetourNode.h:37
dtPolyRef id
Polygon ref the node corresponds to.
Definition DetourNode.h:44
float cost
Cost from previous node to current node.
Definition DetourNode.h:39
float pos[3]
Position of the node.
Definition DetourNode.h:38
unsigned int state
extra state information. A polyRef can have multiple nodes with different extra info....
Definition DetourNode.h:42
unsigned int flags
Node flags. A combination of dtNodeFlags.
Definition DetourNode.h:43
float total
Cost up to the node.
Definition DetourNode.h:40
unsigned int pidx
Index to parent node.
Definition DetourNode.h:41