public void Draw(CameraComponent _camera) { if (_camera != null) { effect.View = _camera.View; effect.Projection = _camera.Projection; int vertexCount = 0; foreach (var shape in activeShapes) { vertexCount += shape.LineCount * 2; } if (vertexCount > 0) { if (verts.Length < vertexCount) { verts = new VertexPositionColor[vertexCount * 2]; } int lineCount = 0; int vertIndex = 0; foreach (DebugShape shape in activeShapes) { lineCount += shape.LineCount; int shapeVerts = shape.LineCount * 2; for (int i = 0; i < shapeVerts; i++) { verts[vertIndex++] = shape.Vertices[i]; } } effect.CurrentTechnique.Passes[0].Apply(); int vertexOffset = 0; while (lineCount > 0) { int linesToDraw = Math.Min(lineCount, 65535); GameUtilities.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; GameUtilities.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, verts, vertexOffset, linesToDraw); vertexOffset += linesToDraw * 2; lineCount -= linesToDraw; } } bool resort = false; for (int i = activeShapes.Count - 1; i >= 0; i--) { DebugShape s = activeShapes[i]; if (s.Lifetime <= 0) { cachedShapes.Add(s); activeShapes.RemoveAt(i); resort = true; } } if (resort) { cachedShapes.Sort(CachedShapesSort); } } }
public static extern void getCameraComponent_Native(ulong gameObjectID, out CameraComponent component);