public dtNode pop() { dtNode result = m_heap[0]; m_size--; trickleDown(0, m_heap[m_size]); return(result); }
public uint getNodeIdx(dtNode node) { if (node == null) { return(0); } return((uint)(System.Array.IndexOf(m_nodes, node)) + 1); }
public void modify(dtNode node) { for (int i = 0; i < m_size; ++i) { if (m_heap[i] == node) { bubbleUp(i, node); return; } } }
public void bubbleUp(int i, dtNode node) { int parent = (i - 1) / 2; while ((i > 0) && (m_heap[parent].total > node.total)) { m_heap[i] = m_heap[parent]; i = parent; parent = (i - 1) / 2; } m_heap[i] = node; }
public void trickleDown(int i, dtNode node) { int child = (i * 2) + 1; while (child < m_size) { if (((child + 1) < m_size) && (m_heap[child].total > m_heap[child + 1].total)) { child++; } m_heap[i] = m_heap[child]; i = child; child = (i * 2) + 1; } bubbleUp(i, node); }
public dtNode getNode(dtPolyRef id, uint state) { uint bucket = (uint)(DetourNode.dtHashRef(id) & (m_hashSize - 1)); dtNodeIndex i = m_first[bucket]; dtNode node = null; while (i != DetourNode.DT_NULL_IDX) { if (m_nodes[i].id == id && m_nodes[i].state == state) { return(m_nodes[i]); } i = m_next[i]; } if (m_nodeCount >= m_maxNodes) { return(null); } i = (dtNodeIndex)m_nodeCount; m_nodeCount++; node = m_nodes[i]; node.pidx = 0; node.cost = 0; node.total = 0; node.id = id; node.state = state; node.flags = 0; m_next[i] = m_first[bucket]; m_first[bucket] = i; return(node); }
public void push(dtNode node) { m_size++; bubbleUp(m_size - 1, node); }
public uint getNodeIdx(dtNode node) { if (node == null) return 0; return (uint)(System.Array.IndexOf(m_nodes, node)) + 1; }