// Token: 0x06002DB1 RID: 11697 RVA: 0x001D0890 File Offset: 0x001CEA90 public void DrawMesh(RetainedGizmos gizmos, Vector3[] vertices, List <int> triangles, Color[] colors) { Mesh mesh = gizmos.GetMesh(); mesh.vertices = vertices; mesh.SetTriangles(triangles, 0); mesh.colors = colors; mesh.UploadMeshData(true); this.meshes.Add(mesh); }
public void DrawMesh(RetainedGizmos gizmos, Vector3[] vertices, List <int> triangles, Color[] colors) { var mesh = gizmos.GetMesh(); // Set all data on the mesh mesh.vertices = vertices; mesh.SetTriangles(triangles, 0); mesh.colors = colors; // Upload all data mesh.UploadMeshData(false); meshes.Add(mesh); }
void SubmitLines(RetainedGizmos gizmos, ulong hash) { // Unity only supports 65535 vertices per mesh. 65532 used because MaxLineEndPointsPerBatch needs to be even. const int MaxLineEndPointsPerBatch = 65532 / 2; int batches = (lines.Count + MaxLineEndPointsPerBatch - 1) / MaxLineEndPointsPerBatch; for (int batch = 0; batch < batches; batch++) { int startIndex = MaxLineEndPointsPerBatch * batch; int endIndex = Mathf.Min(startIndex + MaxLineEndPointsPerBatch, lines.Count); int lineEndPointCount = endIndex - startIndex; UnityEngine.Assertions.Assert.IsTrue(lineEndPointCount % 2 == 0); // Use pooled lists to avoid excessive allocations var vertices = ListPool <Vector3> .Claim(lineEndPointCount *2); var colors = ListPool <Color32> .Claim(lineEndPointCount *2); var normals = ListPool <Vector3> .Claim(lineEndPointCount *2); var uv = ListPool <Vector2> .Claim(lineEndPointCount *2); var tris = ListPool <int> .Claim(lineEndPointCount *3); // Loop through each endpoint of the lines // and add 2 vertices for each for (int j = startIndex; j < endIndex; j++) { var vertex = (Vector3)lines[j]; vertices.Add(vertex); vertices.Add(vertex); var color = (Color32)lineColors[j]; colors.Add(color); colors.Add(color); uv.Add(new Vector2(0, 0)); uv.Add(new Vector2(1, 0)); } // Loop through each line and add // one normal for each vertex for (int j = startIndex; j < endIndex; j += 2) { var lineDir = (Vector3)(lines[j + 1] - lines[j]); // Store the line direction in the normals. // A line consists of 4 vertices. The line direction will be used to // offset the vertices to create a line with a fixed pixel thickness normals.Add(lineDir); normals.Add(lineDir); normals.Add(lineDir); normals.Add(lineDir); } // Setup triangle indices // A triangle consists of 3 indices // A line (4 vertices) consists of 2 triangles, so 6 triangle indices for (int j = 0, v = 0; j < lineEndPointCount * 3; j += 6, v += 4) { // First triangle tris.Add(v + 0); tris.Add(v + 1); tris.Add(v + 2); // Second triangle tris.Add(v + 1); tris.Add(v + 3); tris.Add(v + 2); } var mesh = gizmos.GetMesh(); // Set all data on the mesh mesh.SetVertices(vertices); mesh.SetTriangles(tris, 0); mesh.SetColors(colors); mesh.SetNormals(normals); mesh.SetUVs(0, uv); // Upload all data mesh.UploadMeshData(false); // Release the lists back to the pool ListPool <Vector3> .Release(ref vertices); ListPool <Color32> .Release(ref colors); ListPool <Vector3> .Release(ref normals); ListPool <Vector2> .Release(ref uv); ListPool <int> .Release(ref tris); gizmos.meshes.Add(new MeshWithHash { hash = hash, mesh = mesh, lines = true }); gizmos.existingHashes.Add(hash); } }
// Token: 0x06002DB6 RID: 11702 RVA: 0x001D0CC8 File Offset: 0x001CEEC8 private void SubmitLines(RetainedGizmos gizmos, ulong hash) { int num = (this.lines.Count + 32766 - 1) / 32766; for (int i = 0; i < num; i++) { int num2 = 32766 * i; int num3 = Mathf.Min(num2 + 32766, this.lines.Count); int num4 = num3 - num2; List <Vector3> list = ListPool <Vector3> .Claim(num4 * 2); List <Color32> list2 = ListPool <Color32> .Claim(num4 * 2); List <Vector3> list3 = ListPool <Vector3> .Claim(num4 * 2); List <Vector2> list4 = ListPool <Vector2> .Claim(num4 * 2); List <int> list5 = ListPool <int> .Claim(num4 * 3); for (int j = num2; j < num3; j++) { Vector3 item = this.lines[j]; list.Add(item); list.Add(item); Color32 item2 = this.lineColors[j]; list2.Add(item2); list2.Add(item2); list4.Add(new Vector2(0f, 0f)); list4.Add(new Vector2(1f, 0f)); } for (int k = num2; k < num3; k += 2) { Vector3 item3 = this.lines[k + 1] - this.lines[k]; list3.Add(item3); list3.Add(item3); list3.Add(item3); list3.Add(item3); } int l = 0; int num5 = 0; while (l < num4 * 3) { list5.Add(num5); list5.Add(num5 + 1); list5.Add(num5 + 2); list5.Add(num5 + 1); list5.Add(num5 + 3); list5.Add(num5 + 2); l += 6; num5 += 4; } Mesh mesh = gizmos.GetMesh(); mesh.SetVertices(list); mesh.SetTriangles(list5, 0); mesh.SetColors(list2); mesh.SetNormals(list3); mesh.SetUVs(0, list4); mesh.UploadMeshData(true); ListPool <Vector3> .Release(ref list); ListPool <Color32> .Release(ref list2); ListPool <Vector3> .Release(ref list3); ListPool <Vector2> .Release(ref list4); ListPool <int> .Release(ref list5); gizmos.meshes.Add(new RetainedGizmos.MeshWithHash { hash = hash, mesh = mesh, lines = true }); gizmos.existingHashes.Add(hash); } }