@par If the @p segmentRefs parameter is provided, then all polygon segments will be returned. Otherwise only the wall segments are returned. A segment that is normally a portal will be included in the result set as a wall if the @p filter results in the neighbor polygon becoomming impassable. The @p segmentVerts and @p segmentRefs buffers should normally be sized for the maximum segments per po
| 3312 | /// maximum segments per polygon of the source navigation mesh. |
| 3313 | /// |
| 3314 | dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* filter, |
| 3315 | float* segmentVerts, dtPolyRef* segmentRefs, int* segmentCount, |
| 3316 | const int maxSegments) const |
| 3317 | { |
| 3318 | dtAssert(m_nav); |
| 3319 | |
| 3320 | if (!segmentCount) |
| 3321 | return DT_FAILURE | DT_INVALID_PARAM; |
| 3322 | |
| 3323 | *segmentCount = 0; |
| 3324 | |
| 3325 | const dtMeshTile* tile = 0; |
| 3326 | const dtPoly* poly = 0; |
| 3327 | if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly))) |
| 3328 | return DT_FAILURE | DT_INVALID_PARAM; |
| 3329 | |
| 3330 | if (!filter || !segmentVerts || maxSegments < 0) |
| 3331 | return DT_FAILURE | DT_INVALID_PARAM; |
| 3332 | |
| 3333 | int n = 0; |
| 3334 | static const int MAX_INTERVAL = 16; |
| 3335 | dtSegInterval ints[MAX_INTERVAL]; |
| 3336 | int nints; |
| 3337 | |
| 3338 | const bool storePortals = segmentRefs != 0; |
| 3339 | |
| 3340 | dtStatus status = DT_SUCCESS; |
| 3341 | |
| 3342 | for (int i = 0, j = (int)poly->vertCount-1; i < (int)poly->vertCount; j = i++) |
| 3343 | { |
| 3344 | // Skip non-solid edges. |
| 3345 | nints = 0; |
| 3346 | if (poly->neis[j] & DT_EXT_LINK) |
| 3347 | { |
| 3348 | // Tile border. |
| 3349 | for (unsigned int k = poly->firstLink; k != DT_NULL_LINK; k = tile->links[k].next) |
| 3350 | { |
| 3351 | const dtLink* link = &tile->links[k]; |
| 3352 | if (link->edge == j) |
| 3353 | { |
| 3354 | if (link->ref != 0) |
| 3355 | { |
| 3356 | const dtMeshTile* neiTile = 0; |
| 3357 | const dtPoly* neiPoly = 0; |
| 3358 | m_nav->getTileAndPolyByRefUnsafe(link->ref, &neiTile, &neiPoly); |
| 3359 | if (filter->passFilter(link->ref, neiTile, neiPoly)) |
| 3360 | { |
| 3361 | insertInterval(ints, nints, MAX_INTERVAL, link->bmin, link->bmax, link->ref); |
| 3362 | } |
| 3363 | } |
| 3364 | } |
| 3365 | } |
| 3366 | } |
| 3367 | else |
| 3368 | { |
| 3369 | // Internal edge |
| 3370 | dtPolyRef neiRef = 0; |
| 3371 | if (poly->neis[j]) |
no test coverage detected