can edit drawHUDLayer property

This commit is contained in:
SamGondelman 2017-07-25 12:57:52 -07:00
parent 3149c3e16c
commit 0117950546
5 changed files with 35 additions and 2 deletions

View file

@ -13,6 +13,8 @@
#include <NumericalConstants.h>
#include <RegisteredMetaTypes.h>
#include "Application.h"
static const xColor DEFAULT_OVERLAY_COLOR = { 255, 255, 255 };
static const float DEFAULT_ALPHA = 0.7f;
@ -168,6 +170,12 @@ float Overlay::getAlpha() {
return (_alphaPulse >= 0.0f) ? _alpha * pulseLevel : _alpha * (1.0f - pulseLevel);
}
void Overlay::setDrawHUDLayer(bool drawHUDLayer) {
if (drawHUDLayer != _drawHUDLayer) {
qApp->getOverlays().setOverlayDrawHUDLayer(getOverlayID(), drawHUDLayer);
_drawHUDLayer = drawHUDLayer;
}
}
// pulse travels from min to max, then max to min in one period.
float Overlay::updatePulse() {

View file

@ -73,7 +73,7 @@ public:
// setters
void setVisible(bool visible) { _visible = visible; }
void setDrawHUDLayer(bool drawHUDLayer) { _drawHUDLayer = drawHUDLayer; }
void setDrawHUDLayer(bool drawHUDLayer);
void setColor(const xColor& color) { _color = color; }
void setAlpha(float alpha) { _alpha = alpha; }
void setAnchor(Anchor anchor) { _anchor = anchor; }

View file

@ -253,6 +253,28 @@ OverlayID Overlays::addOverlay(const Overlay::Pointer& overlay) {
return thisID;
}
void Overlays::setOverlayDrawHUDLayer(const OverlayID& id, const bool drawHUDLayer) {
QMutexLocker locker(&_mutex);
if (drawHUDLayer && _overlaysWorld.contains(id)) {
std::shared_ptr<Overlay> overlay = _overlaysWorld.take(id);
render::ScenePointer scene = qApp->getMain3DScene();
render::Transaction transaction;
auto itemID = overlay->getRenderItemID();
if (render::Item::isValidID(itemID)) {
overlay->removeFromScene(overlay, scene, transaction);
scene->enqueueTransaction(transaction);
}
_overlays3DHUD[id] = overlay;
} else if (!drawHUDLayer && _overlays3DHUD.contains(id)) {
std::shared_ptr<Overlay> overlay = _overlays3DHUD.take(id);
render::ScenePointer scene = qApp->getMain3DScene();
render::Transaction transaction;
overlay->addToScene(overlay, scene, transaction);
scene->enqueueTransaction(transaction);
_overlaysWorld[id] = overlay;
}
}
OverlayID Overlays::cloneOverlay(OverlayID id) {
if (QThread::currentThread() != thread()) {
OverlayID result;

View file

@ -103,6 +103,8 @@ public:
OverlayID addOverlay(Overlay* overlay) { return addOverlay(Overlay::Pointer(overlay)); }
OverlayID addOverlay(const Overlay::Pointer& overlay);
void setOverlayDrawHUDLayer(const OverlayID& id, const bool drawHUDLayer);
bool mousePressEvent(QMouseEvent* event);
bool mouseDoublePressEvent(QMouseEvent* event);
bool mouseReleaseEvent(QMouseEvent* event);

View file

@ -641,7 +641,8 @@ void OpenGLDisplayPlugin::compositeLayers() {
compositePointer();
}
{
// Only render HUD layer 3D overlays in HMD mode
if (isHmd()) {
PROFILE_RANGE_EX(render_detail, "compositeHUDOverlays", 0xff0077ff, (uint64_t)presentCount())
render([&](gpu::Batch& batch) {
batch.enableStereo(false);