-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
[3.x] Fix rendering tiles using nested AtlasTextures #76703
[3.x] Fix rendering tiles using nested AtlasTextures #76703
Conversation
3dca77b
to
12c923c
Compare
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.
Looks good to me. Once @lawnjelly takes a look this should be good to merge
Sorry been away for week, great work on finding this! 👍 |
Looks like I didn't notice this function was virtual 😊 when making the PR and had some different implementations... The general approach here looks good to me too, replacing the call to I wonder if for the complex texture types
From a quick search in the original PR #68960 it seems like only the tilemap is calling The only thing I wasn't totally sure about was the name of the new function |
Am now working on a slightly modified version of this PR (will add coauthor with @kleonc as he found the problem / fix) that should fix all the cases, so maybe we can hold off on merging this until we have the other PR for comparison / discussion. |
Thanks! |
Oops, I hadn't seen this comment and this PR had two approvals so I went ahead and merged it. #76775 can probably be updated to include a revert of the changes that would not be necessary with that other approach, so it can still be evaluated as a potentially better option to merge later on. |
Oops! 😄 Is okay, I'll rebase. This PR does fix the major bug, but we want to catch the other cases as well. |
In #68960 rendering TileMap tiles was changed from:
godot/scene/2d/tile_map.cpp
Line 571 in 1426cd3
to:
godot/scene/2d/tile_map.cpp
Line 578 in 910ddd1
AtlasTexture's override of the
Texture::draw_rect_region
was properly handling nested AtlasTextures, butVisualServerCanvasHelper::tilemap_add_rect
is not, it uses the passed rects directly within the VisualServer.This PR adds
Texture::get_combined_rect_region
virtual method which returns the proper final dst/src rects in case of nested AtlasTextures. Such rects can be passed toVisualServerCanvasHelper::tilemap_add_rect
and alike.I've changed only the TileMap to use this new method, not sure if anything else would need to be changed too (like fonts or anything else changed in #68960? 🤔).
Not sure if that's the best solution but it works. 🙃
Fixes #76686.
Also removed
MeshTexture::get_rect_region
override as it was doing the same thing asTexture::get_rect_region
anyway.