From 9aae9d13f6cc8fe128ad20fb7167ef6d00ca2dde Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 28 Jan 2019 22:19:31 -0800 Subject: [PATCH] fix tablet home button --- interface/src/devices/DdeFaceTracker.cpp | 4 -- interface/src/ui/overlays/Overlays.cpp | 26 +++++++++-- interface/src/ui/overlays/Overlays.h | 6 ++- scripts/system/libraries/WebTablet.js | 55 ++---------------------- scripts/system/libraries/utils.js | 3 +- 5 files changed, 31 insertions(+), 63 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index c123585afa..b9dc8326e8 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -615,10 +615,6 @@ void DdeFaceTracker::setEyeClosingThreshold(float eyeClosingThreshold) { static const int CALIBRATION_BILLBOARD_WIDTH = 300; static const int CALIBRATION_BILLBOARD_HEIGHT = 120; -static const int CALIBRATION_BILLBOARD_TOP_MARGIN = 30; -static const int CALIBRATION_BILLBOARD_LEFT_MARGIN = 30; -static const int CALIBRATION_BILLBOARD_FONT_SIZE = 16; -static const float CALIBRATION_BILLBOARD_ALPHA = 0.5f; static QString CALIBRATION_INSTRUCTION_MESSAGE = "Hold still to calibrate camera"; void DdeFaceTracker::calibrate() { diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index c677c3dbb5..13476e4841 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -397,6 +397,20 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove } overlayProps["rotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation); } + if (add || overlayProps.contains("localRotation")) { + glm::quat rotation; + { + auto iter = overlayProps.find("localRotation"); + if (iter != overlayProps.end()) { + rotation = quatFromVariant(iter.value()); + } else if (!add) { + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_LOCAL_ROTATION; + rotation = DependencyManager::get()->getEntityProperties(id, desiredProperties).getLocalRotation(); + } + } + overlayProps["localRotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation); + } { RENAME_PROP(color, innerStartColor); @@ -536,8 +550,6 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie RENAME_PROP(position, point); RENAME_PROP(dimensions, scale); RENAME_PROP(dimensions, size); - RENAME_PROP(rotation, orientation); - RENAME_PROP(localRotation, localOrientation); RENAME_PROP(ignorePickIntersection, ignoreRayIntersection); { @@ -586,13 +598,17 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie RENAME_PROP(sourceUrl, url); RENAME_PROP_CONVERT(inputMode, inputMode, [](const QVariant& v) { return v.toString() == "mouse" ? "Mouse" : "Touch"; }); } else if (type == "Gizmo") { - RENAME_PROP_CONVERT(dimensions, outerRadius, [](const QVariant& v) { return vec3FromVariant(v).x; }); + RENAME_PROP_CONVERT(dimensions, outerRadius, [](const QVariant& v) { return 2.0f * vec3FromVariant(v).x; }); RENAME_PROP(outerRadius, radius); RENAME_PROP_CONVERT(rotation, rotation, [](const QVariant& v) { glm::quat rot = quatFromVariant(v); return quatToVariant(glm::angleAxis((float)M_PI_2, rot * Vectors::RIGHT) * rot); }); + RENAME_PROP_CONVERT(localRotation, localRotation, [](const QVariant& v) { + glm::quat rot = quatFromVariant(v); + return quatToVariant(glm::angleAxis((float)M_PI_2, rot * Vectors::RIGHT) * rot); + }); GROUP_ENTITY_TO_OVERLAY_PROP(ring, startAngle, startAt); GROUP_ENTITY_TO_OVERLAY_PROP(ring, endAngle, endAt); @@ -638,6 +654,10 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie RENAME_PROP_CONVERT(glow, glow, [](const QVariant& v) { return v.toBool() ? 1.0f : 0.0f; }); } + // Do at the end, in case this type was rotated above + RENAME_PROP(rotation, orientation); + RENAME_PROP(localRotation, localOrientation); + return overlayProps; } diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index 5db90fecf4..992431f3ed 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -358,8 +358,10 @@ public slots: * @param {boolean} [precisionPicking=false] - Unused; exists to match Entity API. * @param {Array.} [include=[]] - If not empty then the search is restricted to these overlays. * @param {Array.} [discard=[]] - Overlays to ignore during the search. - * @param {boolean} [visibleOnly=false] - Unused; exists to match Entity API. - * @param {boolean} [collidableOnly=false] - Unused; exists to match Entity API. + * @param {boolean} [visibleOnly=false] - If true then only entities that are + * {@link Entities.EntityProperties|visible} are searched. + * @param {boolean} [collideableOnly=false] - If true then only entities that are not + * {@link Entities.EntityProperties|collisionless} are searched. * @returns {Overlays.RayToOverlayIntersectionResult} The closest 3D overlay intersected by pickRay, taking * into account overlayIDsToInclude and overlayIDsToExclude if they're not empty. * @example Create a cube overlay in front of your avatar. Report 3D overlay intersection details for mouse diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 4178cd4aec..a578ed0d97 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -170,8 +170,7 @@ WebTablet = function (url, width, dpi, hand, location, visible) { visible: visible }); - // FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here - var homeButtonDim = 4.0 * tabletScaleFactor / 3.0; + var homeButtonDim = 4.0 * tabletScaleFactor / 1.5; var HOME_BUTTON_X_OFFSET = 0.00079 * sensorScaleFactor; var HOME_BUTTON_Y_OFFSET = -1 * ((tabletHeight / 2) - (4.0 * tabletScaleFactor / 2)); var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleFactor; @@ -224,23 +223,6 @@ WebTablet = function (url, width, dpi, hand, location, visible) { } }; - this.myOnHoverEnterOverlay = function (overlayID, pointerEvent) { - _this.onHoverEnterOverlay(overlayID, pointerEvent); - }; - - Overlays.hoverEnterOverlay.connect(this.myOnHoverEnterOverlay); - - this.myOnHoverLeaveOverlay = function (overlayID, pointerEvent) { - _this.onHoverLeaveOverlay(overlayID, pointerEvent); - }; - - Overlays.hoverLeaveOverlay.connect(this.myOnHoverLeaveOverlay); - - this.myOnHoverOverOverlay = function (overlayID, pointerEvent) { - _this.onHoverOverOverlay(overlayID, pointerEvent); - }; - Overlays.hoverOverOverlay.connect(this.myOnHoverOverOverlay); - this.state = "idle"; this.getRoot = function() { @@ -350,10 +332,6 @@ WebTablet.prototype.setWidth = function (width) { }; WebTablet.prototype.destroy = function () { - Overlays.hoverEnterOverlay.disconnect(this.myOnHoverEnterOverlay); - Overlays.hoverLeaveOverlay.disconnect(this.myOnHoverLeaveOverlay); - Overlays.hoverOverOverlay.disconnect(this.myOnHoverOverOverlay); - Overlays.deleteOverlay(this.webOverlayID); Overlays.deleteOverlay(this.tabletEntityID); Overlays.deleteOverlay(this.homeButtonID); @@ -449,24 +427,6 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos }; }; -WebTablet.prototype.onHoverEnterOverlay = function (overlayID, pointerEvent) { - if (overlayID === this.homeButtonID) { - Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 1.0 }); - } -}; - -WebTablet.prototype.onHoverOverOverlay = function (overlayID, pointerEvent) { - if (overlayID !== this.homeButtonID) { - Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 }); - } -}; - -WebTablet.prototype.onHoverLeaveOverlay = function (overlayID, pointerEvent) { - if (overlayID === this.homeButtonID) { - Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 }); - } -}; - // compute position, rotation & parentJointIndex of the tablet WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, useMouse, tabletProperties) { if (HMD.active) { @@ -595,17 +555,8 @@ WebTablet.prototype.scheduleMouseMoveProcessor = function() { WebTablet.prototype.handleHomeButtonHover = function(x, y) { var pickRay = Camera.computePickRay(x, y); - var entityPickResults; - var homebuttonHovered = false; - entityPickResults = Overlays.findRayIntersection(pickRay, true, [this.tabletEntityID]); - if (entityPickResults.intersects && (entityPickResults.entityID === this.tabletEntityID || - entityPickResults.overlayID === this.tabletEntityID)) { - var overlayPickResults = Overlays.findRayIntersection(pickRay, true, [this.homeButtonID], []); - if (overlayPickResults.intersects && overlayPickResults.overlayID === this.homeButtonID) { - homebuttonHovered = true; - } - } - Overlays.editOverlay(this.homeButtonHighlightID, { alpha: homebuttonHovered ? 1.0 : 0.0 }); + var homePickResult = Overlays.findRayIntersection(pickRay, true, [this.homeButtonID]); + Overlays.editOverlay(this.homeButtonHighlightID, { alpha: homePickResult.intersects ? 1.0 : 0.0 }); }; WebTablet.prototype.mouseMoveEvent = function (event) { diff --git a/scripts/system/libraries/utils.js b/scripts/system/libraries/utils.js index c0a52a45c6..931c346299 100644 --- a/scripts/system/libraries/utils.js +++ b/scripts/system/libraries/utils.js @@ -412,8 +412,7 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) }); // update homeButton - // FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here - var homeButtonDim = 4.0 * tabletScaleFactor / 3.0; + var homeButtonDim = 4.0 * tabletScaleFactor / 1.5; var HOME_BUTTON_X_OFFSET = 0.00079 * sensorScaleOffsetOverride * sensorScaleFactor; var HOME_BUTTON_Y_OFFSET = -1 * ((tabletHeight / 2) - (4.0 * tabletScaleFactor / 2)) * sensorScaleOffsetOverride; var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleOffsetOverride;