-
Notifications
You must be signed in to change notification settings - Fork 59
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
CgltfImporter #107
CgltfImporter #107
Conversation
1cf071b
to
edaeba2
Compare
Oooo, wonderful! 🎉 Looking forward to diving into the code. Wait, the tinygltf plugin compiles in just 5 seconds for you? Here I always have to wait about half a minute for a compile + link, longer than all other plugins combined... The binary size reduction is awesome.
Wow, also? 🤩 I suppose there's some bits missing in |
Yeah, that needs some extra wiring in As for CI failures: the Emscripten one I'm not sure about, seems like a recent issue with sourceforge? The AddressSanitizer error is interesting, I'll have to see if that's a genuine bug but it has to be fixed upstream either way. It doesn't like overlapping |
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.
I went through hopefully everything, what's left is looking at the coverage and checking if there are some untested areas.
- The Emscripten CI failure is worked around in a7a8b43, so if you rebase then it should go through.
- The ASan failure about overlapping
strcpy()
is valid I guess (would happen with e.g.\\ab
already, copyingab
over\a
), and same as withmemcpy()
it's not allowed. Not sure if there's any standardstrmove()
equivalent tomemmove()
tho, I suppose you'd need to get the string size first and then use themem*()
APIs instead?
edaeba2
to
4189b53
Compare
I addressed everything except moving validation to the plugin side, I'll work on that tomorrow. I'll send PRs for the two cgltf changes related to string decoding, but those might take a few days to get merged. Should I push the changes locally for now so tests pass and you can see test coverage? |
Yes please, good idea. The Emscripten test seems to be failing due to some files not being specified in the |
With Possible candidates:
|
That sounds great, if it's not too much boring work :)
Now that you made
Yes, if it reduces the amount of tests it's good :)
The Khronos Basis extension only, as that one is long overdue. No need for the others, CgltfImporter will get all the new goodies instead.
Yes, this counts as a security/robustness fix.
I'd keep this as-is, some projects depend on the current way already, and once the attributes become builtin it would change again. No need to make a breaking change twice I'd say. (For CgltfImporter the way you implemented is fine, as it's closer to the builtin way.)
No need, it'd however be good to mention it among the limitations so people are aware. Similarly for the missing Apart from the above, the scene cycle detection is probably worth backporting as well. |
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.
Looked at the coverage, pretty good actually :) The few uncovered lines might point to some error checking redundancy.
Apart from that there's some uncovered lines in two switch cases that deal with types and formats, but I don't think that's worth writing explicit tests for, the code in question is trivial enough to not need that.
|
||
Containers::Optional<Containers::StridedArrayView2D<const char>> src = _d->accessorView(accessor, "mesh"); | ||
if(!src) | ||
return Containers::NullOpt; |
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.
Also uncovered, probably the same as the two other cases before. Hmm, doesn't checkAccessor()
handle this already? In that case maybe accessorView()
and checkAccessor()
could be conflated into a single function that returns a null view on failure, instead of having one that returns a bool and then another where you have to check the return value again.
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.
checkAccessor
makes sure accessor ranges are correct, ie. the buffer (view) is large enough, etc. accessorView
on the other hand, loads the buffer (if not already loaded). Main reason they're separate is to delay buffer loading to the latest possible point. This is currently used in doMesh
, where for each attribute the accessors are checked and their ranges are merged, and at the very end the single buffer is loaded.
I'm almost done with the coverage improvements, but the Finish line todo list:
|
e3e2e11
to
c60bbea
Compare
This should be ready for (the last? 🙉) review. All outstanding issues should be fixed (except for that cgltf change, but that can be done in a later PR). |
Ah, this is missing test coverage for invalid input to |
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.
Okay, last things:
- This one comment about extension warnings
- The coverage fixes you mentioned above
- I looked at the commit log and given that some changes were rather sweeping (adapting to TinyGltf test changes, ditching
cgltf_validate()
...) I'm thinking it could be all squashed into two commits:- one with adding the cgltf dependency (and mentioning jkuhlmann/cgltf@9ba04b0 in the commit message now that the last change was merged as well)
- and the other with the rest :)
Thank you!
Just double-checking so I don't do anything stupid here: you want me to squash the entire PR down to two commits locally and then force-push? One commit with cgltf.h and all the other files in another commit? |
Yep :) |
commit dd70e93c7e40a328bde2a1a8f30c6597f6df69c1
c60bbea
to
5881d19
Compare
I squashed everything down, but I kept a branch in my fork with the full commit history just in case 👀 |
Ahh, playing with the new plugin feels great, everything exceeds expectations. In my case it's the following (native builds use the
I blame the leftover Looked at import time using For memory consumption ( |
👋 Here's the initial version of
CgltfImporter
to import glTF 2.0 files using cgltf.As far as features are concerned, it's a drop-in replacement for
TinyGltfImporter
, but there are a few minor changes in behaviour (see below). Large parts of its code and tests were re-used and adapted for cgltf, making some parts more trivial than expected.There aren't any major TODOs, only a few things I'd appreciate some feedback on, all marked with
@todo
in the code (some are kept fromTinyGltfImporter
code). So unless CI breaks I won't be changing anything until the first review round.Noticable improvements
Compared to
TinyGltfImporter
, using VS 2019, Release build:Subtle differences that may impact users switching from
TinyGltfImporter
LoadPermanent
and returned views on resources have to stay valid until the importer is closed.WEIGHTS
andJOINTS
are imported as a single custom attribute with multiple sets, mimicking behaviour ofAssimpImporter
and preparing for Skinned Mesh attributes magnum#441TinyGltfImporter
ignored percent encoding.New features
GOOGLE_texture_basis
)asset.version
is checked against the supported glTF version (2.0)