Clean m_ondemand_load_texture_paths after texture loaded
This commit is contained in:
parent
dcc7397668
commit
5e161f663d
@ -48,9 +48,11 @@ GEVulkanTexture::GEVulkanTexture(const std::string& path,
|
||||
}
|
||||
|
||||
auto& paths = getGEConfig()->m_ondemand_load_texture_paths;
|
||||
m_ondemand_load = (paths.find(m_full_path.c_str()) != paths.end());
|
||||
auto path_itr = paths.find(m_full_path.c_str());
|
||||
m_ondemand_load = (path_itr != paths.end());
|
||||
if (m_ondemand_load)
|
||||
{
|
||||
paths.erase(path_itr);
|
||||
video::IImageLoader* loader = NULL;
|
||||
io::IReadFile* file = io::createReadFile(m_full_path);
|
||||
getDriver()->createImageFromFile(file, &loader);
|
||||
|
@ -1173,6 +1173,7 @@ void IrrDriver::applyResolutionSettings(bool recreate_device)
|
||||
GUIEngine::addLoadingIcon(irr_driver->getTexture(banana) );
|
||||
// No need to reload cached track data (track_manager->cleanAllCachedData
|
||||
// above) - this happens dynamically when the tracks are loaded.
|
||||
track_manager->updateScreenshotCache();
|
||||
GUIEngine::reshowCurrentScreen();
|
||||
MessageQueue::updatePosition();
|
||||
// Preload the explosion effects (explode.png)
|
||||
|
@ -129,18 +129,6 @@ KartProperties::~KartProperties()
|
||||
ShaderFilesManager::getInstance()->removeUnusedShaderFiles();
|
||||
SP::SPTextureManager::get()->removeUnusedTextures();
|
||||
}
|
||||
|
||||
if (GE::getDriver()->getDriverType() != video::EDT_VULKAN)
|
||||
return;
|
||||
auto& paths = GE::getGEConfig()->m_ondemand_load_texture_paths;
|
||||
auto it = paths.begin();
|
||||
while (it != paths.end())
|
||||
{
|
||||
if (StringUtils::startsWith(*it, m_root_absolute_path))
|
||||
it = paths.erase(it);
|
||||
else
|
||||
it++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // ~KartProperties
|
||||
@ -383,6 +371,10 @@ void KartProperties::load(const std::string &filename, const std::string &node)
|
||||
file_manager->popTextureSearchPath();
|
||||
file_manager->popModelSearchPath();
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
|
||||
GE::getGEConfig()->m_ondemand_load_texture_paths.clear();
|
||||
#endif
|
||||
} // load
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -194,11 +194,6 @@ Track::Track(const std::string &filename)
|
||||
/** Destructor, removes quad data structures etc. */
|
||||
Track::~Track()
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
|
||||
GE::getGEConfig()->m_ondemand_load_texture_paths.erase(m_screenshot);
|
||||
#endif
|
||||
|
||||
// Note that the music information in m_music is globally managed
|
||||
// by the music_manager, and is freed there. So no need to free it
|
||||
// here (esp. since various track might share the same music).
|
||||
@ -432,13 +427,6 @@ void Track::cleanup()
|
||||
for(unsigned int i=0; i<m_sky_textures.size(); i++)
|
||||
{
|
||||
video::ITexture* tex = (video::ITexture*)m_sky_textures[i];
|
||||
#ifndef SERVER_ONLY
|
||||
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
|
||||
{
|
||||
std::string fullpath = tex->getFullPath().c_str();
|
||||
GE::getGEConfig()->m_ondemand_load_texture_paths.erase(fullpath);
|
||||
}
|
||||
#endif
|
||||
tex->drop();
|
||||
if (tex->getReferenceCount() == 1)
|
||||
irr_driver->removeTexture(tex);
|
||||
@ -631,17 +619,7 @@ void Track::loadTrackInfo()
|
||||
|
||||
// Set the correct paths
|
||||
if (m_screenshot.length() > 0)
|
||||
{
|
||||
m_screenshot = m_root+m_screenshot;
|
||||
#ifndef SERVER_ONLY
|
||||
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
|
||||
{
|
||||
m_screenshot = file_manager->getFileSystem()
|
||||
->getAbsolutePath(m_screenshot.c_str()).c_str();
|
||||
GE::getGEConfig()->m_ondemand_load_texture_paths.insert(m_screenshot);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
delete root;
|
||||
|
||||
std::string dir = StringUtils::getPath(m_filename);
|
||||
|
@ -29,9 +29,14 @@
|
||||
#include <stdexcept>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <IFileSystem.h>
|
||||
#include <ITexture.h>
|
||||
#include <IVideoDriver.h>
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
#include <ge_main.hpp>
|
||||
#endif
|
||||
|
||||
TrackManager* track_manager = 0;
|
||||
std::vector<std::string> TrackManager::m_track_search_path;
|
||||
|
||||
@ -178,6 +183,7 @@ void TrackManager::loadTrackList()
|
||||
loadTrack(dir+*subdir+"/");
|
||||
} // for dir in dirs
|
||||
} // for i <m_track_search_path.size()
|
||||
updateScreenshotCache();
|
||||
onDemandLoadTrackScreenshots();
|
||||
} // loadTrackList
|
||||
|
||||
@ -221,12 +227,6 @@ bool TrackManager::loadTrack(const std::string& dirname)
|
||||
m_tracks.push_back(track);
|
||||
m_track_avail.push_back(true);
|
||||
updateGroups(track);
|
||||
|
||||
// Populate the texture cache with track screenshots
|
||||
// (internal tracks like end cutscene don't have screenshots)
|
||||
if (!track->isInternal())
|
||||
irr_driver->getTexture(track->getScreenshotFile());
|
||||
|
||||
return true;
|
||||
} // loadTrack
|
||||
|
||||
@ -361,3 +361,25 @@ void TrackManager::onDemandLoadTrackScreenshots()
|
||||
screenshot->getTextureHandler();
|
||||
}
|
||||
} // onDemandLoadTrackScreenshots
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TrackManager::updateScreenshotCache()
|
||||
{
|
||||
for (unsigned i = 0; i < m_tracks.size(); i++)
|
||||
{
|
||||
// Populate the texture cache with track screenshots
|
||||
// (internal tracks like end cutscene don't have screenshots)
|
||||
Track* t = m_tracks[i];
|
||||
if (t->isInternal() || t->getScreenshotFile().empty())
|
||||
continue;
|
||||
std::string full_path = file_manager->getFileSystem()
|
||||
->getAbsolutePath(t->getScreenshotFile().c_str()).c_str();
|
||||
if (!file_manager->fileExists(full_path))
|
||||
continue;
|
||||
#ifndef SERVER_ONLY
|
||||
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
|
||||
GE::getGEConfig()->m_ondemand_load_texture_paths.insert(full_path);
|
||||
#endif
|
||||
irr_driver->getTexture(t->getScreenshotFile());
|
||||
}
|
||||
} // updateScreenshotCache
|
||||
|
@ -138,7 +138,8 @@ public:
|
||||
} // getArenasInGroup
|
||||
// ------------------------------------------------------------------------
|
||||
void onDemandLoadTrackScreenshots();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void updateScreenshotCache();
|
||||
}; // TrackManager
|
||||
|
||||
extern TrackManager* track_manager;
|
||||
|
Loading…
Reference in New Issue
Block a user