示例#1
0
        public static Vector3 GetHitPosition(this NetSegment segment, Segment3 ray, out float rayT, out Vector3 position)
        {
            var hitPos = ray.GetRayPosition(segment.m_middlePosition.y, out rayT);

            position = segment.GetClosestPosition(hitPos);

            for (var i = 0; i < 3 && Mathf.Abs(hitPos.y - position.y) > 1f; i += 1)
            {
                hitPos   = ray.GetRayPosition(position.y, out rayT);
                position = segment.GetClosestPosition(hitPos);
            }

            return(hitPos);
        }
示例#2
0
        public static Vector3 GetHitPosition(this Bezier3 bezier, Segment3 ray, out float rayT, out float bezierT, out Vector3 position)
        {
            var hitPos = ray.GetRayPosition(bezier.Position(0.5f).y, out rayT);

            bezier.ClosestPositionAndDirection(hitPos, out position, out _, out bezierT);

            for (var i = 0; i < 3 && Mathf.Abs(hitPos.y - position.y) > 1f; i += 1)
            {
                hitPos = ray.GetRayPosition(position.y, out rayT);
                bezier.ClosestPositionAndDirection(hitPos, out position, out _, out bezierT);
            }

            return(hitPos);
        }
示例#3
0
 public virtual Vector3 GetHitPosition(Segment3 ray, out float t) => ray.GetRayPosition(Center.y, out t);