From c11480ce2ed39942938dda5fae0dde99e57ef57b Mon Sep 17 00:00:00 2001 From: maj00r Date: Thu, 8 Oct 2026 20:20:12 +0200 Subject: [PATCH] fix flipped ortophot + clear cache --- application/editormode.cpp | 4 ++++ editor/editorOrthophoto.cpp | 18 ++++++++++++++++++ editor/editorOrthophoto.hpp | 2 ++ lang/editor_pl.po | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/application/editormode.cpp b/application/editormode.cpp index 0ee3d1db..98dfd14b 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -1838,6 +1838,10 @@ void editor_mode::render_orthophoto_ui() if (!editor_orthophoto::can_download()) ImGui::TextDisabled(STR_C("This build has no HTTP client, only cached tiles are shown")); ImGui::TextDisabled(STR_C("Cache: %s"), editor_orthophoto::cache_directory().c_str()); + if (ImGui::Button(STR_C("Clear cache"))) + m_orthophoto.clear_cache(); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip(STR_C("Deletes downloaded tiles from disk. They are fetched again around the camera.")); ImGui::TextDisabled(STR_C("Imagery: GUGiK, geoportal.gov.pl")); } diff --git a/editor/editorOrthophoto.cpp b/editor/editorOrthophoto.cpp index 26bbb646..7a33b127 100644 --- a/editor/editorOrthophoto.cpp +++ b/editor/editorOrthophoto.cpp @@ -417,6 +417,9 @@ bool fetch(http_client &Client, std::string const &Url, fs::path const &Path, st bool decode(std::vector const &Data, image &Out, std::string &Error) { int width{0}, height{0}, components{0}; + // WMS GetMap is north-up. the texture loader sets a process-wide stb flip for OpenGL; + // pin this thread to no flip immediately before load so the first row stays north + stbi_set_flip_vertically_on_load_thread(0); stbi_uc *pixels = stbi_load_from_memory(Data.data(), static_cast(Data.size()), &width, &height, &components, 4); if (pixels == nullptr) { @@ -738,6 +741,21 @@ void editor_orthophoto::cancel_pending() entry.second.requested = 0; } +void editor_orthophoto::clear_cache() +{ + cancel_pending(); + for (auto &entry : m_tiles) + release_tile(entry.second); + m_tiles.clear(); + ++m_generation; + { + std::lock_guard lock(m_mutex); + m_done.clear(); + } + std::error_code ec; + fs::remove_all(cache_root(), ec); +} + void editor_orthophoto::retry_failed() { for (auto &entry : m_tiles) diff --git a/editor/editorOrthophoto.hpp b/editor/editorOrthophoto.hpp index a2e5b761..dd081021 100644 --- a/editor/editorOrthophoto.hpp +++ b/editor/editorOrthophoto.hpp @@ -107,6 +107,8 @@ class editor_orthophoto void draw(glm::mat4 const &ViewProjection, glm::dvec3 const &CameraPos, float ScreenWidth, float ScreenHeight) const; // forgets pending (not yet started) downloads, e.g. when the editor is left void cancel_pending(); + // drops resident tiles and deletes the on-disk cache; enabled tiles are fetched again + void clear_cache(); // clears failure state so failed tiles are attempted again void retry_failed(); diff --git a/lang/editor_pl.po b/lang/editor_pl.po index 31b79ba5..510d5c9b 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -4057,6 +4057,12 @@ msgstr "Ten build nie ma klienta HTTP, widać tylko kafle z pamięci podręcznej msgid "Cache: %s" msgstr "Pamięć podręczna: %s" +msgid "Clear cache" +msgstr "Wyczyść cache" + +msgid "Deletes downloaded tiles from disk. They are fetched again around the camera." +msgstr "Usuwa pobrane kafle z dysku. Zostaną ponownie pobrane wokół kamery." + msgid "Imagery: GUGiK, geoportal.gov.pl" msgstr "Zdjęcia: GUGiK, geoportal.gov.pl"