Skip to content

Make Hexagonal tiles rotate 180 degrees to fit grid #107728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TheSofox
Copy link
Contributor

Fixes #107510

Normally, clicking a "rotate left" or "rotate right" button for a tile in a grid would rotate it 90 degrees. This was fine for square tiles, but would make hexagonal tiles not fit the grid properly. This PR makes hexagonal tiles only rotate 180 degrees when the button is pushed, so it still fits. (making them rotate by 60 degrees would have been ideal, but comes with additional complications).

@Chaosus Chaosus added this to the 4.x milestone Jun 19, 2025
@Chubercik
Copy link
Contributor

(making them rotate by 60 degrees would have been ideal, but comes with additional complications).

Could you elaborate on that? Like you said, that would seem ideal.

@TheSofox
Copy link
Contributor Author

(making them rotate by 60 degrees would have been ideal, but comes with additional complications).

Could you elaborate on that? Like you said, that would seem ideal.

  1. The tiles don't have a "rotate" property, only a "flip_h", "flip_y" and "transpose" (transpose rotates tile 90 degrees counter-clockwise and then flipped vertically according to here: https://docs.godotengine.org/en/stable/tutorials/2d/using_tilesets.html#doc-using-tilesets-creating-alternative-tiles ). These three properties are used to rotate a regular square tile in the 4 main directions, but can't be easily adjusted to make them 60 degree rotations
  2. Rotating 60 degrees would introduce rotation artifacts. It would not be pixel perfect.

@kleonc
Copy link
Member

kleonc commented Jun 20, 2025

Not sure if this is a good change. For a full-hex tile rotating by 90° doesn't make much sense indeed (as it won't fit the hex grid), but note that the tile visuals might be not matching the tile shape, e.g. it could be only some prop/item in the middle of the tile etc. Thus I'm not sure if 90° rotations are always undesired.
If anyone is using 90° tile rotations with hex grid (no idea if that's the case) then this PR would introduce a regression for them (only regarding the editor usability though, as it's still possible to manually set any transform flags using a script).

AFAICT #107510 is mainly about not being able to rotate by 60°. Being able to rotate hex-tiles by 90° would probably be a non-issue if it would be possible to switch between 90°/60° rotations (and 60° would be the default mode for hexes). Aka I consider 90° rotations for hex tiles as an additional option/feature, not sure if disallowing it editor-wise is a correct solution here, even given 60° rotations are currently not supported at all.

Just something to consider before merging. 🙃

@@ -1522,18 +1522,30 @@ int TileMapLayerEditorTilesPlugin::_get_transformed_alternative(int p_alternativ
bool transform_flip_v = p_alternative_id & TileSetAtlasSource::TRANSFORM_FLIP_V;
bool transform_transpose = p_alternative_id & TileSetAtlasSource::TRANSFORM_TRANSPOSE;

bool is_hexagon = _get_edited_layer()->get_tile_set()->get_tile_shape() == TileSet::TILE_SHAPE_HEXAGON;

switch (p_transform) {
case TRANSFORM_ROTATE_LEFT: { // (h, v, t) -> (v, !h, !t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the changes make this comment partially outdated (same for case TRANSFORM_ROTATE_RIGHT), as it refers only to 90° rotations, which now is not what would be always performed.

@AThousandShips AThousandShips modified the milestones: 4.x, 4.6 Jun 20, 2025
@groud
Copy link
Member

groud commented Jun 20, 2025

If anyone is using 90° tile rotations with hex grid (no idea if that's the case) then this PR would introduce a regression for them (only regarding the editor usability though, as it's still possible to manually set any transform flags using a script).

Ah yeah, I guess that if you have some tiles that are not, like, hexagon-shaped, it make sense... Well that I guess we'll have to keep the "feature" then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hexagonal Tiles Rotating 90° instead of 60°, Making them misaligned
6 participants