Sparrow.Utils.Vertex.Copy C# (CSharp) Метод

Copy() публичный статический Метод

Copies the source to the target array. Note that this is an unsafe operation, if you supply wrong offset/count values it can lead to memory corruption!
public static Copy ( Vertex source, int sourceOffset, Vertex target, int targetOffset, int count ) : void
source Vertex
sourceOffset int
target Vertex
targetOffset int
count int
Результат void
        public static unsafe void Copy(Vertex[] source, int sourceOffset, Vertex[] target, int targetOffset, int count)
        {
            // The following fixed statement pins the location of the source and 
            // target objects in memory so that they will not be moved by garbage 
            // collection. 
            fixed (Vertex* pSource = source, pTarget = target)
            {
                // Set the starting points in source and target for the copying. 
                Vertex* ps = pSource + sourceOffset;
                Vertex* pt = pTarget + targetOffset;

                // Copy the specified number of bytes from source to target. 
                for (int i = 0; i < count; i++)
                {
                    *pt = *ps;
                    pt++;
                    ps++;
                }
            }
        }
    }

Usage Example

Пример #1
0
        /// <summary>
        /// Copies a range of vertices of this instance to another vertex data object.
        /// </summary>
        public void CopyToVertexData(VertexData target, bool copyColor, int atIndex, int numVertices)
        {
            Vertex.Copy(_vertices, 0, target.Vertices, atIndex, numVertices);

            if (copyColor)
            {
                Array.Copy(_vertexColors, 0, target.VertexColors, atIndex, numVertices);
            }
        }
Vertex