From 4830ba24aef5b793a81214c3c76303876af1a16f Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 28 Aug 2018 09:53:54 +1200 Subject: [PATCH 1/9] Highlight tablet when it is near-grabbable --- .../controllers/controllerDispatcher.js | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 7a916392b9..b1b41ded04 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -37,6 +37,20 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); PROFILE = true; } + var TABLET_GRABBABLE_SELECTION_NAME = "tabletGrabbableSelection"; + var TABLET_GRABBABLE_SELECTION_STYLE = { + outlineUnoccludedColor: { red: 0, green: 180, blue: 239 }, // #00b4ef + outlineUnoccludedAlpha: 1, + outlineOccludedColor: { red: 0, green: 0, blue: 0 }, + outlineOccludedAlpha: 0, + fillUnoccludedColor: { red: 0, green: 0, blue: 0 }, + fillUnoccludedAlpha: 0, + fillOccludedColor: { red: 0, green: 0, blue: 0 }, + fillOccludedAlpha: 0, + outlineWidth: 2, + isOutlineSmooth: false + }; + function ControllerDispatcher() { var _this = this; this.lastInterval = Date.now(); @@ -168,6 +182,8 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.setTimeout(_this.update, BASIC_TIMER_INTERVAL_MS); }; + this.isTabletNearGrabbable = false; + this.updateInternal = function () { if (PROFILE) { Script.beginProfileRange("dispatch.pre"); @@ -206,6 +222,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); // find 3d overlays near each hand var nearbyOverlayIDs = []; + var isTabletNearGrabbable = false; var h; for (h = LEFT_HAND; h <= RIGHT_HAND; h++) { if (controllerLocations[h].valid) { @@ -218,12 +235,26 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var bDistance = Vec3.distance(bPosition, controllerLocations[h].position); return aDistance - bDistance; }); + if (HMD.tabletID && nearbyOverlays.indexOf(HMD.tabletID) !== -1) { + isTabletNearGrabbable = true; + } nearbyOverlayIDs.push(nearbyOverlays); } else { nearbyOverlayIDs.push([]); } } + // Highlight tablet if it is near-grabbable. + if (isTabletNearGrabbable !== _this.isTabletNearGrabbable) { + if (isTabletNearGrabbable) { + Selection.addToSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID); + } else { + Selection.removeFromSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID); + } + _this.isTabletNearGrabbable = isTabletNearGrabbable; + } + + // find entities near each hand var nearbyEntityProperties = [[], []]; var nearbyEntityPropertiesByID = {}; @@ -485,6 +516,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Selection.disableListHighlight(DISPATCHER_HOVERING_LIST); }; } + function mouseReleaseOnOverlay(overlayID, event) { if (HMD.homeButtonID && overlayID === HMD.homeButtonID && event.button === "Primary") { Messages.sendLocalMessage("home", overlayID); @@ -503,12 +535,29 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } } } + Overlays.mouseReleaseOnOverlay.connect(mouseReleaseOnOverlay); Overlays.mousePressOnOverlay.connect(mousePress); Entities.mousePressOnEntity.connect(mousePress); + + function onDisplayModeChanged() { + if (HMD.active) { + Selection.enableListHighlight(TABLET_GRABBABLE_SELECTION_NAME, TABLET_GRABBABLE_SELECTION_STYLE); + } else { + Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME); + Selection.clearSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME); + } + } + + HMD.displayModeChanged.connect(onDisplayModeChanged); + HMD.mountedChanged.connect(onDisplayModeChanged); + var controllerDispatcher = new ControllerDispatcher(); Messages.subscribe('Hifi-Hand-RayPick-Blacklist'); Messages.messageReceived.connect(controllerDispatcher.handleHandMessage); - Script.scriptEnding.connect(controllerDispatcher.cleanup); + Script.scriptEnding.connect(function () { + controllerDispatcher.cleanup(); + Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME); + }); Script.setTimeout(controllerDispatcher.update, BASIC_TIMER_INTERVAL_MS); }()); From f84f3b20cdf79c2d75ff4703808838912a4c44d9 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 31 Aug 2018 10:25:12 +1200 Subject: [PATCH 2/9] Disable near and far lasers when tablet is grabbable --- .../controllerModules/farActionGrabEntity.js | 3 +- .../farActionGrabEntityDynOnly.js | 3 +- .../controllerModules/farParentGrabEntity.js | 3 +- .../controllerModules/nearTabletHighlight.js | 67 +++++++++++++++++++ .../controllerModules/webSurfaceLaserInput.js | 7 ++ .../system/controllers/controllerScripts.js | 3 +- 6 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 scripts/system/controllers/controllerModules/nearTabletHighlight.js diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 5e798ed680..b5141699f9 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -420,7 +420,8 @@ Script.include("/~/system/libraries/Xform.js"); this.hand === RIGHT_HAND ? "RightFarTriggerEntity" : "LeftFarTriggerEntity", this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity", this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity", - this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay" + this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay", + this.hand === RIGHT_HAND ? "RightNearTabletHighlight" : "LeftNearTabletHighlight" ]; var nearGrabReadiness = []; diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntityDynOnly.js b/scripts/system/controllers/controllerModules/farActionGrabEntityDynOnly.js index 78abcb9b20..4fab0098b9 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntityDynOnly.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntityDynOnly.js @@ -396,7 +396,8 @@ Script.include("/~/system/libraries/Xform.js"); this.hand === RIGHT_HAND ? "RightFarTriggerEntity" : "LeftFarTriggerEntity", this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity", this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity", - this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay" + this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay", + this.hand === RIGHT_HAND ? "RightNearTabletHighlight" : "LeftNearTabletHighlight" ]; var nearGrabReadiness = []; diff --git a/scripts/system/controllers/controllerModules/farParentGrabEntity.js b/scripts/system/controllers/controllerModules/farParentGrabEntity.js index a9ec246a32..d58cbb9907 100644 --- a/scripts/system/controllers/controllerModules/farParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farParentGrabEntity.js @@ -442,7 +442,8 @@ Script.include("/~/system/libraries/Xform.js"); this.hand === RIGHT_HAND ? "RightFarTriggerEntity" : "LeftFarTriggerEntity", this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity", this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity", - this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay" + this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay", + this.hand === RIGHT_HAND ? "RightNearTabletHighlight" : "LeftNearTabletHighlight" ]; var nearGrabReadiness = []; diff --git a/scripts/system/controllers/controllerModules/nearTabletHighlight.js b/scripts/system/controllers/controllerModules/nearTabletHighlight.js new file mode 100644 index 0000000000..5f4dac232e --- /dev/null +++ b/scripts/system/controllers/controllerModules/nearTabletHighlight.js @@ -0,0 +1,67 @@ +// +// nearTabletHighlight.js +// +// Highlight the tablet if a hand is near enough to grab it. +// +// Created by David Rowe on 28 Aug 2018. +// Copyright 2018 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 +// + +/* global LEFT_HAND, RIGHT_HAND, makeDispatcherModuleParameters, makeRunningValues, enableDispatcherModule, + * disableDispatcherModule */ + +Script.include("/~/system/libraries/controllerDispatcherUtils.js"); + +(function () { + + "use strict"; + + function NearTabletHighlight(hand) { + this.hand = hand; + + this.parameters = makeDispatcherModuleParameters( + 95, + this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], + [], + 100 + ); + + this.isNearTablet = function (controllerData) { + return HMD.tabletID && controllerData.nearbyOverlayIDs[this.hand].indexOf(HMD.tabletID) !== -1; + }; + + this.isReady = function (controllerData) { + if (this.isNearTablet(controllerData)) { + return makeRunningValues(true, [], []); + } + return makeRunningValues(false, [], []); + }; + + this.run = function (controllerData) { + if (!this.isNearTablet(controllerData)) { + return makeRunningValues(false, [], []); + } + + if (controllerData.triggerClicks[this.hand]) { + return makeRunningValues(false, [], []); + } + + return makeRunningValues(true, [], []); + }; + } + + var leftNearTabletHighlight = new NearTabletHighlight(LEFT_HAND); + var rightNearTabletHighlight = new NearTabletHighlight(RIGHT_HAND); + enableDispatcherModule("LeftNearTabletHighlight", leftNearTabletHighlight); + enableDispatcherModule("RightNearTabletHighlight", rightNearTabletHighlight); + + function cleanUp() { + disableDispatcherModule("LeftNearTabletHighlight"); + disableDispatcherModule("RightNearTabletHighlight"); + } + Script.scriptEnding.connect(cleanUp); + +}()); diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index a2fe0bfcd4..7ed9fd68b5 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -43,6 +43,13 @@ Script.include("/~/system/libraries/controllers.js"); } } } + + var nearTabletHighlightModule = getEnabledModuleByName(this.hand === RIGHT_HAND + ? "RightNearTabletHighlight" : "LeftNearTabletHighlight"); + if (nearTabletHighlightModule) { + return nearTabletHighlightModule.isNearTablet(controllerData); + } + return false; }; diff --git a/scripts/system/controllers/controllerScripts.js b/scripts/system/controllers/controllerScripts.js index 6899577de2..8011c2b644 100644 --- a/scripts/system/controllers/controllerScripts.js +++ b/scripts/system/controllers/controllerScripts.js @@ -35,7 +35,8 @@ var CONTOLLER_SCRIPTS = [ "controllerModules/scaleEntity.js", "controllerModules/highlightNearbyEntities.js", "controllerModules/nearGrabHyperLinkEntity.js", - "controllerModules/mouseHighlightEntities.js" + "controllerModules/mouseHighlightEntities.js", + "controllerModules/nearTabletHighlight.js" ]; if (Settings.getValue("useFarGrabJoints", false)) { From 9203bbc5d8ec265169d1293287614837c6e2043d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 31 Aug 2018 11:02:36 +1200 Subject: [PATCH 3/9] Don't highlight tablet when it is grabbed --- .../controllers/controllerDispatcher.js | 48 +--------------- .../controllerModules/nearTabletHighlight.js | 55 ++++++++++++++++++- 2 files changed, 55 insertions(+), 48 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index b1b41ded04..a707050a9d 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -37,20 +37,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); PROFILE = true; } - var TABLET_GRABBABLE_SELECTION_NAME = "tabletGrabbableSelection"; - var TABLET_GRABBABLE_SELECTION_STYLE = { - outlineUnoccludedColor: { red: 0, green: 180, blue: 239 }, // #00b4ef - outlineUnoccludedAlpha: 1, - outlineOccludedColor: { red: 0, green: 0, blue: 0 }, - outlineOccludedAlpha: 0, - fillUnoccludedColor: { red: 0, green: 0, blue: 0 }, - fillUnoccludedAlpha: 0, - fillOccludedColor: { red: 0, green: 0, blue: 0 }, - fillOccludedAlpha: 0, - outlineWidth: 2, - isOutlineSmooth: false - }; - function ControllerDispatcher() { var _this = this; this.lastInterval = Date.now(); @@ -182,8 +168,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.setTimeout(_this.update, BASIC_TIMER_INTERVAL_MS); }; - this.isTabletNearGrabbable = false; - this.updateInternal = function () { if (PROFILE) { Script.beginProfileRange("dispatch.pre"); @@ -222,7 +206,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); // find 3d overlays near each hand var nearbyOverlayIDs = []; - var isTabletNearGrabbable = false; var h; for (h = LEFT_HAND; h <= RIGHT_HAND; h++) { if (controllerLocations[h].valid) { @@ -235,26 +218,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var bDistance = Vec3.distance(bPosition, controllerLocations[h].position); return aDistance - bDistance; }); - if (HMD.tabletID && nearbyOverlays.indexOf(HMD.tabletID) !== -1) { - isTabletNearGrabbable = true; - } nearbyOverlayIDs.push(nearbyOverlays); } else { nearbyOverlayIDs.push([]); } } - // Highlight tablet if it is near-grabbable. - if (isTabletNearGrabbable !== _this.isTabletNearGrabbable) { - if (isTabletNearGrabbable) { - Selection.addToSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID); - } else { - Selection.removeFromSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID); - } - _this.isTabletNearGrabbable = isTabletNearGrabbable; - } - - // find entities near each hand var nearbyEntityProperties = [[], []]; var nearbyEntityPropertiesByID = {}; @@ -540,24 +509,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Overlays.mousePressOnOverlay.connect(mousePress); Entities.mousePressOnEntity.connect(mousePress); - function onDisplayModeChanged() { - if (HMD.active) { - Selection.enableListHighlight(TABLET_GRABBABLE_SELECTION_NAME, TABLET_GRABBABLE_SELECTION_STYLE); - } else { - Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME); - Selection.clearSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME); - } - } - - HMD.displayModeChanged.connect(onDisplayModeChanged); - HMD.mountedChanged.connect(onDisplayModeChanged); - var controllerDispatcher = new ControllerDispatcher(); Messages.subscribe('Hifi-Hand-RayPick-Blacklist'); Messages.messageReceived.connect(controllerDispatcher.handleHandMessage); - Script.scriptEnding.connect(function () { - controllerDispatcher.cleanup(); - Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME); - }); + Script.scriptEnding.connect(controllerDispatcher.cleanup); Script.setTimeout(controllerDispatcher.update, BASIC_TIMER_INTERVAL_MS); }()); diff --git a/scripts/system/controllers/controllerModules/nearTabletHighlight.js b/scripts/system/controllers/controllerModules/nearTabletHighlight.js index 5f4dac232e..d436bad458 100644 --- a/scripts/system/controllers/controllerModules/nearTabletHighlight.js +++ b/scripts/system/controllers/controllerModules/nearTabletHighlight.js @@ -1,7 +1,7 @@ // // nearTabletHighlight.js // -// Highlight the tablet if a hand is near enough to grab it. +// Highlight the tablet if a hand is near enough to grab it and it isn't grabbed. // // Created by David Rowe on 28 Aug 2018. // Copyright 2018 High Fidelity, Inc. @@ -19,6 +19,43 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); "use strict"; + var TABLET_GRABBABLE_SELECTION_NAME = "tabletGrabbableSelection"; + var TABLET_GRABBABLE_SELECTION_STYLE = { + outlineUnoccludedColor: { red: 0, green: 180, blue: 239 }, // #00b4ef + outlineUnoccludedAlpha: 1, + outlineOccludedColor: { red: 0, green: 0, blue: 0 }, + outlineOccludedAlpha: 0, + fillUnoccludedColor: { red: 0, green: 0, blue: 0 }, + fillUnoccludedAlpha: 0, + fillOccludedColor: { red: 0, green: 0, blue: 0 }, + fillOccludedAlpha: 0, + outlineWidth: 2, + isOutlineSmooth: false + }; + + var isTabletNearGrabbable = [false, false]; + var isTabletHighlighted = false; + + function setTabletNearGrabbable(hand, enabled) { + if (enabled === isTabletNearGrabbable[hand]) { + return; + } + + isTabletNearGrabbable[hand] = enabled; + + if (isTabletNearGrabbable[LEFT_HAND] || isTabletNearGrabbable[RIGHT_HAND]) { + if (!isTabletHighlighted) { + Selection.addToSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID); + isTabletHighlighted = true; + } + } else { + if (isTabletHighlighted) { + Selection.removeFromSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID); + isTabletHighlighted = false; + } + } + } + function NearTabletHighlight(hand) { this.hand = hand; @@ -37,18 +74,22 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); if (this.isNearTablet(controllerData)) { return makeRunningValues(true, [], []); } + setTabletNearGrabbable(this.hand, false); return makeRunningValues(false, [], []); }; this.run = function (controllerData) { if (!this.isNearTablet(controllerData)) { + setTabletNearGrabbable(this.hand, false); return makeRunningValues(false, [], []); } if (controllerData.triggerClicks[this.hand]) { + setTabletNearGrabbable(this.hand, false); return makeRunningValues(false, [], []); } + setTabletNearGrabbable(this.hand, true); return makeRunningValues(true, [], []); }; } @@ -58,9 +99,21 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); enableDispatcherModule("LeftNearTabletHighlight", leftNearTabletHighlight); enableDispatcherModule("RightNearTabletHighlight", rightNearTabletHighlight); + function onDisplayModeChanged() { + if (HMD.active) { + Selection.enableListHighlight(TABLET_GRABBABLE_SELECTION_NAME, TABLET_GRABBABLE_SELECTION_STYLE); + } else { + Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME); + Selection.clearSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME); + } + } + HMD.displayModeChanged.connect(onDisplayModeChanged); + HMD.mountedChanged.connect(onDisplayModeChanged); + function cleanUp() { disableDispatcherModule("LeftNearTabletHighlight"); disableDispatcherModule("RightNearTabletHighlight"); + Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME); } Script.scriptEnding.connect(cleanUp); From daae3f50c8080b1e03b6e81155d43c5efcc12cd4 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 6 Sep 2018 09:09:30 +1200 Subject: [PATCH 4/9] Increase tablet highlight outline width --- .../system/controllers/controllerModules/nearTabletHighlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/nearTabletHighlight.js b/scripts/system/controllers/controllerModules/nearTabletHighlight.js index d436bad458..7738f48561 100644 --- a/scripts/system/controllers/controllerModules/nearTabletHighlight.js +++ b/scripts/system/controllers/controllerModules/nearTabletHighlight.js @@ -29,7 +29,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); fillUnoccludedAlpha: 0, fillOccludedColor: { red: 0, green: 0, blue: 0 }, fillOccludedAlpha: 0, - outlineWidth: 2, + outlineWidth: 4, isOutlineSmooth: false }; From f23d93add3f0f9489e2a2cdaf65cabdf47e79cf6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 6 Sep 2018 09:17:00 +1200 Subject: [PATCH 5/9] Fix grabbing tablet with grip not working --- .../system/controllers/controllerModules/nearTabletHighlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/nearTabletHighlight.js b/scripts/system/controllers/controllerModules/nearTabletHighlight.js index 7738f48561..2b02bf3aed 100644 --- a/scripts/system/controllers/controllerModules/nearTabletHighlight.js +++ b/scripts/system/controllers/controllerModules/nearTabletHighlight.js @@ -84,7 +84,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); return makeRunningValues(false, [], []); } - if (controllerData.triggerClicks[this.hand]) { + if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand]) { setTabletNearGrabbable(this.hand, false); return makeRunningValues(false, [], []); } From 16a94f827df1c4406f0750c1b1e62fdac84bcf67 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 11 Sep 2018 09:51:28 +1200 Subject: [PATCH 6/9] Fix tablet highlight not working with stylus --- .../system/controllers/controllerModules/stylusInput.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/stylusInput.js b/scripts/system/controllers/controllerModules/stylusInput.js index a512fd89db..a60ea596e9 100644 --- a/scripts/system/controllers/controllerModules/stylusInput.js +++ b/scripts/system/controllers/controllerModules/stylusInput.js @@ -70,7 +70,13 @@ Script.include("/~/system/libraries/controllers.js"); var farGrabModuleName = this.hand === RIGHT_HAND ? "RightFarActionGrabEntity" : "LeftFarActionGrabEntity"; var farGrabModule = getEnabledModuleByName(farGrabModuleName); var farGrabModuleReady = farGrabModule ? farGrabModule.isReady(controllerData) : makeRunningValues(false, [], []); - return grabOverlayModuleReady.active || farGrabModuleReady.active || grabEntityModuleReady.active; + var nearTabletHighlightModuleName = + this.hand === RIGHT_HAND ? "RightNearTabletHighlight" : "LeftNearTabletHighlight"; + var nearTabletHighlightModule = getEnabledModuleByName(nearTabletHighlightModuleName); + var nearTabletHighlightModuleReady = nearTabletHighlightModule + ? nearTabletHighlightModule.isReady(controllerData) : makeRunningValues(false, [], []); + return grabOverlayModuleReady.active || farGrabModuleReady.active || grabEntityModuleReady.active + || nearTabletHighlightModuleReady.active; }; this.overlayLaserActive = function(controllerData) { From 992b9f847ca9eb85adc5430fc4cddf959a96c581 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 11 Sep 2018 09:58:19 +1200 Subject: [PATCH 7/9] Reduce near grab distance of tablet so that stylus works on tablet --- scripts/system/controllers/controllerDispatcher.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index a707050a9d..69b1b27035 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -26,6 +26,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); (function() { Script.include("/~/system/libraries/pointersUtils.js"); var NEAR_MAX_RADIUS = 0.1; + var NEAR_TABLET_MAX_RADIUS = 0.05; var TARGET_UPDATE_HZ = 60; // 50hz good enough, but we're using update var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ; @@ -211,6 +212,17 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); if (controllerLocations[h].valid) { var nearbyOverlays = Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS * sensorScaleFactor); + + // Tablet must be within NEAR_TABLET_MAX_RADIUS in order to be grabbed. + var tabletIndex = nearbyOverlays.indexOf(HMD.tabletID); + if (tabletIndex !== -1) { + var closebyOverlays = + Overlays.findOverlays(controllerLocations[h].position, NEAR_TABLET_MAX_RADIUS * sensorScaleFactor); + if (tabletIndex !== -1 && closebyOverlays.indexOf(HMD.tabletID) === -1) { + nearbyOverlays.splice(tabletIndex, 1); + } + } + nearbyOverlays.sort(function (a, b) { var aPosition = Overlays.getProperty(a, "position"); var aDistance = Vec3.distance(aPosition, controllerLocations[h].position); From 71ec5f3612713cfae43c20dabc3c9986f60a4309 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 20 Oct 2018 11:57:46 +1300 Subject: [PATCH 8/9] Fix tablet highlighting when using the Create and Shapes apps --- .../controllers/controllerModules/inEditMode.js | 11 ++++++----- .../controllers/controllerModules/inVREditMode.js | 13 ++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index 1917505bd8..2b17f447a0 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -158,11 +158,12 @@ Script.include("/~/system/libraries/utils.js"); } } - var nearOverlay = getEnabledModuleByName(this.hand === RIGHT_HAND - ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"); - if (nearOverlay) { - var nearOverlayReady = nearOverlay.isReady(controllerData); - if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) { + // Tablet highlight and grabbing. + var tabletHighlight = getEnabledModuleByName(this.hand === RIGHT_HAND + ? "RightNearTabletHighlight" : "LeftNearTabletHighlight"); + if (tabletHighlight) { + var tabletHighlightReady = tabletHighlight.isReady(controllerData); + if (tabletHighlightReady.active) { return this.exitModule(); } } diff --git a/scripts/system/controllers/controllerModules/inVREditMode.js b/scripts/system/controllers/controllerModules/inVREditMode.js index 65b6744646..0c04918ab1 100644 --- a/scripts/system/controllers/controllerModules/inVREditMode.js +++ b/scripts/system/controllers/controllerModules/inVREditMode.js @@ -101,13 +101,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } } - // Tablet grabbing. - var nearOverlay = getEnabledModuleByName(this.hand === RIGHT_HAND ? - "RightNearParentingGrabOverlay" : - "LeftNearParentingGrabOverlay"); - if (nearOverlay) { - var nearOverlayReady = nearOverlay.isReady(controllerData); - if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) { + // Tablet highlight and grabbing. + var tabletHighlight = getEnabledModuleByName(this.hand === RIGHT_HAND + ? "RightNearTabletHighlight" : "LeftNearTabletHighlight"); + if (tabletHighlight) { + var tabletHighlightReady = tabletHighlight.isReady(controllerData); + if (tabletHighlightReady.active) { return this.exitModule(); } } From 35c1241c9886909cad86dce0b8079245806b5bee Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 23 Oct 2018 09:08:38 +1300 Subject: [PATCH 9/9] Fix tablet highlighting not working if start up in HMD --- .../system/controllers/controllerModules/nearTabletHighlight.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/controllers/controllerModules/nearTabletHighlight.js b/scripts/system/controllers/controllerModules/nearTabletHighlight.js index 2b02bf3aed..c24464ab38 100644 --- a/scripts/system/controllers/controllerModules/nearTabletHighlight.js +++ b/scripts/system/controllers/controllerModules/nearTabletHighlight.js @@ -109,6 +109,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } HMD.displayModeChanged.connect(onDisplayModeChanged); HMD.mountedChanged.connect(onDisplayModeChanged); + onDisplayModeChanged(); function cleanUp() { disableDispatcherModule("LeftNearTabletHighlight");