From 56c897cc2faccc60c38b9a625a1956112bba4ad9 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 18 Jan 2017 15:30:38 -0800 Subject: [PATCH] Process the tablet stylus even when reticle is over 2d HUD overlay. --- .../system/controllers/handControllerGrab.js | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 770f75e610..d2f39f93de 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -828,6 +828,12 @@ function MyController(hand) { } if (this.ignoreInput()) { + + // Most hand input is disabled, because we are interacting with the 2d hud. + // However, we still should check for collisions of the stylus with the web overlay. + var controllerLocation = getControllerWorldLocation(this.handToController(), true); + this.processStylus(controllerLocation.position); + this.turnOffVisualizations(); return; } @@ -1155,6 +1161,36 @@ function MyController(hand) { return _this.rawThumbValue < THUMB_ON_VALUE; }; + this.processStylus = function(worldHandPosition) { + // see if the hand is near a tablet or web-entity + var candidateEntities = Entities.findEntities(worldHandPosition, WEB_DISPLAY_STYLUS_DISTANCE); + entityPropertiesCache.addEntities(candidateEntities); + var nearWeb = false; + for (var i = 0; i < candidateEntities.length; i++) { + var props = entityPropertiesCache.getProps(candidateEntities[i]); + if (props && (props.type == "Web" || this.isTablet(props))) { + nearWeb = true; + break; + } + } + + if (nearWeb) { + this.showStylus(); + var rayPickInfo = this.calcRayPickInfo(this.hand); + if (rayPickInfo.distance < WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) { + if (this.handleStylusOnWebEntity(rayPickInfo)) { + return; + } + if (this.handleStylusOnWebOverlay(rayPickInfo)) { + return; + } + this.handleStylusOnHomeButton(rayPickInfo); + } + } else { + this.hideStylus(); + } + }; + this.off = function(deltaTime, timestamp) { this.checkForUnexpectedChildren(); @@ -1202,32 +1238,7 @@ function MyController(hand) { this.grabPointSphereOff(); } - // see if the hand is near a tablet or web-entity - candidateEntities = Entities.findEntities(worldHandPosition, WEB_DISPLAY_STYLUS_DISTANCE); - var nearWeb = false; - for (var i = 0; i < candidateEntities.length; i++) { - var props = entityPropertiesCache.getProps(candidateEntities[i]); - if (props && (props.type == "Web" || this.isTablet(props))) { - nearWeb = true; - break; - } - } - - if (nearWeb) { - this.showStylus(); - var rayPickInfo = this.calcRayPickInfo(this.hand); - if (rayPickInfo.distance < WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) { - if (this.handleStylusOnWebEntity(rayPickInfo)) { - return; - } - if (this.handleStylusOnWebOverlay(rayPickInfo)) { - return; - } - this.handleStylusOnHomeButton(rayPickInfo); - } - } else { - this.hideStylus(); - } + this.processStylus(worldHandPosition); }; this.handleStylusOnHomeButton = function(rayPickInfo) {