1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-28 14:39:41 +00:00

Merge pull request #2562 from Capostrophic/weather

Weather-related fixes (incl. bug #4783)
This commit is contained in:
Bret Curtis 2019-10-21 21:56:02 +02:00 committed by GitHub
commit 36119ec2c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 27 deletions

View file

@ -55,6 +55,7 @@
Bug #4768: Fallback numerical value recovery chokes on invalid arguments Bug #4768: Fallback numerical value recovery chokes on invalid arguments
Bug #4775: Slowfall effect resets player jumping flag Bug #4775: Slowfall effect resets player jumping flag
Bug #4778: Interiors of Illusion puzzle in Sotha Sil Expanded mod is broken 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 #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 #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 Bug #4800: Standing collisions are not updated immediately when an object is teleported without a cell change

View file

@ -225,7 +225,7 @@ protected:
virtual void apply(osg::StateSet *stateset, osg::NodeVisitor *nv) virtual void apply(osg::StateSet *stateset, osg::NodeVisitor *nv)
{ {
osg::TexMat* texMat = static_cast<osg::TexMat*>(stateset->getTextureAttribute(0, osg::StateAttribute::TEXMAT)); 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(0, mTexture, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
stateset->setTextureAttribute(1, 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) , mMonth(0)
, mCloudAnimationTimer(0.f) , mCloudAnimationTimer(0.f)
, mRainTimer(0.f) , mRainTimer(0.f)
, mStormDirection(0,-1,0) , mStormDirection(0,1,0)
, mClouds() , mClouds()
, mNextClouds() , mNextClouds()
, mCloudBlendFactor(0.0f) , mCloudBlendFactor(0.0f)
@ -1597,10 +1597,14 @@ void SkyManager::update(float duration)
osg::Quat quat; osg::Quat quat;
quat.makeRotate(osg::Vec3f(0,1,0), mStormDirection); quat.makeRotate(osg::Vec3f(0,1,0), mStormDirection);
if (mParticleNode)
mParticleNode->setAttitude(quat);
mCloudNode->setAttitude(quat); 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);
}
} }
else else
mCloudNode->setAttitude(osg::Quat()); mCloudNode->setAttitude(osg::Quat());
@ -1636,7 +1640,7 @@ void SkyManager::updateRainParameters()
{ {
if (mRainShooter) 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->setVelocity(osg::Vec3f(0, mRainSpeed*std::sin(angle), -mRainSpeed/std::cos(angle)));
mRainShooter->setAngle(angle); mRainShooter->setAngle(angle);

View file

@ -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 WeatherManager::calculateWindSpeed(int weatherId, float currentSpeed)
{ {
float targetSpeed = std::min(8.0f * mWeatherSettings[weatherId].mWindSpeed, 70.f); 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; float updatedSpeed = (Misc::Rng::rollClosedProbability() - 0.5f) * multiplier * targetSpeed + currentSpeed;
if (updatedSpeed > 0.5f * targetSpeed && updatedSpeed < 2.f * targetSpeed) if (updatedSpeed > 0.5f * targetSpeed && updatedSpeed < 2.f * targetSpeed)
{
currentSpeed = updatedSpeed; currentSpeed = updatedSpeed;
}
// Take in account direction to the Red Mountain, when needed
if (weatherId == 6 || weatherId == 7)
{
currentSpeed = (calculateStormDirection() * currentSpeed).length();
}
return currentSpeed; return currentSpeed;
} }
@ -750,7 +731,16 @@ void WeatherManager::update(float duration, bool paused, const TimeStamp& time,
if (mIsStorm) 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); mRendering.getSkyManager()->setStormDirection(mStormDirection);
} }

View file

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