staging changes

This commit is contained in:
Wayne Chen 2018-09-11 15:23:40 -07:00
parent 0a145fbe2e
commit b6c5ae2a68
3 changed files with 30 additions and 17 deletions

View file

@ -31,7 +31,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ; var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ;
var PROFILE = false; var PROFILE = false;
var DEBUG = false; var DEBUG = true;
if (typeof Test !== "undefined") { if (typeof Test !== "undefined") {
PROFILE = true; PROFILE = true;

View file

@ -24,6 +24,9 @@ Script.include("/~/system/libraries/controllers.js");
// XXX this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true; // XXX this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true;
// XXX this.kinematicGrab = (grabbableData.kinematic !== undefined) ? grabbableData.kinematic : NEAR_GRABBING_KINEMATIC; // 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) { function getGrabOffset(handController) {
var offset = GRAB_POINT_SPHERE_OFFSET; var offset = GRAB_POINT_SPHERE_OFFSET;
if (handController === Controller.Standard.LeftHand) { if (handController === Controller.Standard.LeftHand) {

View file

@ -21,6 +21,10 @@ Script.include("/~/system/libraries/controllers.js");
this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND;
this.running = false; this.running = false;
// parameters for things to be working on
this.isObjectEntity = false;
this.objectID = null;
this.parameters = makeDispatcherModuleParameters( this.parameters = makeDispatcherModuleParameters(
160, 160,
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
@ -60,15 +64,6 @@ Script.include("/~/system/libraries/controllers.js");
return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; 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) { 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
@ -123,14 +118,17 @@ Script.include("/~/system/libraries/controllers.js");
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.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) {
this.updateAllwaysOn(); this.updateAllwaysOn();
if (isTriggerPressed) { if (isTriggerPressed) {
this.dominantHandOverride = true; // Override dominant hand. this.dominantHandOverride = true; // Override dominant hand.
this.getOtherModule().dominantHandOverride = false; this.getOtherModule().dominantHandOverride = false;
} }
if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { 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, [], []); 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.getDominantHand() !== this.hand; // Auto-swap to dominant hand.
otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand.
var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); 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 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) {
(controllerData.nearbyEntityProperties[this.hand] !== [])) { if (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) {
this.running = true; this.running = true;
return makeRunningValues(true, [], []); return makeRunningValues(true, [], []);
} else {
this.deleteContextOverlay();
this.running = false;
this.dominantHandOverride = false;
return makeRunningValues(false, [], []);
}
} }
this.deleteContextOverlay(); this.deleteContextOverlay();
this.running = false; this.running = false;
this.dominantHandOverride = 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, [], []); return makeRunningValues(false, [], []);
}; };
} }