mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Proper handling of cull flags
This commit is contained in:
parent
2b43e59c09
commit
a9cea565f9
5 changed files with 30 additions and 15 deletions
|
@ -675,18 +675,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
Settings::Manager::getInt("anisotropy", "General")
|
||||
);
|
||||
|
||||
// geometry shader must be enabled before the RenderingManager sets up any shaders
|
||||
// therefore this part is separate from the rest of stereo setup.
|
||||
mStereoEnabled = mEnvironment.getVrMode() || Settings::Manager::getBool("stereo enabled", "Stereo");
|
||||
if (mStereoEnabled)
|
||||
{
|
||||
// Mask in everything that does not currently use shaders.
|
||||
// Remove that altogether when the sky finally uses them.
|
||||
auto noShaderMask = MWRender::VisMask::Mask_Sky | MWRender::VisMask::Mask_Sun | MWRender::VisMask::Mask_WeatherParticles;
|
||||
// Since shaders are not yet created, we need to use the brute force technique initially
|
||||
mStereoView.reset(new Misc::StereoView(noShaderMask, MWRender::VisMask::Mask_Scene));
|
||||
}
|
||||
|
||||
int numThreads = Settings::Manager::getInt("preload num threads", "Cells");
|
||||
if (numThreads <= 0)
|
||||
throw std::runtime_error("Invalid setting: 'preload num threads' must be >0");
|
||||
|
@ -782,6 +770,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
#ifdef USE_OPENXR
|
||||
mXrEnvironment.setGUIManager(new MWVR::VRGUIManager(mViewer, mResourceSystem.get(), rootNode));
|
||||
mXrEnvironment.getViewer()->configureCallbacks();
|
||||
mStereoView->setCullMask(mStereoView->getCullMask() & ~MWRender::VisMask::Mask_GUI);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -816,7 +805,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
// Stereo shader technique can be set up now.
|
||||
mStereoView->setStereoTechnique(Misc::getStereoTechnique());
|
||||
mStereoView->initializeScene();
|
||||
mStereoView->setCullMask(mStereoView->getCullMask());
|
||||
mStereoView->setCullMask(mViewer->getCamera()->getCullMask() & ~MWRender::VisMask::Mask_GUI);
|
||||
}
|
||||
|
||||
window->setStore(mEnvironment.getWorld()->getStore());
|
||||
|
@ -935,6 +924,22 @@ void OMW::Engine::go()
|
|||
// Create encoder
|
||||
mEncoder = new ToUTF8::Utf8Encoder(mEncoding);
|
||||
|
||||
#ifdef USE_OPENXR
|
||||
mEnvironment.setVrMode(true);
|
||||
#endif
|
||||
|
||||
// geometry shader must be enabled before the RenderingManager sets up any shaders
|
||||
// therefore this part is separate from the rest of stereo setup.
|
||||
mStereoEnabled = mEnvironment.getVrMode() || Settings::Manager::getBool("stereo enabled", "Stereo");
|
||||
if (mStereoEnabled)
|
||||
{
|
||||
// Mask in everything that does not currently use shaders.
|
||||
// Remove that altogether when the sky finally uses them.
|
||||
auto noShaderMask = MWRender::VisMask::Mask_Sky | MWRender::VisMask::Mask_Sun | MWRender::VisMask::Mask_WeatherParticles;
|
||||
// Since shaders are not yet created, we need to use the brute force technique initially
|
||||
mStereoView.reset(new Misc::StereoView(noShaderMask, MWRender::VisMask::Mask_Scene));
|
||||
}
|
||||
|
||||
// Setup viewer
|
||||
mViewer = new osgViewer::Viewer;
|
||||
mViewer->setReleaseContextAtEndOfFrameHint(false);
|
||||
|
|
|
@ -606,11 +606,15 @@ namespace MWGui
|
|||
mOldCullMask = mViewer->getCamera()->getCullMask();
|
||||
mViewer->getUpdateVisitor()->setTraversalMask(disablemask);
|
||||
mViewer->getCamera()->setCullMask(disablemask);
|
||||
mViewer->getCamera()->setCullMaskLeft(disablemask);
|
||||
mViewer->getCamera()->setCullMaskRight(disablemask);
|
||||
}
|
||||
else if (enable && mViewer->getCamera()->getCullMask() == disablemask)
|
||||
{
|
||||
mViewer->getUpdateVisitor()->setTraversalMask(mOldUpdateMask);
|
||||
mViewer->getCamera()->setCullMask(mOldCullMask);
|
||||
mViewer->getCamera()->setCullMaskLeft(mOldCullMask);
|
||||
mViewer->getCamera()->setCullMaskRight(mOldCullMask);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -369,7 +369,10 @@ namespace MWRender
|
|||
mViewer->getCamera()->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
mViewer->getCamera()->setCullingMode(cullingMode);
|
||||
|
||||
mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater));
|
||||
auto mask = ~(Mask_UpdateVisitor | Mask_SimpleWater);
|
||||
mViewer->getCamera()->setCullMask(mask);
|
||||
mViewer->getCamera()->setCullMaskLeft(mask);
|
||||
mViewer->getCamera()->setCullMaskRight(mask);
|
||||
NifOsg::Loader::setHiddenNodeMask(Mask_UpdateVisitor);
|
||||
NifOsg::Loader::setIntersectionDisabledNodeMask(Mask_Effect);
|
||||
Nif::NIFFile::setLoadUnsupportedFiles(Settings::Manager::getBool("load unsupported nif files", "Models"));
|
||||
|
@ -586,6 +589,8 @@ namespace MWRender
|
|||
else
|
||||
mask &= ~Mask_Scene;
|
||||
mViewer->getCamera()->setCullMask(mask);
|
||||
mViewer->getCamera()->setCullMaskLeft(mask);
|
||||
mViewer->getCamera()->setCullMaskRight(mask);
|
||||
return enabled;
|
||||
}
|
||||
else if (mode == Render_NavMesh)
|
||||
|
|
|
@ -14,7 +14,6 @@ void OMW::Engine::initVr()
|
|||
if (!mViewer)
|
||||
throw std::logic_error("mViewer must be initialized before calling initVr()");
|
||||
|
||||
mEnvironment.setVrMode(true);
|
||||
mXrEnvironment.setManager(new MWVR::OpenXRManager);
|
||||
mXrEnvironment.setSession(new MWVR::VRSession());
|
||||
mXrEnvironment.setViewer(new MWVR::VRViewer(mViewer));
|
||||
|
|
|
@ -720,6 +720,8 @@ namespace Misc
|
|||
else
|
||||
{
|
||||
mMainCamera->setCullMask(cullMask);
|
||||
mMainCamera->setCullMaskLeft(cullMask);
|
||||
mMainCamera->setCullMaskRight(cullMask);
|
||||
}
|
||||
}
|
||||
osg::Node::NodeMask StereoView::getCullMask()
|
||||
|
|
Loading…
Reference in a new issue