Install all materials before loading meshes

This commit is contained in:
auria.mg 2016-12-27 22:08:27 -05:00
parent 0be858f7f8
commit 5e415e3331
5 changed files with 22 additions and 3 deletions

View File

@ -518,10 +518,12 @@ void Material::install(bool is_full_path, bool complain_if_not_found)
if (m_mask.size() > 0)
{
m_texture->grab();
irr_driver->removeTexture(m_texture);
video::ITexture* tex = irr_driver->applyMask(m_texture, m_mask);
if (tex)
{
irr_driver->removeTexture(m_texture);
// TODO: cleanup
//m_texture->drop();
m_texture = tex;
}
else

View File

@ -271,7 +271,6 @@ private:
bool m_installed;
void init ();
void install (bool is_full_path=false, bool complain_if_not_found=true);
void initCustomSFX(const XMLNode *sfx);
void initParticlesEffect(const XMLNode *node);
@ -283,7 +282,8 @@ public:
bool load_texture = true);
~Material ();
void unloadTexture();
void install(bool is_full_path = false, bool complain_if_not_found = true);
void unloadTexture();
void setSFXSpeed(SFXBase *sfx, float speed, bool should_be_paused) const;
void setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* mb);

View File

@ -395,6 +395,18 @@ void MaterialManager::unloadAllTextures()
}
}
// ----------------------------------------------------------------------------
void MaterialManager::installAllTextures()
{
std::string texture_folder = file_manager->getAssetDirectory(FileManager::TEXTURE);
for (int i = 0; i < m_shared_material_index; i++)
{
if (m_materials[i]->getTexFullPath().find(texture_folder) != std::string::npos)
m_materials[i]->install(true, true);
}
}
// ----------------------------------------------------------------------------
bool MaterialManager::hasMaterial(const std::string& fname)
{

View File

@ -83,6 +83,7 @@ public:
void makeMaterialsPermanent();
bool hasMaterial(const std::string& fname);
void installAllTextures();
void unloadAllTextures();
Material* getLatestMaterial() { return m_materials[m_materials.size()-1]; }

View File

@ -1645,10 +1645,14 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
{
if(!m_materials_loaded)
material_manager->addSharedMaterial(materials_file);
material_manager->installAllTextures();
m_materials_loaded = true;
}
else
{
material_manager->pushTempMaterial(materials_file);
material_manager->installAllTextures();
}
}
catch (std::exception& e)
{