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
275 stars 42 forks source link

Buffer URIs are exported with backslash as directory separator on Windows #51

Closed Cyphall closed 6 months ago

Cyphall commented 6 months ago

Calling fastgltf::FileExporter::setBufferPath with "." and adding a buffer named "test" results in the buffer URI having a backslash as separator in the generated glTF file:

"buffers":[
    {
        "uri":".\\test.bin",
        "byteLength":720,
        "name":"test"
    }
],

However, URIs are expected to only ever use forward slashes as separators. This makes the glTF file invalid.

After going through the code, I believe that this issue is caused by the use of std::filesystem::path::string (which uses the native separators) instead of std::filesystem::path::generic_string (which always uses forward slashes as separators).

Cyphall commented 6 months ago

Thank you :smiley: