-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Customizable Chunk Size for Infinite Maps #2121
Comments
Hmm, right now, the 16x16 chunks match the in-memory representation of tile layers so it is the most straight-forward way to output a tile map. Anything else will require writing some custom code that iterates a tile layer to figure out which of those custom chunks contain any tiles, though that shouldn't be too involved. And indeed Tiled supports reading of arbitrary chunks, even chunks of different sizes, which is mostly for future compatibility reasons. I could certainly imagine adding a custom chunk size option. Is it maybe something you'd like to try contributing? I'm generally available for questions regarding the code here or on Discord. |
Ah, yeah, if this matches the internal memory representation, that makes a lot of sense. Yeah, I think I'll give it a try. Since I'll have to write some code for rearrangeing chunks, anyways, I could try to do it directly in Tiled and see how far I'll get with it. Will check this out at home. |
The list of chunks to write is currently determined by the following function: As can be seen, it fills a list of rectangles, one for each non-empty chunk, which then gets sorted (since the chunks are in a hash map, so their ordering is random). Empty areas are skipped very fast because they do not generally have a chunk allocated (except when there was some content that was erased in the meantime). For custom chunk sizes, this check will get a little bit more expensive. An initial implementation could just iterate the entire bounds of the tile layer, chunk by chunk. |
Hello,
I have a minor feature request for Tiled (but one that I hope should not take long to implement).
I've noticed that when working with infinitely sized maps, Tiled automatically organizes tiles in the .tmx file into chunks. These chunks are sized 16x16 tiles by default. This can be changed by modifying/writing .tmx files by hand. Tiled seems to read the chunks in correctly from the .tmx file, no matter their size. However, once saving back to the .tmx file, Tiled always seems to rearrange the chunks into 16x16 blocks. Would it be possible to add support for overriding this default output chunk size (via a property in the tile layer or something like that)?
Background: I'm currently writing a script that converts one of my .tmx files into a format usable by some game engine, and while doing that, I want to perform certain optimizations on the output file. Specifially, the engine in question is very bad at working with a high number of tiles and becomes really slow, so I want to optimize performance by batching and prerendering tiles into screen-sized textures. The game uses NES-styled graphics with a screen resolution of 256x224 and tiles with a size of 16x16, amounting to 16x14 tiles per screen. So naturally, I wondered if it was possible to directly organize my tiles in the .tmx file into chunks of exactly this size, since it would make it easier to write my conversion script (I could use the data from the chunks directly and wouldn't have to add a step to reorganize the chunks into 16x14 blocks).
I hope my explanation was understandable, if not, let me know and I'll try to clarify.
Thanks!
The text was updated successfully, but these errors were encountered: