-
Notifications
You must be signed in to change notification settings - Fork 102
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
Adding tile id to tile #164
Conversation
Ultimately, what I need (and what others are likely to need) are the XY coordinates of a tile in it's TileSet so that its UV coordinates can be derived for rendering. It might be better for the Tile to simply store it's XY coordinate and or UV coordinates. But what do you all think? |
No; If you have access to As for UV coordinates, we should probably add a helper in |
This is not precise; You can't obtain the Tile's UV just from its ID. That's assuming that the tileset isn't an image collection tileset and it has no padding nor margin. I do agree that obtaining the UV is a complex issue that shouldn't be left to the user. As such, adding the tile ID is not a solution nor a workaround to the issue. That being said, I'll prioritize having UVs ready for today if possible; Thanks for using the master branch and reporting on everything that's missing! |
I have no idea how I missed LayerTile's id() function....
Of course! Always good to have code battle tested.
I should have clarified: While I'm iterating a TileLayer<'map>, I acquire a LayerTile<'map> and it's Tileset reference. With both of these, I can derive the UVs. My code does do the margin/spacing calculation. My code also ignores image collection tilesets as they're not yet supported.
Awesome! I discovered that the UV calculation is quite the involved process and easy to mess up. This would definitely make things easier for a ton of folks, I imagine. flip_y: bool The reason I ask is that I'm using Bevy, which uses OpenGL-style UVs, where (0, 0) is bottom left, (1, 1) is top-right. |
Since UVs depend on the API as you said, it's probably much better to just provide a tile_texture_rect function that returns the result in pixels which the user can then convert into their desired coordinates. Let's keep track of this issue in #166 |
I'd like for the Tile struct to include it's own id.
For my personal project, I need to know the tile id in order to derive it's coordinates in the tileset it belongs to.
IE: