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

[3.x] Fix Mesh::get_face_count() #88198

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Feb 11, 2024

This fixes a minor bug whereby facecount was actually returning the facecount * 3. There were no major problems from this, but it did mean the optional threshold poly count used when merging was out by a factor of 3.

I've also taken the opportunity to rename it to triangle count rather than face, because generate_triangle_mesh() currently relies on it being triangles.

Notes

  • get_face_count() has only been present in 3.x for a few days since [3.x] Add MergeGroup node to simplify merging Meshes at runtime #61568 so there is little likelihood of any knockon problems fixing this.
  • I managed to track down why I had inadvertently introduced this during MergeGroup PR: it was due to some rather dodgy naming cough by the previous author 😁 (that I copy pasted code from) where faces_size was not the face count, but the number of vertices used by the faces.
  • I have improved the naming of the variable in Mesh::generate_triangle_mesh() to prevent this happening again.
  • It was only used in 2 places: In Mesh::generate_triangle_mesh() (where it caused no problems due to the aforementioned naming), and optionally when merging if the user had set a threshold poly count for splitting (where the threshold would have been out by 3, which is no big problem).

@lawnjelly lawnjelly added this to the 3.6 milestone Feb 11, 2024
@AThousandShips AThousandShips changed the title Fix Mesh::get_face_count() [3.x] Fix Mesh::get_face_count() Feb 11, 2024
@kleonc
Copy link
Member

kleonc commented Feb 11, 2024

  • I managed to track down why I had inadvertently introduced this during MergeGroup PR: it was due to some rather dodgy naming cough by the previous author 😁 (that I copy pasted code from) where faces_size was not the face count, but the number of vertices used by the faces.

This sounds familiar... yep - that was me! I've changed it to faces_size from... facecount (#61559). I've also had "who named it like that" moment back then. 😆

scene/resources/mesh.cpp Outdated Show resolved Hide resolved
@lawnjelly
Copy link
Member Author

This sounds familiar... yep - that was me! I've changed it to faces_size from... facecount (#61559). I've also had "who named it like that" moment back then. 😆

Ha that's super funny, I'd assumed the pointy finger of blame was Juan! 😆

Hopefully new name is a little more obvious, but it is slightly confusing code there.

This fixes a minor bug whereby facecount was actually returning the facecount * 3.
There were no major problems from this, but it did mean the optional threshold poly count used when merging was out by a factor of 3.
Copy link
Member

@kleonc kleonc left a comment

Choose a reason for hiding this comment

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

LGTM!

@akien-mga akien-mga merged commit 1ad9e85 into godotengine:3.x Mar 8, 2024
13 checks passed
@akien-mga
Copy link
Member

Thanks!

@lawnjelly lawnjelly deleted the fix_facecount_bug branch March 8, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants