Fix exterior sun direction/position (bug #4898)

ini_importer_tests
Alexei Kotov 4 months ago
parent 961c53f1c4
commit 1f26485c47

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

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

@ -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<float>(osg::PI) * (adjustedHour - mSunriseTime) / dayDuration;
float t = (adjustedHour - mSunriseTime) / dayDuration;
orbit = 1.f - 2.f * t;
}
else
{
theta = static_cast<float>(osg::PI)
- static_cast<float>(osg::PI) * (adjustedHour - adjustedNightStart) / nightDuration;
float t = (adjustedHour - adjustedNightStart) / nightDuration;
orbit = 2.f * t - 1.f;
}
osg::Vec3f final(static_cast<float>(cos(theta)),
-0.268f, // approx tan( -15 degrees )
static_cast<float>(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);
}

Loading…
Cancel
Save