Add onDemandLoadTrackScreenshots for all tracks

This commit is contained in:
Benau 2022-08-14 15:21:37 +08:00
parent f777e01a21
commit 8fead715da
4 changed files with 34 additions and 0 deletions

View File

@ -1031,6 +1031,8 @@ void RaceManager::exitRace(bool delete_world)
World::deleteWorld();
}
// Reload track screenshot after delete_world (track textures are unloaded)
track_manager->onDemandLoadTrackScreenshots();
m_saved_gp = NULL;
m_track_number = 0;

View File

@ -190,6 +190,11 @@ 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).
@ -614,6 +619,14 @@ void Track::loadTrackInfo()
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;

View File

@ -175,6 +175,7 @@ void TrackManager::loadTrackList()
loadTrack(dir+*subdir+"/");
} // for dir in dirs
} // for i <m_track_search_path.size()
onDemandLoadTrackScreenshots();
} // loadTrackList
// ----------------------------------------------------------------------------
@ -341,3 +342,19 @@ int TrackManager::getTrackIndexByIdent(const std::string& ident) const
}
return -1;
} // getTrackIndexByIdent
// ----------------------------------------------------------------------------
void TrackManager::onDemandLoadTrackScreenshots()
{
if (irr_driver->getVideoDriver()->getDriverType() != video::EDT_VULKAN)
return;
for (unsigned i = 0; i < m_tracks.size(); i++)
{
if (m_tracks[i]->isInternal())
continue;
irr::video::ITexture* screenshot = irr_driver->getTexture(
m_tracks[i]->getScreenshotFile());
if (screenshot && screenshot->useOnDemandLoad())
screenshot->getTextureHandler();
}
} // onDemandLoadTrackScreenshots

View File

@ -136,6 +136,8 @@ public:
{
return soccer_arena ? m_soccer_arena_groups[g] : m_arena_groups[g];
} // getArenasInGroup
// ------------------------------------------------------------------------
void onDemandLoadTrackScreenshots();
}; // TrackManager