public static void Unwrap(Funnel.FunnelPortals funnel, Vector2[] left, Vector2[] right) { Vector3 fromDirection = Vector3.Cross(funnel.right[1] - funnel.left[0], funnel.left[1] - funnel.left[0]); left[0] = (right[0] = Vector2.zero); Vector3 vector = funnel.left[1]; Vector3 vector2 = funnel.right[1]; Vector3 prevPoint = funnel.left[0]; Quaternion rotation = Quaternion.FromToRotation(fromDirection, Vector3.forward); Vector3 b = rotation * -funnel.right[0]; for (int i = 1; i < funnel.left.Count; i++) { if (Funnel.UnwrapHelper(vector, vector2, prevPoint, funnel.left[i], ref rotation, ref b)) { prevPoint = vector; vector = funnel.left[i]; } left[i] = rotation * funnel.left[i] + b; if (Funnel.UnwrapHelper(vector, vector2, prevPoint, funnel.right[i], ref rotation, ref b)) { prevPoint = vector2; vector2 = funnel.right[i]; } right[i] = rotation * funnel.right[i] + b; } }
public override void Apply(Path p) { if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0) { return; } List <Vector3> list = ListPool <Vector3> .Claim(); List <Funnel.PathPart> list2 = Funnel.SplitIntoParts(p); for (int i = 0; i < list2.Count; i++) { Funnel.PathPart part = list2[i]; if (!part.isLink) { Funnel.FunnelPortals funnel = Funnel.ConstructFunnelPortals(p.path, part); List <Vector3> list3 = Funnel.Calculate(funnel, this.unwrap, this.splitAtEveryPortal); list.AddRange(list3); ListPool <Vector3> .Release(list3); } } ListPool <Funnel.PathPart> .Release(list2); ListPool <Vector3> .Release(p.vectorPath); p.vectorPath = list; }
// Token: 0x06002648 RID: 9800 RVA: 0x001A5D98 File Offset: 0x001A3F98 public override void Apply(Path p) { if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0) { return; } List <Vector3> list = ListPool <Vector3> .Claim(); List <Funnel.PathPart> list2 = Funnel.SplitIntoParts(p); if (list2.Count == 0) { return; } for (int i = 0; i < list2.Count; i++) { Funnel.PathPart pathPart = list2[i]; if (!pathPart.isLink) { Funnel.FunnelPortals funnel = Funnel.ConstructFunnelPortals(p.path, pathPart); List <Vector3> collection = Funnel.Calculate(funnel, this.unwrap, this.splitAtEveryPortal); list.AddRange(collection); ListPool <Vector3> .Release(ref funnel.left); ListPool <Vector3> .Release(ref funnel.right); ListPool <Vector3> .Release(ref collection); } else { if (i == 0 || list2[i - 1].isLink) { list.Add(pathPart.startPoint); } if (i == list2.Count - 1 || list2[i + 1].isLink) { list.Add(pathPart.endPoint); } } } ListPool <Funnel.PathPart> .Release(ref list2); ListPool <Vector3> .Release(ref p.vectorPath); p.vectorPath = list; }
public static void ShrinkPortals(Funnel.FunnelPortals portals, float shrink) { if (shrink <= 1E-05f) { return; } for (int i = 0; i < portals.left.Count; i++) { Vector3 a = portals.left[i]; Vector3 b = portals.right[i]; float magnitude = (a - b).magnitude; if (magnitude > 0f) { float num = Mathf.Min(shrink / magnitude, 0.4f); portals.left[i] = Vector3.Lerp(a, b, num); portals.right[i] = Vector3.Lerp(a, b, 1f - num); } } }
public static List <Vector3> Calculate(Funnel.FunnelPortals funnel, bool unwrap, bool splitAtEveryPortal) { Vector2[] array = new Vector2[funnel.left.Count]; Vector2[] array2 = new Vector2[funnel.left.Count]; if (unwrap) { Funnel.Unwrap(funnel, array, array2); } else { for (int i = 0; i < array.Length; i++) { array[i] = Funnel.ToXZ(funnel.left[i]); array2[i] = Funnel.ToXZ(funnel.right[i]); } } Vector2[] array3 = array; int num = Funnel.FixFunnel(ref array, ref array2); List <Vector3> list = funnel.left; List <Vector3> list2 = funnel.right; if (array3 != array) { list = funnel.right; list2 = funnel.left; } List <int> list3 = ListPool <int> .Claim(); if (num == -1) { list3.Add(0); list3.Add(funnel.left.Count - 1); } else { bool flag; Funnel.Calculate(array, array2, num, list3, int.MaxValue, out flag); } List <Vector3> list4 = ListPool <Vector3> .Claim(list3.Count); Vector2 p = array[0]; int num2 = 0; for (int j = 0; j < list3.Count; j++) { int num3 = list3[j]; if (splitAtEveryPortal) { Vector2 vector = (num3 >= 0) ? array[num3] : array2[-num3]; for (int k = num2 + 1; k < Math.Abs(num3); k++) { float t = VectorMath.LineIntersectionFactorXZ(Funnel.FromXZ(array[k]), Funnel.FromXZ(array2[k]), Funnel.FromXZ(p), Funnel.FromXZ(vector)); list4.Add(Vector3.Lerp(list[k], list2[k], t)); } num2 = Mathf.Abs(num3); p = vector; } if (num3 >= 0) { list4.Add(list[num3]); } else { list4.Add(list2[-num3]); } } ListPool <Vector3> .Release(funnel.left); ListPool <Vector3> .Release(funnel.right); ListPool <int> .Release(list3); return(list4); }
// Token: 0x06002797 RID: 10135 RVA: 0x001B2B78 File Offset: 0x001B0D78 public static List <Vector3> Calculate(Funnel.FunnelPortals funnel, bool unwrap, bool splitAtEveryPortal) { if (funnel.left.Count != funnel.right.Count) { throw new ArgumentException("funnel.left.Count != funnel.right.Count"); } Vector2[] array = ArrayPool <Vector2> .Claim(funnel.left.Count); Vector2[] array2 = ArrayPool <Vector2> .Claim(funnel.left.Count); if (unwrap) { Funnel.Unwrap(funnel, array, array2); } else { for (int i = 0; i < funnel.left.Count; i++) { array[i] = Funnel.ToXZ(funnel.left[i]); array2[i] = Funnel.ToXZ(funnel.right[i]); } } int num = Funnel.FixFunnel(array, array2, funnel.left.Count); List <int> list = ListPool <int> .Claim(); if (num == -1) { list.Add(0); list.Add(funnel.left.Count - 1); } else { bool flag; Funnel.Calculate(array, array2, funnel.left.Count, num, list, int.MaxValue, out flag); } List <Vector3> list2 = ListPool <Vector3> .Claim(list.Count); Vector2 p = array[0]; int num2 = 0; for (int j = 0; j < list.Count; j++) { int num3 = list[j]; if (splitAtEveryPortal) { Vector2 vector = (num3 >= 0) ? array[num3] : array2[-num3]; for (int k = num2 + 1; k < Math.Abs(num3); k++) { float t = VectorMath.LineIntersectionFactorXZ(Funnel.FromXZ(array[k]), Funnel.FromXZ(array2[k]), Funnel.FromXZ(p), Funnel.FromXZ(vector)); list2.Add(Vector3.Lerp(funnel.left[k], funnel.right[k], t)); } num2 = Mathf.Abs(num3); p = vector; } if (num3 >= 0) { list2.Add(funnel.left[num3]); } else { list2.Add(funnel.right[-num3]); } } ListPool <int> .Release(ref list); ArrayPool <Vector2> .Release(ref array, false); ArrayPool <Vector2> .Release(ref array2, false); return(list2); }