Skip to content

Commit

Permalink
Don't write empty buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
danwillm committed Jul 1, 2024
1 parent 6febff0 commit 07c6e6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/gltf/GltfModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,14 @@ class GltfModel {
if (!holder.ptrs.empty()) {
std::vector<json> bits;
for (const auto& ptr : holder.ptrs) {
bits.push_back(ptr->serialize());
json bit = ptr->serialize();
if (!bit.empty()) {
bits.push_back(ptr->serialize());
}
}
if (!bits.empty()) {
glTFJson[key] = bits;
}
glTFJson[key] = bits;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/gltf/properties/BufferData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ BufferData::BufferData(
: Holdable(), isGlb(false), uri(isEmbedded ? "" : std::move(uri)), binData(binData) {}

json BufferData::serialize() const {
if (binData->size() == 0) {
return json{};
}

json result{{"byteLength", binData->size()}};
if (!isGlb) {
if (!uri.empty()) {
Expand Down

0 comments on commit 07c6e6a

Please sign in to comment.