diff --git a/android/build.gradle b/android/build.gradle index 1f2c563e1b..b1ac692517 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -138,12 +138,15 @@ def scribeLocalFile='scribe' + EXEC_SUFFIX def scribeFile='scribe_linux_x86_64' def scribeChecksum='c98678d9726bd8bbf1bab792acf3ff6c' +def scribeVersion='onfeBkJWcJiTwiGOyZPVBjlyhoYQ4Axn' if (Os.isFamily(Os.FAMILY_MAC)) { scribeFile = 'scribe_osx_x86_64' scribeChecksum='a137ad62c1bf7cca739da219544a9a16' + scribeVersion='kU.Aq512HVe65uRnkFEWQEqeQfaYF2c0' } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { scribeFile = 'scribe_win32_x86_64.exe' scribeChecksum='75c2ce9ed45d17de375e3988bfaba816' + scribeVersion='24TfWFh1FBY.t6i_LdzAXZYeQOtmQNZp' } def options = [ @@ -398,7 +401,7 @@ task copyDependencies(dependsOn: [ extractDependencies ]) { } task downloadScribe(type: Download) { - src baseUrl + scribeFile + src baseUrl + scribeFile + '?versionId=' + scribeVersion dest new File(baseFolder, scribeLocalFile) onlyIfNewer true } diff --git a/interface/resources/icons/tablet-icons/bubble-a.svg b/interface/resources/icons/tablet-icons/bubble-a.svg index 553636bfbb..6f9c75a0c2 100644 --- a/interface/resources/icons/tablet-icons/bubble-a.svg +++ b/interface/resources/icons/tablet-icons/bubble-a.svg @@ -1,96 +1,15 @@ - - - -image/svg+xml \ No newline at end of file + + + + + + + + + diff --git a/interface/resources/icons/tablet-icons/bubble-i.svg b/interface/resources/icons/tablet-icons/bubble-i.svg index d7c8948e01..567a36d7ba 100644 --- a/interface/resources/icons/tablet-icons/bubble-i.svg +++ b/interface/resources/icons/tablet-icons/bubble-i.svg @@ -1,46 +1,19 @@ - - + - - - - - - - - - - - - - - - - + + + + diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index 66184513da..d4fe8574ca 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -31,6 +31,9 @@ AvatarActionHold::AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntit myAvatar->addHoldAction(this); } + _positionalTargetSet = true; + _rotationalTargetSet = true; + #if WANT_DEBUG qDebug() << "AvatarActionHold::AvatarActionHold" << (void*)this; #endif diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 04f07c5bd3..34703804cd 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -241,7 +241,7 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen } #endif - updateKeyZoneItemFromEntity(); + updateKeyZoneItemFromEntity(entity); if (keyLightChanged) { updateKeySunFromEntity(entity); @@ -329,7 +329,7 @@ void ZoneEntityRenderer::updateKeySunFromEntity(const TypedEntityPointer& entity // Set the keylight sunLight->setColor(ColorUtils::toVec3(_keyLightProperties.getColor())); sunLight->setIntensity(_keyLightProperties.getIntensity()); - sunLight->setDirection(_keyLightProperties.getDirection()); + sunLight->setDirection(entity->getTransform().getRotation() * _keyLightProperties.getDirection()); } void ZoneEntityRenderer::updateAmbientLightFromEntity(const TypedEntityPointer& entity) { @@ -349,6 +349,8 @@ void ZoneEntityRenderer::updateAmbientLightFromEntity(const TypedEntityPointer& } else { setAmbientURL(_ambientLightProperties.getAmbientURL()); } + + ambientLight->setTransform(entity->getTransform().getInverseMatrix()); } void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) { @@ -378,7 +380,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeKeyLightRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); haze->setHazeKeyLightAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude())); - haze->setZoneTransform(entity->getTransform().getMatrix()); + haze->setTransform(entity->getTransform().getMatrix()); } void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { @@ -390,7 +392,10 @@ void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& setSkyboxURL(_skyboxProperties.getURL()); } -void ZoneEntityRenderer::updateKeyZoneItemFromEntity() { +void ZoneEntityRenderer::updateKeyZoneItemFromEntity(const TypedEntityPointer& entity) { + // Update rotation values + editSkybox()->setOrientation(entity->getTransform().getRotation()); + /* TODO: Implement the sun model behavior / Keep this code here for reference, this is how we { // Set the stage diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index 69f0663c06..c5824abef0 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -45,7 +45,7 @@ protected: virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; private: - void updateKeyZoneItemFromEntity(); + void updateKeyZoneItemFromEntity(const TypedEntityPointer& entity); void updateKeySunFromEntity(const TypedEntityPointer& entity); void updateAmbientLightFromEntity(const TypedEntityPointer& entity); void updateHazeFromEntity(const TypedEntityPointer& entity); diff --git a/libraries/graphics/src/graphics/Haze.cpp b/libraries/graphics/src/graphics/Haze.cpp index c788bc57db..dfe70175f4 100644 --- a/libraries/graphics/src/graphics/Haze.cpp +++ b/libraries/graphics/src/graphics/Haze.cpp @@ -182,11 +182,11 @@ void Haze::setHazeBackgroundBlend(const float hazeBackgroundBlend) { } } -void Haze::setZoneTransform(const glm::mat4& zoneTransform) { +void Haze::setTransform(const glm::mat4& transform) { auto& params = _hazeParametersBuffer.get(); - if (params.zoneTransform == zoneTransform) { - _hazeParametersBuffer.edit().zoneTransform = zoneTransform; + if (params.transform != transform) { + _hazeParametersBuffer.edit().transform = transform; } } diff --git a/libraries/graphics/src/graphics/Haze.h b/libraries/graphics/src/graphics/Haze.h index eda9f1e407..c38fadef94 100644 --- a/libraries/graphics/src/graphics/Haze.h +++ b/libraries/graphics/src/graphics/Haze.h @@ -92,7 +92,7 @@ namespace graphics { void setHazeBackgroundBlend(const float hazeBackgroundBlend); - void setZoneTransform(const glm::mat4& zoneTransform); + void setTransform(const glm::mat4& transform); using UniformBufferView = gpu::BufferView; UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; } @@ -113,7 +113,7 @@ namespace graphics { // bit 2 - set to activate directional light attenuation mode // bit 3 - set to blend between blend-in and blend-out colours - glm::mat4 zoneTransform; + glm::mat4 transform; // Amount of background (skybox) to display, overriding the haze effect for the background float hazeBackgroundBlend{ INITIAL_HAZE_BACKGROUND_BLEND }; diff --git a/libraries/graphics/src/graphics/Light.cpp b/libraries/graphics/src/graphics/Light.cpp index cb5209d4cf..9da14fec4f 100755 --- a/libraries/graphics/src/graphics/Light.cpp +++ b/libraries/graphics/src/graphics/Light.cpp @@ -158,3 +158,9 @@ void Light::setAmbientMapNumMips(uint16_t numMips) { _ambientSchemaBuffer.edit().mapNumMips = (float)numMips; } +void Light::setTransform(const glm::mat4& transform) { + if (_ambientSchemaBuffer.edit().transform != transform) { + _ambientSchemaBuffer.edit().transform = transform; + } +} + diff --git a/libraries/graphics/src/graphics/Light.h b/libraries/graphics/src/graphics/Light.h index 360e3f224e..e6ef1e35c5 100755 --- a/libraries/graphics/src/graphics/Light.h +++ b/libraries/graphics/src/graphics/Light.h @@ -149,6 +149,8 @@ public: void setAmbientMapNumMips(uint16_t numMips); uint16_t getAmbientMapNumMips() const { return (uint16_t) _ambientSchemaBuffer->mapNumMips; } + void setTransform(const glm::mat4& transform); + // Light Schema class LightSchema { public: @@ -162,7 +164,9 @@ public: float mapNumMips { 0.0f }; float spare1; float spare2; + gpu::SphericalHarmonics ambientSphere; + glm::mat4 transform; }; using LightSchemaBuffer = gpu::StructBuffer; diff --git a/libraries/graphics/src/graphics/Light.slh b/libraries/graphics/src/graphics/Light.slh index e1202ed6a0..12ac1f3c4b 100644 --- a/libraries/graphics/src/graphics/Light.slh +++ b/libraries/graphics/src/graphics/Light.slh @@ -34,7 +34,9 @@ vec3 getLightIrradiance(Light l) { return lightIrradiance_getIrradiance(l.irradi // Light Ambient struct LightAmbient { vec4 _ambient; + SphericalHarmonics _ambientSphere; + mat4 transform; }; SphericalHarmonics getLightAmbientSphere(LightAmbient l) { return l._ambientSphere; } diff --git a/libraries/graphics/src/graphics/Skybox.cpp b/libraries/graphics/src/graphics/Skybox.cpp index e05a66104a..4baac6f085 100755 --- a/libraries/graphics/src/graphics/Skybox.cpp +++ b/libraries/graphics/src/graphics/Skybox.cpp @@ -37,6 +37,12 @@ void Skybox::setCubemap(const gpu::TexturePointer& cubemap) { } } +void Skybox::setOrientation(const glm::quat& orientation) { + // The zone rotations need to be negated + _orientation = orientation; + _orientation.w = -_orientation.w; +} + void Skybox::updateSchemaBuffer() const { auto blend = 0.0f; if (getCubemap() && getCubemap()->isDefined()) { @@ -115,6 +121,10 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky Transform viewTransform; viewFrustum.evalViewTransform(viewTransform); + + // Orientate view transform to be relative to zone + viewTransform.setRotation(skybox.getOrientation() * viewTransform.getRotation()); + batch.setProjectionTransform(projMat); batch.setViewTransform(viewTransform); batch.setModelTransform(Transform()); // only for Mac diff --git a/libraries/graphics/src/graphics/Skybox.h b/libraries/graphics/src/graphics/Skybox.h index d06989a457..a739b9a745 100755 --- a/libraries/graphics/src/graphics/Skybox.h +++ b/libraries/graphics/src/graphics/Skybox.h @@ -37,6 +37,9 @@ public: void setCubemap(const gpu::TexturePointer& cubemap); const gpu::TexturePointer& getCubemap() const { return _cubemap; } + void setOrientation(const glm::quat& orientation); + const glm::quat getOrientation() const { return _orientation; } + virtual bool empty() { return _empty; } virtual void clear(); @@ -61,6 +64,8 @@ protected: mutable gpu::BufferView _schemaBuffer; gpu::TexturePointer _cubemap; + glm::quat _orientation; + bool _empty{ true }; }; typedef std::shared_ptr SkyboxPointer; diff --git a/libraries/physics/src/ObjectActionTractor.cpp b/libraries/physics/src/ObjectActionTractor.cpp index ec34023926..03e6533c87 100644 --- a/libraries/physics/src/ObjectActionTractor.cpp +++ b/libraries/physics/src/ObjectActionTractor.cpp @@ -77,13 +77,18 @@ bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) { return false; } + bool doLinearTraction = _positionalTargetSet && (_linearTimeScale < MAX_TRACTOR_TIMESCALE); + bool doAngularTraction = _rotationalTargetSet && (_angularTimeScale < MAX_TRACTOR_TIMESCALE); + if (!doLinearTraction && !doAngularTraction) { + // nothing to do + return false; + } + glm::quat rotation; glm::vec3 position; glm::vec3 angularVelocity; - bool linearValid = false; int linearTractorCount = 0; - bool angularValid = false; int angularTractorCount = 0; QList tractorDerivedActions; @@ -105,7 +110,6 @@ bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) { linearTimeScale, angularTimeScale); if (success) { if (angularTimeScale < MAX_TRACTOR_TIMESCALE) { - angularValid = true; angularTractorCount++; angularVelocity += angularVelocityForAction; if (tractorAction.get() == this) { @@ -115,41 +119,40 @@ bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) { } if (linearTimeScale < MAX_TRACTOR_TIMESCALE) { - linearValid = true; linearTractorCount++; position += positionForAction; } } } - if ((angularValid && angularTractorCount > 0) || (linearValid && linearTractorCount > 0)) { + if (angularTractorCount > 0 || linearTractorCount > 0) { withWriteLock([&]{ - if (linearValid && linearTractorCount > 0) { + if (doLinearTraction && linearTractorCount > 0) { position /= linearTractorCount; - if (_positionalTargetSet) { - _lastPositionTarget = _positionalTarget; - _positionalTarget = position; - if (deltaTimeStep > EPSILON) { + _lastPositionTarget = _positionalTarget; + _positionalTarget = position; + if (deltaTimeStep > EPSILON) { + if (_havePositionTargetHistory) { // blend the new velocity with the old (low-pass filter) glm::vec3 newVelocity = (1.0f / deltaTimeStep) * (_positionalTarget - _lastPositionTarget); const float blend = 0.25f; _linearVelocityTarget = (1.0f - blend) * _linearVelocityTarget + blend * newVelocity; + } else { + _havePositionTargetHistory = true; } } - _positionalTargetSet = true; _active = true; } - if (angularValid && angularTractorCount > 0) { + if (doAngularTraction && angularTractorCount > 0) { angularVelocity /= angularTractorCount; _rotationalTarget = rotation; _angularVelocityTarget = angularVelocity; - _rotationalTargetSet = true; _active = true; } }); } - return linearValid || angularValid; + return true; } @@ -239,7 +242,9 @@ bool ObjectActionTractor::updateArguments(QVariantMap arguments) { // targets are required, tractor-constants are optional bool ok = true; positionalTarget = EntityDynamicInterface::extractVec3Argument("tractor action", arguments, "targetPosition", ok, false); - if (!ok) { + if (ok) { + _positionalTargetSet = true; + } else { positionalTarget = _desiredPositionalTarget; } ok = true; @@ -250,7 +255,9 @@ bool ObjectActionTractor::updateArguments(QVariantMap arguments) { ok = true; rotationalTarget = EntityDynamicInterface::extractQuatArgument("tractor action", arguments, "targetRotation", ok, false); - if (!ok) { + if (ok) { + _rotationalTargetSet = true; + } else { rotationalTarget = _desiredRotationalTarget; } diff --git a/libraries/physics/src/ObjectActionTractor.h b/libraries/physics/src/ObjectActionTractor.h index a17526f5f9..2273a1e720 100644 --- a/libraries/physics/src/ObjectActionTractor.h +++ b/libraries/physics/src/ObjectActionTractor.h @@ -39,6 +39,7 @@ protected: glm::vec3 _lastPositionTarget; float _linearTimeScale; bool _positionalTargetSet; + bool _havePositionTargetHistory { false }; glm::quat _rotationalTarget; glm::quat _desiredRotationalTarget; diff --git a/libraries/render-utils/src/Haze.slh b/libraries/render-utils/src/Haze.slh index 15e484e055..10b493da2c 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/render-utils/src/Haze.slh @@ -26,7 +26,7 @@ struct HazeParams { vec3 colorModulationFactor; int hazeMode; - mat4 zoneTransform; + mat4 transform; float backgroundBlend; float hazeRangeFactor; diff --git a/libraries/render-utils/src/LightAmbient.slh b/libraries/render-utils/src/LightAmbient.slh index 89d3f4faee..0502446db8 100644 --- a/libraries/render-utils/src/LightAmbient.slh +++ b/libraries/render-utils/src/LightAmbient.slh @@ -5,9 +5,6 @@ // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - - <@func declareSkyboxMap()@> // declareSkyboxMap @@ -15,7 +12,6 @@ uniform samplerCube skyboxMap; vec4 evalSkyboxLight(vec3 direction, float lod) { // textureQueryLevels is not available until #430, so we require explicit lod - // float mipmapLevel = lod * textureQueryLevels(skyboxMap); float filterLod = textureQueryLod(skyboxMap, direction).x; // Keep texture filtering LOD as limit to prevent aliasing on specular reflection lod = max(lod, filterLod); @@ -28,15 +24,13 @@ vec4 evalSkyboxLight(vec3 direction, float lod) { vec3 fresnelSchlickAmbient(vec3 fresnelColor, float ndotd, float gloss) { float f = pow(1.0 - ndotd, 5.0); return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * f; -// return fresnelColor + (vec3(1.0) - fresnelColor) * f; } <@if supportAmbientMap@> <$declareSkyboxMap()$> <@endif@> -vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, SurfaceData surface) { - vec3 lightDir = -reflect(surface.eyeDir, surface.normal); +vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, SurfaceData surface, vec3 lightDir) { vec3 specularLight; <@if supportIfAmbientMapElseAmbientSphere@> if (getLightHasAmbientMap(ambient)) @@ -80,14 +74,21 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambie <@endif@> ) { - // Fresnel + // Rotate surface normal and eye direction + vec3 ambientSpaceSurfaceNormal = (ambient.transform * vec4(surface.normal, 0.0)).xyz; + vec3 ambientSpaceSurfaceEyeDir = (ambient.transform * vec4(surface.eyeDir, 0.0)).xyz; +<@if supportScattering@> + vec3 ambientSpaceLowNormalCurvature = (ambient.transform * lowNormalCurvature).xyz; +<@endif@> + vec3 ambientFresnel = fresnelSchlickAmbient(fresnelF0, surface.ndotv, 1.0-surface.roughness); - // Diffuse from ambient - diffuse = (1.0 - metallic) * (vec3(1.0) - ambientFresnel) * sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), surface.normal).xyz; + diffuse = (1.0 - metallic) * (vec3(1.0) - ambientFresnel) * + sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), ambientSpaceSurfaceNormal).xyz; // Specular highlight from ambient - specular = evalAmbientSpecularIrradiance(ambient, surface) * ambientFresnel; + vec3 ambientSpaceLightDir = -reflect(ambientSpaceSurfaceEyeDir, ambientSpaceSurfaceNormal); + specular = evalAmbientSpecularIrradiance(ambient, surface, ambientSpaceLightDir) * ambientFresnel; <@if supportScattering@> if (scattering * isScatteringEnabled() > 0.0) { @@ -98,7 +99,7 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambie obscurance = min(obscurance, ambientOcclusion); // Diffuse from ambient - diffuse = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), lowNormalCurvature.xyz).xyz; + diffuse = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), ambientSpaceLowNormalCurvature).xyz; // Scattering ambient specular is the same as non scattering for now // TODO: we should use the same specular answer as for direct lighting diff --git a/libraries/render-utils/src/model_translucent_fade.slf b/libraries/render-utils/src/model_translucent_fade.slf index 316dae7aad..e767d0ffa5 100644 --- a/libraries/render-utils/src/model_translucent_fade.slf +++ b/libraries/render-utils/src/model_translucent_fade.slf @@ -1,25 +1,18 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> // Generated on <$_SCRIBE_DATE$> -// // model_translucent_fade.frag -// fragment shader -// // Created by Olivier Prat on 06/05/17. // Copyright 2017 High Fidelity, Inc. -// // Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// +// See the accompanying file LICENSE <@include graphics/Material.slh@> - <@include DeferredGlobalLight.slh@> <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> <@include LightLocal.slh@> - <@include gpu/Transform.slh@> <$declareStandardCameraTransform()$> diff --git a/scripts/system/commerce/wallet.js b/scripts/system/commerce/wallet.js index cef61bdc53..8cf5b72b9a 100644 --- a/scripts/system/commerce/wallet.js +++ b/scripts/system/commerce/wallet.js @@ -636,14 +636,9 @@ openLoginWindow(); break; case 'disableHmdPreview': - isHmdPreviewDisabled = Menu.isOptionChecked("Disable Preview"); - DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN"); - Menu.setIsOptionChecked("Disable Preview", true); - break; + break; // do nothing here, handled in marketplaces.js case 'maybeEnableHmdPreview': - DesktopPreviewProvider.setPreviewDisabledReason("USER"); - Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled); - break; + break; // do nothing here, handled in marketplaces.js case 'passphraseReset': onButtonClicked(); onButtonClicked(); @@ -731,11 +726,7 @@ // -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string // value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML. function onTabletScreenChanged(type, url) { - var onWalletScreenNow = (type === "QML" && url === WALLET_QML_SOURCE); - if (!onWalletScreenNow && onWalletScreen) { - DesktopPreviewProvider.setPreviewDisabledReason("USER"); - } - onWalletScreen = onWalletScreenNow; + onWalletScreen = (type === "QML" && url === WALLET_QML_SOURCE); wireEventBridge(onWalletScreen); // Change button to active when window is first openend, false otherwise. if (button) { diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index facb932eb0..edcd488a01 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -112,11 +112,23 @@ var selectionDisplay = null; // for gridTool.js to ignore var referrerURL; // Used for updating Purchases QML var filterText; // Used for updating Purchases QML + + var onWalletScreen = false; function onScreenChanged(type, url) { onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1; - onWalletScreen = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1; + var onWalletScreenNow = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1; onCommerceScreen = type === "QML" && (url.indexOf(MARKETPLACE_CHECKOUT_QML_PATH) !== -1 || url === MARKETPLACE_PURCHASES_QML_PATH || url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1); + + if (!onWalletScreenNow && onWalletScreen) { // exiting wallet screen + if (isHmdPreviewDisabledBySecurity) { + DesktopPreviewProvider.setPreviewDisabledReason("USER"); + Menu.setIsOptionChecked("Disable Preview", false); + isHmdPreviewDisabledBySecurity = false; + } + } + + onWalletScreen = onWalletScreenNow; wireEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen); if (url === MARKETPLACE_PURCHASES_QML_PATH) { @@ -480,7 +492,7 @@ var selectionDisplay = null; // for gridTool.js to ignore // Description: // -Called when a message is received from Checkout.qml. The "message" argument is what is sent from the Checkout QML // in the format "{method, params}", like json-rpc. - var isHmdPreviewDisabled = true; + var isHmdPreviewDisabledBySecurity = false; function fromQml(message) { switch (message.method) { case 'purchases_openWallet': @@ -548,11 +560,19 @@ var selectionDisplay = null; // for gridTool.js to ignore openLoginWindow(); break; case 'disableHmdPreview': - isHmdPreviewDisabled = Menu.isOptionChecked("Disable Preview"); - Menu.setIsOptionChecked("Disable Preview", true); + var isHmdPreviewDisabled = Menu.isOptionChecked("Disable Preview"); + if (!isHmdPreviewDisabled) { + DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN"); + Menu.setIsOptionChecked("Disable Preview", true); + isHmdPreviewDisabledBySecurity = true; + } break; case 'maybeEnableHmdPreview': - Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled); + if (isHmdPreviewDisabledBySecurity) { + DesktopPreviewProvider.setPreviewDisabledReason("USER"); + Menu.setIsOptionChecked("Disable Preview", false); + isHmdPreviewDisabledBySecurity = false; + } break; case 'purchases_openGoTo': tablet.loadQMLSource("hifi/tablet/TabletAddressDialog.qml");