spnda / fastgltf

A modern C++17 glTF 2.0 library focused on speed, correctness, and usability
https://fastgltf.readthedocs.io/v0.8.x/
MIT License
306 stars 45 forks source link

Fix: Bad chunk padding for GLB export #57

Closed Cyphall closed 8 months ago

Cyphall commented 8 months ago

This PR fixes two bugs:

1) The trailing padding for the BIN chunk was applied between chunkType and chunkData instead of after chunkData (terms from the glTF Specs) 2) The padding code was not adding the right amount of bytes (e.g. for a chunk size of 11, it was adding 3 bytes instead of 1).

I also refactored a few lines to have the same code structure of "write and pad" for the JSON and BIN chunks

spnda commented 8 months ago

Thank you, really stupid mistake of having the padding in front of the chunk data...