From 6f53aaed5c42a704c12aee69e3b60c2915c79ccb Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 9 Mar 2017 14:04:13 -0800 Subject: [PATCH] Small simplification of building stylusTarget list. --- .../system/controllers/handControllerGrab.js | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index abd0484ec4..284bb3af15 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1618,44 +1618,26 @@ function MyController(hand) { overlays: [] }; - // find web-entites near the stylusTip. + // build list of stylus targets, near the stylusTip + var stylusTargets = []; var candidateEntities = Entities.findEntities(tipPosition, WEB_DISPLAY_STYLUS_DISTANCE); entityPropertiesCache.addEntities(candidateEntities); var i, props; for (i = 0; i < candidateEntities.length; i++) { props = entityPropertiesCache.getProps(candidateEntities[i]); if (props && (props.type === "Web" || this.isTablet(candidateEntities[i]))) { - candidates.entities.push(candidateEntities[i]); + stylusTargets.push(calculateStylusTargetFromEntity(this.stylusTip, candidateEntities[i])); } } // add the tabletScreen, if it is valid if (HMD.tabletScreenID && HMD.tabletScreenID !== NULL_UUID) { - candidates.overlays.push(HMD.tabletScreenID); + stylusTargets.push(calculateStylusTargetFromOverlay(this.stylusTip, HMD.tabletScreenID)); } // add the tablet home button. if (HMD.homeButtonID && HMD.homeButtonID !== NULL_UUID) { - candidates.overlays.push(HMD.homeButtonID); - } - - // build list of stylus targets - var stylusTargets = []; - if (candidates.entities.length > 0 || candidates.overlays.length > 0) { - var stylusTarget; - for (i = 0; i < candidates.entities.length; i++) { - stylusTarget = calculateStylusTargetFromEntity(this.stylusTip, candidates.entities[i]); - if (stylusTarget) { - stylusTargets.push(stylusTarget); - } - } - - for (i = 0; i < candidates.overlays.length; i++) { - stylusTarget = calculateStylusTargetFromOverlay(this.stylusTip, candidates.overlays[i]); - if (stylusTarget) { - stylusTargets.push(stylusTarget); - } - } + stylusTargets.push(calculateStylusTargetFromOverlay(this.stylusTip, HMD.homeButtonID)); } var TABLET_MIN_HOVER_DISTANCE = 0.01;