| 75 | } |
| 76 | |
| 77 | void dtPathQueue::update(const int maxIters) |
| 78 | { |
| 79 | static const int MAX_KEEP_ALIVE = 2; // in update ticks. |
| 80 | |
| 81 | // Update path request until there is nothing to update |
| 82 | // or upto maxIters pathfinder iterations has been consumed. |
| 83 | int iterCount = maxIters; |
| 84 | |
| 85 | for (int i = 0; i < MAX_QUEUE; ++i) |
| 86 | { |
| 87 | PathQuery& q = m_queue[m_queueHead % MAX_QUEUE]; |
| 88 | |
| 89 | // Skip inactive requests. |
| 90 | if (q.ref == DT_PATHQ_INVALID) |
| 91 | { |
| 92 | m_queueHead++; |
| 93 | continue; |
| 94 | } |
| 95 | |
| 96 | // Handle completed request. |
| 97 | if (dtStatusSucceed(q.status) || dtStatusFailed(q.status)) |
| 98 | { |
| 99 | // If the path result has not been read in few frames, free the slot. |
| 100 | q.keepAlive++; |
| 101 | if (q.keepAlive > MAX_KEEP_ALIVE) |
| 102 | { |
| 103 | q.ref = DT_PATHQ_INVALID; |
| 104 | q.status = 0; |
| 105 | } |
| 106 | |
| 107 | m_queueHead++; |
| 108 | continue; |
| 109 | } |
| 110 | |
| 111 | // Handle query start. |
| 112 | if (q.status == 0) |
| 113 | { |
| 114 | q.status = m_navquery->initSlicedFindPath(q.startRef, q.endRef, q.startPos, q.endPos, q.filter); |
| 115 | } |
| 116 | // Handle query in progress. |
| 117 | if (dtStatusInProgress(q.status)) |
| 118 | { |
| 119 | int iters = 0; |
| 120 | q.status = m_navquery->updateSlicedFindPath(iterCount, &iters); |
| 121 | iterCount -= iters; |
| 122 | } |
| 123 | if (dtStatusSucceed(q.status)) |
| 124 | { |
| 125 | q.status = m_navquery->finalizeSlicedFindPath(q.path, &q.npath, m_maxPathSize); |
| 126 | } |
| 127 | |
| 128 | if (iterCount <= 0) |
| 129 | break; |
| 130 | |
| 131 | m_queueHead++; |
| 132 | } |
| 133 | } |
| 134 |
nothing calls this directly
no test coverage detected