@par The order of the result set is from least to highest cost. At least one result array must be provided. A common use case for this method is to perform Dijkstra searches. Candidate polygons are found by searching the graph beginning at the start polygon. The same intersection test restrictions that apply to findPolysAroundCircle() method apply to this method. The 3D centroid of the search
| 2892 | /// be filled to capacity. |
| 2893 | /// |
| 2894 | dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* verts, const int nverts, |
| 2895 | const dtQueryFilter* filter, |
| 2896 | dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost, |
| 2897 | int* resultCount, const int maxResult) const |
| 2898 | { |
| 2899 | dtAssert(m_nav); |
| 2900 | dtAssert(m_nodePool); |
| 2901 | dtAssert(m_openList); |
| 2902 | |
| 2903 | if (!resultCount) |
| 2904 | return DT_FAILURE | DT_INVALID_PARAM; |
| 2905 | |
| 2906 | *resultCount = 0; |
| 2907 | |
| 2908 | if (!m_nav->isValidPolyRef(startRef) || |
| 2909 | !verts || nverts < 3 || |
| 2910 | !filter || maxResult < 0) |
| 2911 | { |
| 2912 | return DT_FAILURE | DT_INVALID_PARAM; |
| 2913 | } |
| 2914 | |
| 2915 | // Validate input |
| 2916 | if (!startRef || !m_nav->isValidPolyRef(startRef)) |
| 2917 | return DT_FAILURE | DT_INVALID_PARAM; |
| 2918 | |
| 2919 | m_nodePool->clear(); |
| 2920 | m_openList->clear(); |
| 2921 | |
| 2922 | float centerPos[3] = {0,0,0}; |
| 2923 | for (int i = 0; i < nverts; ++i) |
| 2924 | dtVadd(centerPos,centerPos,&verts[i*3]); |
| 2925 | dtVscale(centerPos,centerPos,1.0f/nverts); |
| 2926 | |
| 2927 | dtNode* startNode = m_nodePool->getNode(startRef); |
| 2928 | dtVcopy(startNode->pos, centerPos); |
| 2929 | startNode->pidx = 0; |
| 2930 | startNode->cost = 0; |
| 2931 | startNode->total = 0; |
| 2932 | startNode->id = startRef; |
| 2933 | startNode->flags = DT_NODE_OPEN; |
| 2934 | m_openList->push(startNode); |
| 2935 | |
| 2936 | dtStatus status = DT_SUCCESS; |
| 2937 | |
| 2938 | int n = 0; |
| 2939 | |
| 2940 | while (!m_openList->empty()) |
| 2941 | { |
| 2942 | dtNode* bestNode = m_openList->pop(); |
| 2943 | bestNode->flags &= ~DT_NODE_OPEN; |
| 2944 | bestNode->flags |= DT_NODE_CLOSED; |
| 2945 | |
| 2946 | // Get poly and tile. |
| 2947 | // The API input has been cheked already, skip checking internal data. |
| 2948 | const dtPolyRef bestRef = bestNode->id; |
| 2949 | const dtMeshTile* bestTile = 0; |
| 2950 | const dtPoly* bestPoly = 0; |
| 2951 | m_nav->getTileAndPolyByRefUnsafe(bestRef, &bestTile, &bestPoly); |
nothing calls this directly
no test coverage detected