mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:10:06 +00:00
Textures may change between loads, don't skip reloading
This commit is contained in:
parent
1929ee9eef
commit
4fcfb54890
1 changed files with 4 additions and 12 deletions
|
|
@ -78,16 +78,6 @@ void TextureAtlas::RegisterTexture(const std::string& name,
|
||||||
bool TextureAtlas::CacheTexture(const std::string& name,
|
bool TextureAtlas::CacheTexture(const std::string& name,
|
||||||
const std::string& path)
|
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
|
// Attempt to load the image
|
||||||
boost::gil::rgba8_image_t image = TextureAtlas::Impl::LoadImage(path);
|
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
|
// Store it in the texture cache
|
||||||
std::unique_lock lock(p->textureCacheMutex_);
|
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)
|
void TextureAtlas::BuildAtlas(size_t width, size_t height)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue