Skip to content

Commit

Permalink
gltfpack: Don't output empty children array
Browse files Browse the repository at this point in the history
If a node doesn't have attached meshes and all child nodes were
discarded because they were not referenced, we used to output an empty
children array which is not allowed by glTF spec.

Fixes zeux#294.
  • Loading branch information
zeux committed May 29, 2021
1 parent a44ccf6 commit ba03939
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gltf/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,12 @@ void writeNode(std::string& json, const cgltf_node& node, const std::vector<Node
}
append(json, "]");
}
if (node.children_count || !ni.meshes.empty())

bool has_children = !ni.meshes.empty();
for (size_t j = 0; j < node.children_count; ++j)
has_children |= nodes[node.children[j] - data->nodes].keep;

if (has_children)
{
comma(json);
append(json, "\"children\":[");
Expand Down

0 comments on commit ba03939

Please sign in to comment.