mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-28 19:06:40 +00:00
Add emission of water ripple particles for water-walking actors (Fixes #3608)
This commit is contained in:
parent
385db50f2d
commit
16a913c549
4 changed files with 6 additions and 7 deletions
|
@ -548,7 +548,7 @@ namespace MWBase
|
||||||
/// Resets all actors in the current active cells to their original location within that cell.
|
/// Resets all actors in the current active cells to their original location within that cell.
|
||||||
virtual void resetActors() = 0;
|
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.
|
/// Return a vector aiming the actor's weapon towards a target.
|
||||||
/// @note The length of the vector is the distance between actor and 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)
|
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)
|
for (std::vector<Emitter>::iterator it=mEmitters.begin(); it !=mEmitters.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->mPtr == MWBase::Environment::get().getWorld ()->getPlayerPtr())
|
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());
|
osg::Vec3f currentPos (it->mPtr.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
if ( (currentPos - it->mLastEmitPosition).length() > 10
|
bool shouldEmit = ( world->isUnderwater (it->mPtr.getCell(), it->mPtr.getRefData().getPosition().asVec3()) && !world->isSubmerged(it->mPtr) ) || world->isWalkingOnWater(it->mPtr);
|
||||||
// Only emit when close to the water surface, not above it and not too deep in the water
|
if ( shouldEmit && (currentPos - it->mLastEmitPosition).length() > 10 )
|
||||||
&& MWBase::Environment::get().getWorld ()->isUnderwater (it->mPtr.getCell(), it->mPtr.getRefData().getPosition().asVec3())
|
|
||||||
&& !MWBase::Environment::get().getWorld()->isSubmerged(it->mPtr))
|
|
||||||
{
|
{
|
||||||
it->mLastEmitPosition = currentPos;
|
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);
|
const MWPhysics::Actor* physicActor = mPhysics->getActor(actor);
|
||||||
if (physicActor && physicActor->isWalkingOnWater())
|
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.
|
/// Resets all actors in the current active cells to their original location within that cell.
|
||||||
virtual void resetActors();
|
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.
|
/// Return a vector aiming the actor's weapon towards a target.
|
||||||
/// @note The length of the vector is the distance between actor and target.
|
/// @note The length of the vector is the distance between actor and target.
|
||||||
|
|
Loading…
Reference in a new issue