From efac516101b76622c6c5114ced1cd7225c847499 Mon Sep 17 00:00:00 2001 From: Peter Verswyvelen Date: Tue, 16 Mar 2021 10:56:03 +0100 Subject: [PATCH] FIX: Exporting a GLB without data chunk now produces a valid file. --- src/ExportableAsset.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ExportableAsset.cpp b/src/ExportableAsset.cpp index e737a62..f383e46 100644 --- a/src/ExportableAsset.cpp +++ b/src/ExportableAsset.cpp @@ -371,8 +371,9 @@ void ExportableAsset::save() { const int headerLength = 12; const int chunkHeaderLength = 8; - writeHeader[1] = headerLength + (chunkHeaderLength + jsonLength + jsonPadding) + - (chunkHeaderLength + bufferLength + binPadding); // length + const int dataChunkSize = bufferLength ? (chunkHeaderLength + bufferLength + binPadding) : 0; + + writeHeader[1] = headerLength + (chunkHeaderLength + jsonLength + jsonPadding) + dataChunkSize; // length file.write(reinterpret_cast(writeHeader), sizeof(uint32_t) * 2); // GLB header