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

Check normal presence before trying to read asMesh normals #654

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

qingyouzhao
Copy link
Contributor

@qingyouzhao qingyouzhao commented Dec 6, 2024

🦟 Bug fix

Fixes there isn't a bug number

Summary

An assimp mesh could contain either

  • the same number of vertices and normals
  • only vertices

Existing code crashes when a mesh contains no normals

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.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

@qingyouzhao qingyouzhao requested a review from marcoag as a code owner December 6, 2024 21:01
Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

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

LGTM!

@azeey
Copy link
Contributor

azeey commented Dec 6, 2024

I'm not sure if the rest of Gazebo handles the case where there are no normals properly. @iche033 do you know?

@iche033
Copy link
Contributor

iche033 commented Dec 7, 2024

I'm not sure if the rest of Gazebo handles the case where there are no normals properly. @iche033 do you know?

gz-rendering should be able to handle meshes without normals

However, I see that gz-physics' dartsim plugin requires normals to be present.

To be safe I think we should add a check and auto generate normals if the assimp mesh does not contain normals, i.e. in the same function before return subMesh; we can add something like:

if (subMesh.NormalCount() == 0u)
  subMesh.RecalculateNormals();

@qingyouzhao
Copy link
Contributor Author

I'm not sure if the rest of Gazebo handles the case where there are no normals properly. @iche033 do you know?

gz-rendering should be able to handle meshes without normals

However, I see that gz-physics' dartsim plugin requires normals to be present.

To be safe I think we should add a check and auto generate normals if the assimp mesh does not contain normals, i.e. in the same function before return subMesh; we can add something like:

if (subMesh.NormalCount() == 0u)
  subMesh.RecalculateNormals();

@iche033 Added.

@iche033 iche033 merged commit a50d8d3 into gazebosim:main Dec 10, 2024
10 checks passed
@iche033
Copy link
Contributor

iche033 commented Dec 13, 2024

@Mergifyio backport gz-common5 gz-common6

Copy link

mergify bot commented Dec 13, 2024

backport gz-common5 gz-common6

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Dec 13, 2024
* In AssimpLoader::Implementation::CreateSubMesh check normal presence before reading
* RecalculateNormals if submesh has no normals

---------

Signed-off-by: Qingyou Zhao <[email protected]>
(cherry picked from commit a50d8d3)
mergify bot pushed a commit that referenced this pull request Dec 13, 2024
* In AssimpLoader::Implementation::CreateSubMesh check normal presence before reading
* RecalculateNormals if submesh has no normals

---------

Signed-off-by: Qingyou Zhao <[email protected]>
(cherry picked from commit a50d8d3)
iche033 pushed a commit that referenced this pull request Dec 13, 2024
* In AssimpLoader::Implementation::CreateSubMesh check normal presence before reading
* RecalculateNormals if submesh has no normals

---------

Signed-off-by: Qingyou Zhao <[email protected]>
(cherry picked from commit a50d8d3)
iche033 pushed a commit that referenced this pull request Dec 13, 2024
* In AssimpLoader::Implementation::CreateSubMesh check normal presence before reading
* RecalculateNormals if submesh has no normals

---------

Signed-off-by: Qingyou Zhao <[email protected]>
(cherry picked from commit a50d8d3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants