deepnight / ldtk

Modern, lightweight and efficient 2D level editor
https://ldtk.io
MIT License
3.44k stars 192 forks source link

autoLayerTiles having too many tiles exported in some cases #851

Open jeremyfa opened 1 year ago

jeremyfa commented 1 year ago

I noticed that in some situations, autoLayerTiles contains tiles that are out of the bounds of the layer grid. Also noticed that some tiles are not discarded and removed from autoLayerTiles as well although they are below another opaque tile.

The AutoLayers_3_Mosaic.ldtk sample project does have those issues in the Walls layer, which is using "stamp" auto layer rules.

This is not blocking because I managed to discard those out of bound tiles in my parser (in Ceramic) by checking for each tile if it's not outside those bounds, and also managed to discard tiles below opaque ones thanks to the tileset's cachedPixelData, but I guess that would be better to handle this beforehand in LDtk editor directly, to make reading that data easier for parser.

Out of curiosity, I tested the rendering code for flixel provided by ldtk-haxe-api, and it does display tiles, even those that are out of bounds, so the issue is not specific to my parser.

jeremyfa commented 1 year ago

AutoLayers_3_Mosaic.ldtk.zip

Here is a modified AutoLayers_3_Mosaic.ldtk file that I used to identify the issue: it's reduced to a 5x5 grid with only the Walls layer, but we can see the autoLayerTiles array in the file contains way more tiles than the 25 that are required.

This is what the tilemap looks like in the LDtk editor:

image

And what I get if I render it with flixel + ldtk-haxe-api:

image