public void ConstructFunnel(IFunnelGraph funnelGraph, Vector3[] vectorPath, Node[] path, int sIndex, int eIndex, List <Vector3> funnelPath, List <Vector3> left, List <Vector3> right) { //Construct a funnel corridor for the nodes in the path segment left.Clear(); right.Clear(); left.Add(vectorPath[sIndex]); right.Add(vectorPath[sIndex]); funnelGraph.BuildFunnelCorridor(path, sIndex, eIndex, left, right); left.Add(vectorPath[eIndex]); right.Add(vectorPath[eIndex]); if (!RunFunnel(left, right, funnelPath)) { //Add the start and end positions to the path funnelPath.Add(vectorPath[sIndex]); funnelPath.Add(vectorPath[eIndex]); //If the funnel failed (probably too short), add the individual positions instead //for (int j=sIndex;j<=eIndex;j++) { // funnelPath.Add (path[j].position); //} } lastLeftFunnel = left.ToArray(); lastRightFunnel = right.ToArray(); }
public RichFunnel() { this.left = ListPool<Vector3>.Claim(); this.right = ListPool<Vector3>.Claim(); this.nodes = new List<TriangleMeshNode>(); this.graph = null; }
public RichFunnel() { left = Pathfinding.Util.ListPool <Vector3> .Claim(); right = Pathfinding.Util.ListPool <Vector3> .Claim(); nodes = new List <TriangleMeshNode>(); this.graph = null; }
public RichFunnel() { this.left = ListPool <Vector3> .Claim(); this.right = ListPool <Vector3> .Claim(); this.nodes = new List <TriangleMeshNode>(); this.graph = null; }
public override void OnEnterPool() { this.left.Clear(); this.right.Clear(); this.nodes.Clear(); this.graph = null; this.currentNode = 0; this.checkForDestroyedNodesCounter = 0; }
public override void OnEnterPool() { left.Clear(); right.Clear(); nodes.Clear(); graph = null; currentNode = 0; tmpCounter = 0; }
public override void OnEnterPool() { left.Clear(); right.Clear(); nodes.Clear(); graph = null; currentNode = 0; checkForDestroyedNodesCounter = 0; }
public RichFunnel Initialize(RichPath path, IFunnelGraph graph) { if (graph == null) { throw new ArgumentNullException("graph"); } if (this.graph != null) { throw new InvalidOperationException("Trying to initialize an already initialized object. " + graph); } this.graph = graph; this.path = path; return(this); }
public override void Apply(Path p, ModifierData source) { Node[] path = p.path; Vector3[] vectorPath = p.vectorPath; if (path == null || path.Length == 0 || vectorPath == null || vectorPath.Length != path.Length) { return; } //The graph index for the current nodes int currentGraphIndex = path[0].graphIndex; //First node which is in the graph currentGraphIndex int currentGraphStart = 0; List <Vector3> funnelPath = new List <Vector3> (); List <Vector3> left = new List <Vector3> (); List <Vector3> right = new List <Vector3> (); for (int i = 0; i < path.Length; i++) { if (path[i].graphIndex != currentGraphIndex) { IFunnelGraph funnelGraph = AstarData.GetGraph(path[currentGraphStart]) as IFunnelGraph; if (funnelGraph == null) { //Debug.Log ("Funnel Graph is null"); for (int j = currentGraphStart; j <= i; j++) { funnelPath.Add((Vector3)path[j].position); } } else { ConstructFunnel(funnelGraph, vectorPath, path, currentGraphStart, i - 1, funnelPath, left, right); } currentGraphIndex = path[i].graphIndex; currentGraphStart = i; } } IFunnelGraph funnelGraph2 = AstarData.GetGraph(path[currentGraphStart]) as IFunnelGraph; if (funnelGraph2 == null) { for (int j = currentGraphStart; j < path.Length - 1; j++) { funnelPath.Add((Vector3)path[j].position); } } else { ConstructFunnel(funnelGraph2, vectorPath, path, currentGraphStart, path.Length - 1, funnelPath, left, right); } p.vectorPath = funnelPath.ToArray(); }
// Token: 0x06000033 RID: 51 RVA: 0x0000417C File Offset: 0x0000257C public void Initialize(Seeker s, Path p, bool mergePartEndpoints, RichFunnel.FunnelSimplification simplificationMode) { if (p.error) { throw new ArgumentException("Path has an error"); } List <GraphNode> path = p.path; if (path.Count == 0) { throw new ArgumentException("Path traverses no nodes"); } this.seeker = s; for (int i = 0; i < this.parts.Count; i++) { if (this.parts[i] is RichFunnel) { ObjectPool <RichFunnel> .Release(this.parts[i] as RichFunnel); } else if (this.parts[i] is RichSpecial) { ObjectPool <RichSpecial> .Release(this.parts[i] as RichSpecial); } } this.parts.Clear(); this.currentPart = 0; for (int j = 0; j < path.Count; j++) { if (path[j] is TriangleMeshNode) { IFunnelGraph graph = AstarData.GetGraph(path[j]) as IFunnelGraph; RichFunnel richFunnel = ObjectPool <RichFunnel> .Claim().Initialize(this, graph); richFunnel.funnelSimplificationMode = simplificationMode; int num = j; uint graphIndex = path[num].GraphIndex; while (j < path.Count) { if (path[j].GraphIndex != graphIndex && !(path[j] is NodeLink3Node)) { break; } j++; } j--; if (num == 0) { richFunnel.exactStart = p.vectorPath[0]; } else if (mergePartEndpoints) { richFunnel.exactStart = (Vector3)path[num - 1].position; } else { richFunnel.exactStart = (Vector3)path[num].position; } if (j == path.Count - 1) { richFunnel.exactEnd = p.vectorPath[p.vectorPath.Count - 1]; } else if (mergePartEndpoints) { richFunnel.exactEnd = (Vector3)path[j + 1].position; } else { richFunnel.exactEnd = (Vector3)path[j].position; } richFunnel.BuildFunnelCorridor(path, num, j); this.parts.Add(richFunnel); } else if (path[j] != null && NodeLink2.GetNodeLink(path[j]) != null) { NodeLink2 nodeLink = NodeLink2.GetNodeLink(path[j]); int num2 = j; uint graphIndex2 = path[num2].GraphIndex; for (j++; j < path.Count; j++) { if (path[j].GraphIndex != graphIndex2) { break; } } j--; if (j - num2 > 1) { throw new Exception("NodeLink2 path length greater than two (2) nodes. " + (j - num2)); } if (j - num2 != 0) { RichSpecial item = ObjectPool <RichSpecial> .Claim().Initialize(nodeLink, path[num2]); this.parts.Add(item); } } } }
/** Use this for initialization. * * \param s May be null if you do not use a Seeker */ public void Initialize(Seeker s, Path p, bool mergePartEndpoints, RichFunnel.FunnelSimplification simplificationMode) { if (p.error) { throw new System.ArgumentException("Path has an error"); } List <GraphNode> nodes = p.path; if (nodes.Count == 0) { throw new System.ArgumentException("Path traverses no nodes"); } seeker = s; // Release objects back to object pool // Yeah, I know, it's casting... but this won't be called much for (int i = 0; i < parts.Count; i++) { if (parts[i] is RichFunnel) { ObjectPool <RichFunnel> .Release(parts[i] as RichFunnel); } else if (parts[i] is RichSpecial) { ObjectPool <RichSpecial> .Release(parts[i] as RichSpecial); } } parts.Clear(); currentPart = 0; // Initialize new //Break path into parts for (int i = 0; i < nodes.Count; i++) { if (nodes[i] is TriangleMeshNode) { IFunnelGraph funnelGraph = AstarData.GetGraph(nodes[i]) as IFunnelGraph; RichFunnel f = ObjectPool <RichFunnel> .Claim().Initialize(this, funnelGraph); f.funnelSimplificationMode = simplificationMode; int sIndex = i; uint currentGraphIndex = nodes[sIndex].GraphIndex; for (; i < nodes.Count; i++) { if (nodes[i].GraphIndex != currentGraphIndex && !(nodes[i] is NodeLink3Node)) { break; } } i--; if (sIndex == 0) { f.exactStart = p.vectorPath[0]; } else { if (mergePartEndpoints) { f.exactStart = (Vector3)nodes[sIndex - 1].position; } else { f.exactStart = (Vector3)nodes[sIndex].position; } } if (i == nodes.Count - 1) { f.exactEnd = p.vectorPath[p.vectorPath.Count - 1]; } else { if (mergePartEndpoints) { f.exactEnd = (Vector3)nodes[i + 1].position; } else { f.exactEnd = (Vector3)nodes[i].position; } } f.BuildFunnelCorridor(nodes, sIndex, i); parts.Add(f); } else if (nodes[i] is Pathfinding.GraphNode && NodeLink2.GetNodeLink(nodes[i]) != null) { NodeLink2 nl = NodeLink2.GetNodeLink(nodes[i]); int sIndex = i; uint currentGraphIndex = nodes[sIndex].GraphIndex; for (i++; i < nodes.Count; i++) { if (nodes[i].GraphIndex != currentGraphIndex) { break; } } i--; if (i - sIndex > 1) { throw new System.Exception("NodeLink2 path length greater than two (2) nodes. " + (i - sIndex)); } else if (i - sIndex == 0) { //Debug.DrawRay ((Vector3)nodes[sIndex].Position, Vector3.up*2, Color.red, 2); //Debug.Log ("!"); //Just continue, it might be the case that a NodeLink was the closest node continue; } RichSpecial rps = ObjectPool <RichSpecial> .Claim().Initialize(nl, nodes[sIndex]); parts.Add(rps); } } }
public override void OnEnterPool () { left.Clear (); right.Clear (); nodes.Clear (); graph = null; currentNode = 0; checkForDestroyedNodesCounter = 0; }
public override void Apply(Path p, ModifierData source) { List <Node> path = p.path; List <Vector3> vectorPath = p.vectorPath; if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count) { return; } //The graph index for the current nodes int currentGraphIndex = path[0].graphIndex; //First node which is in the graph currentGraphIndex int currentGraphStart = 0; List <Vector3> funnelPath = ListPool <Vector3> .Claim(); List <Vector3> left = ListPool <Vector3> .Claim(); List <Vector3> right = ListPool <Vector3> .Claim(); AstarProfiler.StartProfile("Construct Funnel"); for (int i = 0; i < path.Count; i++) { if (path[i].graphIndex != currentGraphIndex) { IFunnelGraph funnelGraph = AstarData.GetGraph(path[currentGraphStart]) as IFunnelGraph; if (funnelGraph == null) { //Debug.Log ("Funnel Graph is null"); for (int j = currentGraphStart; j <= i; j++) { funnelPath.Add((Vector3)path[j].position); } } else { AstarProfiler.StartProfile("Construct Funnel Real"); ConstructFunnel(funnelGraph, vectorPath, path, currentGraphStart, i - 1, funnelPath, left, right); AstarProfiler.EndProfile(); } currentGraphIndex = path[i].graphIndex; currentGraphStart = i; } } IFunnelGraph funnelGraph2 = AstarData.GetGraph(path[currentGraphStart]) as IFunnelGraph; if (funnelGraph2 == null) { for (int j = currentGraphStart; j < path.Count - 1; j++) { funnelPath.Add((Vector3)path[j].position); } } else { AstarProfiler.StartProfile("Construct Funnel Real"); ConstructFunnel(funnelGraph2, vectorPath, path, currentGraphStart, path.Count - 1, funnelPath, left, right); AstarProfiler.EndProfile(); } AstarProfiler.EndProfile(); ListPool <Vector3> .Release(p.vectorPath); p.vectorPath = funnelPath; ListPool <Vector3> .Release(left); ListPool <Vector3> .Release(right); }
/** Works like a constructor, but can be used even for pooled objects. Returns \a this for easy chaining */ public RichFunnel Initialize (RichPath path, IFunnelGraph graph) { if (graph == null) throw new System.ArgumentNullException ("graph"); if (this.graph != null) throw new System.InvalidOperationException ("Trying to initialize an already initialized object. " + graph); this.graph = graph; this.path = path; return this; }
public RichFunnel () { left = Pathfinding.Util.ListPool<Vector3>.Claim(); right = Pathfinding.Util.ListPool<Vector3>.Claim(); nodes = new List<TriangleMeshNode>(); this.graph = null; }
public override void OnEnterPool () { left.Clear (); right.Clear (); nodes.Clear (); graph = null; currentNode = 0; tmpCounter = 0; }
public void ConstructFunnel(IFunnelGraph funnelGraph, Vector3[] vectorPath, Node[] path, int sIndex, int eIndex, List<Vector3> funnelPath, List<Vector3> left, List<Vector3> right) { //Construct a funnel corridor for the nodes in the path segment left.Clear (); right.Clear (); left.Add (vectorPath[sIndex]); right.Add (vectorPath[sIndex]); funnelGraph.BuildFunnelCorridor (path,sIndex, eIndex, left, right); left.Add (vectorPath[eIndex]); right.Add (vectorPath[eIndex]); if (!RunFunnel (left,right,funnelPath)) { //Add the start and end positions to the path funnelPath.Add (vectorPath[sIndex]); funnelPath.Add (vectorPath[eIndex]); //If the funnel failed (probably too short), add the individual positions instead //for (int j=sIndex;j<=eIndex;j++) { // funnelPath.Add (path[j].position); //} } lastLeftFunnel = left.ToArray (); lastRightFunnel = right.ToArray (); }