Skip to content

Commit b84aee2

Browse files
committed
glTF: Ignore animation channels missing target nodes
The glTF spec allows omitting this. For us it makes the animation channels pointless since we support no extension that would provide a target via some other means. Exporters like Blockbench do produce this, and for interoperability it's better to ignore and warn.
1 parent fc47cfd commit b84aee2

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

irr/src/CGLTFMeshFileLoader.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,6 @@ void SelfType::MeshExtractor::loadAnimation(const std::size_t animIdx)
701701
auto &irr_anim = m_irr_model.getAnimation(m_irr_model.addAnimation());
702702
irr_anim.name = anim.name.value_or("");
703703

704-
for (const auto &chan : anim.channels) {
705-
if (!chan.target.node.has_value())
706-
throw std::runtime_error("no animated node");
707-
}
708-
709704
std::vector<decltype(anim.channels)::const_iterator> chan_its(anim.channels.size());
710705
std::iota(chan_its.begin(), chan_its.end(), anim.channels.cbegin());
711706
// Group by target node
@@ -715,10 +710,17 @@ void SelfType::MeshExtractor::loadAnimation(const std::size_t animIdx)
715710
});
716711

717712
for (auto it = chan_its.begin(); it != chan_its.end();) {
713+
if (!(*it)->target.node) {
714+
warn("animation channel targets no node, ignoring");
715+
++it;
716+
continue;
717+
}
718+
718719
const std::size_t target_node = *((*it)->target.node);
719720
const auto *joint = m_loaded_nodes.at(target_node);
720721
if (std::holds_alternative<core::matrix4>(joint->transform)) {
721722
warn("nodes using matrix transforms must not be animated");
723+
++it;
722724
continue;
723725
}
724726
SkinnedMesh::Keys keys;

0 commit comments

Comments
 (0)