-
Notifications
You must be signed in to change notification settings - Fork 62
AssimpImporter: import animations #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
To expand a bit on the interpolation issues: In the case of glTF cubic spline animations, Assimp simply takes the spline knots. While this is not terribly wrong, it's still wrong, but there is no way to get the interpolation function out of Assimp. Same thing applies to step interpolation, although that's probably less relevant. There's also a nasty bug that only got fixed less than a year ago (so way after the latest tagged release 5.0.1): glTF spline tangents are read as key frame values instead of skipping them, producing unusable garbage and, worst of all, leaving no way to reliably detect that we got garbage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
Some ideas that could hopefully unblock the glTF import disaster :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got just a few minutes today, so only a bunch of random comments :)
Looks great so far! 👍
This file is part of Magnum. | ||
|
||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, | ||
2020, 2021 Vladimír Vondruš <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add yourself here, to all touched files :)
Thanks for taking the time to check in even if you're busy, appreciate it. I adressed your recent feedback locally, I'll push it along with all the tests probably tomorrow. Assimp is still abusing me with a funny bug, gotta fix that first. |
Here are the tests 🐌 A few related notes:
Some general comments on format support:
I wanted to test with older versions, but various vcpkg shenanigans threw a wrench in my plans. Not sure how much of this is tested on CI, but I could give this another try with WSL (or as a CMake subdirectory - is that supported for Assimp?). So for now, consider the test extent to be 5.0.1 and master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more you look at Assimp, the more bugs it has 🙈
Thanks!
/* There is a *ridiculous* bug in Assimp 5.0.1(?) with glTF animations that makes it | ||
ignore the value sampler size and always uses the key sampler size | ||
(instead of using the minimum of the two). Wouldn't be surprised | ||
if this produces an out-of-bounds access somewhere, too. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's the trash fire emoji when I need it? 🔥
About the OOB accesses, the ASan CI build is using Assimp 3.2, so I guess we won't get notified there. I suspect it'll be failing locally on my machine tho, will pull the branch and check once I have time.
I already mark the support as red in the file format tables, but perhaps this case would warrant a black "DANGEROUS" label 😆
Good to know. Can you add this as a comment next to the
That's fine. People who still use Collada for animations are fully responsible for their fate, not us. The format is an overengineered insanity.
What's tested is 3.2 on Ubuntu 16.04, whatever is the current version on Homebrew and 5.0.1 on Windows. Assimp supports a CMake subproject (recipe in the docs) but I don't know how far back this works, it's possible that early 4.x might have issues that my Find module isn't aware of. Personally I'd only manually test with 4.0 and let the CI take care of the other versions, or even don't bother with version 4 at all. About the CI failures:
|
Assimp docs say this node must exist, so this should already be an assimp error at import time
798bbea
to
9afb329
Compare
CI still fails, compiler doesn't like the tuple assignment, but I'll rework that bit of code in another commit. Thanks for the detailed feedback with code snippets, makes it a breeze to implement any changes 😃 Exercises left:
|
I fixed the CI failure on Linux locally (loading .gltf without checking for the Assimp version), but the Mac/Mingw one needs some more debugging. Track order seems to be mixed up there. Final stretch 🙏 |
Sigh, FFS. I think this is the problem: https://github.com/assimp/assimp/blob/d855ec2472e82066aedb6d43efd63355d2eb2ef2/code/AssetLib/glTF2/glTF2Importer.cpp#L1364 There's no guarantee about iteration order for a So... I guess the test will need to do some mapping / reordering first (based on target type and target ID, maybe?) and then compare the ordered IDs. Probably not worth the extra maintenance hell to do this directly in the importer code, just in the test. |
@@ -482,9 +482,9 @@ void AssimpImporterTest::animation() { | |||
|
|||
constexpr Vector3 rotationData[KeyCount]{ | |||
{0.0f, 0.0f, 0.0f}, | |||
{0.0f, 0.0f, Float{Rad(-90.0_degf)}}, | |||
{Float{Rad(90.0_degf)}, 0.0f, Float{Rad(-90.0_degf)}}, | |||
{Float{Rad(135.0_degf)}, 0.0f, Float{Rad(-90.0_degf)}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why GCC 4.8 doesn't like the curly braces here?
error: cannot convert 'Magnum::Rad {aka Magnum::Math::Rad}' to 'Magnum::Float {aka float}' in initialization
{Float{Rad(135.0_degf)}, 0.0f, Float{Rad(-90.0_degf)}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, early C++11 spec didn't allow using {}
for conversion operators, only for constructors. Old Clang (3.8) has the same issue. Similar issue is with initializing references, e.g. int& a{b}
doesn't compile there. Newer compilers are more consistent and allow {}
for all those cases.
C++17 then allows using {}
for enum initialization as well (the main reason was to be able to do e.g. std::byte{56}
).
Look at all these green checkmarks 😱🎉
Pending any review changes (and adding copyright data), this is complete from my side. |
Codecov Report
@@ Coverage Diff @@
## master #97 +/- ##
==========================================
- Coverage 94.63% 94.63% -0.01%
==========================================
Files 101 101
Lines 7257 7453 +196
==========================================
+ Hits 6868 7053 +185
- Misses 389 400 +11
Continue to review full report at Codecov.
|
I squashed the commits slightly, keeping the major parts separate, and merged as 9baaadb...e733222. Apart from the "integration tests" with Littlest Tokyo glTF and Steam Locomotive using magnum-player, which went great, I checked locally with AddressSanitizer and there were no out-of-bounds reads or memory issues, only a silly
inside Thanks for a great piece of work, and sorry for having to deal with this buggy 💩 |
This PR adds support for importing node animations with
AssimpImporter
.doAnimation
imports translation vectors, rotation quaternions and scale vectors in separate tracks for each animation channel. Interpolation is assumed to always be linear as Assimp doesn't support any other interpolation types, and it's impossible to get the source data.I reused the
TinyGltfImporter
config values to perform the same sanity fixups. While some Assimp importers perform these themselves (e.g. the FBX importer makes sure to get the shortest rotation path), not all of them do.What's missing:
there's a bug with uninitialized quaternions when usingsee comments about spline-interpolated glTFmagnum-player
, have to investigateCommissioned by Wonderland.