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

Tileset helper for obtaining UVs #166

Open
aleokdev opened this issue Feb 20, 2022 · 5 comments
Open

Tileset helper for obtaining UVs #166

aleokdev opened this issue Feb 20, 2022 · 5 comments

Comments

@aleokdev
Copy link
Contributor

Add a function for obtaining the UV of a tile given its ID.

@aleokdev
Copy link
Contributor Author

Perhaps it would be a good idea to also create a TileData and make Tile an encapsulation, which would avoid the extra index if the user already had the tile in question.

@Anti-Alias
Copy link
Contributor

Perhaps it would be a good idea to also create a TileData and make Tile an encapsulation, which would avoid the extra index if the user already had the tile in question.

I am for this, as it keeps the API flatter and more performant.
It means, excluding Tileset and maybe some other types, that the user only needs to talk to the facade types rather than sometimes talking to Type1<'map> and sometimes talking to &'map Type2, which is a little inconsistent.
(Perhaps, if the situation changes, Tileset may need its own wrapper, though I don't know of any usecases yet)

I like your suggestion in #164 of just returning a rect measured in pixels.
I think we can also add a helper function to this new Tile<'map> type called uvs(flip_y: bool) -> ((f32, f32), (f32, f32)), which can make use of the rect function.

In the helper function:

  • If flip_y is true, then use OpenGL uvs.
  • If flip_y is false, then use DirectX, Metal, Vulkan uvs.

@aleokdev
Copy link
Contributor Author

It means, excluding Tileset and maybe some other types, that the user only needs to talk to the facade types rather than sometimes talking to Type1<'map> and sometimes talking to &'map Type2, which is a little inconsistent.

It would be inconsistent anyways. The lifetime of the suggested Tile facade would be of 'tileset, not map. But yes, the interface is very inconsistent right now, specially in terms of types and properties.

@bjorn
Copy link
Member

bjorn commented Mar 1, 2022

Add a function for obtaining the UV of a tile given its ID.

Just to mention, personally I would find it more suitable to pre-calculate and store the UVs (or rather, the pixel location) of each tile and store it in the TileData. That way the rendering loop doesn't need to keep calculating this based on the margin and spacing and such. But, I guess with TileData wrapped in the public API, it would be possible to add that later as well.

@aleokdev
Copy link
Contributor Author

aleokdev commented Mar 1, 2022

Postponing to 0.11 since the change is no longer breaking.

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

No branches or pull requests

3 participants