Build fix.

This commit is contained in:
Alexander Wood 2021-10-08 16:57:56 -04:00
parent 190382aecd
commit 9e3d1f6db5

View File

@ -7534,13 +7534,13 @@ static void WriteBinaryGltfStream(std::ostream &stream,
const uint32_t content_size = uint32_t(content.size()); const uint32_t content_size = uint32_t(content.size());
const uint32_t binBuffer_size = uint32_t(binBuffer.size()); const uint32_t binBuffer_size = uint32_t(binBuffer.size());
// determine number of padding bytes required to ensure 4 byte alignment // determine number of padding bytes required to ensure 4 byte alignment
const uint32_t padding_size = content_size % 4 == 0 ? 0 : 4 - content_size % 4; const uint32_t content_padding_size = content_size % 4 == 0 ? 0 : 4 - content_size % 4;
const uint32_t bin_padding_size = binBuffer_size % 4 == 0 ? 0 : 4 - binBuffer_size % 4; const uint32_t bin_padding_size = binBuffer_size % 4 == 0 ? 0 : 4 - binBuffer_size % 4;
// 12 bytes for header, JSON content length, 8 bytes for JSON chunk info. // 12 bytes for header, JSON content length, 8 bytes for JSON chunk info.
// Chunk data must be located at 4-byte boundary, which may require padding // Chunk data must be located at 4-byte boundary, which may require padding
const uint32_t length = const uint32_t length =
12 + 8 + content_size + content_padding + 12 + 8 + content_size + content_padding_size +
(binBuffer_size ? (8 + binBuffer_size + bin_padding_size : 0); (binBuffer_size ? (8 + binBuffer_size + bin_padding_size : 0);
stream.write(header.c_str(), std::streamsize(header.size())); stream.write(header.c_str(), std::streamsize(header.size()));
@ -7548,7 +7548,7 @@ static void WriteBinaryGltfStream(std::ostream &stream,
stream.write(reinterpret_cast<const char *>(&length), sizeof(length)); stream.write(reinterpret_cast<const char *>(&length), sizeof(length));
// JSON chunk info, then JSON data // JSON chunk info, then JSON data
const uint32_t model_length = uint32_t(content.size()) + padding_size; const uint32_t model_length = uint32_t(content.size()) + content_padding_size;
const uint32_t model_format = 0x4E4F534A; const uint32_t model_format = 0x4E4F534A;
stream.write(reinterpret_cast<const char *>(&model_length), stream.write(reinterpret_cast<const char *>(&model_length),
sizeof(model_length)); sizeof(model_length));
@ -7557,8 +7557,8 @@ static void WriteBinaryGltfStream(std::ostream &stream,
stream.write(content.c_str(), std::streamsize(content.size())); stream.write(content.c_str(), std::streamsize(content.size()));
// Chunk must be multiplies of 4, so pad with spaces // Chunk must be multiplies of 4, so pad with spaces
if (padding_size > 0) { if (content_padding_size > 0) {
const std::string padding = std::string(size_t(padding_size), ' '); const std::string padding = std::string(size_t(content_padding_size), ' ');
stream.write(padding.c_str(), std::streamsize(padding.size())); stream.write(padding.c_str(), std::streamsize(padding.size()));
} }
if (binBuffer.size() > 0) { if (binBuffer.size() > 0) {