@par This method is optimized for a small search radius and small number of result polygons. Candidate polygons are found by searching the navigation graph beginning at the start polygon. The same intersection test restrictions that apply to the findPolysAroundCircle mehtod applies to this method. The value of the center point is used as the start point for cost calculations. It is not project
| 3090 | /// be filled to capacity. |
| 3091 | /// |
| 3092 | dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float* centerPos, const float radius, |
| 3093 | const dtQueryFilter* filter, |
| 3094 | dtPolyRef* resultRef, dtPolyRef* resultParent, |
| 3095 | int* resultCount, const int maxResult) const |
| 3096 | { |
| 3097 | dtAssert(m_nav); |
| 3098 | dtAssert(m_tinyNodePool); |
| 3099 | |
| 3100 | if (!resultCount) |
| 3101 | return DT_FAILURE | DT_INVALID_PARAM; |
| 3102 | |
| 3103 | *resultCount = 0; |
| 3104 | |
| 3105 | if (!m_nav->isValidPolyRef(startRef) || |
| 3106 | !centerPos || !dtVisfinite(centerPos) || |
| 3107 | radius < 0 || !dtMathIsfinite(radius) || |
| 3108 | !filter || maxResult < 0) |
| 3109 | { |
| 3110 | return DT_FAILURE | DT_INVALID_PARAM; |
| 3111 | } |
| 3112 | |
| 3113 | static const int MAX_STACK = 48; |
| 3114 | dtNode* stack[MAX_STACK]; |
| 3115 | int nstack = 0; |
| 3116 | |
| 3117 | m_tinyNodePool->clear(); |
| 3118 | |
| 3119 | dtNode* startNode = m_tinyNodePool->getNode(startRef); |
| 3120 | startNode->pidx = 0; |
| 3121 | startNode->id = startRef; |
| 3122 | startNode->flags = DT_NODE_CLOSED; |
| 3123 | stack[nstack++] = startNode; |
| 3124 | |
| 3125 | const float radiusSqr = dtSqr(radius); |
| 3126 | |
| 3127 | float pa[DT_VERTS_PER_POLYGON*3]; |
| 3128 | float pb[DT_VERTS_PER_POLYGON*3]; |
| 3129 | |
| 3130 | dtStatus status = DT_SUCCESS; |
| 3131 | |
| 3132 | int n = 0; |
| 3133 | if (n < maxResult) |
| 3134 | { |
| 3135 | resultRef[n] = startNode->id; |
| 3136 | if (resultParent) |
| 3137 | resultParent[n] = 0; |
| 3138 | ++n; |
| 3139 | } |
| 3140 | else |
| 3141 | { |
| 3142 | status |= DT_BUFFER_TOO_SMALL; |
| 3143 | } |
| 3144 | |
| 3145 | while (nstack) |
| 3146 | { |
| 3147 | // Pop front. |
| 3148 | dtNode* curNode = stack[0]; |
| 3149 | for (int i = 0; i < nstack-1; ++i) |
no test coverage detected