change gui render order based on vr vs non-vr

pull/615/head
Mads Buvik Sandvei 5 years ago
parent 47ce69899d
commit 6296f9f124

@ -563,7 +563,13 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem.get(), mWorkQueue.get(),
mCfgMgr.getLogPath().string() + std::string("/"), myguiResources,
mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts,
Version::getOpenmwVersionDescription(mResDir.string()), mCfgMgr.getUserConfigPath().string());
Version::getOpenmwVersionDescription(mResDir.string()), mCfgMgr.getUserConfigPath().string(),
#ifdef USE_OPENXR
true
#else
false
#endif
);
mEnvironment.setWindowManager (window);
// Create sound system

@ -134,8 +134,9 @@ namespace MWGui
WindowManager::WindowManager(
osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& userDataPath)
ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& userDataPath, bool VRMode)
: mStore(nullptr)
, mVRMode(VRMode)
, mResourceSystem(resourceSystem)
, mWorkQueue(workQueue)
, mViewer(viewer)
@ -202,7 +203,7 @@ namespace MWGui
, mVersionDescription(versionDescription)
{
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
mGuiPlatform = new osgMyGUI::Platform(viewer, guiRoot, resourceSystem->getImageManager(), uiScale);
mGuiPlatform = new osgMyGUI::Platform(viewer, guiRoot, resourceSystem->getImageManager(), uiScale, mVRMode);
mGuiPlatform->initialise(resourcePath, logpath);
mGui = new MyGUI::Gui;

@ -132,7 +132,7 @@ namespace MWGui
WindowManager(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& localPath);
ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& localPath, bool VRMode);
virtual ~WindowManager();
/// Set the ESMStore to use for retrieving of GUI-related strings.
@ -393,6 +393,7 @@ namespace MWGui
private:
const MWWorld::ESMStore* mStore;
bool mVRMode;
Resource::ResourceSystem* mResourceSystem;
osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;

@ -143,7 +143,7 @@ void StateMachine::update(float dt, bool enabled)
// Next determine current hand movement
// If tracking is lost, openxr will return a position of 0
// Reset position when tracking is re-acquired
// So i reset position when tracking is re-acquired to avoid a superspeed strike.
// Theoretically, the player's hand really could be at 0,0,0
// but that's a super rare case so whatever.
if (previousPosition == osg::Vec3(0.f, 0.f, 0.f))

@ -7,14 +7,15 @@
namespace osgMyGUI
{
Platform::Platform(osgViewer::Viewer *viewer, osg::Group *guiRoot, Resource::ImageManager *imageManager, float uiScalingFactor)
Platform::Platform(osgViewer::Viewer *viewer, osg::Group *guiRoot, Resource::ImageManager *imageManager, float uiScalingFactor, bool VRMode)
: mRenderManager(nullptr)
, mDataManager(nullptr)
, mLogManager(nullptr)
, mLogFacility(nullptr)
, mVRMode(VRMode)
{
mLogManager = new MyGUI::LogManager();
mRenderManager = new RenderManager(viewer, guiRoot, imageManager, uiScalingFactor);
mRenderManager = new RenderManager(viewer, guiRoot, imageManager, uiScalingFactor, VRMode);
mDataManager = new DataManager();
}

@ -30,7 +30,7 @@ namespace osgMyGUI
class Platform
{
public:
Platform(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ImageManager* imageManager, float uiScalingFactor);
Platform(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ImageManager* imageManager, float uiScalingFactor, bool VRMode);
~Platform();
@ -47,6 +47,7 @@ namespace osgMyGUI
DataManager* mDataManager;
MyGUI::LogManager* mLogManager;
LogFacility* mLogFacility;
bool mVRMode;
void operator=(const Platform&);
Platform(const Platform&);

@ -2,6 +2,9 @@
#include <MyGUI_Gui.h>
#include <MyGUI_Timer.h>
#include <MyGUI_LayerManager.h>
#include <MyGUI_LayerNode.h>
#include <MyGUI_Enumerator.h>
#include <osg/Drawable>
#include <osg/BlendFunc>
@ -346,7 +349,7 @@ osg::VertexBufferObject* OSGVertexBuffer::getVertexBuffer()
// ---------------------------------------------------------------------------
RenderManager::RenderManager(osgViewer::Viewer *viewer, osg::Group *sceneroot, Resource::ImageManager* imageManager, float scalingFactor)
RenderManager::RenderManager(osgViewer::Viewer *viewer, osg::Group *sceneroot, Resource::ImageManager* imageManager, float scalingFactor, bool VRMode)
: mViewer(viewer)
, mSceneRoot(sceneroot)
, mImageManager(imageManager)
@ -354,6 +357,7 @@ RenderManager::RenderManager(osgViewer::Viewer *viewer, osg::Group *sceneroot, R
, mIsInitialise(false)
, mInvScalingFactor(1.f)
, mInjectState(nullptr)
, mVRMode(VRMode)
{
if (scalingFactor != 0.f)
mInvScalingFactor = 1.f / scalingFactor;
@ -393,7 +397,7 @@ void RenderManager::initialise()
camera->setProjectionResizePolicy(osg::Camera::FIXED);
camera->setProjectionMatrix(osg::Matrix::identity());
camera->setViewMatrix(osg::Matrix::identity());
camera->setRenderOrder(osg::Camera::NESTED_RENDER);
camera->setRenderOrder(mVRMode ? osg::Camera::NESTED_RENDER : osg::Camera::POST_RENDER);
camera->setClearMask(GL_NONE);
mDrawable->setCullingActive(false);
camera->addChild(mDrawable.get());
@ -452,6 +456,19 @@ void RenderManager::doRender(MyGUI::IVertexBuffer *buffer, MyGUI::ITexture *text
mDrawable->addBatch(batch);
}
void RenderManager::onRenderToTarget(IRenderTarget* _target, bool _update)
{
MyGUI::LayerManager* layers = MyGUI::LayerManager::getInstancePtr();
if (layers != nullptr)
{
for (unsigned i = 0; i < layers->getLayerCount(); i++)
{
auto layer = layers->getLayer(i);
layer->renderToTarget(_target, _update);
}
}
}
void RenderManager::setInjectState(osg::StateSet* stateSet)
{
mInjectState = stateSet;

@ -51,10 +51,12 @@ class RenderManager : public MyGUI::RenderManager, public MyGUI::IRenderTarget
osg::StateSet* mInjectState;
bool mVRMode;
void destroyAllResources();
public:
RenderManager(osgViewer::Viewer *viewer, osg::Group *sceneroot, Resource::ImageManager* imageManager, float scalingFactor);
RenderManager(osgViewer::Viewer *viewer, osg::Group *sceneroot, Resource::ImageManager* imageManager, float scalingFactor, bool VRMode);
virtual ~RenderManager();
void initialise();
@ -96,7 +98,10 @@ public:
/** @see IRenderTarget::end */
virtual void end();
/** @see IRenderTarget::doRender */
virtual void doRender(MyGUI::IVertexBuffer *buffer, MyGUI::ITexture *texture, size_t count);
void doRender(MyGUI::IVertexBuffer *buffer, MyGUI::ITexture *texture, size_t count) override;
/** @see IRenderTarget::onRenderToTarget */
void onRenderToTarget(IRenderTarget* _target, bool _update) override;
/** specify a StateSet to inject for rendering. The StateSet will be used by future doRender calls until you reset it to nullptr again. */
void setInjectState(osg::StateSet* stateSet);

Loading…
Cancel
Save