-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Improve TileMap performances by using quadrants only for rendering #81070
Improve TileMap performances by using quadrants only for rendering #81070
Conversation
047ff4f
to
2c601f3
Compare
What happened to the EDIT:
Not sure what causes it though as it doesn't happen with every scene. EDIT2:
EDIT3: |
Ah good point. I removed it as update are ran once per frame by the TileMap node itself, and not by each layer individually. But it likely makes sense to add it to I'll have a look to the bugs. |
2c601f3
to
d8236c8
Compare
Done. I fixed the bugs and added an optional argument to Edit: I "fixed" CI by adding some lines to the .expected file. However, this error is still logged:
Not sure what we want to do about it. |
4fbc81d
to
924155a
Compare
The previous problems are fixed, but I'm getting this error:
Might be caused by me deleting all collision polygons on a layer. Not sure if intended. |
This is the message given by I am not sure what you mean by "deleting all collision polygons on a layer", I guess by using a runtime update ? If that's the case, it should not prevent |
924155a
to
c6983cf
Compare
As discussed on RocketChat, the compatibility methods added here will provide compatibility for GDExtension, however, renaming these methods will still affect GDScript and C# compatibility. I don't how popular/obscure these methods are, so maybe it's OK if GDScript/C# code calling the old names breaks, but that's a discussion that should be had! If we want to preserve GDScript/C# compatibility, the old methods could be marked as deprecated and simply call the new methods. (And, if we went that way, the compatibility methods for GDExtension could be removed.) |
Yes, I use it do disable collisions on a layer.
In my project I only had 3 uses of |
217bf51
to
8a0b045
Compare
a1b6cc3
to
58327d1
Compare
Put that PR to draft for now, |
f3ead98
to
1326b95
Compare
This is now fixed. Edit: I think the bug was probably here on 4.1 already. This PR likely fix it (see #79658) |
Regarding @akien-mga suggested |
Yeah, that could work fine too. I thought about I don't know, I can't decide ahah. |
They kind of do with the notify method, no? But in that case, just |
If they use the runtime TileData update (which I believe not a lot of users need) they might. But the current For example, if you paint a scene tile, the actual scene will be added only at the end of the frame. That's where you might want to call $TileMap.set_cell(0, position, 0, Vector2i(0,0)) # Set a scene tile.
$TileMap.get_child_count() # returns 0
$TileMap.update_now()
$TileMap.get_child_count() # returns 1 Basically, that means that the main use case for |
Okay, I'm a bit confused about how old code maps to the new one. Can't it be just |
Well, yeah. That would work perfectly, lol. I think I did not consider the idea because it was not possible before due to Edit: done, renamed to |
1326b95
to
dec1f88
Compare
While I welcome the consensus, I'm a bit wary of re-adding methods with a name that's quite generic / can clash with user defined methods. Since it's on TileMap, which is a node users are likely to assign a script too, it's not unreasonable to expect some would have a method named |
dec1f88
to
8c1e282
Compare
Renamed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just re-approve to confirm this consensus :)
Thanks! |
A bit like #74603, but adds a ton of additional optimization and cleanup.
All TileMap update are now pushed at the end of the frame, though you may trigger this update earlier on by calling
force_update()
. Also, I added anotify_runtime_tile_data_update
so that you can tell the TileMap that some runtime data was updated, without triggering a direct update.The TileMap now uses a
dirty
structure (with flags and a list of modified cells) to know what was modified since the last update. Each TileMap's subsystem (rendering, physics, scenes...) then uses those flags and list of dirty cells to smartly update only what is needed. Unlike before, cells are only grouped in quadrants where needed. That means that updating a single cell does not update hundreds of others (at least on the physics matter) for nothing.This improvement, added to a reduction of the number of allocations, lead to a x2.8 performance improvement on TileMap updates. Using this small benchmark script, I measured FPSs:
Right now this is a draft as I need to fix CI, add compatibility methods for
set_quadrant_size
and document a few things. But it's ready for testing otherwise. :)Probably fixes: #79658