コード例 #1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="VertexDeclaration"/> class.
        /// </summary>
        /// <param name="elements">The elements that compose a vertex.</param>
        /// <param name="instanceCount">The instance count.</param>
        /// <param name="vertexStride">The vertex stride, in bytes. Specify 0 to compute the stride from <paramref name="elements"/>.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="elements"/> is a <c>null</c> reference.</exception>
        public VertexDeclaration(VertexElement[] elements, int instanceCount, int vertexStride)
        {
            if (elements is null)
            {
                throw new ArgumentNullException(nameof(elements));
            }

            VertexElements = elements;
            VertexStride   = vertexStride == 0 ? VertexElementValidator.GetVertexStride(elements) : vertexStride;
            InstanceCount  = instanceCount;

            // Validate vertex declaration elements
            VertexElementValidator.Validate(VertexStride, VertexElements);

            hashCode = InstanceCount;
            hashCode = (hashCode * 397) ^ VertexStride;
            foreach (var vertexElement in VertexElements)
            {
                hashCode = (hashCode * 397) ^ vertexElement.GetHashCode();
            }
        }
コード例 #2
0
ファイル: VertexDeclaration.cs プロジェクト: Aggror/Stride
        /// <summary>
        /// Initializes a new instance of the <see cref="VertexDeclaration"/> class.
        /// </summary>
        /// <param name="elements">The elements.</param>
        /// <param name="instanceCount">The instance count.</param>
        /// <param name="vertexStride">The vertex stride.</param>
        /// <exception cref="System.ArgumentNullException">elements</exception>
        public VertexDeclaration(VertexElement[] elements, int instanceCount, int vertexStride)
        {
            if (elements == null)
            {
                throw new ArgumentNullException("elements");
            }

            this.elements      = elements;
            this.vertexStride  = vertexStride == 0 ? VertexElementValidator.GetVertexStride(elements) : vertexStride;
            this.instanceCount = instanceCount;

            // Validate Vertices
            VertexElementValidator.Validate(VertexStride, elements);

            hashCode = instanceCount;
            hashCode = (hashCode * 397) ^ vertexStride;
            foreach (var vertexElement in elements)
            {
                hashCode = (hashCode * 397) ^ vertexElement.GetHashCode();
            }
        }