From cb55fa22920eb4bd86283f892765ac43a045356d Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 6 Apr 2024 18:59:41 +0200 Subject: [PATCH] Backported from godot4: Fixes "no cached rect" errors in TileMapLayer editor - groud https://github.com/godotengine/godot/commit/c928273c6c74dbbe3a21f9978ffdfa3fb03ea547 --- .../editor/layered_tile_map_layer_editor.cpp | 8 +++++--- modules/layered_tile_map/layered_tile_set.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp b/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp index d39013cdf..c011ca43f 100644 --- a/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp +++ b/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp @@ -1915,7 +1915,8 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_atlas_control_draw() { Color grid_color = EDITOR_GET("editors/layered_tiles_editor/grid_color"); Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); for (const RBSet::Element *E = tile_set_selection.front(); E; E = E->next()) { - if (E->get().source_id == source_id && E->get().alternative_tile == 0) { + int16_t untransformed_alternative_id = E->get().alternative_tile & LayeredTileSetAtlasSource::UNTRANSFORM_MASK; + if (E->get().source_id == source_id && untransformed_alternative_id == 0) { for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E->get().get_atlas_coords()); frame++) { Color color = selection_color; if (frame > 0) { @@ -2099,8 +2100,9 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_alternatives_control_draw() { // Draw the selection. for (const RBSet::Element *E = tile_set_selection.front(); E; E = E->next()) { - if (E->get().source_id == source_id && E->get().get_atlas_coords() != LayeredTileSetSource::INVALID_ATLAS_COORDS && E->get().alternative_tile > 0) { - Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().get_atlas_coords(), E->get().alternative_tile); + int16_t untransformed_alternative_id = E->get().alternative_tile & LayeredTileSetAtlasSource::UNTRANSFORM_MASK; + if (E->get().source_id == source_id && E->get().get_atlas_coords() != LayeredTileSetSource::INVALID_ATLAS_COORDS && untransformed_alternative_id > 0) { + Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().get_atlas_coords(), untransformed_alternative_id); if (rect != Rect2i()) { LayeredTilesEditorUtils::draw_selection_rect(alternative_tiles_control, rect); } diff --git a/modules/layered_tile_map/layered_tile_set.h b/modules/layered_tile_map/layered_tile_set.h index 99e434414..ff9de41e7 100644 --- a/modules/layered_tile_map/layered_tile_set.h +++ b/modules/layered_tile_map/layered_tile_set.h @@ -618,6 +618,8 @@ public: TRANSFORM_FLIP_V = 1 << 13, TRANSFORM_TRANSPOSE = 1 << 14, }; + + static const int16_t UNTRANSFORM_MASK = ~(LayeredTileSetAtlasSource::TRANSFORM_FLIP_H + LayeredTileSetAtlasSource::TRANSFORM_FLIP_V + LayeredTileSetAtlasSource::TRANSFORM_TRANSPOSE); private: struct TileAlternativesData {