Skip to content

Commit c928273

Browse files
committed
Fixes "no cached rect" errors in TileMapLayer editor
1 parent 7a42afb commit c928273

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

editor/plugins/tiles/tile_map_layer_editor.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,8 @@ void TileMapLayerEditorTilesPlugin::_tile_atlas_control_draw() {
18461846
Color grid_color = EDITOR_GET("editors/tiles_editor/grid_color");
18471847
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);
18481848
for (const TileMapCell &E : tile_set_selection) {
1849-
if (E.source_id == source_id && E.alternative_tile == 0) {
1849+
int16_t untransformed_alternative_id = E.alternative_tile & TileSetAtlasSource::UNTRANSFORM_MASK;
1850+
if (E.source_id == source_id && untransformed_alternative_id == 0) {
18501851
for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E.get_atlas_coords()); frame++) {
18511852
Color color = selection_color;
18521853
if (frame > 0) {
@@ -2029,8 +2030,9 @@ void TileMapLayerEditorTilesPlugin::_tile_alternatives_control_draw() {
20292030

20302031
// Draw the selection.
20312032
for (const TileMapCell &E : tile_set_selection) {
2032-
if (E.source_id == source_id && E.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && E.alternative_tile > 0) {
2033-
Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.get_atlas_coords(), E.alternative_tile);
2033+
int16_t untransformed_alternative_id = E.alternative_tile & TileSetAtlasSource::UNTRANSFORM_MASK;
2034+
if (E.source_id == source_id && E.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && untransformed_alternative_id > 0) {
2035+
Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.get_atlas_coords(), untransformed_alternative_id);
20342036
if (rect != Rect2i()) {
20352037
TilesEditorUtils::draw_selection_rect(alternative_tiles_control, rect);
20362038
}

scene/resources/2d/tile_set.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ class TileSetAtlasSource : public TileSetSource {
619619
TRANSFORM_TRANSPOSE = 1 << 14,
620620
};
621621

622+
static const int16_t UNTRANSFORM_MASK = ~(TileSetAtlasSource::TRANSFORM_FLIP_H + TileSetAtlasSource::TRANSFORM_FLIP_V + TileSetAtlasSource::TRANSFORM_TRANSPOSE);
623+
622624
private:
623625
struct TileAlternativesData {
624626
Vector2i size_in_atlas = Vector2i(1, 1);

0 commit comments

Comments
 (0)