-
Notifications
You must be signed in to change notification settings - Fork 106
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 tileset index #162
Adding tileset index #162
Conversation
@@ -107,6 +107,7 @@ impl TileLayerData { | |||
#[derive(Debug, Clone, PartialEq)] | |||
pub struct LayerTile<'map> { | |||
pub tileset: &'map Tileset, | |||
pub tileset_index: usize, |
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.
Another way of doing this would be to store the index in the tileset itself.
That would make the facade type LayerTile<'map> slightly cheaper to construct, though makes Tileset more tightly coupled with Map, which might be awkward.
This is my preferred way at the moment.
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.
Right, it's not possible to store the tileset index on the tileset, because a tileset can be used by multiple loaded maps, and it could have a different index in each of those maps.
This makes it obvious that we really need to change these public members for properties. Other than that, maybe we should store a reference to the map rather than the tileset itself in the tile, and then have a |
Could it be that we went too far with our desire to make things "easy" for the user, when introducing The |
If the issue is that the user might not need the tileset, then we can just convert LayerTile into a |
The whole ordeal about wrapping everything with a map/tileset was to save the user from having to do exactly this (i.e. Having to do their own wrapper over a tile+map if they want to pass the tile somewhere else). If getting a tileset is trivial, then we should just bundle the map with the tile, not the tileset. |
Ah, that sounds like a clean solution indeed! |
#158 will fix this. I'll try to submit a PR ASAP. For the time being, this can be a workaround. |
I wish to include the tileset index in the LayerTile<'map> facade.
This would assist in making simple rendering code significantly faster.
Say I've loaded my map file and acquire the tilesets:
Now, say I load all of the textures of the tilesets.
Assume they're all single-image tilesets.
textures
is parallel totilesets
Now, say my rendering code looks something like this:
Having a tileset index in the LayerTile<'map> facade type would make rendering the map to a batch much faster.
This unfortunately exposes the tileset's "id" which I am guessing we'd rather not do unless we have to.
I think that rendering code like this is common enough to warrant this sort of change.
Let me know what you all think, though.
There may already be an efficient way of doing this with the current codebase I'm not aware of, and I've just got tunnel vision.