Fix World::isUnderwater to use dynamic waterlevel

This commit is contained in:
scrawl 2013-02-25 17:27:50 +01:00
parent 73d48a95f6
commit 355390429e
4 changed files with 8 additions and 8 deletions

View file

@ -288,7 +288,7 @@ namespace MWBase
virtual bool isFlying(const MWWorld::Ptr &ptr) const = 0; virtual bool isFlying(const MWWorld::Ptr &ptr) const = 0;
virtual bool isSwimming(const MWWorld::Ptr &object) const = 0; virtual bool isSwimming(const MWWorld::Ptr &object) const = 0;
virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) const = 0; virtual bool isUnderwater(const MWWorld::Ptr::CellStore* cell, const Ogre::Vector3 &pos) const = 0;
virtual bool isOnGround(const MWWorld::Ptr &ptr) const = 0; virtual bool isOnGround(const MWWorld::Ptr &ptr) const = 0;
virtual void togglePOV() = 0; virtual void togglePOV() = 0;

View file

@ -381,7 +381,7 @@ void RenderingManager::update (float duration, bool paused)
mWater->updateUnderwater( mWater->updateUnderwater(
world->isUnderwater( world->isUnderwater(
*world->getPlayer().getPlayer().getCell()->mCell, world->getPlayer().getPlayer().getCell(),
Ogre::Vector3(cam.x, -cam.z, cam.y)) Ogre::Vector3(cam.x, -cam.z, cam.y))
); );
mWater->update(duration); mWater->update(duration);

View file

@ -1411,16 +1411,16 @@ namespace MWWorld
const OEngine::Physic::PhysicActor *actor = mPhysEngine->getCharacter(object.getRefData().getHandle()); const OEngine::Physic::PhysicActor *actor = mPhysEngine->getCharacter(object.getRefData().getHandle());
if(actor) pos.z += actor->getHalfExtents().z * 1.5; if(actor) pos.z += actor->getHalfExtents().z * 1.5;
return isUnderwater(*object.getCell()->mCell, pos); return isUnderwater(object.getCell(), pos);
} }
bool bool
World::isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) const World::isUnderwater(const MWWorld::Ptr::CellStore* cell, const Ogre::Vector3 &pos) const
{ {
if (!(cell.mData.mFlags & ESM::Cell::HasWater)) { if (!(cell->mCell->mData.mFlags & ESM::Cell::HasWater)) {
return false; return false;
} }
return pos.z < cell.mWater; return pos.z < cell->mWaterLevel;
} }
bool World::isOnGround(const MWWorld::Ptr &ptr) const bool World::isOnGround(const MWWorld::Ptr &ptr) const
@ -1448,7 +1448,7 @@ namespace MWWorld
Ogre::Vector3 playerPos(refdata.getPosition().pos); Ogre::Vector3 playerPos(refdata.getPosition().pos);
const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle()); const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle());
if(!physactor->getOnGround() || isUnderwater(*currentCell->mCell, playerPos)) if(!physactor->getOnGround() || isUnderwater(currentCell, playerPos))
return 2; return 2;
if((currentCell->mCell->mData.mFlags&ESM::Cell::NoSleep)) if((currentCell->mCell->mData.mFlags&ESM::Cell::NoSleep))
return 1; return 1;

View file

@ -316,7 +316,7 @@ namespace MWWorld
virtual bool isFlying(const MWWorld::Ptr &ptr) const; virtual bool isFlying(const MWWorld::Ptr &ptr) const;
virtual bool isSwimming(const MWWorld::Ptr &object) const; virtual bool isSwimming(const MWWorld::Ptr &object) const;
virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) const; virtual bool isUnderwater(const MWWorld::Ptr::CellStore* cell, const Ogre::Vector3 &pos) const;
virtual bool isOnGround(const MWWorld::Ptr &ptr) const; virtual bool isOnGround(const MWWorld::Ptr &ptr) const;
virtual void togglePOV() { virtual void togglePOV() {