From 3ae69f792ada3bbe9c44f2eaa12d1fb11ae1d6b8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 17 Mar 2012 12:57:52 +0100 Subject: [PATCH] no light-"jumps" during night --- apps/openmw/mwworld/weather.cpp | 56 +++++++++++---------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 12a413ccf..a5c954ef8 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -465,14 +465,6 @@ WeatherResult WeatherManager::transition(float factor) result.mNight = current.mNight; - // sound change behaviour: - // if 'other' has a new sound, switch to it after 1/2 of the transition length - if (other.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = factor>0.5 ? other.mAmbientLoopSoundID : current.mAmbientLoopSoundID; - // if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately - else if (current.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = ""; - return result; } @@ -541,15 +533,6 @@ void WeatherManager::update(float duration) } setWeather(weather, false); - /* - std::cout << "roll result: " << random << std::endl; - - std::cout << regionstr << " weather probabilities: " << clear << " " << cloudy << " " << foggy << " " - << overcast << " " << rain << " " << thunder << " " << ash << " " << blight << " " << snow << " " - << blizzard << std::endl; - - std::cout << "New weather : " << weather << std::endl; - */ } WeatherResult result; @@ -575,18 +558,26 @@ void WeatherManager::update(float duration) if (mHour >= 20 || mHour <= 6.f) mRendering->getSkyManager()->sunDisable(); else - { - // during day, calculate sun angle - float height = 1-std::abs(((mHour-13)/7.f)); - int facing = mHour > 13.f ? 1 : -1; - Vector3 final( - (1-height)*facing, - (1-height)*facing, - height); - mRendering->setSunDirection(final); - mRendering->getSkyManager()->sunEnable(); - } + + // sun angle + float height; + + // rise at 6, set at 20 + if (mHour >= 6 && mHour <= 20) + height = 1-std::abs(((mHour-13)/7.f)); + else if (mHour > 20) + height = (mHour-20.f)/4.f; + else //if (mHour > 0 && mHour < 6) + height = 1-(mHour/6.f); + + int facing = (mHour > 13.f) ? 1 : -1; + + Vector3 final( + (1-height)*facing, + (1-height)*facing, + height); + mRendering->setSunDirection(final); // moon calculations float night; @@ -755,15 +746,6 @@ void WeatherManager::update(float duration) void WeatherManager::setHour(const float hour) { - // accelerate a bit for testing - /* - mHour += 0.005; - - if (mHour >= 24.f) mHour = 0.f; - - std::cout << "hour " << mHour << std::endl; - */ - mHour = hour; }