NiZBufferProperty: handle depth test flag (bug #5902)

pull/3054/head
Dobrohotov Alexei 3 years ago
parent 3736cd45cd
commit 952b31ac5c

@ -109,6 +109,7 @@
Bug #5871: The console appears if you type the Russian letter "Ё" in the name of the enchantment
Bug #5877: Effects appearing with empty icon
Bug #5899: Visible modal windows and dropdowns crashing game on exit
Bug #5902: NiZBufferProperty is unable to disable the depth test
Feature #390: 3rd person look "over the shoulder"
Feature #832: OpenMW-CS: Handle deleted references
Feature #1536: Show more information about level on menu

@ -1725,11 +1725,16 @@ namespace NifOsg
case Nif::RC_NiZBufferProperty:
{
const Nif::NiZBufferProperty* zprop = static_cast<const Nif::NiZBufferProperty*>(property);
// VER_MW doesn't support a DepthFunction according to NifSkope
osg::StateSet* stateset = node->getOrCreateStateSet();
// Depth test flag
stateset->setMode(GL_DEPTH_TEST, zprop->flags&1 ? osg::StateAttribute::ON
: osg::StateAttribute::OFF);
osg::ref_ptr<osg::Depth> depth = new osg::Depth;
// Depth write flag
depth->setWriteMask((zprop->flags>>1)&1);
// Morrowind ignores depth test function
depth = shareAttribute(depth);
node->getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON);
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
break;
}
// OSG groups the material properties that NIFs have separate, so we have to parse them all again when one changed

Loading…
Cancel
Save