Merge pull request #12634 from sethalves/overlay-visible-in-2nd-cam

Overlays visible in 2nd cam
This commit is contained in:
Brad Hefta-Gaub 2018-03-16 10:07:26 -07:00 committed by GitHub
commit 634e642db3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 6 deletions

View file

@ -37,7 +37,8 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
_ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection), _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection),
_drawInFront(base3DOverlay->_drawInFront), _drawInFront(base3DOverlay->_drawInFront),
_drawHUDLayer(base3DOverlay->_drawHUDLayer), _drawHUDLayer(base3DOverlay->_drawHUDLayer),
_isGrabbable(base3DOverlay->_isGrabbable) _isGrabbable(base3DOverlay->_isGrabbable),
_isVisibleInSecondaryCamera(base3DOverlay->_isVisibleInSecondaryCamera)
{ {
setTransform(base3DOverlay->getTransform()); setTransform(base3DOverlay->getTransform());
} }
@ -142,6 +143,13 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
setIsGrabbable(isGrabbable.toBool()); setIsGrabbable(isGrabbable.toBool());
} }
auto isVisibleInSecondaryCamera = properties["isVisibleInSecondaryCamera"];
if (isVisibleInSecondaryCamera.isValid()) {
bool value = isVisibleInSecondaryCamera.toBool();
setIsVisibleInSecondaryCamera(value);
needRenderItemUpdate = true;
}
if (properties["position"].isValid()) { if (properties["position"].isValid()) {
setLocalPosition(vec3FromVariant(properties["position"])); setLocalPosition(vec3FromVariant(properties["position"]));
needRenderItemUpdate = true; needRenderItemUpdate = true;
@ -221,6 +229,8 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
* @property {boolean} drawInFront=false - If <code>true</code>, the overlay is rendered in front of other overlays that don't * @property {boolean} drawInFront=false - If <code>true</code>, the overlay is rendered in front of other overlays that don't
* have <code>drawInFront</code> set to <code>true</code>, and in front of entities. * have <code>drawInFront</code> set to <code>true</code>, and in front of entities.
* @property {boolean} grabbable=false - Signal to grabbing scripts whether or not this overlay can be grabbed. * @property {boolean} grabbable=false - Signal to grabbing scripts whether or not this overlay can be grabbed.
* @property {boolean} isVisibleInSecondaryCamera=false - If <code>true</code>, the overlay is rendered in secondary
* camera views.
* @property {Uuid} parentID=null - The avatar, entity, or overlay that the overlay is parented to. * @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 * @property {number} parentJointIndex=65535 - Integer value specifying the skeleton joint that the overlay is attached to if
* <code>parentID</code> is an avatar skeleton. A value of <code>65535</code> means "no joint". * <code>parentID</code> is an avatar skeleton. A value of <code>65535</code> means "no joint".
@ -259,6 +269,9 @@ QVariant Base3DOverlay::getProperty(const QString& property) {
if (property == "grabbable") { if (property == "grabbable") {
return _isGrabbable; return _isGrabbable;
} }
if (property == "isVisibleInSecondaryCamera") {
return _isVisibleInSecondaryCamera;
}
if (property == "parentID") { if (property == "parentID") {
return getParentID(); return getParentID();
} }

View file

@ -48,6 +48,7 @@ public:
bool getDrawInFront() const { return _drawInFront; } bool getDrawInFront() const { return _drawInFront; }
bool getDrawHUDLayer() const { return _drawHUDLayer; } bool getDrawHUDLayer() const { return _drawHUDLayer; }
bool getIsGrabbable() const { return _isGrabbable; } bool getIsGrabbable() const { return _isGrabbable; }
virtual bool getIsVisibleInSecondaryCamera() const override { return _isVisibleInSecondaryCamera; }
void setIsSolid(bool isSolid) { _isSolid = isSolid; } void setIsSolid(bool isSolid) { _isSolid = isSolid; }
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; } void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
@ -55,6 +56,7 @@ public:
virtual void setDrawInFront(bool value) { _drawInFront = value; } virtual void setDrawInFront(bool value) { _drawInFront = value; }
virtual void setDrawHUDLayer(bool value) { _drawHUDLayer = value; } virtual void setDrawHUDLayer(bool value) { _drawHUDLayer = value; }
void setIsGrabbable(bool value) { _isGrabbable = value; } void setIsGrabbable(bool value) { _isGrabbable = value; }
virtual void setIsVisibleInSecondaryCamera(bool value) { _isVisibleInSecondaryCamera = value; }
virtual AABox getBounds() const override = 0; virtual AABox getBounds() const override = 0;
@ -92,6 +94,7 @@ protected:
bool _drawInFront; bool _drawInFront;
bool _drawHUDLayer; bool _drawHUDLayer;
bool _isGrabbable { false }; bool _isGrabbable { false };
bool _isVisibleInSecondaryCamera { false };
mutable bool _renderVariableDirty { true }; mutable bool _renderVariableDirty { true };
QString _name; QString _name;

View file

@ -89,8 +89,11 @@ void ModelOverlay::update(float deltatime) {
} }
if (_visibleDirty) { if (_visibleDirty) {
_visibleDirty = false; _visibleDirty = false;
// don't show overlays in mirrors // don't show overlays in mirrors or spectator-cam unless _isVisibleInSecondaryCamera is true
_model->setVisibleInScene(getVisible(), scene, render::ItemKey::TAG_BITS_0, false); _model->setVisibleInScene(getVisible(), scene,
render::ItemKey::TAG_BITS_0 |
(_isVisibleInSecondaryCamera ? render::ItemKey::TAG_BITS_1 : render::ItemKey::TAG_BITS_NONE),
false);
} }
if (_drawInFrontDirty) { if (_drawInFrontDirty) {
_drawInFrontDirty = false; _drawInFrontDirty = false;

View file

@ -36,6 +36,11 @@ public:
void clearSubRenderItemIDs(); void clearSubRenderItemIDs();
void setSubRenderItemIDs(const render::ItemIDs& ids); void setSubRenderItemIDs(const render::ItemIDs& ids);
virtual void setIsVisibleInSecondaryCamera(bool value) override {
Base3DOverlay::setIsVisibleInSecondaryCamera(value);
_visibleDirty = true;
}
void setProperties(const QVariantMap& properties) override; void setProperties(const QVariantMap& properties) override;
QVariant getProperty(const QString& property) override; QVariant getProperty(const QString& property) override;
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,

View file

@ -56,6 +56,8 @@ public:
bool isLoaded() { return _isLoaded; } bool isLoaded() { return _isLoaded; }
bool getVisible() const { return _visible; } bool getVisible() const { return _visible; }
virtual bool isTransparent() { return getAlphaPulse() != 0.0f || getAlpha() != 1.0f; }; virtual bool isTransparent() { return getAlphaPulse() != 0.0f || getAlpha() != 1.0f; };
virtual bool getIsVisibleInSecondaryCamera() const { return false; }
xColor getColor(); xColor getColor();
float getAlpha(); float getAlpha();

View file

@ -49,7 +49,11 @@ namespace render {
builder.withInvisible(); 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(); return builder.build();
} }

View file

@ -9,7 +9,8 @@
// //
/* global Tablet, Script, HMD, UserActivityLogger, Entities, Account, Wallet, ContextOverlay, Settings, Camera, Vec3, /* 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 }] */ /* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
var selectionDisplay = null; // for gridTool.js to ignore var selectionDisplay = null; // for gridTool.js to ignore
@ -116,6 +117,24 @@ var selectionDisplay = null; // for gridTool.js to ignore
var onWalletScreen = false; var onWalletScreen = false;
var onCommerceScreen = 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) { function onScreenChanged(type, url) {
onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1; onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1;
@ -127,6 +146,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
if (isHmdPreviewDisabledBySecurity) { if (isHmdPreviewDisabledBySecurity) {
DesktopPreviewProvider.setPreviewDisabledReason("USER"); DesktopPreviewProvider.setPreviewDisabledReason("USER");
Menu.setIsOptionChecked("Disable Preview", false); Menu.setIsOptionChecked("Disable Preview", false);
setTabletVisibleInSecondaryCamera(true);
isHmdPreviewDisabledBySecurity = false; isHmdPreviewDisabledBySecurity = false;
} }
} }
@ -245,7 +265,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
var wearableDimensions = null; var wearableDimensions = null;
if (itemType === "contentSet") { 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; return;
} }
@ -575,6 +595,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
if (!isHmdPreviewDisabled) { if (!isHmdPreviewDisabled) {
DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN"); DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN");
Menu.setIsOptionChecked("Disable Preview", true); Menu.setIsOptionChecked("Disable Preview", true);
setTabletVisibleInSecondaryCamera(false);
isHmdPreviewDisabledBySecurity = true; isHmdPreviewDisabledBySecurity = true;
} }
break; break;
@ -582,6 +603,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
if (isHmdPreviewDisabledBySecurity) { if (isHmdPreviewDisabledBySecurity) {
DesktopPreviewProvider.setPreviewDisabledReason("USER"); DesktopPreviewProvider.setPreviewDisabledReason("USER");
Menu.setIsOptionChecked("Disable Preview", false); Menu.setIsOptionChecked("Disable Preview", false);
setTabletVisibleInSecondaryCamera(true);
isHmdPreviewDisabledBySecurity = false; isHmdPreviewDisabledBySecurity = false;
} }
break; break;