Merge pull request #31063 from rzllmr/fix-tilemap-order

Fix row-column-swap in TileMap palette
This commit is contained in:
Rémi Verschelde 2019-08-05 08:12:14 +02:00 committed by GitHub
commit 7d5ad99cde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -521,7 +521,13 @@ void TileMapEditor::_update_palette() {
for (const Map<Vector2, uint32_t>::Element *E = tiles2.front(); E; E = E->next()) {
entries2.push_back(E->key());
}
entries2.sort();
// Sort tiles in row-major order
struct SwapComparator {
_FORCE_INLINE_ bool operator()(const Vector2 &v_l, const Vector2 &v_r) const {
return v_l.y != v_r.y ? v_l.y < v_r.y : v_l.x < v_r.x;
}
};
entries2.sort_custom<SwapComparator>();
Ref<Texture> tex = tileset->tile_get_texture(sel_tile);