-
-
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
Make TileMapLayers extend Node2D and work as children of TileMap #87115
Conversation
f72850e
to
dde7bdf
Compare
dde7bdf
to
c2735dc
Compare
Ah yeah, I'll fix that.
Yes, that's the plan. Basically you would select a layer node in the scene tree instead of selecting the layer in the bottom dropdown.
Yes, for backward compatibility, but for the TileMap nodes. I might keep the TileMap editor as-is and provide a converter from a TileMap node to TileMapGroup + TileMapLayers. I thought about removing the TileMap editor, and only provide the converter, but I think forcing people to change all their API calls might be a bit too early right now. Basically the plan is:
I kind of agree. Ideally I would have preferred the TileMapLayer node to be a TileMap one (basically removing the possibility to have layers on the TileMap node), but that would have made the backward compatibility a lot more complicated. We could rename TileMapGroup to TileMapLayerGroup, but that felt a bit long to me. |
So this is a problem. The current workflow allows to quickly switch between layers with a shortcut and it's very efficient. This ability should be preserved with the new workflow. However, even if we are able to quickly switch between layers, it will involve inspector updates, which are often expensive. Hence I think the Group node should allow editing all layers at once, like currently. It doesn't need any duplicate code, the editor can handle 2 node types and the group would be an extended case. |
I almost sure this was already discussed, but is it possible (reasonable) to integrate new layer system into old one using concept "use new system if has TileMapLayer child node, use old system if there are no TileMapLayer children"? Of course this will be complicated in terms of code maintinability, but solves "easy to use" goal. BTW please link proposal issue to first post. |
That's a good point, but I think it's probably easily doable.
Hmm, that could maybe be doable but I am not sure. The main problem is that the TileMap node relies on the layers being strictly indexed, so right now, in this PR, there's even an array to list all children layers. So, like, there's kind of an incompatibility between the TileMap editor (with the dropdown) and the TileMapLayer workflow. That probably means that I would need a special editor for TileMapGroup, and would not be able to reuse parts of the TileMap editor. But maybe I can figure out a solution later on. However, this kind of sounds like putting a band-aid on a wooden leg. If switching node is slow due to inspector updates, we should maybe improve the inspector for that (like, threading its update or something).
I'd rather avoid it TBH, this makes things more confusing than they need to be IMO. |
0ebe621
to
71c6be7
Compare
The TileMapLayer editor is the same as TileMap editor, but the dropdown is hidden and fixed to the currently selected layer. As for indexing, when selecting TileMap you can run through all children and assign layers based on the order they appear. They won't change while editing. |
I tested the changes and found some weird bug with collisions. Here I go from one scene to another, and the other scene has tiles with no collision and invisible tiles. The bricks are on a different layer (0) than the sand (2). Output.mp4What's worse, when I return to the first scene, my EDIT: <svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 7v2h2v-2zm3 0v2h2v-2zm3 0v2h2v-2zm3 0v2h2v-2zm3 0v2h2v-2z" fill="#8da5f3"/></svg> |
Have you compared it with master ? The issue might be related to what #86841 solves, so I am not sure this PR causes it. Let me know. |
The problem does not exist on master. |
71c6be7
to
b4c2572
Compare
The collision issue is fixed, but the null collider bug still exists (i.e. |
Hmm, that's quite weird. It seems attached to the tilemap node correctly: |
It does not happen consistently. In my case it happens when going to another scene and back (refer to my comment/video above). |
I tried reproducing the bug but no luck. I tried something like that (trying to see if reloading would would have an impact):
But it still works after a reload (the collider ID is different after pressing R, which proves the TileMap has been correctly replaced). |
In my case I don't truly change/reload scene, just swap the map. The player node exists between scenes. Seems like this is the required condition. Here's some simple repro scene: |
c3e40b0
to
7ac6112
Compare
The destructor for layers was simply not cleaning things up, including physics bodies. So you would end up with bodies attached to a freed node. I updated the PR and it should be fixed now. (It works in the MRP at least) |
7ac6112
to
48bed50
Compare
I also added @KoBeWi 's icon. It's a bit weird, but that's a good placeholder for now: |
Thanks! |
Ah damn, the canvas_item.cpp changes was wrong, I was expecting the other PR to be merged before and to rebase that one. Sorry, I should have said it. I'll open a PR to fix that tomorrow. |
No worries, we're not going into stable yet 🙃 Edit: If by the other you mean #86841, I assume all we need to do is to remove the line about the transform from this changeset? |
Will this change make an idea like selecting tiles in multiple layers, as described in this proposal (godotengine/godot-proposals#9296) harder or easier? |
Selecting multiple layers will be easier, but it doesn't affect editing them. The editor can still only handle a single layer. |
The main goal of this PR is to start the work of moving TileMapLayers to individual nodes. For now, those are implemented as TileMap internal nodes, but I aim to move them as independent nodes in later PRs.
A few notes:
collision_animatable
,rendering_quandrant_size
,collision_visibility_mode
, etc...). The plan here is to "duplicate" those properties at the layer-level, then make the TileMap node update all its children layers at once.Once this is merged, I plan in the short term to remove the remaining dependencies from TileMapLayer to TileMap, then to split TileMap into two:
Related to: godotengine/godot-proposals#7122