summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaganty Rushyendra <mrushyendra@yahoo.com.sg>2020-08-04 23:54:59 +0800
committerMaganty Rushyendra <mrushyendra@yahoo.com.sg>2020-08-05 10:12:08 +0800
commitcf04aabef13629b01d6bbf724ca1ab60e041d656 (patch)
treeddf3bafe94deabdc7c772491c9d13e04e00b9264
parentec678c5e94ac1c91c099c15fabc398e80ede7bfe (diff)
Fix tile placement preview for rotated, skewed or scaled TileMaps
Ensures that the editor preview when placing a tile on a TileMap takes into account the transformation of the TileMap. Previously, only the origin of the Tile was transformed, but not its orientation or scaling.
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 307a8a9001..e71485e9fc 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -886,17 +886,17 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
rect.position += tile_ofs;
}
- rect.position = p_xform.xform(rect.position);
- rect.size *= sc;
-
Color modulate = node->get_tileset()->tile_get_modulate(p_cell);
modulate.a = 0.5;
+ Transform2D old_transform = p_viewport->get_viewport_transform();
+ p_viewport->draw_set_transform_matrix(p_xform); // Take into account TileMap transformation when displaying cell
if (r.has_no_area()) {
p_viewport->draw_texture_rect(t, rect, false, modulate, p_transpose);
} else {
p_viewport->draw_texture_rect_region(t, rect, r, modulate, p_transpose);
}
+ p_viewport->draw_set_transform_matrix(old_transform);
}
void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) {