public void Process(MeshTile tile, Poly[] polys, int[] refs, int count)
        {
            for (int i = 0; i < count; ++i)
            {
                int r = refs[i];
                m_query.ClosestPointOnPoly(r, m_center, out Vector3 closestPtPoly, out bool posOverPoly);

                // If a point is directly over a polygon and closer than
                // climb height, favor that instead of straight line nearest point.
                float   d;
                Vector3 diff = Vector3.Subtract(m_center, closestPtPoly);
                if (posOverPoly)
                {
                    d = Math.Abs(diff.Y) - tile.Header.WalkableClimb;
                    d = d > 0 ? d * d : 0;
                }
                else
                {
                    d = diff.LengthSquared();
                }

                if (d < m_nearestDistanceSqr)
                {
                    m_nearestPoint = closestPtPoly;

                    m_nearestDistanceSqr = d;
                    m_nearestRef         = r;
                }
            }
        }
예제 #2
0
        public static int AllocLink(MeshTile tile)
        {
            if (tile.LinksFreeList == DT_NULL_LINK)
            {
                return(DT_NULL_LINK);
            }
            int link = tile.LinksFreeList;

            tile.LinksFreeList = tile.Links[link].next;
            return(link);
        }
예제 #3
0
        public void Process(MeshTile tile, Poly[] polys, int[] refs, int count)
        {
            int numLeft = MaxPolys - NumCollected;
            int toCopy  = count;

            if (toCopy > numLeft)
            {
                Overflow = true;
                toCopy   = numLeft;
            }

            Array.Copy(Polys, NumCollected, refs, 0, toCopy);

            NumCollected += toCopy;
        }
예제 #4
0
 public static void FreeLink(MeshTile tile, int link)
 {
     tile.Links[link].next = tile.LinksFreeList;
     tile.LinksFreeList    = link;
 }