diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp index ff5a202910..f4efd1301d 100644 --- a/interface/src/ui/overlays/Base3DOverlay.cpp +++ b/interface/src/ui/overlays/Base3DOverlay.cpp @@ -37,7 +37,8 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) : _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection), _drawInFront(base3DOverlay->_drawInFront), _drawHUDLayer(base3DOverlay->_drawHUDLayer), - _isGrabbable(base3DOverlay->_isGrabbable) + _isGrabbable(base3DOverlay->_isGrabbable), + _isVisibleInSecondaryCamera(base3DOverlay->_isVisibleInSecondaryCamera) { setTransform(base3DOverlay->getTransform()); } @@ -142,6 +143,13 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) { setIsGrabbable(isGrabbable.toBool()); } + auto isVisibleInSecondaryCamera = properties["isVisibleInSecondaryCamera"]; + if (isVisibleInSecondaryCamera.isValid()) { + bool value = isVisibleInSecondaryCamera.toBool(); + setIsVisibleInSecondaryCamera(value); + needRenderItemUpdate = true; + } + if (properties["position"].isValid()) { setLocalPosition(vec3FromVariant(properties["position"])); needRenderItemUpdate = true; @@ -221,6 +229,8 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) { * @property {boolean} drawInFront=false - If true, the overlay is rendered in front of other overlays that don't * have drawInFront set to true, and in front of entities. * @property {boolean} grabbable=false - Signal to grabbing scripts whether or not this overlay can be grabbed. + * @property {boolean} isVisibleInSecondaryCamera=false - If true, the overlay is rendered in secondary + * camera views. * @property {Uuid} parentID=null - The avatar, entity, or overlay that the overlay is parented to. * @property {number} parentJointIndex=65535 - Integer value specifying the skeleton joint that the overlay is attached to if * parentID is an avatar skeleton. A value of 65535 means "no joint". @@ -259,6 +269,9 @@ QVariant Base3DOverlay::getProperty(const QString& property) { if (property == "grabbable") { return _isGrabbable; } + if (property == "isVisibleInSecondaryCamera") { + return _isVisibleInSecondaryCamera; + } if (property == "parentID") { return getParentID(); } diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index bbf064fddd..ab83a64273 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -48,6 +48,7 @@ public: bool getDrawInFront() const { return _drawInFront; } bool getDrawHUDLayer() const { return _drawHUDLayer; } bool getIsGrabbable() const { return _isGrabbable; } + virtual bool getIsVisibleInSecondaryCamera() const override { return _isVisibleInSecondaryCamera; } void setIsSolid(bool isSolid) { _isSolid = isSolid; } void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; } @@ -55,6 +56,7 @@ public: virtual void setDrawInFront(bool value) { _drawInFront = value; } virtual void setDrawHUDLayer(bool value) { _drawHUDLayer = value; } void setIsGrabbable(bool value) { _isGrabbable = value; } + virtual void setIsVisibleInSecondaryCamera(bool value) { _isVisibleInSecondaryCamera = value; } virtual AABox getBounds() const override = 0; @@ -92,6 +94,7 @@ protected: bool _drawInFront; bool _drawHUDLayer; bool _isGrabbable { false }; + bool _isVisibleInSecondaryCamera { false }; mutable bool _renderVariableDirty { true }; QString _name; diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index 651213ae99..1c00f57eec 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -89,8 +89,11 @@ void ModelOverlay::update(float deltatime) { } if (_visibleDirty) { _visibleDirty = false; - // don't show overlays in mirrors - _model->setVisibleInScene(getVisible(), scene, render::ItemKey::TAG_BITS_0, false); + // don't show overlays in mirrors or spectator-cam unless _isVisibleInSecondaryCamera is true + _model->setVisibleInScene(getVisible(), scene, + render::ItemKey::TAG_BITS_0 | + (_isVisibleInSecondaryCamera ? render::ItemKey::TAG_BITS_1 : render::ItemKey::TAG_BITS_NONE), + false); } if (_drawInFrontDirty) { _drawInFrontDirty = false; diff --git a/interface/src/ui/overlays/ModelOverlay.h b/interface/src/ui/overlays/ModelOverlay.h index 88a1729d68..3ef3f23fec 100644 --- a/interface/src/ui/overlays/ModelOverlay.h +++ b/interface/src/ui/overlays/ModelOverlay.h @@ -36,6 +36,11 @@ public: void clearSubRenderItemIDs(); void setSubRenderItemIDs(const render::ItemIDs& ids); + virtual void setIsVisibleInSecondaryCamera(bool value) override { + Base3DOverlay::setIsVisibleInSecondaryCamera(value); + _visibleDirty = true; + } + void setProperties(const QVariantMap& properties) override; QVariant getProperty(const QString& property) override; virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, diff --git a/interface/src/ui/overlays/Overlay.h b/interface/src/ui/overlays/Overlay.h index f1be23ed39..2f27d50f7e 100644 --- a/interface/src/ui/overlays/Overlay.h +++ b/interface/src/ui/overlays/Overlay.h @@ -56,6 +56,8 @@ public: bool isLoaded() { return _isLoaded; } bool getVisible() const { return _visible; } virtual bool isTransparent() { return getAlphaPulse() != 0.0f || getAlpha() != 1.0f; }; + virtual bool getIsVisibleInSecondaryCamera() const { return false; } + xColor getColor(); float getAlpha(); diff --git a/interface/src/ui/overlays/OverlaysPayload.cpp b/interface/src/ui/overlays/OverlaysPayload.cpp index f99ced0021..185547a333 100644 --- a/interface/src/ui/overlays/OverlaysPayload.cpp +++ b/interface/src/ui/overlays/OverlaysPayload.cpp @@ -49,7 +49,11 @@ namespace render { builder.withInvisible(); } - builder.withTagBits(render::ItemKey::TAG_BITS_0); // Only draw overlays in main view + // always visible in primary view. if isVisibleInSecondaryCamera, also draw in secondary view + uint32_t viewTaskBits = render::ItemKey::TAG_BITS_0 | + (overlay->getIsVisibleInSecondaryCamera() ? render::ItemKey::TAG_BITS_1 : render::ItemKey::TAG_BITS_NONE); + + builder.withTagBits(viewTaskBits); return builder.build(); } diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index b3ca300022..32dbe0a43b 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -9,7 +9,8 @@ // /* global Tablet, Script, HMD, UserActivityLogger, Entities, Account, Wallet, ContextOverlay, Settings, Camera, Vec3, - Quat, MyAvatar, Clipboard, Menu, Grid, Uuid, GlobalServices, openLoginWindow */ + Quat, MyAvatar, Clipboard, Menu, Grid, Uuid, GlobalServices, openLoginWindow, Overlays, SoundCache, + DesktopPreviewProvider */ /* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ var selectionDisplay = null; // for gridTool.js to ignore @@ -116,6 +117,24 @@ var selectionDisplay = null; // for gridTool.js to ignore var onWalletScreen = false; var onCommerceScreen = false; + var tabletShouldBeVisibleInSecondaryCamera = false; + + function setTabletVisibleInSecondaryCamera(visibleInSecondaryCam) { + if (visibleInSecondaryCam) { + // if we're potentially showing the tablet, only do so if it was visible before + if (!tabletShouldBeVisibleInSecondaryCamera) { + return; + } + } else { + // if we're hiding the tablet, check to see if it was visible in the first place + tabletShouldBeVisibleInSecondaryCamera = Overlays.getProperty(HMD.tabletID, "isVisibleInSecondaryCamera"); + } + + Overlays.editOverlay(HMD.tabletID, { isVisibleInSecondaryCamera : visibleInSecondaryCam }); + Overlays.editOverlay(HMD.homeButtonID, { isVisibleInSecondaryCamera : visibleInSecondaryCam }); + Overlays.editOverlay(HMD.homeButtonHighlightIDtabletID, { isVisibleInSecondaryCamera : visibleInSecondaryCam }); + Overlays.editOverlay(HMD.tabletScreenID, { isVisibleInSecondaryCamera : visibleInSecondaryCam }); + } function onScreenChanged(type, url) { onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1; @@ -127,6 +146,7 @@ var selectionDisplay = null; // for gridTool.js to ignore if (isHmdPreviewDisabledBySecurity) { DesktopPreviewProvider.setPreviewDisabledReason("USER"); Menu.setIsOptionChecked("Disable Preview", false); + setTabletVisibleInSecondaryCamera(true); isHmdPreviewDisabledBySecurity = false; } } @@ -245,7 +265,7 @@ var selectionDisplay = null; // for gridTool.js to ignore var wearableDimensions = null; if (itemType === "contentSet") { - console.log("Item is a content set; codepath shouldn't go here.") + console.log("Item is a content set; codepath shouldn't go here."); return; } @@ -575,6 +595,7 @@ var selectionDisplay = null; // for gridTool.js to ignore if (!isHmdPreviewDisabled) { DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN"); Menu.setIsOptionChecked("Disable Preview", true); + setTabletVisibleInSecondaryCamera(false); isHmdPreviewDisabledBySecurity = true; } break; @@ -582,6 +603,7 @@ var selectionDisplay = null; // for gridTool.js to ignore if (isHmdPreviewDisabledBySecurity) { DesktopPreviewProvider.setPreviewDisabledReason("USER"); Menu.setIsOptionChecked("Disable Preview", false); + setTabletVisibleInSecondaryCamera(true); isHmdPreviewDisabledBySecurity = false; } break;