Beispiel #1
0
        private void _ValidateWeights(VALIDATIONCTX validate)
        {
            validate = validate.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(validate, BufferMode.ARRAY_BUFFER);

            validate.IsAnyOf(nameof(Format), Format, (DimensionType.VEC4, EncodingType.UNSIGNED_BYTE, true), (DimensionType.VEC4, EncodingType.UNSIGNED_SHORT, true), DimensionType.VEC4);
        }
Beispiel #2
0
        private static void _ValidateWeights(VALIDATIONCTX validate, Accessor weights0, Accessor weights1)
        {
            weights0?._ValidateWeights(validate);
            weights1?._ValidateWeights(validate);

            var memory0 = weights0?._GetMemoryAccessor("WEIGHTS_0");
            var memory1 = weights1?._GetMemoryAccessor("WEIGHTS_1");

            validate.That(() => MemoryAccessor.VerifyWeightsSum(memory0, memory1));
        }
Beispiel #3
0
        protected override void OnValidateReferences(VALIDATIONCTX validate)
        {
            base.OnValidateReferences(validate);

            validate
            .IsDefined(nameof(_bufferView), _bufferView)
            .NonNegative(nameof(_byteOffset), _byteOffset)
            .IsGreaterOrEqual(nameof(_count), _count, _countMinimum)
            .IsNullOrIndex(nameof(_bufferView), _bufferView, this.LogicalParent.LogicalBufferViews);
        }
Beispiel #4
0
        private void _ValidateJoints(VALIDATIONCTX validate, string attributeName, int skinsMaxJointCount)
        {
            validate = validate.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(validate, BufferMode.ARRAY_BUFFER);

            validate
            .IsAnyOf(nameof(Format), Format, (DimensionType.VEC4, EncodingType.UNSIGNED_BYTE), (DimensionType.VEC4, EncodingType.UNSIGNED_SHORT), DimensionType.VEC4)
            .AreJoints(attributeName, this.AsVector4Array(), skinsMaxJointCount);
        }
Beispiel #5
0
        internal void ValidateIndices(VALIDATIONCTX validate, uint vertexCount, PrimitiveType drawingType)
        {
            validate = validate.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(validate, BufferMode.ELEMENT_ARRAY_BUFFER);
            validate.IsAnyOf("Format", Format, (DimensionType.SCALAR, EncodingType.UNSIGNED_BYTE), (DimensionType.SCALAR, EncodingType.UNSIGNED_SHORT), (DimensionType.SCALAR, EncodingType.UNSIGNED_INT));

            validate.AreEqual(nameof(SourceBufferView.ByteStride), SourceBufferView.ByteStride, 0); // "bufferView.byteStride must not be defined for indices accessor.";

            validate.That(() => MemoryAccessor.VerifyVertexIndices(_GetMemoryAccessor(), vertexCount));
        }
Beispiel #6
0
        internal void ValidateMatrices4x3(VALIDATIONCTX validate, bool mustInvert = true, bool mustDecompose = true)
        {
            validate = validate.GetContext(this);

            SourceBufferView.ValidateBufferUsagePlainData(validate);

            validate.IsAnyOf(nameof(Format), Format, (DimensionType.MAT4, EncodingType.BYTE, true), (DimensionType.MAT4, EncodingType.SHORT, true), DimensionType.MAT4);

            var matrices = this.AsMatrix4x4Array();

            for (int i = 0; i < matrices.Count; ++i)
            {
                validate.IsNullOrMatrix4x3("Matrices", matrices[i], mustInvert, mustDecompose);
            }
        }
Beispiel #7
0
        private void _ValidatePositions(VALIDATIONCTX validate)
        {
            validate = validate.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(validate, BufferMode.ARRAY_BUFFER);

            if (!this.LogicalParent.MeshQuantizationAllowed)
            {
                validate.IsAnyOf(nameof(Format), Format, DimensionType.VEC3);
            }
            else
            {
                validate.IsAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC3);
            }

            validate.ArePositions("POSITION", this.AsVector3Array());
        }
Beispiel #8
0
        protected override void OnValidateContent(VALIDATIONCTX validate)
        {
            base.OnValidateContent(validate);

            // if Accessor.Type uses a custom dimension,
            // we cannot check the rest of the accessor.
            if (this.Dimensions == DimensionType.CUSTOM)
            {
                return;
            }

            BufferView.VerifyAccess(validate, this.SourceBufferView, this.ByteOffset, this.Format, this.Count);

            validate.That(() => MemoryAccessor.VerifyAccessorBounds(_GetMemoryAccessor(), _min, _max));

            // at this point we don't know which kind of data we're accessing, so it's up to the components
            // using this accessor to validate the data.
        }
Beispiel #9
0
        internal static void ValidateVertexAttributes(VALIDATIONCTX validate, IReadOnlyDictionary <string, Accessor> attributes, int skinsMaxJointCount)
        {
            if (validate.TryFix)
            {
                foreach (var kvp in attributes.Where(item => item.Key != "POSITION"))
                {
                    // remove unnecessary bounds
                    kvp.Value._min.Clear();
                    kvp.Value._max.Clear();
                }
            }

            if (attributes.TryGetValue("POSITION", out Accessor positions))
            {
                positions._ValidatePositions(validate);
            }

            if (attributes.TryGetValue("NORMAL", out Accessor normals))
            {
                normals._ValidateNormals(validate);
            }
            if (attributes.TryGetValue("TANGENT", out Accessor tangents))
            {
                tangents._ValidateTangents(validate);
            }

            if (attributes.TryGetValue("JOINTS_0", out Accessor joints0))
            {
                joints0._ValidateJoints(validate, "JOINTS_0", skinsMaxJointCount);
            }
            if (attributes.TryGetValue("JOINTS_1", out Accessor joints1))
            {
                joints1._ValidateJoints(validate, "JOINTS_1", skinsMaxJointCount);
            }

            attributes.TryGetValue("WEIGHTS_0", out Accessor weights0);
            attributes.TryGetValue("WEIGHTS_1", out Accessor weights1);
            _ValidateWeights(validate, weights0, weights1);
        }
Beispiel #10
0
        private void _ValidateTangents(VALIDATIONCTX validate)
        {
            validate = validate.GetContext(this);

            SourceBufferView.ValidateBufferUsageGPU(validate, BufferMode.ARRAY_BUFFER);

            if (!this.LogicalParent.MeshQuantizationAllowed)
            {
                validate.IsAnyOf(nameof(Format), Format, DimensionType.VEC3, DimensionType.VEC4);
            }
            else
            {
                validate.IsAnyOf(nameof(Dimensions), Dimensions, DimensionType.VEC3, DimensionType.VEC4);
            }

            if (validate.TryFix)
            {
                if (Dimensions == DimensionType.VEC3)
                {
                    this.AsVector3Array().SanitizeNormals();
                }
                if (Dimensions == DimensionType.VEC4)
                {
                    this.AsVector4Array().SanitizeTangents();
                }
            }

            if (Dimensions == DimensionType.VEC3)
            {
                validate.AreNormals("TANGENT", this.AsVector3Array());
            }
            if (Dimensions == DimensionType.VEC4)
            {
                validate.AreTangents("TANGENT", this.AsVector4Array());
            }
        }
Beispiel #11
0
        internal void ValidateAnimationOutput(VALIDATIONCTX validate)
        {
            SourceBufferView.ValidateBufferUsagePlainData(validate);

            validate.IsAnyOf(nameof(Dimensions), Dimensions, DimensionType.SCALAR, DimensionType.VEC3, DimensionType.VEC4);
        }