From 9c96ffc9cb42ff42274b29f7687f81878ccc8309 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 7 Sep 2016 16:31:02 -0700 Subject: [PATCH] don't show grab-point spheres if controller poses aren't valid --- .../system/controllers/handControllerGrab.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 01be03c14a..588f5f95b6 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -11,7 +11,7 @@ // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global setEntityCustomData, getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation */ +/* global setEntityCustomData, getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset */ (function() { // BEGIN LOCAL_SCOPE @@ -1090,11 +1090,16 @@ function MyController(hand) { } } - this.grabPointSphereOn(); var controllerLocation = getControllerWorldLocation(this.handToController(), true); var worldHandPosition = controllerLocation.position; + if (controllerLocation.valid) { + this.grabPointSphereOn(); + } else { + this.grabPointSphereOff(); + } + var candidateEntities = Entities.findEntities(worldHandPosition, MAX_EQUIP_HOTSPOT_RADIUS); entityPropertiesCache.addEntities(candidateEntities); var potentialEquipHotspot = this.chooseBestEquipHotspot(candidateEntities); @@ -1431,8 +1436,6 @@ function MyController(hand) { this.isInitialGrab = false; this.shouldResetParentOnRelease = false; - this.grabPointSphereOn(); - this.checkForStrayChildren(); if (this.triggerSmoothedReleased()) { @@ -1440,7 +1443,14 @@ function MyController(hand) { return; } - var handPosition = getControllerWorldLocation(this.handToController(), true).position; + var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var handPosition = controllerLocation.position; + + if (controllerLocation.valid) { + this.grabPointSphereOn(); + } else { + this.grabPointSphereOff(); + } var rayPickInfo = this.calcRayPickInfo(this.hand);