some restructurings

actorid
scrawl 13 years ago
parent 41a8b22ebd
commit 1badb5d04f

@ -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;
}

@ -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<Ogre::String, Weather> 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);
};
}

@ -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)

Loading…
Cancel
Save