libgdx icon indicating copy to clipboard operation
libgdx copied to clipboard

Support infinite TMX maps Closes #5764

Open nklbdev opened this issue 5 years ago • 3 comments

nklbdev avatar Apr 27 '20 17:04 nklbdev

Tiled The Editor have strange behaviour with infinite map size. In some cases my code may not load some tiles that go beyond the map size limits. I opened an issue on it's project about this.

nklbdev avatar Apr 30 '20 11:04 nklbdev

This looks probably fine, but I am not very familiar with it. Anyone else to comment if this makes sense?

noblemaster avatar Jun 11 '20 05:06 noblemaster

This code is not ideal: it supports "infinite" tmx-maps which stores tiles in randomly located chunks in "finite" manner - one two dimensional array that represented rectangle that contains all tiles. It is not optimal: there are many elements in this array not contains data.

And for optimization, in this code there are no many checks for indexes going out of bounds.

if I can find the time, then I will try to implement similar chunks in LibGDX.

nklbdev avatar Jun 11 '20 16:06 nklbdev

For anyone taking a look at this PR years later. I thought I would try and take a look real quick and run some tests to help out, so we know where this stands many years later. Sadly, Bjorn is correct.

When using the infinite tilemap feature you usually end up with negative positions in the expanded chunks. And after looking through the codebase with how libGDX sets cells within MapLayers. Each layer contains our cells in a simple 2D Cell array designating their position. So unless I am mistaken, we would never be able to keep a 1 to 1 match to the tile positions in relation to the tiled editor unless we made some big changes.

While nklbdev did a great job to start, as it stands the code as submitted doesn't quite work, even disregarding the negative positions there are a few others issues as well and we would probably need a large overhaul to some other sections of the codebase. Though if anyone wants to tackle that, go for it!

But for now, sadly, it seems like the best workaround for users who want to make use of Tiled's infinite map feature would be to just uncheck it and set it back to a finite map, when they are ready to bring it into libGDX.

BoBIsHere86 avatar Feb 09 '23 04:02 BoBIsHere86