diff options
author | AnyOldName3 <krizdjali+gitlab@gmail.com> | 2023-07-28 14:47:19 +0000 |
---|---|---|
committer | AnyOldName3 <krizdjali+gitlab@gmail.com> | 2023-07-28 14:47:19 +0000 |
commit | 8cd3f5fc074ff180bf1d70023d29e5e774f94751 (patch) | |
tree | 0183c9872d6c3c3d15422469f174fd40db47503f | |
parent | 81deb3796b1b93719458c5bc9046476277dae272 (diff) |
Revert "Merge branch 'async_content_load' into 'master'"revert-6246b479
This reverts merge request !3249
-rw-r--r-- | apps/openmw/engine.cpp | 19 | ||||
-rw-r--r-- | apps/openmw/mwgui/loadingscreen.cpp | 16 | ||||
-rw-r--r-- | apps/openmw/mwgui/loadingscreen.hpp | 3 | ||||
-rw-r--r-- | apps/openmw/mwworld/worldimp.cpp | 30 | ||||
-rw-r--r-- | apps/openmw/mwworld/worldimp.hpp | 14 |
5 files changed, 23 insertions, 59 deletions
diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 64a94e1a57..dc3b6b0728 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -38,8 +38,6 @@ #include <components/l10n/manager.hpp> -#include <components/loadinglistener/loadinglistener.hpp> - #include <components/misc/frameratelimiter.hpp> #include <components/sceneutil/color.hpp> @@ -738,13 +736,6 @@ void OMW::Engine::prepareEngine() mSoundManager = std::make_unique<MWSound::SoundManager>(mVFS.get(), mUseSound); mEnvironment.setSoundManager(*mSoundManager); - // Create the world - mWorld = std::make_unique<MWWorld::World>( - mResourceSystem.get(), mActivationDistanceOverride, mCellName, mCfgMgr.getUserDataPath()); - - std::thread loadDataThread( - [&] { mWorld->loadData(mFileCollections, mContentFiles, mGroundcoverFiles, mEncoder.get()); }); - if (!mSkipMenu) { std::string_view logo = Fallback::Map::getString("Movies_Company_Logo"); @@ -752,12 +743,10 @@ void OMW::Engine::prepareEngine() mWindowManager->playVideo(logo, true); } - Loading::Listener* listener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); - listener->loadingOn(); - loadDataThread.join(); - listener->loadingOff(); - - mWorld->init(mViewer, rootNode, mWorkQueue.get(), *mUnrefQueue); + // Create the world + mWorld = std::make_unique<MWWorld::World>(mViewer, rootNode, mResourceSystem.get(), mWorkQueue.get(), *mUnrefQueue, + mFileCollections, mContentFiles, mGroundcoverFiles, mEncoder.get(), mActivationDistanceOverride, mCellName, + mCfgMgr.getUserDataPath()); mWorld->setupPlayer(); mWorld->setRandomSeed(mRandomSeed); mEnvironment.setWorld(*mWorld); diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 960c831376..fd7afa2d8a 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -76,10 +76,6 @@ namespace MWGui void LoadingScreen::setLabel(const std::string& label, bool important) { - std::lock_guard<std::mutex> guard(mMutex); - if (!isVisible()) - return; - mImportantLabel = important; mLoadingText->setCaptionWithReplacing(label); @@ -145,8 +141,6 @@ namespace MWGui void LoadingScreen::loadingOn(bool visible) { - std::lock_guard<std::mutex> guard(mMutex); - // Early-out if already on if (mNestedLoadingCount++ > 0 && mMainWidget->getVisible()) return; @@ -187,8 +181,6 @@ namespace MWGui void LoadingScreen::loadingOff() { - std::lock_guard<std::mutex> guard(mMutex); - if (--mNestedLoadingCount > 0) return; mLoadingBox->setVisible(true); // restore @@ -247,10 +239,6 @@ namespace MWGui void LoadingScreen::setProgress(size_t value) { - std::lock_guard<std::mutex> guard(mMutex); - if (!isVisible()) - return; - // skip expensive update if there isn't enough visible progress if (mProgressBar->getWidth() <= 0 || value - mProgress < mProgressBar->getScrollRange() / mProgressBar->getWidth()) @@ -265,10 +253,6 @@ namespace MWGui void LoadingScreen::increaseProgress(size_t increase) { - std::lock_guard<std::mutex> guard(mMutex); - if (!isVisible()) - return; - mProgressBar->setScrollPosition(0); size_t value = mProgress + increase; value = std::min(value, mProgressBar->getScrollRange() - 1); diff --git a/apps/openmw/mwgui/loadingscreen.hpp b/apps/openmw/mwgui/loadingscreen.hpp index 939ee72191..2cd3f73576 100644 --- a/apps/openmw/mwgui/loadingscreen.hpp +++ b/apps/openmw/mwgui/loadingscreen.hpp @@ -2,7 +2,6 @@ #define MWGUI_LOADINGSCREEN_H #include <memory> -#include <mutex> #include <osg/Timer> #include <osg/ref_ptr> @@ -70,8 +69,6 @@ namespace MWGui bool mVisible; int mNestedLoadingCount; - std::mutex mMutex; - size_t mProgress; bool mShowWallpaper; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 9852e32548..9c3b27b209 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -244,16 +244,19 @@ namespace MWWorld mRendering->setSkyEnabled(false); } - World::World(Resource::ResourceSystem* resourceSystem, int activationDistanceOverride, const std::string& startCell, + World::World(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode, Resource::ResourceSystem* resourceSystem, + SceneUtil::WorkQueue* workQueue, SceneUtil::UnrefQueue& unrefQueue, const Files::Collections& fileCollections, + const std::vector<std::string>& contentFiles, const std::vector<std::string>& groundcoverFiles, + ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride, const std::string& startCell, const std::filesystem::path& userDataPath) : mResourceSystem(resourceSystem) , mLocalScripts(mStore) , mWorldModel(mStore, mReaders) - , mCurrentDate(std::make_unique<DateTimeManager>()) , mSky(true) , mGodMode(false) , mScriptsEnabled(true) , mDiscardMovements(true) + , mContentFiles(contentFiles) , mUserDataPath(userDataPath) , mActivationDistanceOverride(activationDistanceOverride) , mStartCell(startCell) @@ -267,20 +270,19 @@ namespace MWWorld , mPlayerInJail(false) , mSpellPreloadTimer(0.f) { - } - - void World::loadData(const Files::Collections& fileCollections, const std::vector<std::string>& contentFiles, - const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder) - { - mContentFiles = contentFiles; if (encoder) mReaders.setStatelessEncoder(encoder->getStatelessEncoder()); mESMVersions.resize(mContentFiles.size(), -1); Loading::Listener* listener = MWBase::Environment::get().getWindowManager()->getLoadingScreen(); + listener->loadingOn(); loadContentFiles(fileCollections, contentFiles, encoder, listener); loadGroundcoverFiles(fileCollections, groundcoverFiles, encoder, listener); + listener->loadingOff(); + + mCurrentDate = std::make_unique<DateTimeManager>(); + fillGlobalVariables(); mStore.setUp(); @@ -288,18 +290,14 @@ namespace MWWorld mStore.movePlayerRecord(); mSwimHeightScale = mStore.get<ESM::GameSetting>().find("fSwimHeightScale")->mValue.getFloat(); - } - void World::init(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode, SceneUtil::WorkQueue* workQueue, - SceneUtil::UnrefQueue& unrefQueue) - { - mPhysics = std::make_unique<MWPhysics::PhysicsSystem>(mResourceSystem, rootNode); + mPhysics = std::make_unique<MWPhysics::PhysicsSystem>(resourceSystem, rootNode); if (Settings::Manager::getBool("enable", "Navigator")) { auto navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager(); navigatorSettings.mRecast.mSwimHeightScale = mSwimHeightScale; - mNavigator = DetourNavigator::makeNavigator(navigatorSettings, mUserDataPath); + mNavigator = DetourNavigator::makeNavigator(navigatorSettings, userDataPath); } else { @@ -307,9 +305,9 @@ namespace MWWorld } mRendering = std::make_unique<MWRender::RenderingManager>( - viewer, rootNode, mResourceSystem, workQueue, *mNavigator, mGroundcoverStore, unrefQueue); + viewer, rootNode, resourceSystem, workQueue, *mNavigator, mGroundcoverStore, unrefQueue); mProjectileManager = std::make_unique<ProjectileManager>( - mRendering->getLightRoot()->asGroup(), mResourceSystem, mRendering.get(), mPhysics.get()); + mRendering->getLightRoot()->asGroup(), resourceSystem, mRendering.get(), mPhysics.get()); mRendering->preloadCommonAssets(); mWeatherManager = std::make_unique<MWWorld::WeatherManager>(*mRendering, mStore); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index dfdbe4d689..3c941f68e0 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -195,15 +195,11 @@ namespace MWWorld void addContainerScripts(const Ptr& reference, CellStore* cell) override; void removeContainerScripts(const Ptr& reference) override; - World(Resource::ResourceSystem* resourceSystem, int activationDistanceOverride, const std::string& startCell, - const std::filesystem::path& userDataPath); - - void loadData(const Files::Collections& fileCollections, const std::vector<std::string>& contentFiles, - const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder); - - // Must be called after `loadData`. - void init(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode, SceneUtil::WorkQueue* workQueue, - SceneUtil::UnrefQueue& unrefQueue); + World(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode, Resource::ResourceSystem* resourceSystem, + SceneUtil::WorkQueue* workQueue, SceneUtil::UnrefQueue& unrefQueue, + const Files::Collections& fileCollections, const std::vector<std::string>& contentFiles, + const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder, + int activationDistanceOverride, const std::string& startCell, const std::filesystem::path& userDataPath); virtual ~World(); |