private void RenderLasers(Camera camera) { if (!this.madeLists) { this.beams = new List <LaserBeam>(); this.willRender = new List <LaserBeam>(); this.madeLists = true; } int cullingMask = camera.cullingMask; if (this.beams == null) { this.beams = new List <LaserBeam>(LaserBeam.Collect()); } else { this.beams.Clear(); this.beams.AddRange(LaserBeam.Collect()); } allBeamsMask = 0; foreach (LaserBeam beam in this.beams) { UpdateBeam(ref beam.frame, beam); } if (((cullingMask & allBeamsMask) != 0) && (this.beams.Count > 0)) { Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera); foreach (LaserBeam beam2 in this.beams) { if (beam2.isViewModel || (((cullingMask & beam2.frame.beamsLayer) == beam2.frame.beamsLayer) && GeometryUtility.TestPlanesAABB(planes, beam2.frame.bounds))) { this.willRender.Add(beam2); } } if (this.willRender.Count > 0) { world2Cam = camera.worldToCameraMatrix; cam2World = camera.cameraToWorldMatrix; camProj = camera.projectionMatrix; try { foreach (LaserBeam beam3 in this.willRender) { RenderBeam(planes, camera, beam3, ref beam3.frame); } foreach (MeshBuffer buffer in Computation.beams) { Vector3 vector; Vector3 vector2; bool rebindVertexLayout = buffer.Resize(); int num2 = 0; VertexBuffer buffer2 = buffer.buffer; vector.x = vector.y = vector.z = float.PositiveInfinity; vector2.x = vector2.y = vector2.z = float.NegativeInfinity; foreach (LaserBeam beam4 in buffer.beams) { int index = num2++; int num4 = num2++; int num5 = num2++; int num6 = num2++; buffer2.v[index] = beam4.frame.beamVertices.m0; buffer2.v[num4] = beam4.frame.beamVertices.m1; buffer2.v[num6] = beam4.frame.beamVertices.m2; buffer2.v[num5] = beam4.frame.beamVertices.m3; buffer2.n[index] = beam4.frame.beamNormals.m0; buffer2.n[num4] = beam4.frame.beamNormals.m1; buffer2.n[num6] = beam4.frame.beamNormals.m2; buffer2.n[num5] = beam4.frame.beamNormals.m3; buffer2.c[index] = beam4.frame.beamColor.m0; buffer2.c[num4] = beam4.frame.beamColor.m1; buffer2.c[num6] = beam4.frame.beamColor.m2; buffer2.c[num5] = beam4.frame.beamColor.m3; buffer2.t[index] = beam4.frame.beamUVs.m0; buffer2.t[num4] = beam4.frame.beamUVs.m1; buffer2.t[num6] = beam4.frame.beamUVs.m2; buffer2.t[num5] = beam4.frame.beamUVs.m3; for (int i = index; i <= num5; i++) { if (buffer2.v[i].x < vector.x) { vector.x = buffer2.v[i].x; } if (buffer2.v[i].x > vector2.x) { vector2.x = buffer2.v[i].x; } if (buffer2.v[i].y < vector.y) { vector.y = buffer2.v[i].y; } if (buffer2.v[i].y > vector2.y) { vector2.y = buffer2.v[i].y; } if (buffer2.v[i].z < vector.z) { vector.z = buffer2.v[i].z; } if (buffer2.v[i].z > vector2.z) { vector2.z = buffer2.v[i].z; } } beam4.frame.bufBeam = null; } buffer.beams.Clear(); buffer.BindMesh(rebindVertexLayout, vector, vector2); Graphics.DrawMesh(buffer.mesh, Matrix4x4.identity, buffer.material, 1, camera, 0, null, false, false); } foreach (MeshBuffer buffer3 in Computation.dots) { Vector3 vector3; Vector3 vector4; bool flag2 = buffer3.Resize(); int num8 = 0; VertexBuffer buffer4 = buffer3.buffer; vector3.x = vector3.y = vector3.z = float.PositiveInfinity; vector4.x = vector4.y = vector4.z = float.NegativeInfinity; foreach (LaserBeam beam5 in buffer3.beams) { int num9 = num8++; int num10 = num8++; int num11 = num8++; int num12 = num8++; buffer4.v[num9] = beam5.frame.dotVertices1.m0; buffer4.v[num10] = beam5.frame.dotVertices1.m1; buffer4.v[num12] = beam5.frame.dotVertices1.m2; buffer4.v[num11] = beam5.frame.dotVertices1.m3; buffer4.n[num9] = beam5.frame.beamNormals.m0; buffer4.n[num10] = beam5.frame.beamNormals.m1; buffer4.n[num12] = beam5.frame.beamNormals.m2; buffer4.n[num11] = beam5.frame.beamNormals.m3; buffer4.c[num9] = beam5.frame.dotColor1.m0; buffer4.c[num10] = beam5.frame.dotColor1.m1; buffer4.c[num12] = beam5.frame.dotColor1.m2; buffer4.c[num11] = beam5.frame.dotColor1.m3; buffer4.t[num9] = uv[0]; buffer4.t[num10] = uv[1]; buffer4.t[num12] = uv[2]; buffer4.t[num11] = uv[3]; for (int j = num9; j <= num11; j++) { if (buffer4.v[j].x < vector3.x) { vector3.x = buffer4.v[j].x; } if (buffer4.v[j].x > vector4.x) { vector4.x = buffer4.v[j].x; } if (buffer4.v[j].y < vector3.y) { vector3.y = buffer4.v[j].y; } if (buffer4.v[j].y > vector4.y) { vector4.y = buffer4.v[j].y; } if (buffer4.v[j].z < vector3.z) { vector3.z = buffer4.v[j].z; } if (buffer4.v[j].z > vector4.z) { vector4.z = buffer4.v[j].z; } } num9 = num8++; num10 = num8++; num11 = num8++; num12 = num8++; buffer4.v[num9] = beam5.frame.dotVertices2.m0; buffer4.v[num10] = beam5.frame.dotVertices2.m1; buffer4.v[num12] = beam5.frame.dotVertices2.m2; buffer4.v[num11] = beam5.frame.dotVertices2.m3; buffer4.n[num9] = beam5.frame.beamNormals.m0; buffer4.n[num10] = beam5.frame.beamNormals.m1; buffer4.n[num12] = beam5.frame.beamNormals.m2; buffer4.n[num11] = beam5.frame.beamNormals.m3; buffer4.c[num9] = beam5.frame.dotColor2.m0; buffer4.c[num10] = beam5.frame.dotColor2.m1; buffer4.c[num12] = beam5.frame.dotColor2.m2; buffer4.c[num11] = beam5.frame.dotColor2.m3; buffer4.t[num9] = uv[0]; buffer4.t[num10] = uv[1]; buffer4.t[num12] = uv[2]; buffer4.t[num11] = uv[3]; for (int k = num9; k <= num11; k++) { if (buffer4.v[k].x < vector3.x) { vector3.x = buffer4.v[k].x; } if (buffer4.v[k].x > vector4.x) { vector4.x = buffer4.v[k].x; } if (buffer4.v[k].y < vector3.y) { vector3.y = buffer4.v[k].y; } if (buffer4.v[k].y > vector4.y) { vector4.y = buffer4.v[k].y; } if (buffer4.v[k].z < vector3.z) { vector3.z = buffer4.v[k].z; } if (buffer4.v[k].z > vector4.z) { vector4.z = buffer4.v[k].z; } } beam5.frame.bufDot = null; } buffer3.beams.Clear(); if (flag2) { buffer3.mesh.Clear(false); buffer3.mesh.vertices = buffer4.v; buffer3.mesh.normals = buffer4.n; buffer3.mesh.colors = buffer4.c; buffer3.mesh.uv = buffer4.t; buffer3.mesh.SetIndices(buffer4.i, MeshTopology.Quads, 0); } else { buffer3.mesh.vertices = buffer4.v; buffer3.mesh.normals = buffer4.n; buffer3.mesh.colors = buffer4.c; buffer3.mesh.uv = buffer4.t; } buffer3.BindMesh(flag2, vector3, vector4); Graphics.DrawMesh(buffer3.mesh, Matrix4x4.identity, buffer3.material, 1, camera, 0, null, false, false); } } finally { this.willRender.Clear(); Computation.beams.Clear(); Computation.dots.Clear(); MeshBuffer.Reset(); } } } }