17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 01:39:20 +02:00

fix flipped ortophot + clear cache

This commit is contained in:
maj00r
2026-10-08 20:20:12 +02:00
parent 14e916e81f
commit c11480ce2e
4 changed files with 30 additions and 0 deletions

View File

@@ -417,6 +417,9 @@ bool fetch(http_client &Client, std::string const &Url, fs::path const &Path, st
bool decode(std::vector<std::uint8_t> 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<int>(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<std::mutex> 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)

View File

@@ -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();