improving path aesthetics at tile crossing: in the old code, when a new node is found a single 3D position is associated with it. This position is used regardless of arriving from a new tile. A minor issue on a normal navmesh, this produces many problems when crossing tiles. Points might be located on different borders altogether depending on where one arrived from first.

The new code assigns several (consecutive) dtNodes for polygons that lie on tile boundary. Each node gets its own point. since the nodes are packed together consecutively, it is easy to find the right node by reference even though there are several.
This commit is contained in:
axelrodR
2014-01-30 11:57:13 +02:00
parent e117234170
commit d2306cacdd
3 changed files with 65 additions and 19 deletions
+35 -3
View File
@@ -1047,12 +1047,22 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
if (!filter->passFilter(neighbourRef, neighbourTile, neighbourPoly))
continue;
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef);
// deal explicitly with crossing tile boundaries
int crossSide = 0, extraNodes = 0;
if (bestTile->links[i].side != 0xff)
{
extraNodes = 3;
crossSide = bestTile->links[i].side >> 1;
}
// get the node
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef, extraNodes);
if (!neighbourNode)
{
status |= DT_OUT_OF_NODES;
continue;
}
neighbourNode += crossSide;
// If the node is visited the first time, calculate node position.
if (neighbourNode->flags == 0)
@@ -1304,12 +1314,21 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters)
if (!m_query.filter->passFilter(neighbourRef, neighbourTile, neighbourPoly))
continue;
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef);
// deal explicitly with crossing tile boundaries
int crossSide = 0, extraNodes = 0;
if (bestTile->links[i].side != 0xff)
{
extraNodes = 3;
crossSide = bestTile->links[i].side >> 1;
}
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef, extraNodes);
if (!neighbourNode)
{
m_query.status |= DT_OUT_OF_NODES;
continue;
}
neighbourNode += crossSide;
// If the node is visited the first time, calculate node position.
if (neighbourNode->flags == 0)
@@ -3370,5 +3389,18 @@ bool dtNavMeshQuery::isInClosedList(dtPolyRef ref) const
{
if (!m_nodePool) return false;
const dtNode* node = m_nodePool->findNode(ref);
return node && node->flags & DT_NODE_CLOSED;
if (!node)
return false;
const dtNode* last=m_nodePool->getNodeAtIdx(m_nodePool->getNodeCount() -1);
do // several nodes might be allocated for the same ref
{
if (node->flags & DT_NODE_CLOSED)
return true;
node++;
} while (node<last && node->id == ref);
return false;
}