public static IntersectRaySphere ( |
||
ray | ||
sphereOrigin | Vector3 | |
sphereRadius | float | |
t | float | |
q | Vector3 | |
Результат | bool |
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray ray = HandleUtility.GUIPointToWorldRay(point); Dictionary <int, float> dictionary = new Dictionary <int, float>(); for (int i = 0; i < points.Count; i++) { float num = 0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(ray, cloudTransform.TransformPoint(points.GetPosition(i)), points.GetPointScale() * 0.5f, ref num, ref zero)) { if (num > 0f) { dictionary.Add(i, num); } } } int result; if (dictionary.Count <= 0) { result = -1; } else { IOrderedEnumerable <KeyValuePair <int, float> > source = from x in dictionary orderby x.Value select x; result = source.First <KeyValuePair <int, float> >().Key; } return(result); }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { var r = HandleUtility.GUIPointToWorldRay(point); var found = new Dictionary <int, float>(); for (var i = 0; i < points.Count; i++) { float distance = 0; Vector3 collisionPoint = Vector3.zero; Vector3 position = cloudTransform != null?cloudTransform.TransformPoint(points.GetPosition(i)) : points.GetPosition(i); if (MathUtils.IntersectRaySphere(r, position, points.GetPointScale(), ref distance, ref collisionPoint)) { //Only care if we start outside a probe if (distance > 0) { found.Add(i, distance); } } } if (found.Count <= 0) { return(-1); } var sorted = found.OrderBy(x => x.Value); return(sorted.First().Key); }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray ray = HandleUtility.GUIPointToWorldRay(point); Dictionary <int, float> source = new Dictionary <int, float>(); for (int i = 0; i < points.Count; i++) { float t = 0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(ray, cloudTransform.TransformPoint(points.GetPosition(i)), points.GetPointScale() * 0.5f, ref t, ref zero) && (t > 0f)) { source.Add(i, t); } } if (source.Count <= 0) { return(-1); } if (< > f__am$cache5 == null) {
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray worldRay = HandleUtility.GUIPointToWorldRay(point); Dictionary <int, float> source = new Dictionary <int, float>(); for (int index = 0; index < points.Count; ++index) { float t = 0.0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(worldRay, cloudTransform.TransformPoint(points.GetPosition(index)), points.GetPointScale() * 0.5f, ref t, ref zero) && (double)t > 0.0) { source.Add(index, t); } } if (source.Count <= 0) { return(-1); } return(source.OrderBy <KeyValuePair <int, float>, float>((Func <KeyValuePair <int, float>, float>)(x => x.Value)).First <KeyValuePair <int, float> >().Key); }