From a5adb739007326b0113a33f79f492a12e26aab18 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Mon, 7 Nov 2022 23:09:12 +0300 Subject: [PATCH] Make idle emitters emit ripples every 1.5 seconds (bug #5883) --- CHANGELOG.md | 1 + apps/openmw/mwrender/ripplesimulation.cpp | 8 +++++++- apps/openmw/mwrender/ripplesimulation.hpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 671fa68bc2..fc4ac92339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Bug #5129: Stuttering animation on Centurion Archer Bug #5714: Touch spells cast using ExplodeSpell don't always explode Bug #5849: Paralysis breaks landing + Bug #5883: Immobile creatures don't cause water ripples Bug #5977: Fatigueless NPCs' corpse underwater changes animation on game load Bug #6427: Enemy health bar disappears before damaging effect ends Bug #6645: Enemy block sounds align with animation instead of blocked hits diff --git a/apps/openmw/mwrender/ripplesimulation.cpp b/apps/openmw/mwrender/ripplesimulation.cpp index 99d0023489..306cf7a34a 100644 --- a/apps/openmw/mwrender/ripplesimulation.cpp +++ b/apps/openmw/mwrender/ripplesimulation.cpp @@ -127,6 +127,7 @@ namespace MWRender const MWBase::World* world = MWBase::Environment::get().getWorld(); for (Emitter& emitter : mEmitters) { + emitter.mTimer -= dt; MWWorld::ConstPtr& ptr = emitter.mPtr; if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) { @@ -139,9 +140,13 @@ namespace MWRender bool shouldEmit = (world->isUnderwater(ptr.getCell(), currentPos) && !world->isSubmerged(ptr)) || world->isWalkingOnWater(ptr); - if (shouldEmit && (currentPos - emitter.mLastEmitPosition).length() > 10) + + if (!shouldEmit) + emitter.mTimer = 0.f; + else if (emitter.mTimer <= 0.f || (currentPos - emitter.mLastEmitPosition).length() > 10) { emitter.mLastEmitPosition = currentPos; + emitter.mTimer = 1.5f; currentPos.z() = mParticleNode->getPosition().z(); @@ -160,6 +165,7 @@ namespace MWRender newEmitter.mScale = scale; newEmitter.mForce = force; newEmitter.mLastEmitPosition = osg::Vec3f(0, 0, 0); + newEmitter.mTimer = 0.f; mEmitters.push_back(newEmitter); } diff --git a/apps/openmw/mwrender/ripplesimulation.hpp b/apps/openmw/mwrender/ripplesimulation.hpp index 7a5b2b8ae1..bc2eb91381 100644 --- a/apps/openmw/mwrender/ripplesimulation.hpp +++ b/apps/openmw/mwrender/ripplesimulation.hpp @@ -35,6 +35,7 @@ namespace MWRender osg::Vec3f mLastEmitPosition; float mScale; float mForce; + float mTimer; }; class RippleSimulation