diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index b18415e659..3adfa6929a 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -133,9 +133,13 @@ void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ if(store->cell->data.flags & store->cell->HasWater){ if(mWater == 0) mWater = new MWRender::Water(rend.getCamera(), store->cell); + else + mWater->changeCell(store->cell); //else } + else + removeWater(); } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 4ab809567c..5cf6df99e2 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -12,9 +12,9 @@ namespace MWRender { mIsUnderwater = false; - mCamera->addListener(this); + //mCamera->addListener(this); - mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, mTop); + mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, 0); Ogre::MeshManager::getSingleton().createPlane("water", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, CELL_SIZE*3 + 10000, CELL_SIZE * 3 + 10000, 10, 10, true, 1, 3,5, Ogre::Vector3::UNIT_Z); @@ -27,6 +27,7 @@ namespace MWRender { mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); + mWaterNode->setPosition(0, mTop, 0); if(!(cell->data.flags & cell->Interior)) @@ -40,7 +41,7 @@ namespace MWRender { Water::~Water() { Ogre::MeshManager::getSingleton().remove("water"); - mCamera->removeListener(this); + //mCamera->removeListener(this); mWaterNode->detachObject(mWater); mSceneManager->destroyEntity(mWater); @@ -51,6 +52,17 @@ namespace MWRender { Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport); } + void Water::changeCell(const ESM::Cell* cell){ + mTop = cell->water; + + + + if(!(cell->data.flags & cell->Interior)) + mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY)); + else + mWaterNode->setPosition(0, mTop, 0); + } + void Water::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) { mWater->setVisible(false); @@ -106,7 +118,7 @@ namespace MWRender { void Water::cameraDestroyed(Ogre::Camera *cam) { } Ogre::Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY){ - Ogre::Vector3 out = Ogre::Vector3(gridX * CELL_SIZE + (CELL_SIZE / 2), 0, -gridY * CELL_SIZE - (CELL_SIZE / 2)); + Ogre::Vector3 out = Ogre::Vector3(gridX * CELL_SIZE + (CELL_SIZE / 2), mTop, -gridY * CELL_SIZE - (CELL_SIZE / 2)); return out; } diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index e07e93eefa..bdc9895fd6 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -40,7 +40,7 @@ namespace MWRender { ~Water(); void checkUnderwater(float y); - void changeCell(float x, float y); + void changeCell(const ESM::Cell* cell); }; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index b222d5aec9..0b02a867ee 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -218,7 +218,6 @@ namespace MWWorld void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) { std::cout << "Changing to interior\n"; - mRendering.removeWater(); // remove active CellStoreCollection::iterator active = mActiveCells.begin(); @@ -250,7 +249,6 @@ namespace MWWorld { int x = 0; int y = 0; - mRendering.removeWater(); mWorld->positionToIndex (position.pos[0], position.pos[1], x, y);