diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index b35891e71e..959f217eb4 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -271,6 +271,8 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); } } + // print("QQQ running plugins: " + JSON.stringify(_this.runningPluginNames)); + // give time to running plugins for (var runningPluginName in _this.runningPluginNames) { if (_this.runningPluginNames.hasOwnProperty(runningPluginName)) { diff --git a/scripts/system/controllers/controllerDispatcherUtils.js b/scripts/system/controllers/controllerDispatcherUtils.js index daf6b667ed..a7bd3339d0 100644 --- a/scripts/system/controllers/controllerDispatcherUtils.js +++ b/scripts/system/controllers/controllerDispatcherUtils.js @@ -17,6 +17,7 @@ COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, + NEAR_GRAB_RADIUS, Entities, makeDispatcherModuleParameters, makeRunningValues, @@ -66,6 +67,9 @@ COLORS_GRAB_SEARCHING_FULL_SQUEEZE = { red: 250, green: 10, blue: 10 }; COLORS_GRAB_DISTANCE_HOLD = { red: 238, green: 75, blue: 214 }; +NEAR_GRAB_RADIUS = 0.1; + + // priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step // activitySlots -- indicates which "slots" must not yet be in use for this module to start diff --git a/scripts/system/controllers/controllerModules/equipEntity.js b/scripts/system/controllers/controllerModules/equipEntity.js index 65668f0d23..c009d74764 100644 --- a/scripts/system/controllers/controllerModules/equipEntity.js +++ b/scripts/system/controllers/controllerModules/equipEntity.js @@ -82,7 +82,7 @@ EquipHotspotBuddy.prototype.updateHotspot = function(hotspot, timestamp) { ignoreRayIntersection: true })); overlayInfoSet.type = "model"; - print("QQQ adding hopspot: " + hotspot.key); + print("QQQ adding hotspot: " + hotspot.key); this.map[hotspot.key] = overlayInfoSet; } else { print("QQQ updating hopspot: " + hotspot.key); @@ -520,7 +520,9 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa this.targetEntityID = null; }; - this.isReady = function (controllerData, deltaTime) { + this.checkNearbyHotspots = function (controllerData, deltaTime) { + + var timestamp = Date.now(); this.rawTriggerValue = controllerData.triggerValues[this.hand]; this.triggerClicked = controllerData.triggerClicks[this.hand]; @@ -548,7 +550,6 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa } var nearEquipHotspots = this.chooseNearEquipHotspots(candidateEntityProps, controllerData); - var timestamp = Date.now(); equipHotspotBuddy.updateHotspots(nearEquipHotspots, timestamp); if (potentialEquipHotspot) { equipHotspotBuddy.highlightHotspot(potentialEquipHotspot); @@ -556,11 +557,22 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa equipHotspotBuddy.update(deltaTime, timestamp, controllerData); - return makeRunningValues(false, [], []); + if (potentialEquipHotspot) { + return makeRunningValues(true, [potentialEquipHotspot.entityID], []); + } else { + return makeRunningValues(false, [], []); + } + + }; + + this.isReady = function (controllerData, deltaTime) { + return this.checkNearbyHotspots(controllerData, deltaTime); }; this.run = function (controllerData, deltaTime) { + return this.checkNearbyHotspots(controllerData, deltaTime); + if (controllerData.secondaryValues[this.hand]) { // this.secondaryReleased() will always be true when not depressed // so we cannot simply rely on that for release - ensure that the diff --git a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js index 42859f3e19..217e90ef88 100644 --- a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js @@ -9,7 +9,7 @@ getControllerJointIndex, getGrabbableData, NULL_UUID, enableDispatcherModule, disableDispatcherModule, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable, Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues, - TRIGGER_OFF_VALUE + TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS */ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); @@ -146,6 +146,11 @@ Script.include("/~/system/libraries/controllers.js"); var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand]; for (var i = 0; i < nearbyEntityProperties.length; i++) { var props = nearbyEntityProperties[i]; + var handPosition = controllerData.controllerLocations[this.hand].position; + var distance = Vec3.distance(props.position, handPosition); + if (distance > NEAR_GRAB_RADIUS) { + break; + } if (entityIsGrabbable(props)) { return props; } diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 1de2fee5ea..c5ca95fe3b 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -9,7 +9,7 @@ /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, - makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues + makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS */ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); @@ -129,6 +129,11 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand]; for (var i = 0; i < nearbyEntityProperties.length; i++) { var props = nearbyEntityProperties[i]; + var handPosition = controllerData.controllerLocations[this.hand].position; + var distance = Vec3.distance(props.position, handPosition); + if (distance > NEAR_GRAB_RADIUS) { + break; + } if (entityIsGrabbable(props)) { return props; }