From 704821c41ef48b62d15203d9635ae047c5639ce1 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sun, 26 Jan 2025 00:56:43 +0100 Subject: [PATCH] gltf, doc: warn that nodes using matrix transforms mustn't be animated (this is in the spec) --- doc/lua_api.md | 3 +++ irr/src/CGLTFMeshFileLoader.cpp | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index b604b317c..d26327b85 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -312,6 +312,9 @@ due to their space savings. Bone weights should be normalized, e.g. using ["normalize all" in Blender](https://docs.blender.org/manual/en/4.2/grease_pencil/modes/weight_paint/weights_menu.html#normalize-all). +Note that nodes using matrix transforms must not be animated. +This also extends to bone overrides, which must not be applied to them. + You can use the [Khronos glTF validator](https://github.com/KhronosGroup/glTF-Validator) to check whether a model is a valid glTF file. diff --git a/irr/src/CGLTFMeshFileLoader.cpp b/irr/src/CGLTFMeshFileLoader.cpp index e5cef108e..53ae1b580 100644 --- a/irr/src/CGLTFMeshFileLoader.cpp +++ b/irr/src/CGLTFMeshFileLoader.cpp @@ -632,7 +632,6 @@ void SelfType::MeshExtractor::loadAnimation(const std::size_t animIdx) { const auto &anim = m_gltf_model.animations->at(animIdx); for (const auto &channel : anim.channels) { - const auto &sampler = anim.samplers.at(channel.sampler); bool interpolate = ([&]() { @@ -653,6 +652,11 @@ void SelfType::MeshExtractor::loadAnimation(const std::size_t animIdx) throw std::runtime_error("no animated node"); auto *joint = m_loaded_nodes.at(*channel.target.node); + if (std::holds_alternative(joint->transform)) { + warn("nodes using matrix transforms must not be animated"); + continue; + } + switch (channel.target.path) { case tiniergltf::AnimationChannelTarget::Path::TRANSLATION: { const auto outputAccessor = Accessor::make(m_gltf_model, sampler.output);