public void InternalOnPostScan() { #if !ASTAR_NO_POINT_GRAPH if (AstarPath.active.astarData.pointGraph == null) { AstarPath.active.astarData.AddGraph(new PointGraph()); } //Get nearest nodes from the first point graph, assuming both start and end transforms are nodes startNode = AstarPath.active.astarData.pointGraph.AddNode(new NodeLink3Node(AstarPath.active), (Int3)StartTransform.position); //AstarPath.active.astarData.pointGraph.GetNearest(StartTransform.position).node as PointNode; startNode.link = this; endNode = AstarPath.active.astarData.pointGraph.AddNode(new NodeLink3Node(AstarPath.active), (Int3)EndTransform.position); //AstarPath.active.astarData.pointGraph.GetNearest(EndTransform.position).node as PointNode; endNode.link = this; #else throw new System.Exception("Point graphs are not included. Check your A* Optimization settings."); #endif connectedNode1 = null; connectedNode2 = null; if (startNode == null || endNode == null) { startNode = null; endNode = null; return; } postScanCalled = true; reference[startNode] = this; reference[endNode] = this; Apply(true); }
public void InternalOnPostScan() { if (AstarPath.active.astarData.pointGraph == null) { AstarPath.active.astarData.AddGraph(new PointGraph()); } this.startNode = AstarPath.active.astarData.pointGraph.AddNode <NodeLink3Node>(new NodeLink3Node(AstarPath.active), (Int3)this.StartTransform.position); this.startNode.link = this; this.endNode = AstarPath.active.astarData.pointGraph.AddNode <NodeLink3Node>(new NodeLink3Node(AstarPath.active), (Int3)this.EndTransform.position); this.endNode.link = this; this.connectedNode1 = null; this.connectedNode2 = null; if ((this.startNode == null) || (this.endNode == null)) { this.startNode = null; this.endNode = null; } else { this.postScanCalled = true; reference[this.startNode] = this; reference[this.endNode] = this; this.Apply(true); } }
public void InternalOnPostScan() { if (AstarPath.active.astarData.pointGraph == null) { AstarPath.active.astarData.AddGraph(new PointGraph()); } //Get nearest nodes from the first point graph, assuming both start and end transforms are nodes startNode = AstarPath.active.astarData.pointGraph.AddNode(new NodeLink3Node(AstarPath.active), (Int3)StartTransform.position); //AstarPath.active.astarData.pointGraph.GetNearest(StartTransform.position).node as PointNode; startNode.link = this; endNode = AstarPath.active.astarData.pointGraph.AddNode(new NodeLink3Node(AstarPath.active), (Int3)EndTransform.position); //AstarPath.active.astarData.pointGraph.GetNearest(EndTransform.position).node as PointNode; endNode.link = this; connectedNode1 = null; connectedNode2 = null; if (startNode == null || endNode == null) { startNode = null; endNode = null; return; } postScanCalled = true; reference[startNode] = this; reference[endNode] = this; Apply(true); }
public bool GetPortal(GraphNode _other, System.Collections.Generic.List <Vector3> left, System.Collections.Generic.List <Vector3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; //If the nodes are in different graphs, this function has no idea on how to find a shared edge. if (_other.GraphIndex != GraphIndex) { return(false); } TriangleMeshNode other = _other as TriangleMeshNode; if (!backwards) { int first = -1; int second = -1; int av = GetVertexCount(); int bv = other.GetVertexCount(); /** \todo Maybe optimize with pa=av-1 instead of modulus... */ for (int a = 0; a < av; a++) { int va = GetVertexIndex(a); for (int b = 0; b < bv; b++) { if (va == other.GetVertexIndex((b + 1) % bv) && GetVertexIndex((a + 1) % av) == other.GetVertexIndex(b)) { first = a; second = b; a = av; break; } } } aIndex = first; bIndex = second; if (first != -1) { if (left != null) { //All triangles should be clockwise so second is the rightmost vertex (seen from this node) left.Add((Vector3)GetVertex(first)); right.Add((Vector3)GetVertex((first + 1) % av)); } } else { for (int i = 0; i < connections.Length; i++) { if (connections[i].GraphIndex != GraphIndex) { NodeLink3Node mid = connections[i] as NodeLink3Node; if (mid != null && mid.GetOther(this) == other) { // We have found a node which is connected through a NodeLink3Node if (left != null) { mid.GetPortal(other, left, right, false); return(true); } } } } return(false); } } return(true); }
public bool GetPortal(GraphNode _other, System.Collections.Generic.List <Vector3> left, System.Collections.Generic.List <Vector3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; //If the nodes are in different graphs, this function has no idea on how to find a shared edge. if (_other.GraphIndex != GraphIndex) { return(false); } TriangleMeshNode other = _other as TriangleMeshNode; //Get tile indices int tileIndex = (GetVertexIndex(0) >> RecastGraph.TileIndexOffset) & RecastGraph.TileIndexMask; int tileIndex2 = (other.GetVertexIndex(0) >> RecastGraph.TileIndexOffset) & RecastGraph.TileIndexMask; //When the nodes are in different tiles, the edges might not be completely identical //so another technique is needed //Only do this on recast graphs if (tileIndex != tileIndex2 && (GetNavmeshHolder(GraphIndex) is RecastGraph)) { for (int i = 0; i < connections.Length; i++) { if (connections[i].GraphIndex != GraphIndex) { #if !ASTAR_NO_POINT_GRAPH NodeLink3Node mid = connections[i] as NodeLink3Node; if (mid != null && mid.GetOther(this) == other) { // We have found a node which is connected through a NodeLink3Node if (left != null) { mid.GetPortal(other, left, right, false); return(true); } } #endif } } //Get the tile coordinates, from them we can figure out which edge is going to be shared int x1, x2, z1, z2; int coord; INavmeshHolder nm = GetNavmeshHolder(GraphIndex); nm.GetTileCoordinates(tileIndex, out x1, out z1); nm.GetTileCoordinates(tileIndex2, out x2, out z2); if (System.Math.Abs(x1 - x2) == 1) { coord = 0; } else if (System.Math.Abs(z1 - z2) == 1) { coord = 2; } else { throw new System.Exception("Tiles not adjacent (" + x1 + ", " + z1 + ") (" + x2 + ", " + z2 + ")"); } int av = GetVertexCount(); int bv = other.GetVertexCount(); //Try the X and Z coordinate. For one of them the coordinates should be equal for one of the two nodes' edges //The midpoint between the tiles is the only place where they will be equal int first = -1, second = -1; //Find the shared edge for (int a = 0; a < av; a++) { int va = GetVertex(a)[coord]; for (int b = 0; b < bv; b++) { if (va == other.GetVertex((b + 1) % bv)[coord] && GetVertex((a + 1) % av)[coord] == other.GetVertex(b)[coord]) { first = a; second = b; a = av; break; } } } aIndex = first; bIndex = second; if (first != -1) { Int3 a = GetVertex(first); Int3 b = GetVertex((first + 1) % av); //The coordinate which is not the same for the vertices int ocoord = coord == 2 ? 0 : 2; //When the nodes are in different tiles, they might not share exactly the same edge //so we clamp the portal to the segment of the edges which they both have. int mincoord = System.Math.Min(a[ocoord], b[ocoord]); int maxcoord = System.Math.Max(a[ocoord], b[ocoord]); mincoord = System.Math.Max(mincoord, System.Math.Min(other.GetVertex(second)[ocoord], other.GetVertex((second + 1) % bv)[ocoord])); maxcoord = System.Math.Min(maxcoord, System.Math.Max(other.GetVertex(second)[ocoord], other.GetVertex((second + 1) % bv)[ocoord])); if (a[ocoord] < b[ocoord]) { a[ocoord] = mincoord; b[ocoord] = maxcoord; } else { a[ocoord] = maxcoord; b[ocoord] = mincoord; } if (left != null) { //All triangles should be clockwise so second is the rightmost vertex (seen from this node) left.Add((Vector3)a); right.Add((Vector3)b); } return(true); } } else if (!backwards) { int first = -1; int second = -1; int av = GetVertexCount(); int bv = other.GetVertexCount(); /** \todo Maybe optimize with pa=av-1 instead of modulus... */ for (int a = 0; a < av; a++) { int va = GetVertexIndex(a); for (int b = 0; b < bv; b++) { if (va == other.GetVertexIndex((b + 1) % bv) && GetVertexIndex((a + 1) % av) == other.GetVertexIndex(b)) { first = a; second = b; a = av; break; } } } aIndex = first; bIndex = second; if (first != -1) { if (left != null) { //All triangles should be clockwise so second is the rightmost vertex (seen from this node) left.Add((Vector3)GetVertex(first)); right.Add((Vector3)GetVertex((first + 1) % av)); } } else { for (int i = 0; i < connections.Length; i++) { if (connections[i].GraphIndex != GraphIndex) { #if !ASTAR_NO_POINT_GRAPH NodeLink3Node mid = connections[i] as NodeLink3Node; if (mid != null && mid.GetOther(this) == other) { // We have found a node which is connected through a NodeLink3Node if (left != null) { mid.GetPortal(other, left, right, false); return(true); } } #endif } } return(false); } } return(true); }
public void InternalOnPostScan () { if ( AstarPath.active.astarData.pointGraph == null ) { AstarPath.active.astarData.AddGraph ( new PointGraph () ); } //Get nearest nodes from the first point graph, assuming both start and end transforms are nodes startNode = AstarPath.active.astarData.pointGraph.AddNode ( new NodeLink3Node(AstarPath.active), (Int3)StartTransform.position );//AstarPath.active.astarData.pointGraph.GetNearest(StartTransform.position).node as PointNode; startNode.link = this; endNode = AstarPath.active.astarData.pointGraph.AddNode ( new NodeLink3Node(AstarPath.active), (Int3)EndTransform.position ); //AstarPath.active.astarData.pointGraph.GetNearest(EndTransform.position).node as PointNode; endNode.link = this; connectedNode1 = null; connectedNode2 = null; if (startNode == null || endNode == null) { startNode = null; endNode = null; return; } postScanCalled = true; reference[startNode] = this; reference[endNode] = this; Apply( true ); }
public bool GetPortal(GraphNode _other, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; if (_other.GraphIndex != base.GraphIndex) { return(false); } TriangleMeshNode triangleMeshNode = _other as TriangleMeshNode; int num = this.GetVertexIndex(0) >> 12 & 524287; int num2 = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287; if (num != num2 && TriangleMeshNode.GetNavmeshHolder(base.GraphIndex) is RecastGraph) { for (int i = 0; i < this.connections.Length; i++) { if (this.connections[i].GraphIndex != base.GraphIndex) { NodeLink3Node nodeLink3Node = this.connections[i] as NodeLink3Node; if (nodeLink3Node != null && nodeLink3Node.GetOther(this) == triangleMeshNode && left != null) { nodeLink3Node.GetPortal(triangleMeshNode, left, right, false); return(true); } } } INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); int num3; int num4; navmeshHolder.GetTileCoordinates(num, out num3, out num4); int num5; int num6; navmeshHolder.GetTileCoordinates(num2, out num5, out num6); int num7; if (Math.Abs(num3 - num5) == 1) { num7 = 0; } else { if (Math.Abs(num4 - num6) != 1) { throw new Exception(string.Concat(new object[] { "Tiles not adjacent (", num3, ", ", num4, ") (", num5, ", ", num6, ")" })); } num7 = 2; } int vertexCount = this.GetVertexCount(); int vertexCount2 = triangleMeshNode.GetVertexCount(); int num8 = -1; int num9 = -1; for (int j = 0; j < vertexCount; j++) { int num10 = this.GetVertex(j)[num7]; for (int k = 0; k < vertexCount2; k++) { if (num10 == triangleMeshNode.GetVertex((k + 1) % vertexCount2)[num7] && this.GetVertex((j + 1) % vertexCount)[num7] == triangleMeshNode.GetVertex(k)[num7]) { num8 = j; num9 = k; j = vertexCount; break; } } } aIndex = num8; bIndex = num9; if (num8 != -1) { Int3 vertex = this.GetVertex(num8); Int3 vertex2 = this.GetVertex((num8 + 1) % vertexCount); int i2 = (num7 != 2) ? 2 : 0; int num11 = Math.Min(vertex[i2], vertex2[i2]); int num12 = Math.Max(vertex[i2], vertex2[i2]); num11 = Math.Max(num11, Math.Min(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2])); num12 = Math.Min(num12, Math.Max(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2])); if (vertex[i2] < vertex2[i2]) { vertex[i2] = num11; vertex2[i2] = num12; } else { vertex[i2] = num12; vertex2[i2] = num11; } if (left != null) { left.Add((Vector3)vertex); right.Add((Vector3)vertex2); } return(true); } } else if (!backwards) { int num13 = -1; int num14 = -1; int vertexCount3 = this.GetVertexCount(); int vertexCount4 = triangleMeshNode.GetVertexCount(); for (int l = 0; l < vertexCount3; l++) { int vertexIndex = this.GetVertexIndex(l); for (int m = 0; m < vertexCount4; m++) { if (vertexIndex == triangleMeshNode.GetVertexIndex((m + 1) % vertexCount4) && this.GetVertexIndex((l + 1) % vertexCount3) == triangleMeshNode.GetVertexIndex(m)) { num13 = l; num14 = m; l = vertexCount3; break; } } } aIndex = num13; bIndex = num14; if (num13 == -1) { for (int n = 0; n < this.connections.Length; n++) { if (this.connections[n].GraphIndex != base.GraphIndex) { NodeLink3Node nodeLink3Node2 = this.connections[n] as NodeLink3Node; if (nodeLink3Node2 != null && nodeLink3Node2.GetOther(this) == triangleMeshNode && left != null) { nodeLink3Node2.GetPortal(triangleMeshNode, left, right, false); return(true); } } } return(false); } if (left != null) { left.Add((Vector3)this.GetVertex(num13)); right.Add((Vector3)this.GetVertex((num13 + 1) % vertexCount3)); } } return(true); }
public void InternalOnPostScan () { #if !ASTAR_NO_POINT_GRAPH if ( AstarPath.active.astarData.pointGraph == null ) { AstarPath.active.astarData.AddGraph ( new PointGraph () ); } //Get nearest nodes from the first point graph, assuming both start and end transforms are nodes startNode = AstarPath.active.astarData.pointGraph.AddNode ( new NodeLink3Node(AstarPath.active), (Int3)StartTransform.position );//AstarPath.active.astarData.pointGraph.GetNearest(StartTransform.position).node as PointNode; startNode.link = this; endNode = AstarPath.active.astarData.pointGraph.AddNode ( new NodeLink3Node(AstarPath.active), (Int3)EndTransform.position ); //AstarPath.active.astarData.pointGraph.GetNearest(EndTransform.position).node as PointNode; endNode.link = this; #else throw new System.Exception ("Point graphs are not included. Check your A* Optimization settings."); #endif connectedNode1 = null; connectedNode2 = null; if (startNode == null || endNode == null) { startNode = null; endNode = null; return; } postScanCalled = true; reference[startNode] = this; reference[endNode] = this; Apply( true ); }
// Token: 0x060025FE RID: 9726 RVA: 0x001A6C10 File Offset: 0x001A4E10 public bool GetPortal(GraphNode toNode, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; if (backwards || toNode.GraphIndex != base.GraphIndex) { return(false); } TriangleMeshNode triangleMeshNode = toNode as TriangleMeshNode; int num = this.SharedEdge(triangleMeshNode); if (num == 255) { return(false); } if (num == -1) { for (int i = 0; i < this.connections.Length; i++) { if (this.connections[i].node.GraphIndex != base.GraphIndex) { NodeLink3Node nodeLink3Node = this.connections[i].node as NodeLink3Node; if (nodeLink3Node != null && nodeLink3Node.GetOther(this) == triangleMeshNode) { nodeLink3Node.GetPortal(triangleMeshNode, left, right, false); return(true); } } } return(false); } aIndex = num; bIndex = (num + 1) % this.GetVertexCount(); Int3 vertex = this.GetVertex(num); Int3 vertex2 = this.GetVertex((num + 1) % this.GetVertexCount()); int num2 = this.GetVertexIndex(0) >> 12 & 524287; int num3 = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287; if (num2 != num3) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); int num4; int num5; navmeshHolder.GetTileCoordinates(num2, out num4, out num5); int num6; int num7; navmeshHolder.GetTileCoordinates(num3, out num6, out num7); int i2; if (Math.Abs(num4 - num6) == 1) { i2 = 2; } else { if (Math.Abs(num5 - num7) != 1) { return(false); } i2 = 0; } int num8 = triangleMeshNode.SharedEdge(this); if (num8 == 255) { throw new Exception("Connection used edge in one direction, but not in the other direction. Has the wrong overload of AddConnection been used?"); } if (num8 != -1) { int num9 = Math.Min(vertex[i2], vertex2[i2]); int num10 = Math.Max(vertex[i2], vertex2[i2]); Int3 vertex3 = triangleMeshNode.GetVertex(num8); Int3 vertex4 = triangleMeshNode.GetVertex((num8 + 1) % triangleMeshNode.GetVertexCount()); num9 = Math.Max(num9, Math.Min(vertex3[i2], vertex4[i2])); num10 = Math.Min(num10, Math.Max(vertex3[i2], vertex4[i2])); if (vertex[i2] < vertex2[i2]) { vertex[i2] = num9; vertex2[i2] = num10; } else { vertex[i2] = num10; vertex2[i2] = num9; } } } if (left != null) { left.Add((Vector3)vertex); right.Add((Vector3)vertex2); } return(true); }
public bool GetPortal(GraphNode _other, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; if (_other.GraphIndex != base.GraphIndex) { return(false); } TriangleMeshNode other = _other as TriangleMeshNode; int tileIndex = (this.GetVertexIndex(0) >> 12) & 0x7ffff; int num2 = (other.GetVertexIndex(0) >> 12) & 0x7ffff; if ((tileIndex != num2) && (GetNavmeshHolder(base.GraphIndex) is RecastGraph)) { int num4; int num5; int num6; int num7; int num8; for (int i = 0; i < base.connections.Length; i++) { if (base.connections[i].GraphIndex != base.GraphIndex) { NodeLink3Node node2 = base.connections[i] as NodeLink3Node; if (((node2 != null) && (node2.GetOther(this) == other)) && (left != null)) { node2.GetPortal(other, left, right, false); return(true); } } } INavmeshHolder navmeshHolder = GetNavmeshHolder(base.GraphIndex); navmeshHolder.GetTileCoordinates(tileIndex, out num4, out num6); navmeshHolder.GetTileCoordinates(num2, out num5, out num7); if (Math.Abs((int)(num4 - num5)) == 1) { num8 = 0; } else if (Math.Abs((int)(num6 - num7)) == 1) { num8 = 2; } else { object[] objArray1 = new object[] { "Tiles not adjacent (", num4, ", ", num6, ") (", num5, ", ", num7, ")" }; throw new Exception(string.Concat(objArray1)); } int vertexCount = this.GetVertexCount(); int num10 = other.GetVertexCount(); int num11 = -1; int num12 = -1; for (int j = 0; j < vertexCount; j++) { int num14 = this.GetVertex(j)[num8]; for (int k = 0; k < num10; k++) { if ((num14 == other.GetVertex((k + 1) % num10)[num8]) && (this.GetVertex((j + 1) % vertexCount)[num8] == other.GetVertex(k)[num8])) { num11 = j; num12 = k; j = vertexCount; break; } } } aIndex = num11; bIndex = num12; if (num11 != -1) { Int3 vertex = this.GetVertex(num11); Int3 num17 = this.GetVertex((num11 + 1) % vertexCount); int num18 = (num8 != 2) ? 2 : 0; int num19 = Math.Min(vertex[num18], num17[num18]); int num20 = Math.Max(vertex[num18], num17[num18]); num19 = Math.Max(num19, Math.Min(other.GetVertex(num12)[num18], other.GetVertex((num12 + 1) % num10)[num18])); num20 = Math.Min(num20, Math.Max(other.GetVertex(num12)[num18], other.GetVertex((num12 + 1) % num10)[num18])); if (vertex[num18] < num17[num18]) { vertex[num18] = num19; num17[num18] = num20; } else { vertex[num18] = num20; num17[num18] = num19; } if (left != null) { left.Add((Vector3)vertex); right.Add((Vector3)num17); } return(true); } } else if (!backwards) { int num21 = -1; int num22 = -1; int num23 = this.GetVertexCount(); int num24 = other.GetVertexCount(); for (int m = 0; m < num23; m++) { int vertexIndex = this.GetVertexIndex(m); for (int n = 0; n < num24; n++) { if ((vertexIndex == other.GetVertexIndex((n + 1) % num24)) && (this.GetVertexIndex((m + 1) % num23) == other.GetVertexIndex(n))) { num21 = m; num22 = n; m = num23; break; } } } aIndex = num21; bIndex = num22; if (num21 == -1) { for (int num28 = 0; num28 < base.connections.Length; num28++) { if (base.connections[num28].GraphIndex != base.GraphIndex) { NodeLink3Node node3 = base.connections[num28] as NodeLink3Node; if (((node3 != null) && (node3.GetOther(this) == other)) && (left != null)) { node3.GetPortal(other, left, right, false); return(true); } } } return(false); } if (left != null) { left.Add((Vector3)this.GetVertex(num21)); right.Add((Vector3)this.GetVertex((num21 + 1) % num23)); } } return(true); }