Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make byte_offset optional for sparse accessors #381

Merged
merged 2 commits into from
Jul 24, 2023
Merged

Conversation

elrnv
Copy link
Contributor

@elrnv elrnv commented Jun 14, 2023

This fixes validation of sparse accessors without buffer_views, which must not have a byte_offset. This is not explicit in the spec but is in the official validator (see KhronosGroup/glTF-Validator#207)

This fixes validation of sparse accessors without buffer_views, which
must not have a byte_offset. This is not explicit in the spec but is in
the official validator (see KhronosGroup/glTF-Validator#207)
self.json.byte_offset as usize
///
/// This may be `None` if the corresponding accessor is sparse.
pub fn offset(&self) -> Option<usize> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a semver breaking change. I'm wondering whether we can return zero instead if it's None or whether we should bump the major version. Since #380 I'm tempted to move to version 2 and start taking semver more seriously as discussed in #241.

Copy link
Contributor Author

@elrnv elrnv Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's fine by me. But this PR already breaks semver for gltf-json. Let me know how you would like to proceed and I'll make the adjustment.

Edit: I should add, that if we do return zero, we should probably still change it to return Option<usize> for the next version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alteous any decision on this? I'm happy to make the change, otherwise feel free to make changes to this PR directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so concerned about breaking semver for gltf-json. It's not the first time this has happened. As long as the top-level gltf crate is unaffected. I suggest we go with the 'return zero' approach for now.

Edit: I should add, that if we do return zero, we should probably still change it to return Option for the next version.

I agree with you. This is something that could be missed easily. I'm not how that could be prevented easily though.

@alteous
Copy link
Member

alteous commented Jun 14, 2023

Well spotted and thanks for the PR.

elrnv added a commit to elrnv/gltfgen that referenced this pull request Jun 19, 2023
This change depends on landing a change in gltf-rs:
gltf-rs/gltf#381
This is to avoid breaking semver for gltf
@elrnv
Copy link
Contributor Author

elrnv commented Jul 17, 2023

Should be good to go, @alteous.

@alteous alteous merged commit 45683aa into gltf-rs:main Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants