From 234fdfefb71b1a1dab3b99cd98db2d2fc671257f Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Fri, 31 Jan 2020 15:11:29 +0300 Subject: [PATCH] Revert "Don't apply 1.6 magic value to NiGravity decay factor (#5266)" --- CHANGELOG.md | 1 - components/nifosg/particle.cpp | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e04a1b37c9..11145e61ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -195,7 +195,6 @@ Bug #5249: Wandering NPCs start walking too soon after they hello Bug #5250: Creatures display shield ground mesh instead of shield body part Bug #5255: "GetTarget, player" doesn't return 1 during NPC hello - Bug #5266: Incorrect NiGravity decay implementation Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index 63019fe7fc..c1ccede1a8 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -203,12 +203,12 @@ void GravityAffector::beginOperate(osgParticle::Program* program) void GravityAffector::operate(osgParticle::Particle *particle, double dt) { - // Reverse-engineered value. - float decayFactor = 1.6f; + const float magic = 1.6f; switch (mType) { case Type_Wind: { + float decayFactor = 1.f; if (mDecay != 0.f) { osg::Plane gravityPlane(mCachedWorldDirection, mCachedWorldPosition); @@ -216,19 +216,21 @@ void GravityAffector::operate(osgParticle::Particle *particle, double dt) decayFactor = std::exp(-1.f * mDecay * distance); } - particle->addVelocity(mCachedWorldDirection * mForce * dt * decayFactor); + particle->addVelocity(mCachedWorldDirection * mForce * dt * decayFactor * magic); break; } case Type_Point: { osg::Vec3f diff = mCachedWorldPosition - particle->getPosition(); + + float decayFactor = 1.f; if (mDecay != 0.f) decayFactor = std::exp(-1.f * mDecay * diff.length()); diff.normalize(); - particle->addVelocity(diff * mForce * dt * decayFactor); + particle->addVelocity(diff * mForce * dt * decayFactor * magic); break; } }