Skip to content
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

Add static glTF support #14557

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

JosiahWI
Copy link
Contributor

@JosiahWI JosiahWI commented Apr 18, 2024

This adds code for loading static glTF meshes to get a scaffold in place to keep the rest of the glTF feature PRs small and focused. There is some debate about whether that is worthwhile; I am marking this as draft. But every time I have to rebase this it takes up hours of my time, so I would like to land this very soon so it can be over with. This has been reviewed by me and @appgurueu.

To do

Ready for Review

How to test

The code is covered pretty thoroughly by Catch2 tests, which are waiting on #14656. The code is ready for review, though, and it should now work to load static glTF models. We have screenshots of this we could share as well.

irr/include/IMesh.h Outdated Show resolved Hide resolved
@appgurueu appgurueu mentioned this pull request May 14, 2024
8 tasks
@appgurueu
Copy link
Contributor

I have a branch based on this that also adds animation support now. You can just compile that branch to enjoy an animated gltf spider in Minetest.

The only major thing left to be done is to actually run the tests there via catch2, which depends on #14565.

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented May 17, 2024

I've tested @appgurueu's branch and it works fine! I think it deserves a proper PR, assuming this PR is stale.

@appgurueu
Copy link
Contributor

I've tested @appgurueu's branch and it works fine! I think it deserves a proper PR, assuming this PR is stale.

This PR is (like my branch, which is based on this) waiting on the Catch2 PR, so that we can get the unit tests to work.

However, we don't know yet whether the other devs would like to review this as one big PR which adds supported for animated gltf, or first a slightly smaller PR to add support for static gltf, then a follow-up PR to add animation support.

I personally would prefer one big PR because this lets me avoid rebase hell, but ultimately it's up to the reviewer to decide.

@JosiahWI
Copy link
Contributor Author

This could already be reviewed in its current state. The work to get the unit tests to work with the build should not block any review efforts except that reviewers may have more trouble verifying that the tests work. We could also push a temporary patch so that the tests can be run separately from --run-unittests for review purposes. If a core dev is ready to review this, please go ahead.

@appgurueu appgurueu added Roadmap The change matches an item on the current roadmap. Feature ✨ PRs that add or enhance a feature @ Client rendering labels May 21, 2024
Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said, this has my approval as a co-author. There are still a few details in tiniergltf for me to sort out - nothing that negatively impacts loading of correct models, however - and the aforementioned To-Do of fixing the build to include unit tests. Still, this PR is ready to be reviewed.

@appgurueu appgurueu added One approval ✅ ◻️ Waiting (on dependency) Waiting on another PR or external circumstances (not for rebases/changes requested) labels May 21, 2024
@appgurueu appgurueu marked this pull request as ready for review May 21, 2024 16:07
irr/include/IMesh.h Outdated Show resolved Hide resolved
irr/include/SSkinMeshBuffer.h Outdated Show resolved Hide resolved
irr/src/CGLTFMeshFileLoader.cpp Show resolved Hide resolved
#include "quaternion.h"
#include "vector3d.h"

#include "tiniergltf.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "tiniergltf.hpp"
#include <tiniergltf.hpp>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this, I think we should treat it as one of the Irrlicht headers and not a vendored third-party lib.

irr/include/SSkinMeshBuffer.h Outdated Show resolved Hide resolved
irr/src/CGLTFMeshFileLoader.cpp Outdated Show resolved Hide resolved
irr/src/CGLTFMeshFileLoader.cpp Outdated Show resolved Hide resolved
irr/src/CMakeLists.txt Outdated Show resolved Hide resolved
@@ -337,6 +340,8 @@ add_library(IRROBJ OBJECT
CMeshCache.cpp
)

target_link_libraries(IRROBJ PRIVATE IRRMESHOBJ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh?

Copy link
Contributor Author

@JosiahWI JosiahWI May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRROBJ needs the transitive include for the tiniergltf header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have resolved this, but please check whether this is satisfactory.

irr/src/tests/CMakeLists.txt Outdated Show resolved Hide resolved
@sfan5
Copy link
Member

sfan5 commented May 21, 2024

One more question: since GLB avoids the need to handle base64 decoding and is more efficient, has supporting it been considered?

@JosiahWI
Copy link
Contributor Author

JosiahWI commented May 21, 2024

Yes, it has been considered, and it should be quite an easy change (relative to animation for example), but I did not prioritize it for this PR because it works well as its own chunk of functionality that could be PRd separately. However, we could reconsider whether we want to initially support glTF or glb.

irr/src/CGLTFMeshFileLoader.h Outdated Show resolved Hide resolved
irr/src/tests/CMakeLists.txt Show resolved Hide resolved
@JosiahWI
Copy link
Contributor Author

JosiahWI commented May 21, 2024

I have squashed the commits that were not fixes to recent review comments and rebased on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client rendering Feature ✨ PRs that add or enhance a feature One approval ✅ ◻️ Roadmap The change matches an item on the current roadmap. Waiting (on dependency) Waiting on another PR or external circumstances (not for rebases/changes requested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants