switching near grab priority to be before web surface laser

This commit is contained in:
Wayne Chen 2018-07-17 15:38:56 -07:00
parent f444d0ae28
commit eb7bde1bfc
8 changed files with 36 additions and 10 deletions

View file

@ -37,7 +37,7 @@
this.highlightedEntities = []; this.highlightedEntities = [];
this.parameters = dispatcherUtils.makeDispatcherModuleParameters( this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
480, 120,
this.hand === dispatcherUtils.RIGHT_HAND ? ["rightHand"] : ["leftHand"], this.hand === dispatcherUtils.RIGHT_HAND ? ["rightHand"] : ["leftHand"],
[], [],
100); 100);

View file

@ -30,7 +30,7 @@ Script.include("/~/system/libraries/utils.js");
this.reticleMaxY; this.reticleMaxY;
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
160, 200,
this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"], this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"],
[], [],
100, 100,

View file

@ -21,7 +21,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.disableModules = false; this.disableModules = false;
var NO_HAND_LASER = -1; // Invalid hand parameter so that default laser is not displayed. var NO_HAND_LASER = -1; // Invalid hand parameter so that default laser is not displayed.
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
200, // Not too high otherwise the tablet laser doesn't work. 240, // Not too high otherwise the tablet laser doesn't work.
this.hand === RIGHT_HAND this.hand === RIGHT_HAND
? ["rightHand", "rightHandEquip", "rightHandTrigger"] ? ["rightHand", "rightHandEquip", "rightHandTrigger"]
: ["leftHand", "leftHandEquip", "leftHandTrigger"], : ["leftHand", "leftHandEquip", "leftHandTrigger"],

View file

@ -26,7 +26,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
this.hapticTargetID = null; this.hapticTargetID = null;
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
500, 140,
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
[], [],
100); 100);

View file

@ -21,7 +21,7 @@
this.hyperlink = ""; this.hyperlink = "";
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
485, 125,
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
[], [],
100); 100);

View file

@ -39,7 +39,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
this.cloneAllowed = true; this.cloneAllowed = true;
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
500, 140,
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
[], [],
100); 100);

View file

@ -29,7 +29,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.startSent = false; this.startSent = false;
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
480, 120,
this.hand === RIGHT_HAND ? ["rightHandTrigger", "rightHand"] : ["leftHandTrigger", "leftHand"], this.hand === RIGHT_HAND ? ["rightHandTrigger", "rightHand"] : ["leftHandTrigger", "leftHand"],
[], [],
100); 100);

View file

@ -22,7 +22,7 @@ Script.include("/~/system/libraries/controllers.js");
this.running = false; this.running = false;
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
120, 160,
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
[], [],
100, 100,
@ -60,6 +60,30 @@ Script.include("/~/system/libraries/controllers.js");
return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput;
}; };
this.isPointingAtGrabbableEntity = function(controllerData, triggerPressed) {
// we are searching for an entity that is not a web entity. We want to be able to
// grab a non-web entity if the ray-pick intersects one.
var intersection = controllerData.rayPicks[this.hand];
if(intersection.type === Picks.INTERSECTED_ENTITY) {
// is pointing at an entity.
var entityProperty = Entities.getEntityProperties(intersection.objectID);
var entityType = entityProperty.type;
var isGrabbable = entityIsGrabbable(entityProperty);
return (isGrabbable && triggerPressed && entityType !== "Web");
} else if (intersection.type === Picks.INTERSECTED_OVERLAY) {
var objectID = intersection.objectID;
if ((HMD.tabletID && objectID === HMD.tabletID) ||
(HMD.tabletScreenID && objectID === HMD.tabletScreenID) ||
(HMD.homeButtonID && objectID === HMD.homeButtonID)) {
return true;
} else {
var overlayType = Overlays.getOverlayType(objectID);
return overlayType === "web3d" || triggerPressed;
}
}
return false;
}
this.isPointingAtTriggerable = function(controllerData, triggerPressed) { this.isPointingAtTriggerable = function(controllerData, triggerPressed) {
// allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, // 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 // but for pointing at locked web entities or non-web overlays user must be pressing trigger
@ -113,7 +137,8 @@ Script.include("/~/system/libraries/controllers.js");
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE &&
controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
var allowThisModule = !otherModuleRunning || isTriggerPressed; var allowThisModule = !otherModuleRunning || isTriggerPressed;
if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) {
//this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) {
this.updateAllwaysOn(); this.updateAllwaysOn();
if (isTriggerPressed) { if (isTriggerPressed) {
this.dominantHandOverride = true; // Override dominant hand. this.dominantHandOverride = true; // Override dominant hand.
@ -134,7 +159,8 @@ Script.include("/~/system/libraries/controllers.js");
var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun;
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn;
if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed))) { if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) &&
this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) {
this.running = true; this.running = true;
return makeRunningValues(true, [], []); return makeRunningValues(true, [], []);
} }