public override void Apply(Path p) { if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0) { return; } List <Vector3> funnelPath = ListPool <Vector3> .Claim(); var parts = Funnel.SplitIntoParts(p); for (int i = 0; i < parts.Count; i++) { var part = parts[i]; if (!part.isLink) { var portals = Funnel.ConstructFunnelPortals(p.path, part); var result = Funnel.Calculate(portals, unwrap, splitAtEveryPortal); funnelPath.AddRange(result); ListPool <Vector3> .Release(result); } } ListPool <Funnel.PathPart> .Release(parts); ListPool <Vector3> .Release(p.vectorPath); p.vectorPath = funnelPath; }
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 pathPart = list2[i]; if (!pathPart.isLink) { List <Vector3> list3 = Funnel.Calculate(Funnel.ConstructFunnelPortals(p.path, pathPart), this.unwrap, this.splitAtEveryPortal); list.AddRange(list3); ListPool <Vector3> .Release(list3); } } ListPool <Funnel.PathPart> .Release(list2); ListPool <Vector3> .Release(p.vectorPath); p.vectorPath = list; }
public override void Apply(Path p) { if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0) { return; } List <Vector3> funnelPath = ListPool <Vector3> .Claim(); // Split the path into different parts (separated by custom links) // and run the funnel algorithm on each of them in turn var parts = Funnel.SplitIntoParts(p); for (int i = 0; i < parts.Count; i++) { var part = parts[i]; if (!part.isLink) { var portals = Funnel.ConstructFunnelPortals(p.path, part); var result = Funnel.Calculate(portals, unwrap, splitAtEveryPortal); funnelPath.AddRange(result); ListPool <Vector3> .Release(result); } } ListPool <Funnel.PathPart> .Release(parts); // Pool the previous vectorPath ListPool <Vector3> .Release(p.vectorPath); p.vectorPath = funnelPath; }
// 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 override void Apply(Path p) { if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0) { return; } List <Vector3> funnelPath = ListPool <Vector3> .Claim(); // Split the path into different parts (separated by custom links) // and run the funnel algorithm on each of them in turn var parts = Funnel.SplitIntoParts(p); if (parts.Count == 0) { // As a really special case, it might happen that the path contained only a single node // and that node was part of a custom link (e.g added by the NodeLink2 component). // In that case the SplitIntoParts method will not know what to do with it because it is // neither a link (as only 1 of the 2 nodes of the link was part of the path) nor a normal // path part. So it will skip it. This will cause it to return an empty list. // In that case we want to simply keep the original path, which is just a single point. return; } for (int i = 0; i < parts.Count; i++) { var part = parts[i]; if (!part.isLink) { var portals = Funnel.ConstructFunnelPortals(p.path, part); var result = Funnel.Calculate(portals, unwrap, splitAtEveryPortal); funnelPath.AddRange(result); ListPool <Vector3> .Release(ref portals.left); ListPool <Vector3> .Release(ref portals.right); ListPool <Vector3> .Release(ref result); } else { // non-link parts will add the start/end points for the adjacent parts. // So if there is no non-link part before this one, then we need to add the start point of the link // and if there is no non-link part after this one, then we need to add the end point. if (i == 0 || parts[i - 1].isLink) { funnelPath.Add(part.startPoint); } if (i == parts.Count - 1 || parts[i + 1].isLink) { funnelPath.Add(part.endPoint); } } } UnityEngine.Assertions.Assert.IsTrue(funnelPath.Count >= 1); ListPool <Funnel.PathPart> .Release(ref parts); // Pool the previous vectorPath ListPool <Vector3> .Release(ref p.vectorPath); p.vectorPath = funnelPath; }
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); }