diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index f4e0c9769d..e54ee613ff 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -177,8 +177,10 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) { } glPushMatrix(); { + const float NEAR_CLIP = -10000; + const float FAR_CLIP = 10000; glLoadIdentity(); - gluOrtho2D(0, glWidget->width(), glWidget->height(), 0); + glOrtho(0, glWidget->width(), glWidget->height(), 0, NEAR_CLIP, FAR_CLIP); renderAudioMeter(); @@ -1081,7 +1083,7 @@ void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() { delete _framebufferObject; } - _framebufferObject = new QOpenGLFramebufferObject(size); + _framebufferObject = new QOpenGLFramebufferObject(size, QOpenGLFramebufferObject::Depth); bindTexture(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp index a9588cd7a3..7e5bb543d6 100644 --- a/interface/src/ui/overlays/Base3DOverlay.cpp +++ b/interface/src/ui/overlays/Base3DOverlay.cpp @@ -28,7 +28,8 @@ Base3DOverlay::Base3DOverlay() : _isSolid(DEFAULT_IS_SOLID), _isDashedLine(DEFAULT_IS_DASHED_LINE), _ignoreRayIntersection(false), - _drawInFront(false) + _drawInFront(false), + _drawOnApplicationOverlay(false) { } @@ -162,6 +163,9 @@ QScriptValue Base3DOverlay::getProperty(const QString& property) { if (property == "drawInFront") { return _drawInFront; } + if (property == "drawOnApplicationOverlay") { + return _drawOnApplicationOverlay; + } return Overlay::getProperty(property); } diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index b5314bd6d3..b3e3c3df8a 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -37,6 +37,7 @@ public: const glm::quat& getRotation() const { return _rotation; } bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; } bool getDrawInFront() const { return _drawInFront; } + bool getDrawOnApplicationOverlay() const { return _drawOnApplicationOverlay; } // setters void setPosition(const glm::vec3& position) { _position = position; } @@ -46,6 +47,7 @@ public: void setRotation(const glm::quat& value) { _rotation = value; } void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; } void setDrawInFront(bool value) { _drawInFront = value; } + void setDrawOnApplicationOverlay(bool value) { _drawOnApplicationOverlay = value; } virtual void setProperties(const QScriptValue& properties); virtual QScriptValue getProperty(const QString& property); @@ -67,6 +69,7 @@ protected: bool _isDashedLine; bool _ignoreRayIntersection; bool _drawInFront; + bool _drawOnApplicationOverlay; }; #endif // hifi_Base3DOverlay_h diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index ace4ecf353..5871f408da 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -92,6 +92,17 @@ void Overlays::render2D() { foreach(Overlay* thisOverlay, _overlays2D) { thisOverlay->render(&args); } + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + foreach(Overlay* thisOverlay, _overlays3D) { + Base3DOverlay* overlay3D = static_cast(thisOverlay); + if (overlay3D->getDrawOnApplicationOverlay()) { + thisOverlay->render(&args); + } + } + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); } void Overlays::render3D(bool drawFront, RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) { @@ -114,7 +125,7 @@ void Overlays::render3D(bool drawFront, RenderArgs::RenderMode renderMode, Rende foreach(Overlay* thisOverlay, _overlays3D) { Base3DOverlay* overlay3D = static_cast(thisOverlay); - if (overlay3D->getDrawInFront() != drawFront) { + if (overlay3D->getDrawInFront() != drawFront || overlay3D->getDrawOnApplicationOverlay()) { continue; } glPushMatrix(); @@ -251,7 +262,27 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) { } QReadLocker lock(&_lock); - QMapIterator i(_overlays2D); + QMapIterator i(_overlays3D); + i.toBack(); + + const float LARGE_NEGATIVE_FLOAT = -9999999; + glm::vec3 origin(pointCopy.x, pointCopy.y, LARGE_NEGATIVE_FLOAT); + glm::vec3 direction(0, 0, 1); + BoxFace thisFace; + float distance; + + while (i.hasPrevious()) { + i.previous(); + unsigned int thisID = i.key(); + Base3DOverlay* thisOverlay = static_cast(i.value()); + if (thisOverlay->getDrawOnApplicationOverlay() && !thisOverlay->getIgnoreRayIntersection()) { + if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace)) { + return thisID; + } + } + } + + i = QMapIterator(_overlays2D); i.toBack(); while (i.hasPrevious()) { i.previous(); @@ -262,6 +293,7 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) { return thisID; } } + return 0; // not found } @@ -320,6 +352,9 @@ RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray) i.previous(); unsigned int thisID = i.key(); Base3DOverlay* thisOverlay = static_cast(i.value()); + if (thisOverlay->getDrawOnApplicationOverlay()) { + continue; + } if (thisOverlay->getVisible() && !thisOverlay->getIgnoreRayIntersection() && thisOverlay->isLoaded()) { float thisDistance; BoxFace thisFace;