Created
November 28, 2012 18:45
-
-
Save celeron55/4163160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/tile.cpp b/src/tile.cpp | |
index f7f1779..eeddc4e 100644 | |
--- a/src/tile.cpp | |
+++ b/src/tile.cpp | |
@@ -373,6 +373,18 @@ class TextureSource : public IWritableTextureSource | |
// AtlasPointer based on it's texture id | |
void updateAP(AtlasPointer &ap); | |
+ bool isKnownSourceImage(const std::string &name) | |
+ { | |
+ bool is_known = false; | |
+ bool cache_found = m_source_image_existence.get(name, &is_known); | |
+ if(cache_found) | |
+ return is_known; | |
+ // Not found in cache; find out if a local file exists | |
+ is_known = (getTexturePath(name) != ""); | |
+ m_source_image_existence.set(name, is_known); | |
+ return is_known; | |
+ } | |
+ | |
// Processes queued texture requests from other threads. | |
// Shall be called from the main thread. | |
void processQueue(); | |
@@ -400,6 +412,9 @@ class TextureSource : public IWritableTextureSource | |
// This should be only accessed from the main thread | |
SourceImageCache m_sourcecache; | |
+ // Thread-safe cache of what source images are known (true = known) | |
+ MutexedMap<std::string, bool> m_source_image_existence; | |
+ | |
// A texture id is index in this array. | |
// The first position contains a NULL texture. | |
core::array<SourceAtlasPointer> m_atlaspointer_cache; | |
@@ -781,6 +796,7 @@ void TextureSource::insertSourceImage(const std::string &name, video::IImage *im | |
assert(get_current_thread_id() == m_main_thread); | |
m_sourcecache.insert(name, img, true, m_device->getVideoDriver()); | |
+ m_source_image_existence.set(name, true); | |
} | |
void TextureSource::rebuildImagesAndTextures() | |
diff --git a/src/tile.h b/src/tile.h | |
index ae986e7..12c40c8 100644 | |
--- a/src/tile.h | |
+++ b/src/tile.h | |
@@ -131,6 +131,7 @@ class ITextureSource | |
virtual IrrlichtDevice* getDevice() | |
{return NULL;} | |
virtual void updateAP(AtlasPointer &ap){}; | |
+ virtual bool isKnownSourceImage(const std::string &name)=0; | |
}; | |
class IWritableTextureSource : public ITextureSource | |
@@ -149,6 +150,7 @@ class IWritableTextureSource : public ITextureSource | |
virtual IrrlichtDevice* getDevice() | |
{return NULL;} | |
virtual void updateAP(AtlasPointer &ap){}; | |
+ virtual bool isKnownSourceImage(const std::string &name)=0; | |
virtual void processQueue()=0; | |
virtual void insertSourceImage(const std::string &name, video::IImage *img)=0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment