// Ray returns a single light ray from the source (viewer) position to another.
// It should be preceded by a VisionMap call. If the destination position is
// not within the max distance from the source, a nil slice will be returned.
//
// The returned slice is cached for efficiency, so results will be invalidated
// by future calls.
Ray returns a single light ray from the source (viewer) position to another.
It should be preceded by a VisionMap call. If the destination position is
not within the max distance from the source, a nil slice will be returned.

The returned slice is cached for efficiency, so results will be invalidated
by future calls.
// Ray returns a single light ray from the source ( viewer ) position to another . // It should be preceded by a VisionMap call . If the destination position is // not within the max distance from the source a nil slice will be returned . // // The returned slice is cached for efficiency so results will be invalidated // by future calls .
func (fov *FOV) Ray(lt Lighter, to gruid.Point) []LightNode {
	_, okTo := fov.At(to)
	if !okTo {
		return nil
	}
	fov.RayCache = fov.RayCache[:0]
	var n LightNode
	for to != fov.Src {
		n = fov.from(lt, to)
		fov.RayCache = append(fov.RayCache, LightNode{P: to, Cost: n.Cost - 1})
		to = n.P
	}
	fov.RayCache = append(fov.RayCache, LightNode{P: fov.Src, Cost: 0})
	for i := range fov.RayCache[:len(fov.RayCache)/2] {
		fov.RayCache[i], fov.RayCache[len(fov.RayCache)-i-1] = fov.RayCache[len(fov.RayCache)-i-1], fov.RayCache[i]
	}
	return fov.RayCache
}
func ( fov * FOV ) Ray ( lt Lighter , to gruid . Point ) [ ] LightNode { _ , okTo := fov . At ( to ) if ! okTo { return nil } fov . RayCache = fov . RayCache [ : 0 ] var n LightNode for to != fov . Src { n = fov . from ( lt , to ) fov . RayCache = append ( fov . RayCache , LightNode { P : to , Cost : n . Cost - 1 } ) to = n . P } fov . RayCache = append ( fov . RayCache , LightNode { P : fov . Src , Cost : 0 } ) for i := range fov . RayCache [ : len ( fov . RayCache ) / 2 ] { fov . RayCache [ i ] , fov . RayCache [ len ( fov . RayCache ) - i - 1 ] = fov . RayCache [ len ( fov . RayCache ) - i - 1 ] , fov . RayCache [ i ] } return fov . RayCache }
Ray returns a single light ray from the source (viewer) position to another.
Ray returns a single light ray from the source ( viewer ) position to another .