Improve NavigationRegion2D debug performance #92372
Merged
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.
Improves NavigationRegion2D debug performance by replacing the canvas polygon and line commands with a static mesh.
This largely copies from the NavigationRegion3D debug mesh creation. The result is a whooping performance jump from ~100 fps to ~1400 fps in my test project with a 10.000+ polygon mesh and an unoptimized dev build.
Like most 2D nodes the NavigationRegion2D used the canvas draw functions for lines and polygons to draw its debug. This caused significant performance issues on complex navigation meshes as the rendering could not keep up with so many inefficient draw commands. This PR changes the debug and turns the entire region debug visuals to a single static mesh used for the rendering.
Note: That the mesh uses an array of vertex colors for everything is not a mistake. This was done due to issues with the 2D canvas rendering api not rendering colors correctly when using meshes without textures. With textures the materials and node canvas modulate did not play nice together and created weird color combinations.