mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:23:53 +00:00
Merge branch 'sundirection' into 'master'
Fix exterior sun direction/position (bug #4898) Closes #4898 See merge request OpenMW/openmw!3733
This commit is contained in:
commit
6ced0ab397
3 changed files with 13 additions and 9 deletions
|
@ -16,6 +16,7 @@
|
||||||
Bug #4754: Stack of ammunition cannot be equipped partially
|
Bug #4754: Stack of ammunition cannot be equipped partially
|
||||||
Bug #4816: GetWeaponDrawn returns 1 before weapon is attached
|
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 #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 #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 #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
|
Bug #5066: Quirks with starting and stopping scripted animations
|
||||||
|
|
|
@ -716,9 +716,12 @@ namespace MWRender
|
||||||
// need to wrap this in a StateUpdater?
|
// need to wrap this in a StateUpdater?
|
||||||
mSunLight->setPosition(osg::Vec4(position.x(), position.y(), position.z(), 0));
|
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);
|
mSky->setSunDirection(position);
|
||||||
|
|
||||||
mPostProcessor->getStateUpdater()->setSunPos(mSunLight->getPosition(), mNight);
|
mPostProcessor->getStateUpdater()->setSunPos(osg::Vec4f(position, 0.f), mNight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingManager::addCell(const MWWorld::CellStore* store)
|
void RenderingManager::addCell(const MWWorld::CellStore* store)
|
||||||
|
|
|
@ -747,21 +747,21 @@ namespace MWWorld
|
||||||
const float dayDuration = adjustedNightStart - mSunriseTime;
|
const float dayDuration = adjustedNightStart - mSunriseTime;
|
||||||
const float nightDuration = 24.f - dayDuration;
|
const float nightDuration = 24.f - dayDuration;
|
||||||
|
|
||||||
double theta;
|
float orbit;
|
||||||
if (!is_night)
|
if (!is_night)
|
||||||
{
|
{
|
||||||
theta = static_cast<float>(osg::PI) * (adjustedHour - mSunriseTime) / dayDuration;
|
float t = (adjustedHour - mSunriseTime) / dayDuration;
|
||||||
|
orbit = 1.f - 2.f * t;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
theta = static_cast<float>(osg::PI)
|
float t = (adjustedHour - adjustedNightStart) / nightDuration;
|
||||||
- static_cast<float>(osg::PI) * (adjustedHour - adjustedNightStart) / nightDuration;
|
orbit = 2.f * t - 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec3f final(static_cast<float>(cos(theta)),
|
// Hardcoded constant from Morrowind
|
||||||
-0.268f, // approx tan( -15 degrees )
|
const osg::Vec3f sunDir(-400.f * orbit, 75.f, -100.f);
|
||||||
static_cast<float>(sin(theta)));
|
mRendering.setSunDirection(sunDir);
|
||||||
mRendering.setSunDirection(final * -1);
|
|
||||||
mRendering.setNight(is_night);
|
mRendering.setNight(is_night);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue