-
-
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
Fix TileMap
quadrant canvas item position not being local
#86847
Fix TileMap
quadrant canvas item position not being local
#86847
Conversation
Thanks for the contribution. I am not sure this makes sense, and not sure the original issue either. I think this will break anyway as soon as you have tiles that are bigger than a cell, with either big tiles, or a texture region size configured in the atlas bigger than the tile size. The "top left corner" of the CanvasItem cannot be determined unless you know which tile is in the top left cell, which is a problem as all vertex coordinates would change depending on it. For me, the original behavior is expected and preferable. |
c8da9fb
to
011ac74
Compare
First of all I had a bug in this PR as
Oh, I meant the top left of the bounding rect of the quadrant's "first cell" (cell at Like for isometric or hexagonal shapes using The most important part is that when opening this PR I haven't remembered about I still think the current positions set for quadrant canvas items are strange / confusing though. But with this PR I see users still being confused, just differently. 😄
So in case you still disagree with this PR then please close / give a closing note in #86812 as in such case there's nothing to be done about it. And of course thanks for the feedback! |
What I mean is that this value does not mean a lot. If you have a texture region size bigger than the grid, then all quadrants will end up unaligned with you textures anyway, and the origin won't be a the "correct" position. To make it clear, my point is that there's not a lot more sense to align the origin of canvas items to the top-left corner of the cell than there is to align it to the center of the top-left cell. The center of the cell is in general consistent with the way the TileMap node deals with cells. So yeah, it might be a bit weird at first, but all offsets/positions in the tile configurations are done according to the center of the cell. So I think we should keep things consistent there.
I wonder if we could provide some built-in shader variables for the TileMap node. That could be a better approach IMO. |
This would be a good idea in general |
011ac74
to
3c25274
Compare
Yeah, I agree. Pretty much the only advantage I can see of the top-left over the center is that it seems nicer for the most basic case of a rectangular grid. For any other setup there will always be something off. For such other setups the center indeed seems like a more reliable reference point. And consistency is a good point in favor of the center. Just to be clear: currently (before this PR) it's neither the top-left corner nor the center of the cell, it's the map-coords of the cell (see #86812 (comment)). Anyway, I agree in general center makes more sense than top-left, so I've pushed a change so it's center now in this PR (if needed it's easy to offset manually by the half cell size anyway).
AFAICT from the rendering POV a TileMap is just an arbitrary canvas item in the middle of some canvas item parent-children hierarchy. And if I get it right you're suggesting to somehow provide some partial transforms to such specific canvas item (TileMap) to be available in a shader run for a different (descendant) canvas item (quadrant)? I have no idea if this is feasible / how would it meant to be done. Of course I agree having built-in transforms like (quadrant to TileMap / TileMap to global / their inverses) would be nice from the user POV. But yeah, I don't see the "how". 🙃 |
Oh damn, you are right. Indeed that was the original intent for that code. I just focused on the "half a cell" offset but not on that. using
Yeah I'm not sure either. It's unclear to me what could be done, I was suggesting this as a general idea if it could help. Anyway, in its current state the PR looks good. Approved. |
Thanks! |
Should fix #86812, see #86812 (comment) for details.