Example #1
0
        public void UpdateMesh()
        {
            if (!IsModified)
            {
                return;
            }

            List <VertexPositionColorTexture> vertices = new List <VertexPositionColorTexture>();
            var indices = new LinkedList <int>();

            lock (shapes)
            {
                foreach (var line in shapes.SelectMany(shape => shape.Lines))
                {
                    int startIndex = OptionalInsert(line.Start, vertices);
                    int endIndex   = OptionalInsert(line.End, vertices);
                    indices.AddLast(startIndex);
                    indices.AddLast(endIndex);
                }
            }

            vertexArray.CopyTo(this.vertices, 0);
            indexArray.CopyTo(this.indices, 0);

            vertices.CopyTo(this.vertices, 0);
            indices.CopyTo(this.indices, 0);

            vertexBuffer.SetData(graphicsContext.CommandList, this.vertices.ToArray());
            indexBuffer.SetData(graphicsContext.CommandList, this.indices.ToArray());

            IsModified = false;
        }