From 4fcfb548900635aacb7279219ff28fe64fbb5116 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 7 Aug 2023 22:57:26 -0500 Subject: [PATCH] Textures may change between loads, don't skip reloading --- scwx-qt/source/scwx/qt/util/texture_atlas.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/scwx-qt/source/scwx/qt/util/texture_atlas.cpp b/scwx-qt/source/scwx/qt/util/texture_atlas.cpp index 65de8c16..274ea8fb 100644 --- a/scwx-qt/source/scwx/qt/util/texture_atlas.cpp +++ b/scwx-qt/source/scwx/qt/util/texture_atlas.cpp @@ -78,16 +78,6 @@ void TextureAtlas::RegisterTexture(const std::string& name, bool TextureAtlas::CacheTexture(const std::string& name, const std::string& path) { - // If the image is already loaded, we don't need to load it again - { - std::shared_lock lock(p->textureCacheMutex_); - - if (p->textureCache_.contains(path)) - { - return false; - } - } - // Attempt to load the image boost::gil::rgba8_image_t image = TextureAtlas::Impl::LoadImage(path); @@ -97,10 +87,12 @@ bool TextureAtlas::CacheTexture(const std::string& name, // Store it in the texture cache std::unique_lock lock(p->textureCacheMutex_); - p->textureCache_.emplace(name, std::move(image)); + p->textureCache_.insert_or_assign(name, std::move(image)); + + return true; } - return true; + return false; } void TextureAtlas::BuildAtlas(size_t width, size_t height)