Skip to content

Commit

Permalink
Merge branch '2' into 'master'
Browse files Browse the repository at this point in the history
stop making new reflacttetures at intext change

See merge request OpenMW/openmw!116
  • Loading branch information
Alexei Dobrohotov committed May 24, 2019
2 parents 97873f9 + 6c310c6 commit e0fb411
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions apps/openmw/mwrender/water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,7 @@ class Reflection : public osg::Camera
setName("ReflectionCamera");
setCullCallback(new InheritViewPointCallback);

int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water");
reflectionDetail = std::min(4, std::max(isInterior ? 2 : 0, reflectionDetail));
unsigned int extraMask = 0;
if(reflectionDetail >= 1) extraMask |= Mask_Terrain;
if(reflectionDetail >= 2) extraMask |= Mask_Static;
if(reflectionDetail >= 3) extraMask |= Mask_Effect|Mask_ParticleSystem|Mask_Object;
if(reflectionDetail >= 4) extraMask |= Mask_Player|Mask_Actor;
setCullMask(Mask_Scene|Mask_Sky|Mask_Lighting|extraMask);
setInterior(isInterior);
setNodeMask(Mask_RenderToTexture);

unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water");
Expand Down Expand Up @@ -374,6 +367,18 @@ class Reflection : public osg::Camera
SceneUtil::ShadowManager::disableShadowsForStateSet(getOrCreateStateSet());
}

void setInterior(bool isInterior)
{
int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water");
reflectionDetail = std::min(4, std::max(isInterior ? 2 : 0, reflectionDetail));
unsigned int extraMask = 0;
if(reflectionDetail >= 1) extraMask |= Mask_Terrain;
if(reflectionDetail >= 2) extraMask |= Mask_Static;
if(reflectionDetail >= 3) extraMask |= Mask_Effect|Mask_ParticleSystem|Mask_Object;
if(reflectionDetail >= 4) extraMask |= Mask_Player|Mask_Actor;
setCullMask(Mask_Scene|Mask_Sky|Mask_Lighting|extraMask);
}

void setWaterLevel(float waterLevel)
{
setViewMatrix(osg::Matrix::scale(1,1,-1) * osg::Matrix::translate(0,0,2 * waterLevel));
Expand Down Expand Up @@ -668,8 +673,8 @@ void Water::changeCell(const MWWorld::CellStore* store)
mWaterNode->setPosition(osg::Vec3f(0,0,mTop));
mInterior = true;
}
if(mInterior != wasInterior)
updateWaterMaterial();
if(mInterior != wasInterior && mReflection)
mReflection->setInterior(mInterior);

// create a new StateSet to prevent threading issues
osg::ref_ptr<osg::StateSet> nodeStateSet (new osg::StateSet);
Expand Down

0 comments on commit e0fb411

Please sign in to comment.