mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Move actors out of the water if there's room for them. Fixes #1138
This commit is contained in:
parent
8a8aa664e3
commit
a72cd896ca
1 changed files with 28 additions and 5 deletions
|
@ -1318,11 +1318,34 @@ namespace MWPhysics
|
|||
const MWMechanics::MagicEffects& effects = iter->first.getClass().getCreatureStats(iter->first).getMagicEffects();
|
||||
|
||||
bool waterCollision = false;
|
||||
if (effects.get(ESM::MagicEffect::WaterWalking).getMagnitude()
|
||||
&& cell->getCell()->hasWater()
|
||||
&& !world->isUnderwater(iter->first.getCell(),
|
||||
osg::Vec3f(iter->first.getRefData().getPosition().asVec3())))
|
||||
waterCollision = true;
|
||||
if (cell->getCell()->hasWater() && effects.get(ESM::MagicEffect::WaterWalking).getMagnitude())
|
||||
{
|
||||
if (!world->isUnderwater(iter->first.getCell(), osg::Vec3f(iter->first.getRefData().getPosition().asVec3())))
|
||||
waterCollision = true;
|
||||
else
|
||||
{
|
||||
Actor *actor = getActor(iter->first);
|
||||
// Actor can collide
|
||||
if (actor->getCollisionMode())
|
||||
{
|
||||
const osg::Vec3f actorPosition = actor->getPosition();
|
||||
const osg::Vec3f destinationPosition(actorPosition.x(), actorPosition.y(), waterlevel);
|
||||
ActorTracer tracer;
|
||||
tracer.doTrace(actor->getCollisionObject(), actorPosition, destinationPosition, mCollisionWorld);
|
||||
if (tracer.mFraction >= 1.0f)
|
||||
{
|
||||
waterCollision = true;
|
||||
actor->setPosition(destinationPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Remove the effect to remove the performance hit of casting in a weird spot
|
||||
//probably makes that Tribunal quest where the water rises a bit safer
|
||||
iter->first.getClass().getCreatureStats(iter->first).getActiveSpells().purgeEffect(ESM::MagicEffect::WaterWalking);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ActorMap::iterator foundActor = mActors.find(iter->first);
|
||||
if (foundActor == mActors.end()) // actor was already removed from the scene
|
||||
|
|
Loading…
Reference in a new issue