Backported from godot4: Fixes "no cached rect" errors in TileMapLayer editor

- groud
c928273c6c
This commit is contained in:
Relintai 2024-04-06 18:59:41 +02:00
parent 4cad999f60
commit cb55fa2292
2 changed files with 7 additions and 3 deletions

View File

@ -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<LayeredTileMapCell>::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<LayeredTileMapCell>::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);
}

View File

@ -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 {