Ejemplo n.º 1
0
        /// <summary>
        /// Sets the vertices of this triangle mesh.
        /// </summary>
        public void SetVertices(Vertex[] vertices, TimeStep timeStep, int srcOffset, int dstOffset, int length)
        {
            if (vertices == null)
            {
                throw new ArgumentNullException("vertices");
            }
            else if (srcOffset < 0)
            {
                throw new ArgumentOutOfRangeException("srcOffset");
            }
            else if (dstOffset < 0)
            {
                throw new ArgumentOutOfRangeException("dstOffset");
            }
            else if (length < 0)
            {
                throw new ArgumentOutOfRangeException("length");
            }
            else if (srcOffset + length > vertices.Length)
            {
                throw new ArgumentOutOfRangeException("length");
            }
            else if (dstOffset + length > Description.NumVertices)
            {
                throw new ArgumentOutOfRangeException("length");
            }
            else if (!Description.LinearMotion && (timeStep != TimeStep.T0))
            {
                throw new ArgumentOutOfRangeException("timeStep");
            }
            else if (length == 0)
            {
                return;
            }

            var vertexBufferType = timeStep.AsVertexBuffer();

            using (var vertexBuffer = new MappedBuffer <Vertex>(Parent, ID, vertexBufferType)) {
                for (int t = 0; t < length; ++t)
                {
                    vertexBuffer[t + dstOffset] = vertices[t + srcOffset];
                }
            }

            RTC.UpdateBuffer(Parent.NativePtr, ID, vertexBufferType);
        }