From 6f25c59a0cb1133827647ab5b1bb1a6bd127b409 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 10 Dec 2018 15:42:33 -0800 Subject: [PATCH] turn-off nearEntityGrab when scaleEntity is active --- .../controllerModules/nearGrabEntity.js | 33 ++++++++----------- .../controllerModules/scaleEntity.js | 2 +- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/scripts/system/controllers/controllerModules/nearGrabEntity.js b/scripts/system/controllers/controllerModules/nearGrabEntity.js index 78e15f51e4..a56c28900e 100644 --- a/scripts/system/controllers/controllerModules/nearGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearGrabEntity.js @@ -6,13 +6,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, - enableDispatcherModule, disableDispatcherModule, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, - TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, - findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH, - HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, findHandChildEntities, TEAR_AWAY_DISTANCE, MSECS_PER_SEC, TEAR_AWAY_CHECK_TIME, - TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, Uuid, highlightTargetEntity, unhighlightTargetEntity, - distanceBetweenEntityLocalPositionAndBoundingBox, getGrabbableData, getGrabPointSphereOffset, DISPATCHER_PROPERTIES +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, enableDispatcherModule, + disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, + makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGroupParent, Vec3, + cloneEntity, entityIsCloneable, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, TEAR_AWAY_DISTANCE, + distanceBetweenPointAndEntityBoundingBox, highlightTargetEntity, unhighlightTargetEntity, getGrabbableData, + DISPATCHER_PROPERTIES, HMD */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); @@ -21,18 +20,6 @@ Script.include("/~/system/libraries/controllers.js"); (function() { - // XXX this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true; - // XXX this.kinematicGrab = (grabbableData.kinematic !== undefined) ? grabbableData.kinematic : NEAR_GRABBING_KINEMATIC; - - // this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp:378 - var GRAB_POINT_SPHERE_OFFSET = { x: 0.04, y: 0.13, z: 0.039 }; // x = upward, y = forward, z = lateral - - function getGrabOffset(handController) { - var offset = getGrabPointSphereOffset(handController, true); - offset.y = -offset.y; - return Vec3.multiply(MyAvatar.sensorToWorldScale, offset); - } - function NearGrabEntity(hand) { this.hand = hand; this.targetEntityID = null; @@ -95,7 +82,6 @@ Script.include("/~/system/libraries/controllers.js"); } this.hapticTargetID = null; - var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID]; var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; Entities.callEntityMethod(this.targetEntityID, "releaseGrab", args); @@ -176,6 +162,13 @@ Script.include("/~/system/libraries/controllers.js"); return makeRunningValues(false, [], []); } + if (controllerData.secondaryValues[LEFT_HAND] >= TRIGGER_ON_VALUE && + controllerData.secondaryValues[RIGHT_HAND] >= TRIGGER_ON_VALUE) { + // let scaleEntity module take over + this.endNearGrabEntity(controllerData); + return makeRunningValues(false, [], []); + } + var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID]; if (!props) { props = Entities.getEntityProperties(this.targetEntityID, DISPATCHER_PROPERTIES); diff --git a/scripts/system/controllers/controllerModules/scaleEntity.js b/scripts/system/controllers/controllerModules/scaleEntity.js index 24c05a1394..0f981d88f8 100644 --- a/scripts/system/controllers/controllerModules/scaleEntity.js +++ b/scripts/system/controllers/controllerModules/scaleEntity.js @@ -19,7 +19,7 @@ this.parameters = dispatcherUtils.makeDispatcherModuleParameters( 120, - this.hand === RIGHT_HAND ? ["rightHandTrigger"] : ["leftHandTrigger"], + this.hand === RIGHT_HAND ? ["rightHandTrigger", "rightHand"] : ["leftHandTrigger", "leftHand"], [], 100 );