Raycast does not try to follow off-mesh links (Issue 64), use references instead of pointers in debugdraw api (Issue 62, Issue 63)

This commit is contained in:
Mikko Mononen 2010-04-15 07:22:47 +00:00
parent 10b330ffb4
commit 6f1e34e9fe

View File

@ -405,7 +405,7 @@ void dtNavMesh::connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int
dtPoly* landPoly = &tile->polys[landPolyIdx];
dtLink* link = &tile->links[idx];
link->ref = getTilePolyRefBase(target) | (unsigned int)(targetCon->poly);
link->edge = 0;
link->edge = 0xff;
link->side = (unsigned char)side;
link->bmin = link->bmax = 0;
// Add to linked list.
@ -513,7 +513,7 @@ void dtNavMesh::connectIntOffMeshLinks(dtMeshTile* tile)
dtPoly* landPoly = &tile->polys[landPolyIdx];
dtLink* link = &tile->links[idx];
link->ref = base | (unsigned int)(con->poly);
link->edge = 0;
link->edge = 0xff;
link->side = 0xff;
link->bmin = link->bmax = 0;
// Add to linked list.
@ -2028,8 +2028,25 @@ int dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float*
for (unsigned int i = poly->firstLink; i != DT_NULL_LINK; i = tile->links[i].next)
{
const dtLink* link = &tile->links[i];
if ((int)link->edge == segMax)
{
// Find link which contains this edge.
if ((int)link->edge != segMax)
continue;
// Get pointer to the next polygon.
it = decodePolyIdTile(link->ref);
ip = decodePolyIdPoly(link->ref);
const dtMeshTile* nextTile = &m_tiles[it];
const dtPoly* nextPoly = &nextTile->polys[ip];
// Skip off-mesh connections.
if (nextPoly->type == DT_POLYTYPE_OFFMESH_CONNECTION)
continue;
// Skip links based on filter.
if (!passFilter(filter, nextPoly->flags))
continue;
// If the link is internal, just return the ref.
if (link->side == 0xff)
{
@ -2077,9 +2094,8 @@ int dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float*
}
}
}
}
if (!nextRef || !passFilter(filter, getPolyFlags(nextRef)))
if (!nextRef)
{
// No neighbour, we hit a wall.