Пример #1
0
        /// <inheritdoc />
        public Mesh Create(IMeshData16 <TVertex> meshData)
        {
            Contracts.Requires.That(meshData != null);
            MeshData.VerifyContracts(meshData);

            var indexBuffer = new IndexBufferBinding(
                Buffer.Index.New(this.GraphicsDevice, meshData.Indices16, GraphicsResourceUsage.Immutable),
                is32Bit: false,
                count: meshData.IndicesCount);

            return(this.CreateMesh(indexBuffer, meshData));
        }
Пример #2
0
        public static void VerifyContracts <TVertex>(IMeshData16 <TVertex> mesh)
            where TVertex : struct
        {
            VerifyCommonContracts(mesh);

            Contracts.Requires.That(mesh.VerticesCount <= MeshConstants.MaxVerticesSupportedBy16BitIndices);
            Contracts.Requires.That(mesh.Indices16 != null);
            Contracts.Requires.That(mesh.IndicesCount.IsIn(Range.New(0, mesh.Indices16.Length)));

            var range = Range.FromLength(mesh.VerticesCount);

            Contracts.Requires.That(mesh.Indices16.Take(mesh.IndicesCount).All(index => ((int)index).IsIn(range)));
        }