SharpNav.TiledNavMesh.GetOffMeshConnectionPolyEndPoints C# (CSharp) Method

GetOffMeshConnectionPolyEndPoints() public method

Retrieve the endpoints of the offmesh connection at the specified polygon
public GetOffMeshConnectionPolyEndPoints ( NavPolyId prevRef, NavPolyId polyRef, Microsoft.Xna.Framework.Vector3 &startPos, Microsoft.Xna.Framework.Vector3 &endPos ) : bool
prevRef NavPolyId The previous polygon reference
polyRef NavPolyId The current polygon reference
startPos Microsoft.Xna.Framework.Vector3 The starting position
endPos Microsoft.Xna.Framework.Vector3 The ending position
return bool
        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;
        }