mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Add the ability for client to check if image exists
This commit is contained in:
parent
84ace27872
commit
778d9b0cd6
16
src/tile.cpp
16
src/tile.cpp
@ -372,6 +372,18 @@ public:
|
|||||||
// Update new texture pointer and texture coordinates to an
|
// Update new texture pointer and texture coordinates to an
|
||||||
// AtlasPointer based on it's texture id
|
// AtlasPointer based on it's texture id
|
||||||
void updateAP(AtlasPointer &ap);
|
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.
|
// Processes queued texture requests from other threads.
|
||||||
// Shall be called from the main thread.
|
// Shall be called from the main thread.
|
||||||
@ -400,6 +412,9 @@ private:
|
|||||||
// This should be only accessed from the main thread
|
// This should be only accessed from the main thread
|
||||||
SourceImageCache m_sourcecache;
|
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.
|
// A texture id is index in this array.
|
||||||
// The first position contains a NULL texture.
|
// The first position contains a NULL texture.
|
||||||
core::array<SourceAtlasPointer> m_atlaspointer_cache;
|
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);
|
assert(get_current_thread_id() == m_main_thread);
|
||||||
|
|
||||||
m_sourcecache.insert(name, img, true, m_device->getVideoDriver());
|
m_sourcecache.insert(name, img, true, m_device->getVideoDriver());
|
||||||
|
m_source_image_existence.set(name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureSource::rebuildImagesAndTextures()
|
void TextureSource::rebuildImagesAndTextures()
|
||||||
|
@ -131,6 +131,7 @@ public:
|
|||||||
virtual IrrlichtDevice* getDevice()
|
virtual IrrlichtDevice* getDevice()
|
||||||
{return NULL;}
|
{return NULL;}
|
||||||
virtual void updateAP(AtlasPointer &ap){};
|
virtual void updateAP(AtlasPointer &ap){};
|
||||||
|
virtual bool isKnownSourceImage(const std::string &name)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IWritableTextureSource : public ITextureSource
|
class IWritableTextureSource : public ITextureSource
|
||||||
@ -149,6 +150,7 @@ public:
|
|||||||
virtual IrrlichtDevice* getDevice()
|
virtual IrrlichtDevice* getDevice()
|
||||||
{return NULL;}
|
{return NULL;}
|
||||||
virtual void updateAP(AtlasPointer &ap){};
|
virtual void updateAP(AtlasPointer &ap){};
|
||||||
|
virtual bool isKnownSourceImage(const std::string &name)=0;
|
||||||
|
|
||||||
virtual void processQueue()=0;
|
virtual void processQueue()=0;
|
||||||
virtual void insertSourceImage(const std::string &name, video::IImage *img)=0;
|
virtual void insertSourceImage(const std::string &name, video::IImage *img)=0;
|
||||||
|
Loading…
Reference in New Issue
Block a user