Пример #1
0
        public dtNode pop()
        {
            dtNode result = m_heap[0];

            m_size--;
            trickleDown(0, m_heap[m_size]);
            return(result);
        }
Пример #2
0
 public uint getNodeIdx(dtNode node)
 {
     if (node == null)
     {
         return(0);
     }
     return((uint)(System.Array.IndexOf(m_nodes, node)) + 1);
 }
Пример #3
0
 public void modify(dtNode node)
 {
     for (int i = 0; i < m_size; ++i)
     {
         if (m_heap[i] == node)
         {
             bubbleUp(i, node);
             return;
         }
     }
 }
Пример #4
0
        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;
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
 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);
 }
Пример #8
0
 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;
 }
Пример #9
0
 public void modify(dtNode node)
 {
     for (int i = 0; i < m_size; ++i)
     {
         if (m_heap[i] == node)
         {
             bubbleUp(i, node);
             return;
         }
     }
 }
Пример #10
0
 public void push(dtNode node)
 {
     m_size++;
     bubbleUp(m_size - 1, node);
 }
Пример #11
0
 public uint getNodeIdx(dtNode node)
 {
     if (node == null)
         return 0;
     return (uint)(System.Array.IndexOf(m_nodes, node)) + 1;
 }
Пример #12
0
 public void push(dtNode node)
 {
     m_size++;
     bubbleUp(m_size - 1, node);
 }