diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 3de4ba8ac1..171fcde7c6 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -325,7 +325,7 @@ void OMW::Engine::go() // Create the world mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster, - mResDir, mNewGame, mEncoding, mFallbackMap)); + mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoding, mFallbackMap)); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index edeb0fe127..e983353cb0 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -40,7 +40,8 @@ using namespace Ogre; namespace MWRender { -RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine) +RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, + const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine) :mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0), mPhysicsEngine(engine) { // select best shader mode @@ -63,7 +64,9 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const // material system sh::OgrePlatform* platform = new sh::OgrePlatform("General", (resDir / "materials").string()); - platform->setCacheFolder ("./"); + if (!boost::filesystem::exists (cacheDir)) + boost::filesystem::create_directory (cacheDir); + platform->setCacheFolder (cacheDir.string()); mFactory = new sh::Factory(platform); sh::Language lang; @@ -75,6 +78,11 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const else lang = sh::Language_CG; mFactory->setCurrentLanguage (lang); + mFactory->setWriteSourceCache (true); + mFactory->setReadSourceCache (true); + mFactory->setReadMicrocodeCache (true); + mFactory->setWriteMicrocodeCache (true); + mFactory->loadAllFiles(); // Set default mipmap level (NB some APIs ignore this) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index de24491504..e5be238bd4 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -53,7 +53,8 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList virtual MWRender::Actors& getActors(); public: - RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine); + RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, + const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine); virtual ~RenderingManager(); void togglePOV() { diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 968aa8ceea..869ce94d1d 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -164,7 +164,7 @@ namespace MWWorld World::World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, - const std::string& master, const boost::filesystem::path& resDir, bool newGame, + const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame, const std::string& encoding, std::map fallbackMap) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm), @@ -173,7 +173,7 @@ namespace MWWorld mPhysics = new PhysicsSystem(renderer); mPhysEngine = mPhysics->getEngine(); - mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine); + mRendering = new MWRender::RenderingManager(renderer, resDir, cacheDir, mPhysEngine); mWeatherManager = new MWWorld::WeatherManager(mRendering); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 1d932bce2c..6279343d41 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -96,7 +96,7 @@ namespace MWWorld World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, - const std::string& master, const boost::filesystem::path& resDir, bool newGame, + const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame, const std::string& encoding, std::map fallbackMap); virtual ~World(); diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index ef810fb061..56e55a98d1 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -147,6 +147,11 @@ const boost::filesystem::path& ConfigurationManager::getGlobalDataPath() const return mFixedPath.getGlobalDataPath(); } +const boost::filesystem::path& ConfigurationManager::getCachePath() const +{ + return mFixedPath.getCachePath(); +} + const boost::filesystem::path& ConfigurationManager::getInstallPath() const { return mFixedPath.getInstallPath(); diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index ecbfac6646..9056e792d0 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -40,6 +40,8 @@ struct ConfigurationManager const boost::filesystem::path& getLocalDataPath() const; const boost::filesystem::path& getInstallPath() const; + const boost::filesystem::path& getCachePath() const; + const boost::filesystem::path& getLogPath() const; private: diff --git a/components/files/fixedpath.hpp b/components/files/fixedpath.hpp index 9e5c4f8f26..3c1f6d8016 100644 --- a/components/files/fixedpath.hpp +++ b/components/files/fixedpath.hpp @@ -75,6 +75,7 @@ struct FixedPath , mLocalPath(mPath.getLocalPath()) , mGlobalDataPath(mPath.getGlobalDataPath()) , mInstallPath(mPath.getInstallPath()) + , mCachePath(mPath.getCachePath()) { if (!application_name.empty()) { @@ -83,6 +84,7 @@ struct FixedPath mUserPath /= suffix; mGlobalPath /= suffix; mGlobalDataPath /= suffix; + mCachePath /= suffix; } } @@ -126,6 +128,11 @@ struct FixedPath return mGlobalDataPath; } + const boost::filesystem::path& getCachePath() const + { + return mCachePath; + } + private: PathType mPath; @@ -135,6 +142,8 @@ struct FixedPath boost::filesystem::path mGlobalDataPath; /**< Global application data path */ + boost::filesystem::path mCachePath; + boost::filesystem::path mInstallPath; }; diff --git a/components/files/linuxpath.cpp b/components/files/linuxpath.cpp index 92e4dce33f..8009fd3e81 100644 --- a/components/files/linuxpath.cpp +++ b/components/files/linuxpath.cpp @@ -62,6 +62,29 @@ boost::filesystem::path LinuxPath::getUserPath() const return userPath; } +boost::filesystem::path LinuxPath::getCachePath() const +{ + boost::filesystem::path userPath("."); + + const char* theDir = getenv("HOME"); + if (theDir == NULL) + { + struct passwd* pwd = getpwuid(getuid()); + if (pwd != NULL) + { + theDir = pwd->pw_dir; + } + } + + if (theDir != NULL) + { + userPath = boost::filesystem::path(theDir); + } + userPath /= "/.cache/"; + + return userPath; +} + boost::filesystem::path LinuxPath::getGlobalPath() const { boost::filesystem::path globalPath("/etc/"); diff --git a/components/files/linuxpath.hpp b/components/files/linuxpath.hpp index 48fdbb2ff6..ce339a5bf8 100644 --- a/components/files/linuxpath.hpp +++ b/components/files/linuxpath.hpp @@ -67,6 +67,13 @@ struct LinuxPath */ boost::filesystem::path getGlobalDataPath() const; + /** + * \brief + * + * \return boost::filesystem::path + */ + boost::filesystem::path getCachePath() const; + /** * \brief Gets the path of the installed Morrowind version if there is one. * diff --git a/components/files/macospath.cpp b/components/files/macospath.cpp index 94dafe7946..bbd1dbcdd1 100644 --- a/components/files/macospath.cpp +++ b/components/files/macospath.cpp @@ -69,6 +69,27 @@ boost::filesystem::path MacOsPath::getGlobalPath() const return globalPath; } +boost::filesystem::path MacOsPath::getCachePath() const +{ + boost::filesystem::path userPath("."); + + const char* theDir = getenv("HOME"); + if (theDir == NULL) + { + struct passwd* pwd = getpwuid(getuid()); + if (pwd != NULL) + { + theDir = pwd->pw_dir; + } + } + if (theDir != NULL) + { + userPath = boost::filesystem::path(theDir) / "Library/Caches/"; + } + + return userPath; +} + boost::filesystem::path MacOsPath::getLocalPath() const { return boost::filesystem::path("./"); diff --git a/components/files/macospath.hpp b/components/files/macospath.hpp index 0e9b3402e6..0e91360788 100644 --- a/components/files/macospath.hpp +++ b/components/files/macospath.hpp @@ -60,6 +60,13 @@ struct MacOsPath */ boost::filesystem::path getLocalPath() const; + /** + * \brief + * + * \return boost::filesystem::path + */ + boost::filesystem::path getCachePath() const; + /** * \brief * diff --git a/components/files/windowspath.cpp b/components/files/windowspath.cpp index dfa8f20cc3..744ad8ce84 100644 --- a/components/files/windowspath.cpp +++ b/components/files/windowspath.cpp @@ -67,6 +67,11 @@ boost::filesystem::path WindowsPath::getGlobalDataPath() const return getGlobalPath(); } +boost::filesystem::path WindowsPath::getCachePath() const +{ + return getUserPath() / "/cache"; +} + boost::filesystem::path WindowsPath::getInstallPath() const { boost::filesystem::path installPath(""); diff --git a/components/files/windowspath.hpp b/components/files/windowspath.hpp index d4c716c502..fa010730e4 100644 --- a/components/files/windowspath.hpp +++ b/components/files/windowspath.hpp @@ -61,6 +61,13 @@ struct WindowsPath */ boost::filesystem::path getLocalPath() const; + /** + * \brief + * + * \return boost::filesystem::path + */ + boost::filesystem::path getCachePath() const; + /** * \brief Return same path like getGlobalPath * diff --git a/extern/shiny b/extern/shiny index 164bc8d3bf..278c6952b5 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit 164bc8d3bfe860bd16ad89c0bd1b59f465c9bb24 +Subproject commit 278c6952b5c38e4b2a10205953e379598fad71a0