@par Must be the first function called after construction, before other functions are used. This function can be used multiple times.
| 169 | /// |
| 170 | /// This function can be used multiple times. |
| 171 | dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes) |
| 172 | { |
| 173 | if (maxNodes > DT_NULL_IDX || maxNodes > (1 << DT_NODE_PARENT_BITS) - 1) |
| 174 | return DT_FAILURE | DT_INVALID_PARAM; |
| 175 | |
| 176 | m_nav = nav; |
| 177 | |
| 178 | if (!m_nodePool || m_nodePool->getMaxNodes() < maxNodes) |
| 179 | { |
| 180 | if (m_nodePool) |
| 181 | { |
| 182 | m_nodePool->~dtNodePool(); |
| 183 | dtFree(m_nodePool); |
| 184 | m_nodePool = 0; |
| 185 | } |
| 186 | m_nodePool = new (dtAlloc(sizeof(dtNodePool), DT_ALLOC_PERM)) dtNodePool(maxNodes, dtNextPow2(maxNodes/4)); |
| 187 | if (!m_nodePool) |
| 188 | return DT_FAILURE | DT_OUT_OF_MEMORY; |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | m_nodePool->clear(); |
| 193 | } |
| 194 | |
| 195 | if (!m_tinyNodePool) |
| 196 | { |
| 197 | m_tinyNodePool = new (dtAlloc(sizeof(dtNodePool), DT_ALLOC_PERM)) dtNodePool(64, 32); |
| 198 | if (!m_tinyNodePool) |
| 199 | return DT_FAILURE | DT_OUT_OF_MEMORY; |
| 200 | } |
| 201 | else |
| 202 | { |
| 203 | m_tinyNodePool->clear(); |
| 204 | } |
| 205 | |
| 206 | if (!m_openList || m_openList->getCapacity() < maxNodes) |
| 207 | { |
| 208 | if (m_openList) |
| 209 | { |
| 210 | m_openList->~dtNodeQueue(); |
| 211 | dtFree(m_openList); |
| 212 | m_openList = 0; |
| 213 | } |
| 214 | m_openList = new (dtAlloc(sizeof(dtNodeQueue), DT_ALLOC_PERM)) dtNodeQueue(maxNodes); |
| 215 | if (!m_openList) |
| 216 | return DT_FAILURE | DT_OUT_OF_MEMORY; |
| 217 | } |
| 218 | else |
| 219 | { |
| 220 | m_openList->clear(); |
| 221 | } |
| 222 | |
| 223 | return DT_SUCCESS; |
| 224 | } |
| 225 | |
| 226 | dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*frand)(), |
| 227 | dtPolyRef* randomRef, float* randomPt) const |
nothing calls this directly
no test coverage detected