tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Update godot 4 exporter to use the new tile rotation/flipping system in godot 4.2

Open Gnumaru opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. Currently the godot 4 exporter creates 7 tile alternatives for each tile when exportAlternates is set. This was the only way of doing flipping/rotation in godot 4.0 and 4.1, but in godot 4.2 this is no longer needed since flipx/flipy/transpose info is stored in the 3 upper bits of the tile id in the map, in a similar way as tiled does.

Describe the solution you'd like The exporter could be updated to always export the flip and transpose info, deprecating the exportAlternates property and breaking compatibility with godot 4.0 and 4.1. Optionally, instead of breaking compatibility, exportAlternates could become an int property with three available modes: 0: ignore flipping and rotation while exporting; 1: export flipping and rotation using alternate tiles; 2: export flip and rotation using the tiles upper bits.

Describe alternatives you've considered The current exporter works as (visually) expected when using the exportAlternates property, but it creates very large tilesets due to creating tile alternatives which is no longer needed in godot 4.2

EDIT It is not exactly the higher bits. The exact values are here: https://docs.godotengine.org/en/latest/classes/class_tilesetatlassource.html#constants

TRANSFORM_FLIP_H = 4096
TRANSFORM_FLIP_V = 8192
TRANSFORM_TRANSPOSE = 16384

Gnumaru avatar Jan 03 '24 15:01 Gnumaru

Optionally, instead of breaking compatibility, exportAlternates could become an int property with three available modes: 0: ignore flipping and rotation while exporting; 1: export flipping and rotation using alternate tiles; 2: export flip and rotation using the tiles upper bits.

To keep things simple, possibly we could export using the new method by default, but export using tile alternatives when this option is enabled?

Alternatively, we could introduce an explicit "godotVersion" project property, which can default to the latest version but which can be set to earlier versions to disable the use of the flip bits, for example. Such a setting could help avoid introducing multiple compatibility options.

bjorn avatar Jan 03 '24 19:01 bjorn

Indeed, an explicit "godotVersion" project property is better since it would be futureproof. Then the transform bits would be used and "exportAlternates" would be totally ignored when "godotVersion" >= 4.2. And the transform bits would be unused and "exportAlternates" would be taken into account when "godotVersion" is in the [4.0, 4.2) range.

Gnumaru avatar Jan 03 '24 20:01 Gnumaru

Since some users may want to use Tiled without Projects, perhaps it's a good idea to allow setting this property on the Map as well?

eishiya avatar Jan 03 '24 20:01 eishiya

Hey, original plugin author here, back from the dead.

I'm not convinced it's worth keeping exportAlternates around. Maybe keep the option around for a year with a warning. godotVersion might be useful one day, but I don't think it's worth it for this.

Godot 4.0/.1 were only around for 8 months, and 4.2 is an easy upgrade, so the cross section of people who need the most current version of Tiled and people who are stuck on 4.0/.1 is going to be approximately zero. I'd rather just keep the code and the documentation simpler.

Skrapion avatar Feb 04 '24 09:02 Skrapion