1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-13 12:40:04 +00:00

don't pingpong depth function on character preview update

This commit is contained in:
glassmancody.info 2021-08-18 15:46:25 -07:00
parent 6360bdc859
commit a6c7fcd436

View File

@ -133,32 +133,40 @@ namespace MWRender
}
if (SceneUtil::getReverseZ() && stateset->getAttribute(osg::StateAttribute::DEPTH))
{
if (!newStateSet)
{
newStateSet = new osg::StateSet(*stateset, osg::CopyOp::SHALLOW_COPY);
node.setStateSet(newStateSet);
}
// Setup standard depth ranges
bool depthModified = false;
osg::Depth* depth = static_cast<osg::Depth*>(stateset->getAttribute(osg::StateAttribute::DEPTH));
osg::ref_ptr<osg::Depth> newDepth = new osg::Depth(*depth);
switch (newDepth->getFunction())
depth->getUserValue("depthModified", depthModified);
if (!depthModified)
{
case osg::Depth::LESS:
newDepth->setFunction(osg::Depth::GREATER);
break;
case osg::Depth::LEQUAL:
newDepth->setFunction(osg::Depth::GEQUAL);
break;
case osg::Depth::GREATER:
newDepth->setFunction(osg::Depth::LESS);
break;
case osg::Depth::GEQUAL:
newDepth->setFunction(osg::Depth::LEQUAL);
break;
default:
break;
if (!newStateSet)
{
newStateSet = new osg::StateSet(*stateset, osg::CopyOp::SHALLOW_COPY);
node.setStateSet(newStateSet);
}
// Setup standard depth ranges
osg::ref_ptr<osg::Depth> newDepth = new osg::Depth(*depth);
switch (newDepth->getFunction())
{
case osg::Depth::LESS:
newDepth->setFunction(osg::Depth::GREATER);
break;
case osg::Depth::LEQUAL:
newDepth->setFunction(osg::Depth::GEQUAL);
break;
case osg::Depth::GREATER:
newDepth->setFunction(osg::Depth::LESS);
break;
case osg::Depth::GEQUAL:
newDepth->setFunction(osg::Depth::LEQUAL);
break;
default:
break;
}
newStateSet->setAttribute(newDepth, osg::StateAttribute::ON);
newDepth->setUserValue("depthModified", true);
}
newStateSet->setAttribute(newDepth, osg::StateAttribute::ON);
}
}
traverse(node);