Preload the particle textures when first load

This prevent hangs when lazy loading texture runtime
This commit is contained in:
Benau 2017-10-16 14:22:09 +08:00
parent 7e0d706946
commit c8d13d7360
3 changed files with 9 additions and 3 deletions

View File

@ -174,8 +174,11 @@ Material::Material(const XMLNode *node, bool deprecated)
// backwards compatibility // backwards compatibility
node->get("crash-reset-particles", &m_collision_particles); node->get("crash-reset-particles", &m_collision_particles);
} }
if (!m_collision_particles.empty())
{
ParticleKindManager::get()->getParticles(m_collision_particles);
}
} }
s = ""; s = "";
if (node->get("shader", &s)) if (node->get("shader", &s))

View File

@ -200,6 +200,8 @@ ParticleKind::ParticleKind(const std::string &file)
{ {
material_manager->pushTempMaterial(materials, file); material_manager->pushTempMaterial(materials, file);
m_material_file = material_manager->getLatestMaterial()->getTexFname(); m_material_file = material_manager->getLatestMaterial()->getTexFname();
// Preload textures
getMaterial();
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -1461,8 +1461,6 @@ void initRest()
race_manager->setTrack(UserConfigParams::m_last_track); race_manager->setTrack(UserConfigParams::m_last_track);
// Preload the explosion effects (explode.png)
ParticleKindManager::get()->getParticles("explosion.xml");
} // initRest } // initRest
//============================================================================= //=============================================================================
@ -1564,6 +1562,9 @@ int main(int argc, char *argv[] )
main_loop = new MainLoop(); main_loop = new MainLoop();
material_manager->loadMaterial(); material_manager->loadMaterial();
// Preload the explosion effects (explode.png)
ParticleKindManager::get()->getParticles("explosion.xml");
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI, GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
"options_video.png")); "options_video.png"));
kart_properties_manager -> loadAllKarts (); kart_properties_manager -> loadAllKarts ();