Add emission of water ripple particles for water-walking actors (Fixes #3608)

coverity_scan^2
scrawl 8 years ago
parent 385db50f2d
commit 16a913c549

@ -548,7 +548,7 @@ namespace MWBase
/// Resets all actors in the current active cells to their original location within that cell.
virtual void resetActors() = 0;
virtual bool isWalkingOnWater (const MWWorld::ConstPtr& actor) = 0;
virtual bool isWalkingOnWater (const MWWorld::ConstPtr& actor) const = 0;
/// Return a vector aiming the actor's weapon towards a target.
/// @note The length of the vector is the distance between actor and target.

@ -117,6 +117,7 @@ RippleSimulation::~RippleSimulation()
void RippleSimulation::update(float dt)
{
const MWBase::World* world = MWBase::Environment::get().getWorld();
for (std::vector<Emitter>::iterator it=mEmitters.begin(); it !=mEmitters.end(); ++it)
{
if (it->mPtr == MWBase::Environment::get().getWorld ()->getPlayerPtr())
@ -128,10 +129,8 @@ void RippleSimulation::update(float dt)
osg::Vec3f currentPos (it->mPtr.getRefData().getPosition().asVec3());
if ( (currentPos - it->mLastEmitPosition).length() > 10
// Only emit when close to the water surface, not above it and not too deep in the water
&& MWBase::Environment::get().getWorld ()->isUnderwater (it->mPtr.getCell(), it->mPtr.getRefData().getPosition().asVec3())
&& !MWBase::Environment::get().getWorld()->isSubmerged(it->mPtr))
bool shouldEmit = ( world->isUnderwater (it->mPtr.getCell(), it->mPtr.getRefData().getPosition().asVec3()) && !world->isSubmerged(it->mPtr) ) || world->isWalkingOnWater(it->mPtr);
if ( shouldEmit && (currentPos - it->mLastEmitPosition).length() > 10 )
{
it->mLastEmitPosition = currentPos;

@ -3313,7 +3313,7 @@ namespace MWWorld
}
}
bool World::isWalkingOnWater(const ConstPtr &actor)
bool World::isWalkingOnWater(const ConstPtr &actor) const
{
const MWPhysics::Actor* physicActor = mPhysics->getActor(actor);
if (physicActor && physicActor->isWalkingOnWater())

@ -651,7 +651,7 @@ namespace MWWorld
/// Resets all actors in the current active cells to their original location within that cell.
virtual void resetActors();
virtual bool isWalkingOnWater (const MWWorld::ConstPtr& actor);
virtual bool isWalkingOnWater (const MWWorld::ConstPtr& actor) const;
/// Return a vector aiming the actor's weapon towards a target.
/// @note The length of the vector is the distance between actor and target.

Loading…
Cancel
Save