add setting to disable the underwater effect

actorid
scrawl 13 years ago
parent b1c84f28a9
commit a5c6207fe7

@ -10,7 +10,7 @@ namespace MWRender
Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) :
mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()), mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()),
mIsUnderwater(false), mReflectDistance(0), mVisibilityFlags(0), mOldCameraFarClip(0), mIsUnderwater(false), mVisibilityFlags(0),
mReflectionTarget(0), mActive(1) mReflectionTarget(0), mActive(1)
{ {
mSky = sky; mSky = sky;
@ -38,7 +38,6 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) :
+ RV_Actors * Settings::Manager::getBool("reflect actors", "Water") + RV_Actors * Settings::Manager::getBool("reflect actors", "Water")
+ RV_Misc * Settings::Manager::getBool("reflect misc", "Water") + RV_Misc * Settings::Manager::getBool("reflect misc", "Water")
+ RV_Sky; + RV_Sky;
mReflectDistance = Settings::Manager::getInt("reflect distance", "Water");
mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
mWaterNode->setPosition(0, mTop, 0); mWaterNode->setPosition(0, mTop, 0);
@ -73,6 +72,8 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) :
createMaterial(); createMaterial();
mWater->setMaterial(mMaterial); mWater->setMaterial(mMaterial);
mUnderwaterEffect = Settings::Manager::getBool("underwater effect", "Water");
} }
void Water::setActive(bool active) void Water::setActive(bool active)
@ -120,9 +121,7 @@ void Water::checkUnderwater(float y)
if (!mActive) return; if (!mActive) return;
if ((mIsUnderwater && y > mTop) || !mWater->isVisible() || mCamera->getPolygonMode() != Ogre::PM_SOLID) if ((mIsUnderwater && y > mTop) || !mWater->isVisible() || mCamera->getPolygonMode() != Ogre::PM_SOLID)
{ {
try { CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false);
CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false);
} catch(...) {}
// tell the shader we are not underwater // tell the shader we are not underwater
Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0); Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0);
@ -139,9 +138,8 @@ void Water::checkUnderwater(float y)
if (!mIsUnderwater && y < mTop && mWater->isVisible() && mCamera->getPolygonMode() == Ogre::PM_SOLID) if (!mIsUnderwater && y < mTop && mWater->isVisible() && mCamera->getPolygonMode() == Ogre::PM_SOLID)
{ {
try { if (mUnderwaterEffect)
CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, true); CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, true);
} catch(...) {}
// tell the shader we are underwater // tell the shader we are underwater
Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0); Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0);
@ -164,10 +162,6 @@ Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY)
void Water::preRenderTargetUpdate(const RenderTargetEvent& evt) void Water::preRenderTargetUpdate(const RenderTargetEvent& evt)
{ {
//mOldCameraFarClip = mCamera->getFarClipDistance();
//if (mReflectDistance != 0)
// mCamera->setFarClipDistance(mReflectDistance);
if (evt.source == mReflectionTarget) if (evt.source == mReflectionTarget)
{ {
mWater->setVisible(false); mWater->setVisible(false);
@ -189,8 +183,6 @@ void Water::postRenderTargetUpdate(const RenderTargetEvent& evt)
{ {
mWater->setVisible(true); mWater->setVisible(true);
//mCamera->setFarClipDistance(mOldCameraFarClip);
if (evt.source == mReflectionTarget) if (evt.source == mReflectionTarget)
{ {
mSky->resetSkyPosition(); mSky->resetSkyPosition();

@ -41,9 +41,8 @@ namespace MWRender {
Ogre::RenderTarget* mReflectionTarget; Ogre::RenderTarget* mReflectionTarget;
bool mUnderwaterEffect;
int mVisibilityFlags; int mVisibilityFlags;
int mReflectDistance;
int mOldCameraFarClip;
public: public:
Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell); Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell);

@ -71,6 +71,9 @@ reflect actors = true
reflect misc = false reflect misc = false
# Enable underwater effect. It is not resource intensive, so only disable it if you have problems.
underwater effect = true
[Sound] [Sound]
# Device name. Blank means default # Device name. Blank means default
device = device =

Loading…
Cancel
Save