feat: Add support for importing 64-bit GLB version 3 files#51
Open
aaronfranke wants to merge 1 commit into
Open
feat: Add support for importing 64-bit GLB version 3 files#51aaronfranke wants to merge 1 commit into
aaronfranke wants to merge 1 commit into
Conversation
2901ecf to
efdfb16
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the ability for glTFast to import 64-bit glTF binary format version 3 files. This GLB version 3 format is being defined as part of glTF 2.1, but the format itself is not tied to glTF 2.1: you can use a version 2 file to hold glTF 2.1 data, or use a version 3 file to hold glTF 2.0 data. It's this latter case which this PR supports. KhronosGroup/glTF#2594
This is not all of the changes to the
.glbformat that will be required for glTF 2.1. There will also be a more flexible chunk layout and support for multiple binary chunks. However, that will require changes to the parsing of the actual glTF JSON data as well, and that part has not yet been standardized, and I want to try and avoid sending in a massive unreviewable blob of all the changes all at once, so I am submitting this PR to just add support for GLB version 3 with the same layout.I have added a new test case for this, and ran the tests to confirm it works. The file is named
FormatVariantsGLB3.glb. This file is an exact duplicate of the existingFormatVariants.glbtest asset except with the binary format version changed. I also tested that this file loads in my experimental Godot Engine branch for glTF 2.1.Here is a bulleted list of what specifically this PR changes and why:
GlbBinChunkis primarily used to store buffers, not chunks. And furthermore, it stores the Start and Length, but not any actual data. Therefore, I renamed it toGltfBufferRange.m_BinChunkstom_BufferRanges. The old name was incorrect, it's not the bin chunks, it's the buffers, since it includes buffers read from URIs. This new name correctly identifies what it does.m_Bufferstom_BufferDatato clarify that this holds the actual data.GltfBufferRangetolong. While NativeArray is limited to 32-bit sizes, we should still use larger data types in glTFast code, for alignment with glTF, and to enable better debugging and error messages.ReadUInt64and also changeReadUInt32to acceptlongas input.GltfBinaryTooLargeandGltfUnsupportedChunkEncodingto the log message enum.totalLengthandindextolong, and set them differently based on version 2 or 3.k_MaxByteArraySizeconstant and compare the total file length to it. While the input data is already limited by NativeArray, this explicitly guards the declared file size, which might help with truncated files. In practice it's not super important, though, I can remove it if desired.IBufferView.ByteStride.GltfBufferRangeingraph.json(idk what this file is but may as well).I made a similar PR to UnityGLTF: KhronosGroup/UnityGLTF#905