godot icon indicating copy to clipboard operation
godot copied to clipboard

Improve tilemap performance by using quadrants only for rendering

Open groud opened this issue 1 year ago • 4 comments

This PR is a huge refactor of the TileMap internals. It makes it so any update does not have to update a full quadrant for all systems (physics, navigation, etc...) but only for the rendering part. It should help significantly reduce the slowdowns in the editor.

This PR does not do it right now, but we could probably revert what does: https://github.com/godotengine/godot/pull/67330. This would simplify the code a bit, and since a cell would only be modified if it was actually changed, the original issue would still be solved.

To be tested, but it should close #72405

groud avatar Mar 08 '23 12:03 groud

If I read this pr correctly you are removing the quadrant entirely for everything that is not rendering.

I am not convinced that this is a good idea.

While this may mitigate some performance cost for updating single cells it also basically voiding chances of fixing physics collision and navigation mesh performance and quality issues. Those issues are not the result of quadrant update costs but from having so many splintered and small cells in the first place. For merging collision and navigation polygons an in-between update unit like quadrants is still needed.

smix8 avatar Mar 08 '23 14:03 smix8

While this may mitigate some performance cost for updating single cells it also basically voiding chances of fixing physics collision and navigation mesh performance and quality issues. Those issues are not the result of quadrant update costs but from having so many splintered and small cells in the first place. For merging collision and navigation polygons an in-between update unit like quadrants is still needed.

The idea would be to reintroduce per-system quadrants where needed. We can easily add some PhysicsQuadrant and NavigationQuadrant that can have different sizes from the RenderingQuadrant size. This needed for games with Y-sorting for example, as, right now, enabling Y-sorting forces the quadrant size to 1. Having different quadrant types and different associated size would greatly improve performances in that case.

groud avatar Mar 08 '23 14:03 groud

Guess that is fine too.

Does not have to be this pr but could you add those navigation "quadrants" as you see fit in a draft / pr.

I added the navigation polygon merging for TileMap quadrants in the NavigationMeshGenerator rework expecting the quadrants to be available, now I dont know how to remake that part with them removed.

smix8 avatar Mar 08 '23 14:03 smix8

Does not have to be this pr but could you add those navigation "quadrants" as you see fit in a draft / pr.

Yeah, sounds good! Once this one gets merged, I'll open a branch adding those other quadrant types, I guess you may rebase your work on top of it or something like that.

groud avatar Mar 08 '23 14:03 groud

Whats the status on this one? Will it be added on the next patch? Im the one opened this https://github.com/godotengine/godot/issues/72405 and im struggling bad with crashes/freezes all the time.

grusad avatar Apr 25 '23 06:04 grusad

Whats the status on this one? Will it be added on the next patch? Im the one opened this https://github.com/godotengine/godot/issues/72405 and im struggling bad with crashes/freezes all the time.

I don't think so, it needs a lot of work and I lack time to do so. Maybe someone could help but that's a difficult problem to solve.

groud avatar Apr 25 '23 11:04 groud

thats unfortunate. Tiled just got an exporter for godot 4, i'll have to check that one out.

grusad avatar Jun 06 '23 05:06 grusad

I'll close this PR and open a new one, the changes are a bit different now and need more explanations.

groud avatar Aug 28 '23 11:08 groud