1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00

unloadUnreferencedMaterials: Properly unload materials instead of removing techniques

This commit is contained in:
scrawl 2014-08-18 19:23:16 +02:00
parent 83037a1a91
commit 7b2070de5a
4 changed files with 8 additions and 1 deletions

View File

@ -803,7 +803,7 @@ namespace sh
for (MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it)
{
if (it->second.getMaterial()->isUnreferenced())
it->second.destroyAll();
it->second.getMaterial()->unreferenceTextures();
}
}

View File

@ -69,6 +69,7 @@ namespace sh
virtual void removeAll () = 0; ///< remove all configurations
virtual bool isUnreferenced() = 0;
virtual void unreferenceTextures() = 0;
virtual void ensureLoaded() = 0;
virtual void setLodLevels (const std::string& lodLevels) = 0;

View File

@ -35,6 +35,11 @@ namespace sh
return (!mMaterial.isNull() && mMaterial.useCount() <= Ogre::ResourceGroupManager::RESOURCE_SYSTEM_NUM_REFERENCE_COUNTS+1);
}
void OgreMaterial::unreferenceTextures()
{
mMaterial->unload();
}
OgreMaterial::~OgreMaterial()
{
if (!mMaterial.isNull())

View File

@ -19,6 +19,7 @@ namespace sh
virtual bool createConfiguration (const std::string& name, unsigned short lodIndex);
virtual bool isUnreferenced();
virtual void unreferenceTextures();
virtual void ensureLoaded();
virtual void removeAll ();