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

Fix glTF / glb root node transform #543

Merged
merged 5 commits into from
Oct 23, 2023
Merged

Fix glTF / glb root node transform #543

merged 5 commits into from
Oct 23, 2023

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Oct 13, 2023

🦟 Bug fix

Summary

There is a long standing issue in assimp on models having incorrect rotations: assimp/assimp#849.

Currently, our assimp loader drops the root node transform (setting it to identity) to work around the issue. However, this caused other assets's rotation to be appear incorrect and inconsistent with other rendering / modeling tools. This PR adapts a another workaround posted in assimp/assimp#849 to fix the root node transform for glTF / glb meshes.

Update as of 40c7bbb - Changes should how only affect glTF / glb and kept the same behavior for other file formats like dae.

Here are tests with a couple of glb meshes in gazebo and other tools. The camera in Gazebo is set up to have the same orientation as the these tools (Y up, facing -X)

WaterBottle

Gazebo Before (ignore the black seam at the front, it's clipped by camera's near clip plane):
WaterBottle_before

Gazebo After (pay attention to logo on the bottle):
WaterBottle_after

three.js editor:

WaterBottle_threejs_editor

godot:
WaterBottle_godot

BarramundiFish:

Gazebo Before:
BarramundiFish_before

Gazebo After:
BarramundiFish_after

three.js editor:
BarramundiFish_threejs_editor

godot:
BarramundiFish_godot

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Ian Chen <[email protected]>
@iche033 iche033 requested a review from marcoag as a code owner October 13, 2023 22:05
@github-actions github-actions bot added 🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic labels Oct 13, 2023
@iche033
Copy link
Contributor Author

iche033 commented Oct 13, 2023

@luca-della-vedova do you still remember the meshes that you were having the rotation issue with? I should probably also test them to make sure they still work

@iche033 iche033 marked this pull request as draft October 13, 2023 23:28
@iche033 iche033 marked this pull request as ready for review October 14, 2023 02:15
@codecov
Copy link

codecov bot commented Oct 14, 2023

Codecov Report

Merging #543 (183fd39) into gz-common5 (d9d1722) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 183fd39 differs from pull request most recent head 9b533c8. Consider uploading reports for the commit 9b533c8 to get more accurate results

@@              Coverage Diff               @@
##           gz-common5     #543      +/-   ##
==============================================
+ Coverage       83.64%   83.66%   +0.01%     
==============================================
  Files              90       90              
  Lines           10243    10252       +9     
==============================================
+ Hits             8568     8577       +9     
  Misses           1675     1675              
Files Coverage Δ
graphics/src/AssimpLoader.cc 89.33% <100.00%> (+0.36%) ⬆️

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

can we add a test to UpdatedRootNodeTransform ?

@luca-della-vedova
Copy link
Member

luca-della-vedova commented Oct 16, 2023

@luca-della-vedova do you still remember the meshes that you were having the rotation issue with? I should probably also test them to make sure they still work

Very interesting, thanks for the fix!
I believe the issue was actually not found on glb models but on other extensions, I can't remember the details but I believe one of the meshes that gave us the most trouble was the walking actor (collada).
All the glb meshes we used had identity transforms in the root node.

Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Oct 16, 2023

can we add a test to UpdatedRootNodeTransform ?

After testing with different glb meshes, I found that most of the code from the workaround is actually not needed so I simplified the fix quite a bit in 8b0d752. The current AssimpLoader tests has code to load glTF / glb meshes and should now cover all of the the new code (coverage).

@iche033
Copy link
Contributor Author

iche033 commented Oct 16, 2023

I believe the issue was actually not found on glb models but on other extensions

ah ok I see! The changes in this PR should only affect glTF / glb meshes and not daes so I think we should be fine here.

Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Oct 17, 2023

added one more test to verify that the glb mesh's vertices are correct. 9b533c8

@ahcorde ahcorde enabled auto-merge (squash) October 23, 2023 16:28
@ahcorde ahcorde merged commit afc1ab0 into gz-common5 Oct 23, 2023
@ahcorde ahcorde deleted the glb_root_transform branch October 23, 2023 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants