Fix transparent tiles being saved with tile ID instead of 0#4504
Fix transparent tiles being saved with tile ID instead of 0#4504Lillious wants to merge 1 commit intomapeditor:masterfrom
Conversation
|
This doesn't seem like it's necessarily desirable for all users. It's not "incorrect" to save transparent tiles with their actual IDs. After all, they are tiles in the tileset. There may be users that use particular transparent tiles to have a special meaning in their engine. This PR would break that. I think a better solution for you would be to write a script that removes any transparent tiles from your map. |
|
I did not mean to close it, sorry |
It may not seem "incorrect" but I do not see a valid reason for placed tiles with no actual content to have tile IDs. I do not believe this change would actually break anything since a tile ID of 0 would result in the same exact visual and functional result as one with an ID but with no content. I'm open to having a discussion about how this would break something but I simply don't see it. |
|
Some people use a layer of tiles as "data tiles" where the tile in the tileset have custom properties used to indicate logic in their game. It's possible someone could use a transparent tile for this. I just don't think we can assume transparent tiles shouldn't be written out to the map Sorry the close PR button is easy to hit on mobile |
That could be the case but you simply can't identify where this tile is because it has no content. There is no way for someone to know where it is visually because the editor doesn't even show it as a selectable tile. |
For example, if you place a tile with no content and you use the selection tool, drag the selection area over it, copy and paste for placement, that tile with no content is not included. |
|
consider this: a tileset is edited to use a transparent image on accident |
I just don't see someone accidentally doing this as it requires a chain of incorrect steps. Plus the undo functionality exists. it doesn't remove invalid images, just completely transparent tiles which the program already assigns as nothing. If the selection tool can't detect and copy/paste these transparent tiles why does saving treat them differently? |
Summary
Transparent tiles in tilesets are now correctly serialized as GID 0 (empty) instead of their actual tile ID when
saving maps.
Problem
When a tile in a tileset is completely transparent (all pixels have zero alpha), painting with it and saving the
map would incorrectly save that tile's ID instead of 0, resulting in invisible tiles appearing on the map.
Solution
Added a transparency check in
GidMapper::cellToGid()that:This fix applies to all export formats (JSON, TMX, etc.) since they all use the GID mapper for serialization.
Testing