public void RecalculateConnections(QuadtreeNodeHolder holder, int depth, int x, int y) { if (this.root == null) { throw new InvalidOperationException("Graph contains no nodes"); } if (holder.node == null) { throw new ArgumentException("No leaf node specified. Holder has no node."); } int num = 1 << Math.Min(this.editorHeightLog2, this.editorWidthLog2) - depth; ListLinqView <QuadtreeNode> listLinqView = new ListLinqView <QuadtreeNode>(); ListView <QuadtreeNode> arg_75_1 = listLinqView; QuadtreeNodeHolder arg_75_2 = this.root; int arg_75_3 = 0; int arg_75_4 = 0; int arg_75_5 = 0; IntRect intRect = new IntRect(x, y, x + num, y + num); this.AddNeighboursRec(arg_75_1, arg_75_2, arg_75_3, arg_75_4, arg_75_5, intRect.Expand(0), holder.node); holder.node.connections = listLinqView.ToArray(); holder.node.connectionCosts = new uint[listLinqView.Count]; for (int i = 0; i < listLinqView.Count; i++) { uint costMagnitude = (uint)(listLinqView[i].position - holder.node.position).costMagnitude; holder.node.connectionCosts[i] = costMagnitude; } }
public TValue[] GetAllValueArray() { ListLinqView <TValue> view = new ListLinqView <TValue>(); DictionaryView <TKey, HashSet <TValue> > .Enumerator enumerator = base.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <TKey, HashSet <TValue> > current = enumerator.Current; HashSet <TValue> set = current.Value; if (set != null) { IEnumerator enumerator2 = set.GetEnumerator(); while (enumerator2.MoveNext()) { TValue item = (TValue)enumerator2.Current; view.Add(item); } } } return(view.ToArray()); }
public TValue[] GetAllValueArray() { ListLinqView <TValue> listLinqView = new ListLinqView <TValue>(); DictionaryView <TKey, HashSet <TValue> > .Enumerator enumerator = base.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <TKey, HashSet <TValue> > current = enumerator.get_Current(); HashSet <TValue> value = current.get_Value(); if (value != null) { IEnumerator enumerator2 = value.GetEnumerator(); while (enumerator2.MoveNext()) { TValue tValue = (TValue)((object)enumerator2.get_Current()); listLinqView.Add(tValue); } } } return(listLinqView.ToArray()); }
public TValue[] GetValuesAll() { ListLinqView <TValue> view = new ListLinqView <TValue>(); DictionaryView <TKey, ListView <TValue> > .Enumerator enumerator = base.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <TKey, ListView <TValue> > current = enumerator.Current; ListView <TValue> view2 = current.Value; if (view2 != null) { IEnumerator enumerator2 = view2.GetEnumerator(); while (enumerator2.MoveNext()) { TValue item = (TValue)enumerator2.Current; view.Add(item); } } } return(view.ToArray()); }
public HttpReq PackRequest() { RequestLine requestLine = new RequestLine(); requestLine.szRequestMethod = this.method; requestLine.szRequestUri = this.URL; requestLine.szHttpVersion = this.version; ListLinqView <HeaderUnit> listLinqView = new ListLinqView <HeaderUnit>(); using (Dictionary <string, string> .Enumerator enumerator = this.headers.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <string, string> current = enumerator.get_Current(); byte[] bytes = Encoding.get_UTF8().GetBytes(current.get_Key()); byte[] bytes2 = Encoding.get_UTF8().GetBytes(current.get_Value()); listLinqView.Add(new HeaderUnit { szHeaderName = bytes, szHeaderContent = bytes2 }); } } HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.astHeaderUnit = listLinqView.ToArray(); httpHeaders.dwHeaderCount = (uint)httpHeaders.astHeaderUnit.Length; RequestContent requestContent = new RequestContent(); requestContent.szData = this.data; requestContent.dwDataLen = (uint)this.data.Length; HttpReq httpReq = new HttpReq(); httpReq.stRequestLine = requestLine; httpReq.stHttpHeaders = httpHeaders; httpReq.stRequestContent = requestContent; ADebug.Log("send request :" + this.ToString()); return(httpReq); }
public void RecalculateConnections(QuadtreeNodeHolder holder, int depth, int x, int y) { if (this.root == null) { throw new InvalidOperationException("Graph contains no nodes"); } if (holder.node == null) { throw new ArgumentException("No leaf node specified. Holder has no node."); } int num = ((int)1) << (Math.Min(this.editorHeightLog2, this.editorWidthLog2) - depth); ListLinqView <QuadtreeNode> arr = new ListLinqView <QuadtreeNode>(); IntRect rect = new IntRect(x, y, x + num, y + num); this.AddNeighboursRec(arr, this.root, 0, 0, 0, rect.Expand(0), holder.node); holder.node.connections = arr.ToArray(); holder.node.connectionCosts = new uint[arr.Count]; for (int i = 0; i < arr.Count; i++) { VInt3 num4 = arr[i].position - holder.node.position; holder.node.connectionCosts[i] = (uint)num4.costMagnitude; } }
public HttpReq PackRequest() { HttpHeaders headers; RequestLine line = new RequestLine { szRequestMethod = this.method, szRequestUri = this.URL, szHttpVersion = this.version }; ListLinqView <HeaderUnit> view = new ListLinqView <HeaderUnit>(); foreach (KeyValuePair <string, string> pair in this.headers) { byte[] bytes = Encoding.UTF8.GetBytes(pair.Key); byte[] buffer2 = Encoding.UTF8.GetBytes(pair.Value); HeaderUnit item = new HeaderUnit { szHeaderName = bytes, szHeaderContent = buffer2 }; view.Add(item); } headers = new HttpHeaders { astHeaderUnit = view.ToArray(), dwHeaderCount = (uint)headers.astHeaderUnit.Length }; RequestContent content = new RequestContent { szData = this.data, dwDataLen = (uint)this.data.Length }; HttpReq req = new HttpReq { stRequestLine = line, stHttpHeaders = headers, stRequestContent = content }; ADebug.Log("send request :" + this.ToString()); return(req); }
private void CalculateMeshContour() { if (this.mesh != null) { edges.Clear(); pointers.Clear(); Vector3[] vertices = this.mesh.vertices; int[] triangles = this.mesh.triangles; for (int i = 0; i < triangles.Length; i += 3) { if (Polygon.IsClockwise(vertices[triangles[i]], vertices[triangles[i + 1]], vertices[triangles[i + 2]])) { int num2 = triangles[i]; triangles[i] = triangles[i + 2]; triangles[i + 2] = num2; } edges[new VInt2(triangles[i], triangles[i + 1])] = i; edges[new VInt2(triangles[i + 1], triangles[i + 2])] = i; edges[new VInt2(triangles[i + 2], triangles[i])] = i; } for (int j = 0; j < triangles.Length; j += 3) { for (int m = 0; m < 3; m++) { if (!edges.ContainsKey(new VInt2(triangles[j + ((m + 1) % 3)], triangles[j + (m % 3)]))) { pointers[triangles[j + (m % 3)]] = triangles[j + ((m + 1) % 3)]; } } } ListLinqView <Vector3[]> view = new ListLinqView <Vector3[]>(); List <Vector3> list = ListPool <Vector3> .Claim(); for (int k = 0; k < vertices.Length; k++) { if (!pointers.ContainsKey(k)) { continue; } list.Clear(); int index = k; do { int num7 = pointers[index]; if (num7 == -1) { break; } pointers[index] = -1; list.Add(vertices[index]); switch (num7) { case -1: Debug.LogError("Invalid Mesh '" + this.mesh.name + " in " + base.gameObject.name); break; } }while (index != k); if (list.Count > 0) { view.Add(list.ToArray()); } } ListPool <Vector3> .Release(list); this.contours = view.ToArray(); } }
private void CalculateMeshContour() { if (this.mesh == null) { return; } NavmeshCut.edges.Clear(); NavmeshCut.pointers.Clear(); Vector3[] vertices = this.mesh.vertices; int[] triangles = this.mesh.triangles; for (int i = 0; i < triangles.Length; i += 3) { if (Polygon.IsClockwise(vertices[triangles[i]], vertices[triangles[i + 1]], vertices[triangles[i + 2]])) { int num = triangles[i]; triangles[i] = triangles[i + 2]; triangles[i + 2] = num; } NavmeshCut.edges.set_Item(new VInt2(triangles[i], triangles[i + 1]), i); NavmeshCut.edges.set_Item(new VInt2(triangles[i + 1], triangles[i + 2]), i); NavmeshCut.edges.set_Item(new VInt2(triangles[i + 2], triangles[i]), i); } for (int j = 0; j < triangles.Length; j += 3) { for (int k = 0; k < 3; k++) { if (!NavmeshCut.edges.ContainsKey(new VInt2(triangles[j + (k + 1) % 3], triangles[j + k % 3]))) { NavmeshCut.pointers.set_Item(triangles[j + k % 3], triangles[j + (k + 1) % 3]); } } } ListLinqView <Vector3[]> listLinqView = new ListLinqView <Vector3[]>(); List <Vector3> list = ListPool <Vector3> .Claim(); for (int l = 0; l < vertices.Length; l++) { if (NavmeshCut.pointers.ContainsKey(l)) { list.Clear(); int num2 = l; do { int num3 = NavmeshCut.pointers.get_Item(num2); if (num3 == -1) { break; } NavmeshCut.pointers.set_Item(num2, -1); list.Add(vertices[num2]); num2 = num3; if (num2 == -1) { goto Block_9; } }while (num2 != l); IL_1E2: if (list.get_Count() > 0) { listLinqView.Add(list.ToArray()); goto IL_236; } goto IL_236; Block_9: Debug.LogError("Invalid Mesh '" + this.mesh.name + " in " + base.gameObject.name); goto IL_1E2; } IL_236 :; } ListPool <Vector3> .Release(list); this.contours = listLinqView.ToArray(); }
private void GenerateNodes(Vector3[] vectorVertices, int[] triangles, out Vector3[] originalVertices, out VInt3[] vertices) { if (vectorVertices.Length == 0 || triangles.Length == 0) { originalVertices = vectorVertices; vertices = new VInt3[0]; this.nodes = new TriangleMeshNode[0]; return; } vertices = new VInt3[vectorVertices.Length]; int num = 0; for (int i = 0; i < vertices.Length; i++) { vertices[i] = (VInt3)this.matrix.MultiplyPoint3x4(vectorVertices[i]); } Dictionary<VInt3, int> dictionary = new Dictionary<VInt3, int>(); int[] array = new int[vertices.Length]; for (int j = 0; j < vertices.Length; j++) { if (!dictionary.ContainsKey(vertices[j])) { array[num] = j; dictionary.Add(vertices[j], num); num++; } } for (int k = 0; k < triangles.Length; k++) { VInt3 vInt = vertices[triangles[k]]; triangles[k] = dictionary.get_Item(vInt); } VInt3[] array2 = vertices; vertices = new VInt3[num]; originalVertices = new Vector3[num]; for (int l = 0; l < num; l++) { vertices[l] = array2[array[l]]; originalVertices[l] = vectorVertices[array[l]]; } this.nodes = new TriangleMeshNode[triangles.Length / 3]; int graphIndex = this.active.astarData.GetGraphIndex(this); for (int m = 0; m < this.nodes.Length; m++) { this.nodes[m] = new TriangleMeshNode(this.active); TriangleMeshNode triangleMeshNode = this.nodes[m]; triangleMeshNode.GraphIndex = (uint)graphIndex; triangleMeshNode.Penalty = this.initialPenalty; triangleMeshNode.Walkable = true; triangleMeshNode.v0 = triangles[m * 3]; triangleMeshNode.v1 = triangles[m * 3 + 1]; triangleMeshNode.v2 = triangles[m * 3 + 2]; if (!Polygon.IsClockwise(vertices[triangleMeshNode.v0], vertices[triangleMeshNode.v1], vertices[triangleMeshNode.v2])) { int v = triangleMeshNode.v0; triangleMeshNode.v0 = triangleMeshNode.v2; triangleMeshNode.v2 = v; } if (Polygon.IsColinear(vertices[triangleMeshNode.v0], vertices[triangleMeshNode.v1], vertices[triangleMeshNode.v2])) { Debug.DrawLine((Vector3)vertices[triangleMeshNode.v0], (Vector3)vertices[triangleMeshNode.v1], Color.red); Debug.DrawLine((Vector3)vertices[triangleMeshNode.v1], (Vector3)vertices[triangleMeshNode.v2], Color.red); Debug.DrawLine((Vector3)vertices[triangleMeshNode.v2], (Vector3)vertices[triangleMeshNode.v0], Color.red); } triangleMeshNode.UpdatePositionFromVertices(); } DictionaryView<VInt2, TriangleMeshNode> dictionaryView = new DictionaryView<VInt2, TriangleMeshNode>(); int n = 0; int num2 = 0; while (n < triangles.Length) { dictionaryView[new VInt2(triangles[n], triangles[n + 1])] = this.nodes[num2]; dictionaryView[new VInt2(triangles[n + 1], triangles[n + 2])] = this.nodes[num2]; dictionaryView[new VInt2(triangles[n + 2], triangles[n])] = this.nodes[num2]; num2++; n += 3; } ListLinqView<MeshNode> listLinqView = new ListLinqView<MeshNode>(); List<uint> list = new List<uint>(); int num3 = 0; int num4 = 0; int num5 = 0; while (num4 < triangles.Length) { listLinqView.Clear(); list.Clear(); TriangleMeshNode triangleMeshNode2 = this.nodes[num5]; for (int num6 = 0; num6 < 3; num6++) { TriangleMeshNode triangleMeshNode3; if (dictionaryView.TryGetValue(new VInt2(triangles[num4 + (num6 + 1) % 3], triangles[num4 + num6]), out triangleMeshNode3)) { listLinqView.Add(triangleMeshNode3); list.Add((uint)(triangleMeshNode2.position - triangleMeshNode3.position).costMagnitude); } } triangleMeshNode2.connections = listLinqView.ToArray(); triangleMeshNode2.connectionCosts = list.ToArray(); num5++; num4 += 3; } if (num3 > 0) { Debug.LogError("One or more triangles are identical to other triangles, this is not a good thing to have in a navmesh\nIncreasing the scale of the mesh might help\nNumber of triangles with error: " + num3 + "\n"); } NavMeshGraph.RebuildBBTree(this); }
private void GenerateNodes(Vector3[] vectorVertices, int[] triangles, out Vector3[] originalVertices, out VInt3[] vertices) { if ((vectorVertices.Length == 0) || (triangles.Length == 0)) { originalVertices = vectorVertices; vertices = new VInt3[0]; this.nodes = new TriangleMeshNode[0]; } else { vertices = new VInt3[vectorVertices.Length]; int index = 0; for (int i = 0; i < vertices.Length; i++) { vertices[i] = (VInt3)this.matrix.MultiplyPoint3x4(vectorVertices[i]); } Dictionary <VInt3, int> dictionary = new Dictionary <VInt3, int>(); int[] numArray = new int[vertices.Length]; for (int j = 0; j < vertices.Length; j++) { if (!dictionary.ContainsKey(vertices[j])) { numArray[index] = j; dictionary.Add(vertices[j], index); index++; } } for (int k = 0; k < triangles.Length; k++) { VInt3 num5 = vertices[triangles[k]]; triangles[k] = dictionary[num5]; } VInt3[] numArray2 = vertices; vertices = new VInt3[index]; originalVertices = new Vector3[index]; for (int m = 0; m < index; m++) { vertices[m] = numArray2[numArray[m]]; originalVertices[m] = vectorVertices[numArray[m]]; } this.nodes = new TriangleMeshNode[triangles.Length / 3]; int graphIndex = base.active.astarData.GetGraphIndex(this); for (int n = 0; n < this.nodes.Length; n++) { this.nodes[n] = new TriangleMeshNode(base.active); TriangleMeshNode node = this.nodes[n]; node.GraphIndex = (uint)graphIndex; node.Penalty = base.initialPenalty; node.Walkable = true; node.v0 = triangles[n * 3]; node.v1 = triangles[(n * 3) + 1]; node.v2 = triangles[(n * 3) + 2]; if (!Polygon.IsClockwise(vertices[node.v0], vertices[node.v1], vertices[node.v2])) { int num9 = node.v0; node.v0 = node.v2; node.v2 = num9; } if (Polygon.IsColinear(vertices[node.v0], vertices[node.v1], vertices[node.v2])) { Debug.DrawLine((Vector3)vertices[node.v0], (Vector3)vertices[node.v1], Color.red); Debug.DrawLine((Vector3)vertices[node.v1], (Vector3)vertices[node.v2], Color.red); Debug.DrawLine((Vector3)vertices[node.v2], (Vector3)vertices[node.v0], Color.red); } node.UpdatePositionFromVertices(); } DictionaryView <VInt2, TriangleMeshNode> view = new DictionaryView <VInt2, TriangleMeshNode>(); int num10 = 0; int num11 = 0; while (num10 < triangles.Length) { view[new VInt2(triangles[num10], triangles[num10 + 1])] = this.nodes[num11]; view[new VInt2(triangles[num10 + 1], triangles[num10 + 2])] = this.nodes[num11]; view[new VInt2(triangles[num10 + 2], triangles[num10])] = this.nodes[num11]; num11++; num10 += 3; } ListLinqView <MeshNode> view2 = new ListLinqView <MeshNode>(); List <uint> list = new List <uint>(); int num12 = 0; int num13 = 0; int num14 = 0; while (num13 < triangles.Length) { view2.Clear(); list.Clear(); TriangleMeshNode node2 = this.nodes[num14]; for (int num15 = 0; num15 < 3; num15++) { TriangleMeshNode node3; if (view.TryGetValue(new VInt2(triangles[num13 + ((num15 + 1) % 3)], triangles[num13 + num15]), out node3)) { view2.Add(node3); VInt3 num16 = node2.position - node3.position; list.Add((uint)num16.costMagnitude); } } node2.connections = view2.ToArray(); node2.connectionCosts = list.ToArray(); num14++; num13 += 3; } if (num12 > 0) { Debug.LogError("One or more triangles are identical to other triangles, this is not a good thing to have in a navmesh\nIncreasing the scale of the mesh might help\nNumber of triangles with error: " + num12 + "\n"); } RebuildBBTree(this); } }