コード例 #1
0
        internal void ValidateIndices(Validation.ValidationContext result, uint vertexCount, PrimitiveType drawingType)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(result, BufferMode.ELEMENT_ARRAY_BUFFER);
            result.CheckLinkMustBeAnyOf(nameof(Normalized), Normalized, false);
            result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.UNSIGNED_BYTE, EncodingType.UNSIGNED_SHORT, EncodingType.UNSIGNED_INT);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.SCALAR);

            uint restart_value = 0xff;

            if (this.Encoding == EncodingType.UNSIGNED_SHORT)
            {
                restart_value = 0xffff;
            }
            if (this.Encoding == EncodingType.UNSIGNED_INT)
            {
                restart_value = 0xffffffff;
            }

            var indices = this.AsIndicesArray();

            for (int i = 0; i < indices.Count; ++i)
            {
                result.CheckVertexIndex(i, indices[i], vertexCount, restart_value);
            }
        }
コード例 #2
0
        internal void ValidateNormals(Validation.ValidationContext result)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(result, BufferMode.ARRAY_BUFFER);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC3);
            if (!this.LogicalParent.MeshQuantizationAllowed)
            {
                result.CheckLinkMustBeAnyOf(nameof(Normalized), Normalized, false);
                result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.FLOAT);
            }
            else
            {
                if (Normalized)
                {
                    result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.BYTE, EncodingType.SHORT);
                }
                else
                {
                    result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.FLOAT);
                }
            }

            var normals = this.AsVector3Array();

            for (int i = 0; i < normals.Count; ++i)
            {
                if (result.TryFixUnitLengthOrError(i, normals[i]))
                {
                    normals[i] = normals[i].SanitizeNormal();
                }
            }
        }
コード例 #3
0
        internal void ValidateJoints(Validation.ValidationContext result, string attributeName)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(result, BufferMode.ARRAY_BUFFER);
            result.CheckLinkMustBeAnyOf(nameof(Normalized), Normalized, false);
            result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.UNSIGNED_BYTE, EncodingType.UNSIGNED_SHORT, EncodingType.FLOAT);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC4);

            var joints = this.AsVector4Array();

            for (int i = 0; i < joints.Count; ++i)
            {
                result.CheckIsFinite(i, joints[i]);
            }
        }
コード例 #4
0
        internal void ValidateTangents(Validation.ValidationContext result)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(result, BufferMode.ARRAY_BUFFER);
            result.CheckLinkMustBeAnyOf(nameof(Normalized), Normalized, false);
            result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.FLOAT);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC3, DimensionType.VEC4);

            var tangents = this.AsVector4Array();

            for (int i = 0; i < tangents.Count; ++i)
            {
                result.CheckIsTangent(i, tangents[i]);
            }
        }
コード例 #5
0
        internal void ValidateWeights(Validation.ValidationContext result, int jwset)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(result, BufferMode.ARRAY_BUFFER);
            result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.UNSIGNED_BYTE, EncodingType.UNSIGNED_SHORT, EncodingType.FLOAT);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC4);

            var weights = this.AsVector4Array();

            for (int i = 0; i < weights.Count; ++i)
            {
                result.CheckIsInRange(i, weights[i], 0, 1);

                // theoretically, the sum of all the weights should give 1, ASSUMING there's only one weight set.
                // but in practice, that seems not to be true.
            }
        }
コード例 #6
0
        internal void ValidatePositions(Validation.ValidationContext result)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(result, BufferMode.ARRAY_BUFFER);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC3);
            if (!this.LogicalParent.MeshQuantizationAllowed)
            {
                result.CheckLinkMustBeAnyOf(nameof(Normalized), Normalized, false);
                result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.FLOAT);
            }

            var positions = this.AsVector3Array();

            for (int i = 0; i < positions.Count; ++i)
            {
                result.CheckIsFinite(i, positions[i]);
            }
        }
コード例 #7
0
        internal void ValidateTangents(Validation.ValidationContext result)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(result, BufferMode.ARRAY_BUFFER);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC3, DimensionType.VEC4);
            if (!this.LogicalParent.MeshQuantizationAllowed)
            {
                result.CheckLinkMustBeAnyOf(nameof(Normalized), Normalized, false);
                result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.FLOAT);
            }
            else
            {
                if (Normalized)
                {
                    result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.BYTE, EncodingType.SHORT);
                }
                else
                {
                    result.CheckLinkMustBeAnyOf(nameof(Encoding), Encoding, EncodingType.FLOAT);
                }
            }

            // when Dimensions == VEC3, its morph target tangent deltas

            if (Dimensions == DimensionType.VEC4)
            {
                var tangents = this.AsVector4Array();

                for (int i = 0; i < tangents.Count; ++i)
                {
                    if (result.TryFixTangentOrError(i, tangents[i]))
                    {
                        tangents[i] = tangents[i].SanitizeTangent();
                    }
                }
            }
        }
コード例 #8
0
        internal void ValidateMatrices(Validation.ValidationContext result)
        {
            result = result.GetContext(this);

            SourceBufferView.ValidateBufferUsageData(result);
            result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.MAT4);

            var matrices = this.AsMatrix4x4Array();

            for (int i = 0; i < matrices.Count; ++i)
            {
                result.CheckIsMatrix(i, matrices[i]);
            }
        }
コード例 #9
0
 internal void ValidateAnimationOutput(Validation.ValidationContext result)
 {
     SourceBufferView.ValidateBufferUsageData(result);
     result.CheckLinkMustBeAnyOf(nameof(Dimensions), Dimensions, DimensionType.SCALAR, DimensionType.VEC3, DimensionType.VEC4);
 }