␉␉␉␉throw new ArgumentOutOfRangeException("ctype");␊ |
␉␉␉}␊ |
␊ |
␉␉␉// TODO: Needs additional test for not 0.0 and null results.␊ |
␉␉␉result = null;␊ |
␉␉␉float min = float.MinValue;␊ |
␉␉␉float max = float.MaxValue;␊ |
␉␉␉foreach (Plane plane in planes)␊ |
␉␉␉{␊ |
␉␉␉␉Vector3 normal = plane.Normal;␊ |
␉␉␉␉float result2;␊ |
␉␉␉␉Vector3.Dot(ref ray.Direction, ref normal, out result2);␊ |
␉␉␉␉float result3;␊ |
␉␉␉␉Vector3.Dot(ref ray.Position, ref normal, out result3);␊ |
␉␉␉␉result3 += plane.D;␊ |
␉␉␉␉if ((double) Math.Abs(result2) < 9.99999974737875E-06)␊ |
␉␉␉␉{␊ |
␉␉␉␉␉if ((double) result3 > 0.0)␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉return;␊ |
␉␉␉␉␉}␊ |
␉␉␉␉}␊ |
␉␉␉␉else␊ |
␉␉␉␉{␊ |
␉␉␉␉␉float result4 = -result3 / result2;␊ |
␉␉␉␉␉if ((double) result2 < 0.0)␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉if ((double) result4 > (double) max)␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉return;␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉␉if ((double) result4 > (double) min)␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉min = result4;␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉}␊ |
␉␉␉␉␉else␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉if ((double) result4 < (double) min)␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉return;␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉␉if ((double) result4 < (double) max)␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉max = result4;␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉}␊ |
␉␉␉␉}␊ |
␉␉␉␉float? distance = ray.Intersects(plane);␊ |
␉␉␉␉if (distance.HasValue)␊ |
␉␉␉␉{␊ |
␉␉␉␉␉min = Math.Min(min, distance.Value);␊ |
␉␉␉␉␉max = Math.Max(max, distance.Value);␊ |
␉␉␉␉}␊ |
␉␉␉}␊ |
␉␉␉float temp = min >= 0.0 ? min : max;␊ |
␉␉␉if (temp < 0.0)␊ |
␉␉␉{␊ |
␉␉␉␉return;␊ |
␉␉␉}␊ |
␉␉␉result = temp;␊ |
␉␉␉throw new NotImplementedException();␊ |
␉␉}␊ |
␊ |
␉␉#endregion␊ |