Weather-related fixes (incl. bug #4783)

Simplify some calculations
Fix Blizzard weather direction
Fix sky direction during storm
pull/2562/head
Capostrophic 5 years ago
parent dec64a7fba
commit 43b1b9dfa2

@ -55,6 +55,7 @@
Bug #4768: Fallback numerical value recovery chokes on invalid arguments
Bug #4775: Slowfall effect resets player jumping flag
Bug #4778: Interiors of Illusion puzzle in Sotha Sil Expanded mod is broken
Bug #4783: Blizzard behavior is incorrect
Bug #4787: Sneaking makes 1st person walking/bobbing animation super-slow
Bug #4797: Player sneaking and running stances are not accounted for when in air
Bug #4800: Standing collisions are not updated immediately when an object is teleported without a cell change

@ -225,7 +225,7 @@ protected:
virtual void apply(osg::StateSet *stateset, osg::NodeVisitor *nv)
{
osg::TexMat* texMat = static_cast<osg::TexMat*>(stateset->getTextureAttribute(0, osg::StateAttribute::TEXMAT));
texMat->setMatrix(osg::Matrix::translate(osg::Vec3f(0, mAnimationTimer, 0.f)));
texMat->setMatrix(osg::Matrix::translate(osg::Vec3f(0, -mAnimationTimer, 0.f)));
stateset->setTextureAttribute(0, mTexture, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
stateset->setTextureAttribute(1, mTexture, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
@ -1108,7 +1108,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana
, mMonth(0)
, mCloudAnimationTimer(0.f)
, mRainTimer(0.f)
, mStormDirection(0,-1,0)
, mStormDirection(0,1,0)
, mClouds()
, mNextClouds()
, mCloudBlendFactor(0.0f)
@ -1597,10 +1597,14 @@ void SkyManager::update(float duration)
osg::Quat quat;
quat.makeRotate(osg::Vec3f(0,1,0), mStormDirection);
mCloudNode->setAttitude(quat);
if (mParticleNode)
{
// Morrowind deliberately rotates the blizzard mesh, so so should we.
if (mCurrentParticleEffect == "meshes\\blizzard.nif")
quat.makeRotate(osg::Vec3f(-1,0,0), mStormDirection);
mParticleNode->setAttitude(quat);
mCloudNode->setAttitude(quat);
}
}
else
mCloudNode->setAttitude(osg::Quat());
@ -1636,7 +1640,7 @@ void SkyManager::updateRainParameters()
{
if (mRainShooter)
{
float angle = -std::atan2(1, 50.f/mWindSpeed);
float angle = -std::atan(mWindSpeed/50.f);
mRainShooter->setVelocity(osg::Vec3f(0, mRainSpeed*std::sin(angle), -mRainSpeed/std::cos(angle)));
mRainShooter->setAngle(angle);

@ -661,17 +661,6 @@ void WeatherManager::playerTeleported(const std::string& playerRegion, bool isEx
}
}
osg::Vec3f WeatherManager::calculateStormDirection()
{
osg::Vec3f playerPos (MWMechanics::getPlayer().getRefData().getPosition().asVec3());
playerPos.z() = 0;
osg::Vec3f redMountainPos (25000, 70000, 0);
osg::Vec3f stormDirection = (playerPos - redMountainPos);
stormDirection.normalize();
return stormDirection;
}
float WeatherManager::calculateWindSpeed(int weatherId, float currentSpeed)
{
float targetSpeed = std::min(8.0f * mWeatherSettings[weatherId].mWindSpeed, 70.f);
@ -682,15 +671,7 @@ float WeatherManager::calculateWindSpeed(int weatherId, float currentSpeed)
float updatedSpeed = (Misc::Rng::rollClosedProbability() - 0.5f) * multiplier * targetSpeed + currentSpeed;
if (updatedSpeed > 0.5f * targetSpeed && updatedSpeed < 2.f * targetSpeed)
{
currentSpeed = updatedSpeed;
}
// Take in account direction to the Red Mountain, when needed
if (weatherId == 6 || weatherId == 7)
{
currentSpeed = (calculateStormDirection() * currentSpeed).length();
}
return currentSpeed;
}
@ -750,7 +731,16 @@ void WeatherManager::update(float duration, bool paused, const TimeStamp& time,
if (mIsStorm)
{
mStormDirection = calculateStormDirection();
osg::Vec3f stormDirection(0, 1, 0);
if (mResult.mParticleEffect == "meshes\\ashcloud.nif" || mResult.mParticleEffect == "meshes\\blightcloud.nif")
{
osg::Vec3f playerPos (MWMechanics::getPlayer().getRefData().getPosition().asVec3());
playerPos.z() = 0;
osg::Vec3f redMountainPos (25000, 70000, 0);
stormDirection = (playerPos - redMountainPos);
stormDirection.normalize();
}
mStormDirection = stormDirection;
mRendering.getSkyManager()->setStormDirection(mStormDirection);
}

@ -370,7 +370,6 @@ namespace MWWorld
bool updateWeatherRegion(const std::string& playerRegion);
void updateWeatherTransitions(const float elapsedRealSeconds);
void forceWeather(const int weatherID);
osg::Vec3f calculateStormDirection();
bool inTransition();
void addWeatherTransition(const int weatherID);

Loading…
Cancel
Save