diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp index f4efd1301d..39b98b77eb 100644 --- a/interface/src/ui/overlays/Base3DOverlay.cpp +++ b/interface/src/ui/overlays/Base3DOverlay.cpp @@ -283,7 +283,7 @@ QVariant Base3DOverlay::getProperty(const QString& property) { } bool Base3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal) { + float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) { return false; } diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index ab83a64273..7852285271 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -68,11 +68,11 @@ public: virtual QVariant getProperty(const QString& property) override; virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, - BoxFace& face, glm::vec3& surfaceNormal); + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false); virtual bool findRayIntersectionExtraInfo(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo) { - return findRayIntersection(origin, direction, distance, face, surfaceNormal); + float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking = false) { + return findRayIntersection(origin, direction, distance, face, surfaceNormal, precisionPicking); } virtual SpatialParentTree* getParentTree() const override; diff --git a/interface/src/ui/overlays/Circle3DOverlay.cpp b/interface/src/ui/overlays/Circle3DOverlay.cpp index 33f40f7c63..ef89213d68 100644 --- a/interface/src/ui/overlays/Circle3DOverlay.cpp +++ b/interface/src/ui/overlays/Circle3DOverlay.cpp @@ -521,7 +521,7 @@ QVariant Circle3DOverlay::getProperty(const QString& property) { } bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, - BoxFace& face, glm::vec3& surfaceNormal) { + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) { // Scale the dimensions by the diameter glm::vec2 dimensions = getOuterRadius() * 2.0f * getDimensions(); diff --git a/interface/src/ui/overlays/Circle3DOverlay.h b/interface/src/ui/overlays/Circle3DOverlay.h index ef491b7f46..0dc0f8b138 100644 --- a/interface/src/ui/overlays/Circle3DOverlay.h +++ b/interface/src/ui/overlays/Circle3DOverlay.h @@ -55,7 +55,7 @@ public: void setMinorTickMarksColor(const xColor& value) { _minorTickMarksColor = value; } virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, - BoxFace& face, glm::vec3& surfaceNormal) override; + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override; virtual Circle3DOverlay* createClone() const override; diff --git a/interface/src/ui/overlays/Grid3DOverlay.h b/interface/src/ui/overlays/Grid3DOverlay.h index 5a67b21e07..34fe4dbbb6 100644 --- a/interface/src/ui/overlays/Grid3DOverlay.h +++ b/interface/src/ui/overlays/Grid3DOverlay.h @@ -35,7 +35,7 @@ public: virtual Grid3DOverlay* createClone() const override; // Grids are UI tools, and may not be intersected (pickable) - virtual bool findRayIntersection(const glm::vec3&, const glm::vec3&, float&, BoxFace&, glm::vec3&) override { return false; } + virtual bool findRayIntersection(const glm::vec3&, const glm::vec3&, float&, BoxFace&, glm::vec3&, bool precisionPicking = false) override { return false; } protected: Transform evalRenderTransform() override; diff --git a/interface/src/ui/overlays/Image3DOverlay.cpp b/interface/src/ui/overlays/Image3DOverlay.cpp index 6e9946e935..a4ce7f9e0d 100644 --- a/interface/src/ui/overlays/Image3DOverlay.cpp +++ b/interface/src/ui/overlays/Image3DOverlay.cpp @@ -258,7 +258,7 @@ void Image3DOverlay::setURL(const QString& url) { } bool Image3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal) { + float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) { if (_texture && _texture->isLoaded()) { // Make sure position and rotation is updated. Transform transform = getTransform(); diff --git a/interface/src/ui/overlays/Image3DOverlay.h b/interface/src/ui/overlays/Image3DOverlay.h index aa802a82a9..4432e3b07c 100644 --- a/interface/src/ui/overlays/Image3DOverlay.h +++ b/interface/src/ui/overlays/Image3DOverlay.h @@ -43,7 +43,7 @@ public: bool isTransparent() override { return Base3DOverlay::isTransparent() || _alphaTexture; } virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, - BoxFace& face, glm::vec3& surfaceNormal) override; + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override; virtual Image3DOverlay* createClone() const override; diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index a541b3365f..2678889f49 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -477,16 +477,16 @@ QVariant ModelOverlay::getProperty(const QString& property) { } bool ModelOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal) { + float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) { QVariantMap extraInfo; - return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo); + return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo, precisionPicking); } bool ModelOverlay::findRayIntersectionExtraInfo(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo) { + float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking) { - return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo); + return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo, precisionPicking); } ModelOverlay* ModelOverlay::createClone() const { diff --git a/interface/src/ui/overlays/ModelOverlay.h b/interface/src/ui/overlays/ModelOverlay.h index 3ef3f23fec..7de320ec81 100644 --- a/interface/src/ui/overlays/ModelOverlay.h +++ b/interface/src/ui/overlays/ModelOverlay.h @@ -44,9 +44,9 @@ public: 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, - BoxFace& face, glm::vec3& surfaceNormal) override; + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override; virtual bool findRayIntersectionExtraInfo(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo) override; + float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking = false) override; virtual ModelOverlay* createClone() const override; diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 85041aad4e..be7b0d42fc 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -554,7 +554,7 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionVector(const PickRay glm::vec3 thisSurfaceNormal; QVariantMap thisExtraInfo; if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance, - thisFace, thisSurfaceNormal, thisExtraInfo)) { + thisFace, thisSurfaceNormal, thisExtraInfo, precisionPicking)) { bool isDrawInFront = thisOverlay->getDrawInFront(); if ((bestIsFront && isDrawInFront && thisDistance < bestDistance) || (!bestIsFront && (isDrawInFront || thisDistance < bestDistance))) { diff --git a/interface/src/ui/overlays/Planar3DOverlay.cpp b/interface/src/ui/overlays/Planar3DOverlay.cpp index f53d06a239..9a436c7564 100644 --- a/interface/src/ui/overlays/Planar3DOverlay.cpp +++ b/interface/src/ui/overlays/Planar3DOverlay.cpp @@ -71,7 +71,7 @@ QVariant Planar3DOverlay::getProperty(const QString& property) { } bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal) { + float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) { // FIXME - face and surfaceNormal not being returned return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getDimensions(), distance); } diff --git a/interface/src/ui/overlays/Planar3DOverlay.h b/interface/src/ui/overlays/Planar3DOverlay.h index 0a0e75696e..e2a0e1f896 100644 --- a/interface/src/ui/overlays/Planar3DOverlay.h +++ b/interface/src/ui/overlays/Planar3DOverlay.h @@ -31,7 +31,7 @@ public: virtual QVariant getProperty(const QString& property) override; virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, - BoxFace& face, glm::vec3& surfaceNormal) override; + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override; protected: glm::vec2 _dimensions; diff --git a/interface/src/ui/overlays/Volume3DOverlay.cpp b/interface/src/ui/overlays/Volume3DOverlay.cpp index 3aed2a5b42..cf1f7f7fcb 100644 --- a/interface/src/ui/overlays/Volume3DOverlay.cpp +++ b/interface/src/ui/overlays/Volume3DOverlay.cpp @@ -76,7 +76,7 @@ QVariant Volume3DOverlay::getProperty(const QString& property) { } bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - float& distance, BoxFace& face, glm::vec3& surfaceNormal) { + float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) { // extents is the entity relative, scaled, centered extents of the entity glm::mat4 worldToEntityMatrix; Transform transform = getTransform(); diff --git a/interface/src/ui/overlays/Volume3DOverlay.h b/interface/src/ui/overlays/Volume3DOverlay.h index bde8c71aef..e9b996a6dd 100644 --- a/interface/src/ui/overlays/Volume3DOverlay.h +++ b/interface/src/ui/overlays/Volume3DOverlay.h @@ -31,7 +31,7 @@ public: QVariant getProperty(const QString& property) override; virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, - BoxFace& face, glm::vec3& surfaceNormal) override; + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override; protected: // Centered local bounding box diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 8af818edc6..ade478347c 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -622,7 +622,7 @@ void Web3DOverlay::setScriptURL(const QString& scriptURL) { } } -bool Web3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face, glm::vec3& surfaceNormal) { +bool Web3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) { glm::vec2 dimensions = getDimensions(); glm::quat rotation = getWorldOrientation(); glm::vec3 position = getWorldPosition(); diff --git a/interface/src/ui/overlays/Web3DOverlay.h b/interface/src/ui/overlays/Web3DOverlay.h index d888424cbc..2cf35c0172 100644 --- a/interface/src/ui/overlays/Web3DOverlay.h +++ b/interface/src/ui/overlays/Web3DOverlay.h @@ -53,7 +53,7 @@ public: QVariant getProperty(const QString& property) override; virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, - BoxFace& face, glm::vec3& surfaceNormal) override; + BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override; virtual Web3DOverlay* createClone() const override; diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index ffe434e621..ad87dc9f66 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -41,6 +41,8 @@ var LOCAL_BEZEL_HIGHLIGHT = Script.resourcesPath() + "images/buttonBezel_highlig var LOCAL_NORMAL_BEZEL = Script.resourcesPath() + "images/buttonBezel.png"; var LOCAL_TABLET_MODEL_PATH = Script.resourcesPath() + "meshes/tablet-with-home-button-small-bezel.fbx"; +var HIGH_PRIORITY = 1; +var LOW_PRIORITY = 0; var SUBMESH = 3; // returns object with two fields: @@ -138,8 +140,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { Overlays.deleteOverlay(this.webOverlayID); } - var RAYPICK_OFFSET = 0.0007; // Sufficient for raypick to reliably intersect tablet screen before tablet model. - var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.0) / sensorScaleFactor + RAYPICK_OFFSET; + var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.5) / sensorScaleFactor; var WEB_ENTITY_Y_OFFSET = 1 * tabletScaleFactor; var screenWidth = 0.9275 * tabletWidth; var screenHeight = 0.8983 * tabletHeight; @@ -147,7 +148,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { name: "WebTablet Web", url: url, localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET }, - localRotation: Quat.multiply(Quat.angleAxis(-0.25, X_AXIS), Quat.angleAxis(180, Y_AXIS)), + localRotation: Quat.multiply(Quat.angleAxis(-0.5, X_AXIS), Quat.angleAxis(180, Y_AXIS)), dimensions: {x: screenWidth, y: screenHeight, z: 0.1}, dpi: tabletDpi, color: { red: 255, green: 255, blue: 255 }, @@ -184,6 +185,9 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { albedoMap: HOME_BUTTON_TEXTURE } }), + userData: JSON.stringify({ + "grabbableKey": {"grabbable": false} + }), parentMaterialName: 4, parentID: this.tabletEntityID }); @@ -191,13 +195,17 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { this.homeButtonUnhighlightMaterial = Entities.addEntity({ type: "Material", materialURL: "materialData", - priority: 1, + localPosition: { x: 0.0, y: 0.0, z: 0.0 }, + priority: HIGH_PRIORITY, materialData: JSON.stringify({ materials: { albedoMap: LOCAL_NORMAL_BEZEL } }), + userData: JSON.stringify({ + "grabbableKey": {"grabbable": false} + }), visible: false, parentMaterialName: SUBMESH, parentID: this.tabletEntityID @@ -206,7 +214,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { this.homeButtonHighlightMaterial = Entities.addEntity({ type: "Material", materialURL: "materialData", - priority: 1, + localPosition: { x: 0.0, y: 0.0, z: 0.0 }, + priority: LOW_PRIORITY, visible: false, materialData: JSON.stringify({ materials: { @@ -214,8 +223,11 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { } }), + userData: JSON.stringify({ + "grabbableKey": {"grabbable": false} + }), parentMaterialName: SUBMESH, - parentID: null + parentID: this.tabletEntityID }, true); this.receive = function (channel, senderID, senderUUID, localOnly) { @@ -467,22 +479,22 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos WebTablet.prototype.onHoverEnterOverlay = function (overlayID, pointerEvent) { if (overlayID === this.homeButtonID) { - Entities.editEntity(this.homeButtonUnhighlightMaterial, {parentID: null}); - Entities.editEntity(this.homeButtonHighlightMaterial, {parentID: this.tabletEntityID}); + Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: LOW_PRIORITY}); + Entities.editEntity(this.homeButtonHighlightMaterial, {priority: HIGH_PRIORITY}); } }; WebTablet.prototype.onHoverOverOverlay = function (overlayID, pointerEvent) { if (overlayID !== this.homeButtonID) { - Entities.editEntity(this.homeButtonUnhighlightMaterial, {parentID: this.tabletEntityID}); - Entities.editEntity(this.homeButtonHighlightMaterial, {parentID: null}); + Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: HIGH_PRIORITY}); + Entities.editEntity(this.homeButtonHighlightMaterial, {priority: LOW_PRIORITY}); } }; WebTablet.prototype.onHoverLeaveOverlay = function (overlayID, pointerEvent) { if (overlayID === this.homeButtonID) { - Entities.editEntity(this.homeButtonUnhighlightMaterial, {parentID: this.tabletEntityID}); - Entities.editEntity(this.homeButtonHighlightMaterial, {parentID: null}); + Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: HIGH_PRIORITY}); + Entities.editEntity(this.homeButtonHighlightMaterial, {priority: LOW_PRIORITY}); } }; diff --git a/scripts/system/libraries/utils.js b/scripts/system/libraries/utils.js index e6db5139aa..3a36461ccf 100644 --- a/scripts/system/libraries/utils.js +++ b/scripts/system/libraries/utils.js @@ -400,14 +400,13 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) }); // update webOverlay - var RAYPICK_OFFSET = 0.0007; // Sufficient for raypick to reliably intersect tablet screen before tablet model. - var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.0) * sensorScaleOffsetOverride + RAYPICK_OFFSET; + var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.5) * sensorScaleOffsetOverride; var WEB_ENTITY_Y_OFFSET = 1 * tabletScaleFactor * sensorScaleOffsetOverride; var screenWidth = 0.9275 * tabletWidth; var screenHeight = 0.8983 * tabletHeight; var landscape = Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape; Overlays.editOverlay(HMD.tabletScreenID, { - localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET }, + localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET}, dimensions: {x: landscape ? screenHeight : screenWidth, y: landscape ? screenWidth : screenHeight, z: 0.1}, dpi: tabletDpi });