From b6c5ae2a688527cdaf5a58a64f05ce61dc9a2345 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 15:23:40 -0700 Subject: [PATCH] staging changes --- .../controllers/controllerDispatcher.js | 2 +- .../controllerModules/nearParentGrabEntity.js | 3 ++ .../controllerModules/webSurfaceLaserInput.js | 42 ++++++++++++------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 7a916392b9..c7a8de87b9 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -31,7 +31,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ; var PROFILE = false; - var DEBUG = false; + var DEBUG = true; if (typeof Test !== "undefined") { PROFILE = true; diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 6bbd19550b..f805dbf60e 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -24,6 +24,9 @@ Script.include("/~/system/libraries/controllers.js"); // 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 = GRAB_POINT_SPHERE_OFFSET; if (handController === Controller.Standard.LeftHand) { diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index dd0af0ba8f..e4978884d0 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -21,6 +21,10 @@ Script.include("/~/system/libraries/controllers.js"); this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; this.running = false; + // parameters for things to be working on + this.isObjectEntity = false; + this.objectID = null; + this.parameters = makeDispatcherModuleParameters( 160, this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], @@ -60,15 +64,6 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; - this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) { - var intersection = controllerData.rayPicks[this.hand]; - var objectID = intersection.objectID; - if(intersection.type === Picks.INTERSECTED_ENTITY) { - return (controllerData.nearbyEntityPropertiesByID[objectID] !== null && triggerPressed); - } - return false; - } - this.isPointingAtTriggerable = function(controllerData, triggerPressed) { // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, // but for pointing at locked web entities or non-web overlays user must be pressing trigger @@ -123,14 +118,17 @@ Script.include("/~/system/libraries/controllers.js"); controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && - !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. this.getOtherModule().dominantHandOverride = false; } if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { + var intersection = controllerData.rayPicks[this.hand]; + // the object is either an entity or an overlay. + this.isObjectEntity = (intersection.type === Picks.INTERSECTED_ENTITY); + this.objectID = intersection.objectID; return makeRunningValues(true, [], []); } } @@ -142,17 +140,29 @@ Script.include("/~/system/libraries/controllers.js"); otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); - var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; + // only allow for non-near grab + var allowThisModule = !otherModuleRunning && !(grabModuleNeedsToRun && controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; - if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - (controllerData.nearbyEntityProperties[this.hand] !== [])) { - this.running = true; - return makeRunningValues(true, [], []); + if (allowThisModule) { + if (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { + this.running = true; + return makeRunningValues(true, [], []); + } else { + this.deleteContextOverlay(); + this.running = false; + this.dominantHandOverride = false; + return makeRunningValues(false, [], []); + } } this.deleteContextOverlay(); this.running = false; this.dominantHandOverride = false; + this.objectID = null; + if (this.hand === LEFT_HAND) { + print("allowThisModule = " + allowThisModule); + print("isPointingAtTriggerable = " + (laserOn || this.isPointingAtTriggerable(controllerData, isTriggerPressed))); + } return makeRunningValues(false, [], []); }; }