protected override void OnValidate(Validation.ValidationContext result) { base.OnValidate(result); foreach (var p in this.Primitives) { p.Validate(result); } var morphTargetsCount = this.Primitives .Select(item => item.MorphTargetsCount) .Distinct(); if (morphTargetsCount.Count() != 1) { result.AddSemanticError("Count", "All primitives must have the same number of morph targets."); } if (_weights.Count != 0 && morphTargetsCount.First() != _weights.Count) { result.AddSemanticError("Weights", $"The length of weights array ({_weights.Count}) does not match the number of morph targets({morphTargetsCount.First()})."); } }
protected override void OnValidate(Validation.ValidationContext result) { base.OnValidate(result); var buffer = this.LogicalParent.LogicalBuffers[this._buffer]; var bcontent = buffer.Content; result.CheckArrayRangeAccess("ByteOffset", _byteOffset, _byteLength, buffer.Content); if (ByteStride > _byteLength) { result.AddSemanticError(nameof(ByteStride), $"value ({ByteStride}) is larger than byteLength ({_byteLength})."); } // if (this.DeviceBufferTarget.HasValue && this.FindAccessors().Any(item => item.IsSparse)) result.AddError() }
internal static void CheckAccess(Validation.ValidationContext result, BufferView bv, int accessorByteOffset, DimensionType dim, EncodingType enc, bool nrm, int count) { if (nrm) { if (enc != EncodingType.UNSIGNED_BYTE && enc != EncodingType.UNSIGNED_SHORT) { result.AddDataError("Normalized", "Only (u)byte and (u)short accessors can be normalized."); } } var elementByteSize = dim.DimCount() * enc.ByteLength(); if (bv.IsVertexBuffer) { if (bv.ByteStride == 0) { result.CheckSchemaIsMultipleOf("ElementByteSize", elementByteSize, 4); } } if (bv.IsIndexBuffer) { if (bv._byteStride.HasValue) { result.AddSemanticError("bufferView: Invalid ByteStride."); } if (dim != DimensionType.SCALAR) { result.AddLinkError(("BufferView", bv.LogicalIndex), $"is an IndexBuffer, but accessor dimensions is: {dim}"); } // TODO: these could by fixed by replacing BYTE by UBYTE, SHORT by USHORT, etc if (enc == EncodingType.BYTE) { result.AddLinkError(("BufferView", bv.LogicalIndex), $"is an IndexBuffer, but accessor encoding is (s)byte"); } if (enc == EncodingType.SHORT) { result.AddLinkError(("BufferView", bv.LogicalIndex), $"is an IndexBuffer, but accessor encoding is (s)short"); } if (enc == EncodingType.FLOAT) { result.AddLinkError(("BufferView", bv.LogicalIndex), $"is an IndexBuffer, but accessor encoding is float"); } if (nrm) { result.AddLinkError(("BufferView", bv.LogicalIndex), $"is an IndexBuffer, but accessor is normalized"); } } if (bv.ByteStride > 0) { if (bv.ByteStride < elementByteSize) { result.AddLinkError("ElementByteSize", $"Referenced bufferView's byteStride value {bv.ByteStride} is less than accessor element's length {elementByteSize}."); } return; } var accessorByteLength = bv.GetAccessorByteLength(dim, enc, count); // "Accessor(offset: {0}, length: {1}) does not fit referenced bufferView[% 3] length %4."; result.CheckArrayRangeAccess(("BufferView", bv.LogicalIndex), accessorByteOffset, accessorByteLength, bv.Content); }