diff options
| author | Poommetee Ketson <poommetee@protonmail.com> | 2017-12-01 11:46:34 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-01 11:46:34 +0700 |
| commit | e89309b9315d45eb4719180ea75f1db9fc2190a1 (patch) | |
| tree | b4da26bbf7233dd37ae94877ab25b7e3ab5449c7 /editor | |
| parent | 66f60a848e54b11a57f00cb50bda7cd549ab549c (diff) | |
| parent | 2beadf7ac0d9a0dbe1df1d96c1f0d36bbcfadbcc (diff) | |
| download | redot-engine-e89309b9315d45eb4719180ea75f1db9fc2190a1.tar.gz | |
Merge pull request #13216 from hoelzl/pr-fix-tile-origin-center
Fix displacement for centered tilemaps
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index e552e24c17..5cc81f156c 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -565,20 +565,19 @@ void TileMapEditor::_draw_cell(int p_cell, const Point2i &p_point, bool p_flip_h } } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_CENTER) { - rect.position += node->get_cell_size() / 2; - Vector2 s = r.size; + Size2 cell_size = node->get_cell_size(); - Vector2 center = (s / 2) - tile_ofs; + rect.position += tile_ofs; if (p_flip_h) - rect.position.x -= s.x - center.x; + rect.position.x -= cell_size.x / 2; else - rect.position.x -= center.x; + rect.position.x += cell_size.x / 2; if (p_flip_v) - rect.position.y -= s.y - center.y; + rect.position.y -= cell_size.y / 2; else - rect.position.y -= center.y; + rect.position.y += cell_size.y / 2; } rect.position = p_xform.xform(rect.position); |
