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
312 stars 48 forks source link

Content of the embedded buffer is not written to the GLB file when exporting #52

Closed Cyphall closed 8 months ago

Cyphall commented 8 months ago

When exporting an asset as GLB, the first buffer is correctly flagged as embedded and no .bin is created, but the content of said buffer is never actually written to the GLB file.

This is caused by missing const qualifiers in the parameter of the visitor handlers: https://github.com/spnda/fastgltf/blob/753b1610fe161963ba7242b65b744d7927b11303/src/fastgltf.cpp#L5515-L5539

Since buffer is const, buffer.data is also const, but none of the visitor handlers take a const value as parameter so they never get called. All cases are currently routed to the default handler [](auto arg) {}.

spnda commented 8 months ago

I didn't have any time yesterday to tend to your issues, but I quickly tried and tested this.

Since buffer is const, buffer.data is also const, but none of the visitor handlers take a const value as parameter so they never get called.

If I remember correctly specifying them as const didn't fix the issue. Or did that work locally for you? Also, I'll have to figure out some tests that verify that the buffer was correctly written, as that isn't covered right now.

Cyphall commented 8 months ago

Or did that work locally for you?

Yes, I have added the missing const qualifiers locally and it now work as expected.