public Option <EntityRayHitpoint> TryHit(Ray ray, RayParameter bottomBoundary, RayParameter topBoundary)
        {
            if (!_hitableBoundsComputer.Hit(_bounds, ray, bottomBoundary, topBoundary))
            {
                return(Option <EntityRayHitpoint> .Empty);
            }

            var leftHit  = Left.TryHit(ray, bottomBoundary, topBoundary);
            var rightHit = Right.TryHit(ray, bottomBoundary, topBoundary);

            return(leftHit.HasValue switch
            {
                true when rightHit.HasValue => leftHit.Value.Hitpoint.T < rightHit.Value.Hitpoint.T
                    ? leftHit
                    : rightHit,
                true => leftHit,
                _ => rightHit.HasValue ? rightHit : Option <EntityRayHitpoint> .Empty
            });
Esempio n. 2
0
 public bool Hit(Ray ray, RayParameter bottomBoundary, RayParameter topBoundary)
 {
     return(_computer.Hit(_bounds, ray, bottomBoundary, topBoundary));
 }