Fix MeshInstance3D
gizmo redraw performance for PlaneMesh
with larger subdiv value
#96934
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
MeshInstance3D
editor gizmo had really low performance when the node had aPlaneMesh
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.