duality
duality copied to clipboard
Support rotated and flipped tiles in Tilemaps.
Summary
The ability to rotate and flip tiles in Tilemaps would greatly simplify tilesheet creation and reduce texture sizes, especially for top-down maps.
Modification points:
- Tile.cs
- Add enums RotateDirs { Up, Right, Down, Left } and FlipMode { None, Horizontal, Vertical }
- Add properties for above enums
- TilemapRenderer.cs
- Modify Draw() to respect tile rotation and flipmode
- TilemapEditorCamViewState.cs
- Rotate tile brush border according to current brush rotation and flip
- EditTilemapAction.cs
- Rotate/flip added tiles.
- Add editor action to change current flip and rotate values.
Interesting idea! Solid implementation outline too.
Some quick thoughts on the impact:
- Changes to per-tile logic and data can have a big impact due to number of tiles. As a benchmark, I used the scenario of a 1024x1024 tilemap during development of the plugin, multiplied by 3 for a multi-layered setup. Point is: There may be a really huge number of tiles.
-
Tile
is currently 4 + 4 + 2+ 1 = 11 bytes big and should be optimized for size. The two rotation enums could fit into a single byte, which is pretty good. Still, it's not free. - In the same vein, there will be additional cost for added logic in generating drawcalls. We'll never see quite that many tiles at once due to culling, and it's just a very tiny cost, but it's not nothing.
I guess I'm just trying to say, we should make sure the feature would be put to good use when implemented, especially since everyone will pay for it regardless of whether it is used. Would be interested in everyone's thoughts on this:
- What are the main use cases / examples, e.g. when would you need or want to rotate or flip a tile?
- How many tiles in a tileset will typically be rotated or flipped?
- Would it be viable for the user to just add rotated or flipped variants of tiles they need to the tileset manually?
- How big would the overlap with the existing AutoTiling feature be? Could this be useful to achieve the same effect at "zero impact"?
Thank you for the insight!
What are the main use cases / examples, e.g. when would you need or want to rotate or flip a tile?
Right now, it is most useful only on completely top-down maps where the camera is looking straight down the z-axis.
How many tiles in a tileset will typically be rotated or flipped?
An example from http://www.cr31.co.uk/stagecast/wang/3corn.html state that an 3-edge Wang tile set would be reduced from 81 tiles to 24, if rotations are supported.
Would it be viable for the user to just add rotated or flipped variants of tiles they need to the tileset manually?
After doing some thinking and testing, this is actually the best approach. Texture space is cheap, performance hits is not.
How big would the overlap with the existing AutoTiling feature be? Could this be useful to achieve the same effect at "zero impact"?
I did not consider this. I guess a lot of AutoTiling code would be changed also.
From the above, I guess it's better to create an editor plugin that generates the full tileset from an initial set of tiles. This way, impact is virtually nil.