Skip to content
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

Add support for tile image rects in image collection tilesets #277

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

aleokdev
Copy link
Contributor

Wasn't sure whether to put these members inside of TileData or put them in an external struct. Finally I ended up creating a new structure to hold them, but feel free to discuss against it.

@aleokdev aleokdev changed the base branch from current to next August 20, 2023 12:08
@bjorn
Copy link
Member

bjorn commented Aug 21, 2023

I know in the file format this information is currently only used for image collection tilesets. However, internally Tiled also uses it when tileset images are used. So I wonder if it would make sense to not make the image_rect optional, since it would actually be useful to provide this information in that context as well (see #166).

The long-term plan for storing each tile's image rect is to also be able to work with a texture atlas with varying tile sizes, and to improve the handling of expanding the image (when storing each tile's rect, image can be expanded at right and bottom sides without invalidating existing tiles).

Whether this should be a separate struct or not... I don't have a strong opinion. In Tiled I used a QRect just because I had it available and it makes it convenient to pass around. If Rust had a generic rectangle type it might make sense to use it instead, but the ImageRect struct is fine too.

@aleokdev
Copy link
Contributor Author

aleokdev commented Aug 31, 2023

About calculating the image_rect at load time: To my understanding, the <image> tag inside the tileset may appear after any <tile> tag, so the image is not available when loading (Thus we cannot calculate the image rect). Maybe we could just add an image_rect fn to Tile apart from the member in its TileData which returns either the stored image_rect or calculates it from the parent tileset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants