From 1badb5d04f09a6ee11be03ecb913631a259d9a75 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 22 Feb 2012 20:12:08 +0100 Subject: [PATCH] some restructurings --- apps/openmw/mwworld/weather.cpp | 26 +++++++++++++++++++------- apps/openmw/mwworld/weather.hpp | 11 +++++++++-- apps/openmw/mwworld/world.cpp | 4 ++++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 84ab3a0d2..92360eea3 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -46,9 +46,9 @@ void WeatherManager::setWeather(const String& weather, bool instant) } } -WeatherResult WeatherManager::getResult() +WeatherResult WeatherManager::getResult(const String& weather) { - const Weather& current = mWeatherSettings[mCurrentWeather]; + const Weather& current = mWeatherSettings[weather]; WeatherResult result; result.mCloudTexture = current.mCloudTexture; @@ -59,9 +59,10 @@ WeatherResult WeatherManager::getResult() return result; } -WeatherResult WeatherManager::transition(const Weather& other, float factor) +WeatherResult WeatherManager::transition(float factor) { - const Weather& current = mWeatherSettings[mCurrentWeather]; + const WeatherResult& current = getResult(mCurrentWeather); + const WeatherResult& other = getResult(mNextWeather); WeatherResult result; result.mCloudTexture = current.mCloudTexture; @@ -70,7 +71,7 @@ WeatherResult WeatherManager::transition(const Weather& other, float factor) #define lerp(x, y) (x * (1-factor) + y * factor) - result.mCloudOpacity = lerp(current.mCloudsMaximumPercent, other.mCloudsMaximumPercent); + result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); /// \todo @@ -92,9 +93,20 @@ void WeatherManager::update(float duration) } if (mNextWeather != "") - result = transition(mWeatherSettings[mNextWeather], 1-(mRemainingTransitionTime/TRANSITION_TIME)); + result = transition(1-(mRemainingTransitionTime/TRANSITION_TIME)); else - result = getResult(); + result = getResult(mCurrentWeather); mRendering->getSkyManager()->setWeather(result); } + +void WeatherManager::setHour(const float hour) +{ + mHour = hour; +} + +void WeatherManager::setDate(const int day, const int month) +{ + mDay = day; + mMonth = month; +} diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 14e75a463..4153ccdd0 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -120,7 +120,14 @@ namespace MWWorld */ void update(float duration); + void setHour(const float hour); + + void setDate(const int day, const int month); + private: + float mHour; + int mDay, mMonth; + MWRender::RenderingManager* mRendering; std::map mWeatherSettings; @@ -130,8 +137,8 @@ namespace MWWorld float mRemainingTransitionTime; - WeatherResult transition(const Weather& other, const float factor); - WeatherResult getResult(); + WeatherResult transition(const float factor); + WeatherResult getResult(const Ogre::String& weather); }; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 9d874b06f..909989ad1 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -374,6 +374,8 @@ namespace MWWorld mGlobalVariables->setFloat ("gamehour", hour); mRendering->skySetHour (hour); + + mWeatherManager->setHour (hour); if (days>0) setDay (days + mGlobalVariables->getInt ("day")); @@ -409,6 +411,8 @@ namespace MWWorld mGlobalVariables->setInt ("month", month); mRendering->skySetDate (day, month); + + mWeatherManager->setDate (day, month); } void World::setMonth (int month)