Remove drawOnHUD from 3d overlays

This commit is contained in:
Zach Pomerantz 2016-02-15 14:00:23 -08:00
parent 8c01d5f82b
commit 0d29f59e39
4 changed files with 14 additions and 52 deletions

View file

@ -26,8 +26,7 @@ Base3DOverlay::Base3DOverlay() :
_isSolid(DEFAULT_IS_SOLID), _isSolid(DEFAULT_IS_SOLID),
_isDashedLine(DEFAULT_IS_DASHED_LINE), _isDashedLine(DEFAULT_IS_DASHED_LINE),
_ignoreRayIntersection(false), _ignoreRayIntersection(false),
_drawInFront(false), _drawInFront(false)
_drawOnHUD(false)
{ {
} }
@ -38,8 +37,7 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
_isSolid(base3DOverlay->_isSolid), _isSolid(base3DOverlay->_isSolid),
_isDashedLine(base3DOverlay->_isDashedLine), _isDashedLine(base3DOverlay->_isDashedLine),
_ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection), _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection),
_drawInFront(base3DOverlay->_drawInFront), _drawInFront(base3DOverlay->_drawInFront)
_drawOnHUD(base3DOverlay->_drawOnHUD)
{ {
} }
@ -53,13 +51,6 @@ void Base3DOverlay::setProperties(const QScriptValue& properties) {
setDrawInFront(value); setDrawInFront(value);
} }
QScriptValue drawOnHUD = properties.property("drawOnHUD");
if (drawOnHUD.isValid()) {
bool value = drawOnHUD.toVariant().toBool();
setDrawOnHUD(value);
}
QScriptValue position = properties.property("position"); QScriptValue position = properties.property("position");
// if "position" property was not there, check to see if they included aliases: point, p1 // if "position" property was not there, check to see if they included aliases: point, p1
@ -163,9 +154,6 @@ QScriptValue Base3DOverlay::getProperty(const QString& property) {
if (property == "drawInFront") { if (property == "drawInFront") {
return _drawInFront; return _drawInFront;
} }
if (property == "drawOnHUD") {
return _drawOnHUD;
}
return Overlay::getProperty(property); return Overlay::getProperty(property);
} }

View file

@ -37,7 +37,6 @@ public:
bool getIsSolidLine() const { return !_isDashedLine; } bool getIsSolidLine() const { return !_isDashedLine; }
bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; } bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; }
bool getDrawInFront() const { return _drawInFront; } bool getDrawInFront() const { return _drawInFront; }
bool getDrawOnHUD() const { return _drawOnHUD; }
// setters // setters
void setPosition(const glm::vec3& value) { _transform.setTranslation(value); } void setPosition(const glm::vec3& value) { _transform.setTranslation(value); }
@ -50,7 +49,6 @@ public:
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; } void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; } void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
void setDrawInFront(bool value) { _drawInFront = value; } void setDrawInFront(bool value) { _drawInFront = value; }
void setDrawOnHUD(bool value) { _drawOnHUD = value; }
virtual AABox getBounds() const = 0; virtual AABox getBounds() const = 0;
@ -73,7 +71,6 @@ protected:
bool _isDashedLine; bool _isDashedLine;
bool _ignoreRayIntersection; bool _ignoreRayIntersection;
bool _drawInFront; bool _drawInFront;
bool _drawOnHUD;
}; };
#endif // hifi_Base3DOverlay_h #endif // hifi_Base3DOverlay_h

View file

@ -200,17 +200,12 @@ unsigned int Overlays::addOverlay(Overlay::Pointer overlay) {
unsigned int thisID = _nextOverlayID; unsigned int thisID = _nextOverlayID;
_nextOverlayID++; _nextOverlayID++;
if (overlay->is3D()) { if (overlay->is3D()) {
auto overlay3D = std::static_pointer_cast<Base3DOverlay>(overlay);
if (overlay3D->getDrawOnHUD()) {
_overlaysHUD[thisID] = overlay;
} else {
_overlaysWorld[thisID] = overlay; _overlaysWorld[thisID] = overlay;
render::ScenePointer scene = qApp->getMain3DScene(); render::ScenePointer scene = qApp->getMain3DScene();
render::PendingChanges pendingChanges; render::PendingChanges pendingChanges;
overlay->addToScene(overlay, scene, pendingChanges); overlay->addToScene(overlay, scene, pendingChanges);
scene->enqueuePendingChanges(pendingChanges); scene->enqueuePendingChanges(pendingChanges);
}
} else { } else {
_overlaysHUD[thisID] = overlay; _overlaysHUD[thisID] = overlay;
} }
@ -239,38 +234,20 @@ bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
Overlay::Pointer thisOverlay = getOverlay(id); Overlay::Pointer thisOverlay = getOverlay(id);
if (thisOverlay) { if (thisOverlay) {
if (thisOverlay->is3D()) { if (thisOverlay->is3D()) {
auto overlay3D = std::static_pointer_cast<Base3DOverlay>(thisOverlay);
bool oldDrawOnHUD = overlay3D->getDrawOnHUD();
render::ItemKey oldItemKey = render::payloadGetKey(thisOverlay); render::ItemKey oldItemKey = render::payloadGetKey(thisOverlay);
thisOverlay->setProperties(properties); thisOverlay->setProperties(properties);
render::ItemKey itemKey = render::payloadGetKey(thisOverlay);
if (itemKey != oldItemKey) {
auto itemID = thisOverlay->getRenderItemID();
if (itemID != render::Item::INVALID_ITEM_ID) {
render::ScenePointer scene = qApp->getMain3DScene(); render::ScenePointer scene = qApp->getMain3DScene();
render::PendingChanges pendingChanges; render::PendingChanges pendingChanges;
auto itemID = thisOverlay->getRenderItemID();
bool drawOnHUD = overlay3D->getDrawOnHUD();
render::ItemKey itemKey = render::payloadGetKey(thisOverlay);
if (drawOnHUD != oldDrawOnHUD) {
if (drawOnHUD) {
_overlaysWorld.remove(id);
_overlaysHUD[id] = thisOverlay;
if (itemID != render::Item::INVALID_ITEM_ID) {
thisOverlay->removeFromScene(thisOverlay, scene, pendingChanges);
}
} else {
_overlaysHUD.remove(id);
_overlaysWorld[id] = thisOverlay;
thisOverlay->addToScene(thisOverlay, scene, pendingChanges);
}
} else if (itemKey != oldItemKey && !drawOnHUD) {
if (itemID != render::Item::INVALID_ITEM_ID) {
pendingChanges.resortItem(itemID, oldItemKey, itemKey); pendingChanges.resortItem(itemID, oldItemKey, itemKey);
}
}
scene->enqueuePendingChanges(pendingChanges); scene->enqueuePendingChanges(pendingChanges);
}
}
} else { } else {
thisOverlay->setProperties(properties); thisOverlay->setProperties(properties);
} }

View file

@ -36,8 +36,8 @@
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) { template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) {
auto builder = ItemKey::Builder().withTypeShape(); auto builder = ItemKey::Builder().withTypeShape();
if (overlay->is3D() && !std::dynamic_pointer_cast<Base3DOverlay>(overlay)->getDrawOnHUD()) { if (overlay->is3D()) {
if (std::dynamic_pointer_cast<Base3DOverlay>(overlay)->getDrawInFront()) { if (std::static_pointer_cast<Base3DOverlay>(overlay)->getDrawInFront()) {
builder.withLayered(); builder.withLayered();
} }
if (overlay->getAlphaPulse() != 0.0f || overlay->getAlpha() != 1.0f) { if (overlay->getAlphaPulse() != 0.0f || overlay->getAlpha() != 1.0f) {