public bool GetOffMeshConnectionPolyEndPoints(NavPolyId prevRef, NavPolyId polyRef, ref Vector3 startPos, ref Vector3 endPos)
{
int salt = 0, indexTile = 0, indexPoly = 0;
if (polyRef == NavPolyId.Null)
return false;
//get current polygon
idManager.Decode(ref polyRef, out indexPoly, out indexTile, out salt);
if (indexTile >= maxTiles)
return false;
if (tileList[indexTile].Salt != salt)
return false;
NavTile tile = tileList[indexTile];
if (indexPoly >= tile.PolyCount)
return false;
NavPoly poly = tile.Polys[indexPoly];
if (poly.PolyType != NavPolyType.OffMeshConnection)
return false;
int idx0 = 0, idx1 = 1;
//find the link that points to the first vertex
foreach (Link link in poly.Links)
{
if (link.Edge == 0)
{
if (link.Reference != prevRef)
{
idx0 = 1;
idx1 = 0;
}
break;
}
}
startPos = tile.Verts[poly.Verts[idx0]];
endPos = tile.Verts[poly.Verts[idx1]];
return true;
}