Skip to content

Commit

Permalink
reinforced animation accessors validation
Browse files Browse the repository at this point in the history
  • Loading branch information
vpenades committed Aug 12, 2024
1 parent e16aad1 commit 0344b8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/SharpGLTF.Core/Schema2/gltf.Accessors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,14 +576,14 @@ internal void ValidateMatrices4x3(VALIDATIONCTX validate, bool mustInvert = true

internal void ValidateAnimationInput(VALIDATIONCTX validate)
{
SourceBufferView.ValidateBufferUsagePlainData(validate);
SourceBufferView.ValidateBufferUsagePlainData(validate, false); // as per glTF specification, animation accessors must not have ByteStride

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

internal void ValidateAnimationOutput(VALIDATIONCTX validate)
{
SourceBufferView.ValidateBufferUsagePlainData(validate);
SourceBufferView.ValidateBufferUsagePlainData(validate, false); // as per glTF specification, animation accessors must not have ByteStride

validate.IsAnyOf(nameof(Dimensions), Dimensions, DimensionType.SCALAR, DimensionType.VEC3, DimensionType.VEC4);
}
Expand Down
13 changes: 7 additions & 6 deletions src/SharpGLTF.Core/Schema2/gltf.BufferView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,17 @@ internal void ValidateBufferUsageGPU(Validation.ValidationContext validate, Buff
if (this._target.HasValue) validate.EnumsAreEqual(nameof(_target), _target.Value, usingMode);
}

internal void ValidateBufferUsagePlainData(Validation.ValidationContext validate)
{
/*
if (this._byteStride.HasValue)
internal void ValidateBufferUsagePlainData(Validation.ValidationContext validate, bool supportsStride = true)
{
if (this._byteStride.HasValue && !supportsStride)
{
if (result.TryFixLinkOrError("BufferView", "Unexpected ByteStride found. Expected null"))
if (validate.TryFix)
{
this._byteStride = null;
}
}*/

validate.IsUndefined(nameof(_byteStride), this._byteStride);
}

validate = validate.GetContext(this);

Expand Down

0 comments on commit 0344b8f

Please sign in to comment.