diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 98c15e3383..d224385ae5 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -67,6 +67,13 @@ namespace MWWorld return mEngine->rayTest2(from,to); } + void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight){ + playerphysics->hasWater = hasWater; + if(hasWater){ + playerphysics->waterHeight = waterHeight; + } + + } btVector3 PhysicsSystem::getRayPoint(float extent) { diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index fb15a1486f..2d73cab27c 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -49,6 +49,8 @@ namespace MWWorld void insertActorPhysics(const MWWorld::Ptr&, std::string model); OEngine::Physic::PhysicEngine* getEngine(); + + void setCurrentWater(bool hasWater, int waterHeight); private: OEngine::Render::OgreRenderer &mRender; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2123b47999..5244d53f83 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -117,6 +117,8 @@ namespace MWWorld void Scene::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position, bool adjustPlayerPos) { + bool hasWater = cell->cell->data.flags & cell->cell->HasWater; + mPhysics->setCurrentWater(hasWater, cell->cell->water); if (adjustPlayerPos) mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]); diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 86d069273e..214a7e5989 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -1715,11 +1715,11 @@ void PM_SetWaterLevel( playerMove* const pm ) point[1] = pm->ps->origin[1]; point[2] = pm->ps->origin[2] + MINS_Z + 1; */ point.x = pm->ps.origin.x; - point.y = pm->ps.origin.y + MINS_Z + 1; - point.z = pm->ps.origin.z; + point.y = pm->ps.origin.y; + point.z = pm->ps.origin.z + MINS_Z + 1; //cont = pm->pointcontents( point, pm->ps->clientNum ); - bool checkWater = (pml.hasWater && pml.waterHeight > point.y); + bool checkWater = (pml.hasWater && pml.waterHeight > point.z); //if ( cont & MASK_WATER ) if ( checkWater) { @@ -1729,14 +1729,14 @@ void PM_SetWaterLevel( playerMove* const pm ) pm->ps.watertype = CONTENTS_WATER;//cont; pm->ps.waterlevel = WL_ANKLE; //point[2] = pm->ps->origin[2] + MINS_Z + sample1; - point.y = pm->ps.origin.y + MINS_Z + sample1; + point.z = pm->ps.origin.z + MINS_Z + sample1; //cont = pm->pointcontents (point, pm->ps->clientNum ); //if ( cont & MASK_WATER ) if (checkWater) { pm->ps.waterlevel = WL_WAIST; //point[2] = pm->ps->origin[2] + MINS_Z + sample2; - point.y = pm->ps.origin.y + MINS_Z + sample2; + point.z = pm->ps.origin.z + MINS_Z + sample2; //cont = pm->pointcontents (point, pm->ps->clientNum ); //if ( cont & MASK_WATER ) if (checkWater )