diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dbd4e463f..1771d0ab81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Bug #4754: Stack of ammunition cannot be equipped partially Bug #4816: GetWeaponDrawn returns 1 before weapon is attached Bug #4822: Non-weapon equipment and body parts can't inherit time from parent animation + Bug #4898: Odd/Incorrect lighting on meshes Bug #5057: Weapon swing sound plays at same pitch whether it hits or misses Bug #5062: Root bone rotations for NPC animation don't work the same as for creature animation Bug #5066: Quirks with starting and stopping scripted animations diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index fa92fa1420..2e3698a197 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -716,6 +716,9 @@ namespace MWRender // need to wrap this in a StateUpdater? mSunLight->setPosition(osg::Vec4(position.x(), position.y(), position.z(), 0)); + // The sun is not synchronized with the sunlight because sunlight origin can't reach the horizon + // This is based on exterior sun orbit and won't make sense for interiors, see WeatherManager::update + position.z() = 400.f - std::abs(position.x()); mSky->setSunDirection(position); mPostProcessor->getStateUpdater()->setSunPos(mSunLight->getPosition(), mNight); diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index aa75730b40..584f73520c 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -752,21 +752,21 @@ namespace MWWorld const float dayDuration = adjustedNightStart - mSunriseTime; const float nightDuration = 24.f - dayDuration; - double theta; + float orbit; if (!is_night) { - theta = static_cast(osg::PI) * (adjustedHour - mSunriseTime) / dayDuration; + float t = (adjustedHour - mSunriseTime) / dayDuration; + orbit = 1.f - 2.f * t; } else { - theta = static_cast(osg::PI) - - static_cast(osg::PI) * (adjustedHour - adjustedNightStart) / nightDuration; + float t = (adjustedHour - adjustedNightStart) / nightDuration; + orbit = 2.f * t - 1.f; } - osg::Vec3f final(static_cast(cos(theta)), - -0.268f, // approx tan( -15 degrees ) - static_cast(sin(theta))); - mRendering.setSunDirection(final * -1); + // Hardcoded constant from Morrowind + const osg::Vec3f sunDir(-400.f * orbit, 75.f, -100.f); + mRendering.setSunDirection(sunDir); mRendering.setNight(is_night); }