From 64d586929c6ebd3f4ab6fd0e787f2a35685bc6fb Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sun, 31 May 2020 11:57:08 +0200 Subject: [PATCH] Fixed false staticness of VRGUILayer by editing camera ortography rather than texture coordinates. --- apps/openmw/mwvr/vranimation.cpp | 1 + apps/openmw/mwvr/vrgui.cpp | 15 +++++++++------ apps/openmw/mwvr/vrviewer.hpp | 2 -- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwvr/vranimation.cpp b/apps/openmw/mwvr/vranimation.cpp index fe5c475c0..cf5a6e281 100644 --- a/apps/openmw/mwvr/vranimation.cpp +++ b/apps/openmw/mwvr/vranimation.cpp @@ -612,6 +612,7 @@ osg::ref_ptr VRAnimation::createPointerGeometry(void) geometry->setVertexArray(vertexArray); geometry->setColorArray(colorArray, osg::Array::BIND_PER_VERTEX); geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, numVertices)); + geometry->setSupportsDisplayList(false); geometry->setDataVariance(osg::Object::STATIC); auto stateset = geometry->getOrCreateStateSet(); diff --git a/apps/openmw/mwvr/vrgui.cpp b/apps/openmw/mwvr/vrgui.cpp index 34c0e8d5a..b14a2bd12 100644 --- a/apps/openmw/mwvr/vrgui.cpp +++ b/apps/openmw/mwvr/vrgui.cpp @@ -173,6 +173,7 @@ VRGUILayer::VRGUILayer( mGeometry->setNormalArray(normals, osg::Array::BIND_OVERALL); mGeometry->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4)); mGeometry->setDataVariance(osg::Object::STATIC); + mGeometry->setSupportsDisplayList(false); mGeometry->setName("VRGUILayer"); // Create the camera that will render the menu texture @@ -369,12 +370,14 @@ void VRGUILayer::update() mTransform->setScale(osg::Vec3(w / res, 1.f, h / res)); } - osg::ref_ptr texCoords{ new osg::Vec2Array(4) }; - (*texCoords)[0].set(mRealRect.left, 1.f - mRealRect.top); - (*texCoords)[1].set(mRealRect.left, 1.f - mRealRect.bottom); - (*texCoords)[2].set(mRealRect.right, 1.f - mRealRect.bottom); - (*texCoords)[3].set(mRealRect.right, 1.f - mRealRect.top); - mGeometry->setTexCoordArray(0, texCoords); + // Convert from [0,1] range to [-1,1] + float menuLeft = mRealRect.left * 2. - 1.; + float menuRight = mRealRect.right * 2. - 1.; + // Opposite convention + float menuBottom = (1.f - mRealRect.bottom) * 2. - 1.; + float menuTop = (1.f - mRealRect.top) * 2.f - 1.; + + mMyGUICamera->setProjectionMatrixAsOrtho2D(menuLeft, menuRight, menuBottom, menuTop); } void diff --git a/apps/openmw/mwvr/vrviewer.hpp b/apps/openmw/mwvr/vrviewer.hpp index 1299c829b..fab101fb4 100644 --- a/apps/openmw/mwvr/vrviewer.hpp +++ b/apps/openmw/mwvr/vrviewer.hpp @@ -71,8 +71,6 @@ namespace MWVR ~VRViewer(void); - //virtual void traverse(osg::NodeVisitor& visitor) override; - const XrCompositionLayerBaseHeader* layer(); void traversals();