MCPcopy Create free account
hub / github.com/axmolengine/axmol / finalizeSlicedFindPath

Method finalizeSlicedFindPath

3rdparty/recast/DetourNavMeshQuery.cpp:1497–1585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1495}
1496
1497dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, const int maxPath)
1498{
1499 if (!pathCount)
1500 return DT_FAILURE | DT_INVALID_PARAM;
1501
1502 *pathCount = 0;
1503
1504 if (!path || maxPath <= 0)
1505 return DT_FAILURE | DT_INVALID_PARAM;
1506
1507 if (dtStatusFailed(m_query.status))
1508 {
1509 // Reset query.
1510 memset(&m_query, 0, sizeof(dtQueryData));
1511 return DT_FAILURE;
1512 }
1513
1514 int n = 0;
1515
1516 if (m_query.startRef == m_query.endRef)
1517 {
1518 // Special case: the search starts and ends at same poly.
1519 path[n++] = m_query.startRef;
1520 }
1521 else
1522 {
1523 // Reverse the path.
1524 dtAssert(m_query.lastBestNode);
1525
1526 if (m_query.lastBestNode->id != m_query.endRef)
1527 m_query.status |= DT_PARTIAL_RESULT;
1528
1529 dtNode* prev = 0;
1530 dtNode* node = m_query.lastBestNode;
1531 int prevRay = 0;
1532 do
1533 {
1534 dtNode* next = m_nodePool->getNodeAtIdx(node->pidx);
1535 node->pidx = m_nodePool->getNodeIdx(prev);
1536 prev = node;
1537 int nextRay = node->flags & DT_NODE_PARENT_DETACHED; // keep track of whether parent is not adjacent (i.e. due to raycast shortcut)
1538 node->flags = (node->flags & ~DT_NODE_PARENT_DETACHED) | prevRay; // and store it in the reversed path's node
1539 prevRay = nextRay;
1540 node = next;
1541 }
1542 while (node);
1543
1544 // Store path
1545 node = prev;
1546 do
1547 {
1548 dtNode* next = m_nodePool->getNodeAtIdx(node->pidx);
1549 dtStatus status = 0;
1550 if (node->flags & DT_NODE_PARENT_DETACHED)
1551 {
1552 float t, normal[3];
1553 int m;
1554 status = raycast(node->id, node->pos, next->pos, m_query.filter, &t, normal, path+n, &m, maxPath-n);

Callers 2

updateMoveRequestMethod · 0.80
updateMethod · 0.80

Calls 3

dtStatusFailedFunction · 0.85
getNodeAtIdxMethod · 0.80
getNodeIdxMethod · 0.80

Tested by

no test coverage detected