From 14323a06b35c8814c1d48df6e1cb5ee365edb69d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 29 Aug 2016 10:28:27 -0700 Subject: [PATCH] Add interface to disable hand controller grab functionality --- .../system/controllers/handControllerGrab.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 954093854e..2ebf7a828d 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -184,6 +184,10 @@ var STATE_FAR_TRIGGER = 5; var STATE_HOLD = 6; var STATE_ENTITY_TOUCHING = 7; +var holdEnabled = true; +var nearGrabEnabled = true; +var farGrabEnabled = true; + // "collidesWith" is specified by comma-separated list of group names // the possible group names are: static, dynamic, kinematic, myAvatar, otherAvatar var COLLIDES_WITH_WHILE_GRABBED = "dynamic,otherAvatar"; @@ -1440,7 +1444,7 @@ function MyController(hand) { var potentialEquipHotspot = this.chooseBestEquipHotspot(candidateHotSpotEntities); if (potentialEquipHotspot) { - if (this.triggerSmoothedGrab()) { + if (this.triggerSmoothedGrab() && holdEnabled) { this.grabbedHotspot = potentialEquipHotspot; this.grabbedEntity = potentialEquipHotspot.entityID; this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); @@ -1483,7 +1487,7 @@ function MyController(hand) { // potentialNearTriggerEntity = entity; } } else { - if (this.triggerSmoothedGrab()) { + if (this.triggerSmoothedGrab() && nearGrabEnabled) { var props = entityPropertiesCache.getProps(entity); var grabProps = entityPropertiesCache.getGrabProps(entity); var refCount = grabProps.refCount ? grabProps.refCount : 0; @@ -1571,7 +1575,7 @@ function MyController(hand) { // potentialFarTriggerEntity = entity; } } else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) { - if (this.triggerSmoothedGrab() && !isEditing()) { + if (this.triggerSmoothedGrab() && !isEditing() && farGrabEnabled) { this.grabbedEntity = entity; this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'"); return; @@ -1589,7 +1593,9 @@ function MyController(hand) { equipHotspotBuddy.highlightHotspot(potentialEquipHotspot); } - this.searchIndicatorOn(rayPickInfo.searchRay); + if (farGrabEnabled) { + this.searchIndicatorOn(rayPickInfo.searchRay); + } Reticle.setVisible(false); }; @@ -2219,7 +2225,9 @@ function MyController(hand) { if (intersection.intersects) { this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection); } - this.searchIndicatorOn(pickRay); + if (farGrabEnabled) { + this.searchIndicatorOn(pickRay); + } } } @@ -2327,7 +2335,9 @@ function MyController(hand) { } this.intersectionDistance = intersectInfo.distance; - this.searchIndicatorOn(intersectInfo.searchRay); + if (farGrabEnabled) { + this.searchIndicatorOn(intersectInfo.searchRay); + } Reticle.setVisible(false); } else { this.setState(STATE_OFF, "grabbed entity was destroyed"); @@ -2681,6 +2691,7 @@ function update(deltaTime) { entityPropertiesCache.update(); } +Messages.subscribe('Hifi-Grab-Disable'); Messages.subscribe('Hifi-Hand-Disabler'); Messages.subscribe('Hifi-Hand-Grab'); Messages.subscribe('Hifi-Hand-RayPick-Blacklist');