From 7b2070de5adef058cc0d12b611740fa50b38857a Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 18 Aug 2014 19:23:16 +0200 Subject: [PATCH] unloadUnreferencedMaterials: Properly unload materials instead of removing techniques --- extern/shiny/Main/Factory.cpp | 2 +- extern/shiny/Main/Platform.hpp | 1 + extern/shiny/Platforms/Ogre/OgreMaterial.cpp | 5 +++++ extern/shiny/Platforms/Ogre/OgreMaterial.hpp | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp index 48caa225a..d7c4234cb 100644 --- a/extern/shiny/Main/Factory.cpp +++ b/extern/shiny/Main/Factory.cpp @@ -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(); } } diff --git a/extern/shiny/Main/Platform.hpp b/extern/shiny/Main/Platform.hpp index 24afea03b..d3156e680 100644 --- a/extern/shiny/Main/Platform.hpp +++ b/extern/shiny/Main/Platform.hpp @@ -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; diff --git a/extern/shiny/Platforms/Ogre/OgreMaterial.cpp b/extern/shiny/Platforms/Ogre/OgreMaterial.cpp index 77091fe03..04560e1f9 100644 --- a/extern/shiny/Platforms/Ogre/OgreMaterial.cpp +++ b/extern/shiny/Platforms/Ogre/OgreMaterial.cpp @@ -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()) diff --git a/extern/shiny/Platforms/Ogre/OgreMaterial.hpp b/extern/shiny/Platforms/Ogre/OgreMaterial.hpp index bfa6e2c6f..67a2c26e8 100644 --- a/extern/shiny/Platforms/Ogre/OgreMaterial.hpp +++ b/extern/shiny/Platforms/Ogre/OgreMaterial.hpp @@ -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 ();