summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Roudière <gilles.roudiere@gmail.com>2024-04-04 16:28:31 +0200
committerGilles Roudière <gilles.roudiere@gmail.com>2024-04-04 16:28:31 +0200
commitc928273c6c74dbbe3a21f9978ffdfa3fb03ea547 (patch)
treefc73defad504a987220841738174d903a65e6d45
parent7a42afbba050822a66ea5b4c620f6db1b98c49af (diff)
downloadredot-engine-c928273c6c74dbbe3a21f9978ffdfa3fb03ea547.tar.gz
Fixes "no cached rect" errors in TileMapLayer editor
-rw-r--r--editor/plugins/tiles/tile_map_layer_editor.cpp8
-rw-r--r--scene/resources/2d/tile_set.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/editor/plugins/tiles/tile_map_layer_editor.cpp b/editor/plugins/tiles/tile_map_layer_editor.cpp
index ac4708aa06..66915cc075 100644
--- a/editor/plugins/tiles/tile_map_layer_editor.cpp
+++ b/editor/plugins/tiles/tile_map_layer_editor.cpp
@@ -1846,7 +1846,8 @@ void TileMapLayerEditorTilesPlugin::_tile_atlas_control_draw() {
Color grid_color = EDITOR_GET("editors/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 TileMapCell &E : tile_set_selection) {
- if (E.source_id == source_id && E.alternative_tile == 0) {
+ int16_t untransformed_alternative_id = E.alternative_tile & TileSetAtlasSource::UNTRANSFORM_MASK;
+ if (E.source_id == source_id && untransformed_alternative_id == 0) {
for (int frame = 0; frame < atlas->get_tile_animation_frames_count(E.get_atlas_coords()); frame++) {
Color color = selection_color;
if (frame > 0) {
@@ -2029,8 +2030,9 @@ void TileMapLayerEditorTilesPlugin::_tile_alternatives_control_draw() {
// Draw the selection.
for (const TileMapCell &E : tile_set_selection) {
- if (E.source_id == source_id && E.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && E.alternative_tile > 0) {
- Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.get_atlas_coords(), E.alternative_tile);
+ int16_t untransformed_alternative_id = E.alternative_tile & TileSetAtlasSource::UNTRANSFORM_MASK;
+ if (E.source_id == source_id && E.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && untransformed_alternative_id > 0) {
+ Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.get_atlas_coords(), untransformed_alternative_id);
if (rect != Rect2i()) {
TilesEditorUtils::draw_selection_rect(alternative_tiles_control, rect);
}
diff --git a/scene/resources/2d/tile_set.h b/scene/resources/2d/tile_set.h
index f1a8d42b95..dceda1a791 100644
--- a/scene/resources/2d/tile_set.h
+++ b/scene/resources/2d/tile_set.h
@@ -619,6 +619,8 @@ public:
TRANSFORM_TRANSPOSE = 1 << 14,
};
+ static const int16_t UNTRANSFORM_MASK = ~(TileSetAtlasSource::TRANSFORM_FLIP_H + TileSetAtlasSource::TRANSFORM_FLIP_V + TileSetAtlasSource::TRANSFORM_TRANSPOSE);
+
private:
struct TileAlternativesData {
Vector2i size_in_atlas = Vector2i(1, 1);