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 MeshInstance3D gizmo redraw performance for PlaneMesh with larger subdiv value #96934

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

smix8
Copy link
Contributor

@smix8 smix8 commented Sep 12, 2024

The MeshInstance3D editor gizmo had really low performance when the node had a PlaneMesh with larger subdiv value.

This caused noticeable editor frame stutters everytime the node was selected or unselected, the mesh was changed, or just an input happened close to the plane AABB.

E.g. a 100+ subdiv PlaneMesh for terrain / water would cause noticeable performance issues with each update. A 1000+ subdiv would freeze the entire editor for multiple seconds. With this change the update is almost instant again.

It was so slow due to every call to gizmo redraw creating a new TriangleMesh for the PlaneMesh gizmo collision.

The TriangleMesh did exessive BVH tree building and AABB calculations for every single mesh face and an average subdiv plane mesh had easily a few thousands of them. For a specialized Mesh type that can only be a flat plane no matter the subdiv this is totally unnecessary and 2 faces is enough for the input collision that the editor needs.

Fixes gizmo redraw performance for PlaneMesh with larger subdiv value.
@smix8 smix8 added this to the 4.4 milestone Sep 12, 2024
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Makes sense to me. I wish there was an elegant way to expand this for all PrimitiveMeshes. But for now, it makes sense to do for PlaneMesh as that is the most common one to have a huge subdivision amount.

@akien-mga akien-mga merged commit d5d6c73 into godotengine:master Sep 13, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@smix8 smix8 deleted the planemesh_gizmo branch September 13, 2024 14:15
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